:root {
  --bg-primary: #0A0A0C;
  --bg-surface: #101013;
  --text-primary: #F5F5F7;
  --text-secondary: #A3A3AE;
  --text-muted: #5A5A62;
  --signal: #4ADE80;
  --border: #26262C;
  --border-strong: #38383F;

  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 48px;
  --space-xl: 96px;
  --space-2xl: 160px;

  --nav-h: 88px;
  --rail-w: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-style: normal;
  position: relative;
  overflow-x: hidden;
}

.coord {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
  margin: 0;
}
.coord--muted { color: var(--text-muted); }

.connector { width: 1px; height: 32px; background: var(--signal); opacity: 0.4; margin: var(--space-sm) 0; }
.connector--muted { background: var(--border-strong); opacity: 1; }

.accent { color: var(--signal); }

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin: var(--space-md) 0 var(--space-sm);
}

.section__title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.01em;
  line-height: 1.15;
  max-width: 760px;
  margin: 0 0 var(--space-sm);
  overflow-wrap: break-word;
  word-break: break-word;
}

.section__sub {
  font-size: 17px;
  font-style: normal;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 0 var(--space-md);
}

.cta {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-family: inherit;
  white-space: nowrap;
}
.cta--secondary {
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  background: transparent;
  transition: background 150ms ease, border-color 150ms ease;
}
.cta--secondary:hover { background: rgba(245,245,247,0.06); border-color: var(--text-secondary); }
.cta--primary {
  color: var(--bg-primary);
  background: var(--text-primary);
  box-shadow: 0 0 0 0 rgba(74,222,128,0);
  transition: box-shadow 250ms ease, transform 150ms ease;
}
.cta--primary:hover { box-shadow: 0 0 32px 4px rgba(74,222,128,0.35); transform: translateY(-1px); }
.cta--nav { padding: 10px 20px; font-size: 12px; }

.link-out {
  color: var(--signal);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 14px 4px;
  position: relative;
  font-weight: 500;
}
.link-out::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: 10px; height: 1px;
  background: var(--signal); transform: scaleX(0); transform-origin: left; transition: transform 200ms ease;
}
.link-out:hover::after { transform: scaleX(1); }

.actions { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0; left: var(--rail-w); right: var(--rail-w);
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 10;
  background: linear-gradient(to bottom, rgba(10,10,12,0.92) 60%, transparent 100%);
  backdrop-filter: blur(6px);
}
.nav__logo {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px; font-weight: 500; letter-spacing: 0.08em;
  color: var(--text-primary); text-decoration: none;
  display: flex; flex-direction: column; line-height: 1.1;
}
.nav__logo-accent { color: var(--signal); }
.nav__logo-sub { font-size: 9px; letter-spacing: 0.3em; color: var(--text-muted); margin-top: 2px; }
.nav__links { display: flex; gap: var(--space-lg); }
.nav__links a {
  font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary); text-decoration: none; transition: color 150ms ease;
}
.nav__links a:hover { color: var(--text-primary); }

/* ===== RAILS ===== */
.rail {
  position: fixed; top: 0; bottom: 0; width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: var(--space-lg) 0; z-index: 5; pointer-events: none;
}
.rail--left { left: 0; }
.rail--right { right: 0; }
.rail__label {
  writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg);
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 0.2em;
  color: var(--text-muted); text-transform: uppercase;
}
.rail__tick {
  font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--text-muted); opacity: 0.6;
}
.rail__arrow { color: var(--signal); font-size: 14px; animation: bob 2000ms ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ===== Section shell ===== */
.section {
  position: relative;
  padding: var(--space-2xl) var(--space-xl);
  margin: 0 var(--rail-w);
  min-height: 70vh;
  display: flex; flex-direction: column; justify-content: center;
}

/* ===== HERO (asymmetric) ===== */
.hero {
  background: var(--bg-primary);
  display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: var(--space-xl);
  min-height: 100vh; padding-top: calc(var(--nav-h) + var(--space-lg));
  overflow: hidden;
}
.hero__content { max-width: 560px; min-width: 0; text-align: left; position: relative; z-index: 2; }
.hero__title {
  font-size: clamp(32px, 3.6vw, 52px); font-weight: 700; font-style: normal;
  line-height: 1.15; letter-spacing: -0.02em; margin: 0;
  overflow-wrap: break-word; word-break: break-word;
}
.hero__sub { font-size: 16px; color: var(--text-secondary); margin: 0 0 var(--space-lg); max-width: 460px; }

.hero__panel {
  position: relative; min-width: 0; height: 500px;
  margin-right: calc(var(--space-xl) * -1);
  background: linear-gradient(160deg, var(--bg-surface) 0%, #0d0d10 100%);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.panel__svg { width: 70%; max-width: 380px; }
.panel__sys {
  position: absolute; top: 20px; left: 24px;
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 0.05em;
  color: var(--text-muted); line-height: 1.5; margin: 0;
}
.panel__sys span { color: var(--signal); }
.panel__output {
  position: absolute; bottom: 24px; right: 24px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 14px 18px; background: rgba(16,16,19,0.7);
}
.panel__output-title {
  font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.14em;
  color: var(--signal); text-transform: uppercase; margin: 0 0 8px;
}
.panel__output ul { list-style: none; margin: 0; padding: 0; }
.panel__output li {
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text-secondary);
  margin-bottom: 4px;
}

.mark { position: absolute; width: 14px; height: 14px; opacity: 0.5; }
.mark::before, .mark::after { content: ""; position: absolute; background: var(--signal); }
.mark::before { top: 50%; left: 0; width: 100%; height: 1px; transform: translateY(-50%); }
.mark::after { left: 50%; top: 0; height: 100%; width: 1px; transform: translateX(-50%); }
.mark--tl { top: 16px; left: 16px; } .mark--tr { top: 16px; right: 16px; }
.mark--bl { bottom: 16px; left: 16px; } .mark--br { bottom: 16px; right: 16px; }

.ghost {
  position: absolute; right: 4vw; top: 50%; transform: translateY(-50%);
  font-size: min(40vw, 480px); font-weight: 700; color: var(--text-primary);
  opacity: 0.025; line-height: 1; z-index: 1; pointer-events: none; user-select: none;
}

/* ===== IL PROBLEMA — sober, centered, no signal ===== */
.problema { background: var(--bg-surface); align-items: center; text-align: center; }
.problema .coord, .problema .connector,
.problema .section__title, .problema .section__sub { margin-left: auto; margin-right: auto; }

/* ===== IL METODO — first signal ===== */
.metodo { background: var(--bg-primary); align-items: center; text-align: center; }
.metodo .coord, .metodo .connector,
.metodo .section__title, .metodo .section__sub { margin-left: auto; margin-right: auto; }
.metodo .actions { justify-content: center; }

/* ===== LE SOLUZIONI — asymmetric via composition ===== */
.soluzioni { background: var(--bg-surface); }
.soluzioni__grid { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-xl); align-items: start; }
.soluzioni__label-col .coord { display: block; margin-bottom: 4px; }
.soluzioni__content-col .section__title { margin-bottom: var(--space-lg); }

/* ===== INIZIAMO — culmination ===== */
.iniziamo { background: var(--bg-primary); align-items: center; text-align: center; position: relative; overflow: hidden; }
.iniziamo::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: 900px; height: 900px;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle, rgba(74,222,128,0.10) 0%, rgba(74,222,128,0) 65%);
  pointer-events: none;
}
.iniziamo .coord, .iniziamo .connector, .iniziamo .section__title { margin-left: auto; margin-right: auto; position: relative; z-index: 1; }
.iniziamo .cta--primary { position: relative; z-index: 1; }

/* ===== Continuous thread ===== */
.thread {
  position: fixed; top: var(--nav-h); left: 50%; width: 1px; height: calc(100% - var(--nav-h));
  background: linear-gradient(to bottom, transparent 0%, rgba(74,222,128,0.05) 15%, rgba(74,222,128,0.05) 55%, rgba(74,222,128,0.22) 100%);
  pointer-events: none; z-index: 0;
}

/* ===== Corner crosshairs ===== */
.crosshair { position: fixed; width: 16px; height: 16px; z-index: 6; opacity: 0.3; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: var(--signal); }
.crosshair::before { top: 50%; left: 0; width: 100%; height: 1px; transform: translateY(-50%); }
.crosshair::after { left: 50%; top: 0; height: 100%; width: 1px; transform: translateX(-50%); }
.crosshair--tl { top: 24px; left: calc(var(--rail-w) + 8px); }
.crosshair--tr { top: 24px; right: calc(var(--rail-w) + 8px); }
.crosshair--bl { bottom: 24px; left: calc(var(--rail-w) + 8px); }
.crosshair--br { bottom: 24px; right: calc(var(--rail-w) + 8px); }

/* ===== BOTTOM SECTION NAVIGATOR ===== */
.section-nav {
  position: fixed; bottom: 0; left: var(--rail-w); right: var(--rail-w);
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(to top, rgba(10,10,12,0.95) 60%, transparent 100%);
  z-index: 8;
}
.section-nav__item {
  display: flex; flex-direction: column; gap: 4px; text-decoration: none;
  opacity: 0.45; transition: opacity 200ms ease;
}
.section-nav__item.is-active { opacity: 1; }
.section-nav__num {
  font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--signal); letter-spacing: 0.05em;
}
.section-nav__item:not(.is-active) .section-nav__num { color: var(--text-muted); }
.section-nav__name {
  font-family: "Inter", sans-serif; font-size: 13px; color: var(--text-primary); white-space: nowrap;
}
.section-nav__item:not(.is-active) .section-nav__name { color: var(--text-secondary); }
.section-nav__line { flex: 1; height: 1px; background: var(--border); margin: 0 var(--space-sm); }

/* ===== Reveal motion ===== */
[data-reveal] > * { opacity: 0; filter: blur(4px); transform: translateY(10px); }
[data-reveal].is-visible > * { animation: reveal 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards; }
[data-reveal].is-visible > *:nth-child(1) { animation-delay: 0ms; }
[data-reveal].is-visible > *:nth-child(2) { animation-delay: 60ms; }
[data-reveal].is-visible > *:nth-child(3) { animation-delay: 120ms; }
[data-reveal].is-visible > *:nth-child(4) { animation-delay: 180ms; }
[data-reveal].is-visible > *:nth-child(5) { animation-delay: 240ms; }
[data-reveal].is-visible > *:nth-child(6) { animation-delay: 300ms; }
@keyframes reveal { to { opacity: 1; filter: blur(0); transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] > * { animation: none !important; opacity: 1 !important; filter: none !important; transform: none !important; }
  .rail__arrow { animation: none !important; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  :root { --rail-w: 0px; --nav-h: 72px; }
  .rail { display: none; }
  .nav { padding: 0 var(--space-sm); gap: var(--space-sm); }
  .nav__logo { min-width: 0; flex-shrink: 1; font-size: 13px; }
  .nav__links { display: none; }
  .cta--nav { min-width: 0; flex-shrink: 0; padding: 8px 14px; font-size: 11px; }
  .section { padding: var(--space-xl) var(--space-md); margin: 0; min-height: auto; }
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: calc(var(--nav-h) + var(--space-lg)); }
  .hero__panel { height: 300px; margin-right: 0; }
  .hero__content { max-width: 100%; }
  .ghost { display: none; }
  .soluzioni__grid { grid-template-columns: 1fr; gap: var(--space-md); }
  .crosshair { display: none; }
  .section-nav { left: 0; right: 0; overflow-x: auto; gap: var(--space-sm); }
  .section-nav__line { display: none; }
  .section-nav__name { display: none; }
}
