/* ═══════════════════════════════════════════════
   SISTEMA/AI — esperienza standalone
   nero profondo · volt #c8ff2e · ghiaccio #5be3ff
   ═══════════════════════════════════════════════ */

@font-face {
  font-family: "Bricolage";
  src: url("/ai-automazioni/fonts/BricolageGrotesque-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Instrument";
  src: url("/ai-automazioni/fonts/InstrumentSerif-400-italic.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument";
  src: url("/ai-automazioni/fonts/InstrumentSerif-400-normal.woff2") format("woff2");
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "SpaceMono";
  src: url("/ai-automazioni/fonts/SpaceMono-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "SpaceMono";
  src: url("/ai-automazioni/fonts/SpaceMono-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --nero: #060607;
  --carbone: #0a0b0d;
  --panna: #ece9e2;
  --grigio: #8b8f98;
  --linea: #23262c;
  --volt: #c8ff2e;
  --ice: #5be3ff;
  --display: "Bricolage", system-ui, sans-serif;
  --serif: "Instrument", Georgia, serif;
  --mono: "SpaceMono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

html { overflow-x: clip; }

body {
  background: var(--nero);
  color: var(--panna);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* grana */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 200;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.volt { color: var(--volt); }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
a { color: inherit; text-decoration: none; }
.svg-defs { position: absolute; width: 0; height: 0; }
::selection { background: var(--volt); color: var(--nero); }

/* ═══ PRELOADER ═══ */
#preloader {
  position: fixed; inset: 0; z-index: 500;
  background: var(--nero);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 32px clamp(20px, 4vw, 56px);
}
.pre-log {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  color: var(--grigio); text-transform: uppercase;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 40vh; overflow: hidden;
}
.pre-log .ok { color: var(--volt); }
.pre-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; }
.pre-count {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(90px, 18vw, 220px); line-height: 1;
  color: var(--panna); font-variant-numeric: tabular-nums;
}
.pre-count sup { font-size: 0.25em; color: var(--volt); }
.pre-bar { width: min(320px, 60vw); height: 1px; background: var(--linea); margin: 28px auto 0; }
.pre-bar span { display: block; height: 100%; width: 0; background: var(--volt); }
.pre-foot { color: var(--grigio); text-align: center; }

/* ═══ CURSORE ═══ */
.cursor, .cursor-ring {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 300;
  border-radius: 50%; transform: translate(-50%, -50%);
}
.cursor { width: 8px; height: 8px; background: var(--volt); mix-blend-mode: difference; }
.cursor-ring {
  width: 36px; height: 36px; border: 1px solid rgba(200, 255, 46, 0.5);
  transition: width 0.25s, height 0.25s, border-color 0.25s;
}
.cursor-ring.is-hover { width: 64px; height: 64px; border-color: var(--ice); }
@media (hover: none), (pointer: coarse) { .cursor, .cursor-ring { display: none; } }

/* ═══ HUD ═══ */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px clamp(20px, 4vw, 56px);
  mix-blend-mode: difference;
}
.hud-brand { font-weight: 700; font-size: 14px; }
.hud-status { color: var(--grigio); display: flex; align-items: center; gap: 8px; }
.led { width: 6px; height: 6px; border-radius: 50%; background: var(--volt); display: inline-block; animation: led 1.4s steps(1) infinite; }
@keyframes led { 50% { opacity: 0.15; } }
.hud-cta { border: 1px solid var(--linea); padding: 8px 14px; transition: background 0.3s, color 0.3s; }
.hud-cta:hover { background: var(--volt); color: var(--nero); border-color: var(--volt); }
.hud-side {
  position: fixed; right: 18px; top: 50%; z-index: 100;
  transform: rotate(90deg) translateX(50%); transform-origin: right center;
  color: var(--grigio); white-space: nowrap; pointer-events: none;
}
.scroll-progress {
  position: fixed; left: 0; top: 0; bottom: 0; width: 2px; z-index: 100;
  background: var(--linea);
}
.scroll-progress span { display: block; width: 100%; height: 0; background: linear-gradient(var(--volt), var(--ice)); }

@media (max-width: 720px) {
  .hud-status { display: none; }
  .hud-side { display: none; }
}

/* ═══ HERO ═══ */
.hero {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center;
  padding: 0 clamp(20px, 5vw, 72px);
  overflow: hidden;
}
#neural-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; z-index: 2; width: 100%; }
.hero-eyebrow { color: var(--volt); margin-bottom: 4vh; }
.hero-title {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 12.2vw, 200px);
  line-height: 0.92; letter-spacing: -0.02em;
  text-transform: uppercase;
}
.hero-title .line { display: block; overflow: hidden; }
.hero-title .line-in { display: inline-block; will-change: transform; }
.line-serif { font-family: var(--serif); font-weight: 400; text-transform: none; }
.line-serif em { font-size: 0.94em; color: var(--ice); letter-spacing: 0; }
.hero-sub {
  margin-top: 5vh; max-width: 460px;
  font-size: clamp(17px, 1.6vw, 21px); color: var(--grigio);
}
.hero-sub em { color: var(--panna); }
.hero-scroll {
  position: absolute; bottom: 30px; left: clamp(20px, 5vw, 72px); z-index: 2;
  display: flex; align-items: center; gap: 14px; color: var(--grigio);
}
.scroll-line { animation: scrollNudge 1.8s ease-in-out infinite; }
@keyframes scrollNudge { 50% { transform: translateY(5px); } }
.hero-num { position: absolute; bottom: 30px; right: clamp(20px, 5vw, 72px); color: var(--grigio); z-index: 2; }

/* ═══ MARQUEE CINETICO ═══ */
.kinetic { padding: 14vh 0 10vh; overflow: hidden; border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea); }
.k-row { white-space: nowrap; }
.k-track { display: inline-flex; will-change: transform; }
.k-track span {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(64px, 11vw, 160px); line-height: 1.05; letter-spacing: -0.02em;
  padding-right: 0.3em;
}
.k-outline span {
  color: transparent;
  -webkit-text-stroke: 1px var(--grigio);
}

/* ═══ ANATOMIA — una richiesta vera, dal vivo ═══ */
.organism { position: relative; }
.org-pin {
  height: 100vh; height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 84px clamp(20px, 4vw, 56px) 28px;
}
.org-kicker { color: var(--volt); }

.flow-viewport { position: relative; width: 100%; overflow: hidden; margin-top: 3vh; }
.flow-wrap { position: absolute; left: 50%; top: 0; width: 1240px; margin-left: -620px; transform-origin: top center; }
.flow-world { position: relative; width: 1240px; height: 470px; }

.flow-rail { position: absolute; left: 0; top: 268px; overflow: visible; }
.rail-glow { transform-origin: left center; transform: scaleX(0); filter: drop-shadow(0 0 6px rgba(200, 255, 46, 0.6)); }

/* 1 · email */
.mail-card {
  position: absolute; left: 24px; top: 182px; width: 252px;
  background: var(--carbone); border: 1px solid var(--linea); border-radius: 10px;
  padding: 14px 16px 34px; z-index: 4;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.mail-card.scanned { border-color: var(--volt); box-shadow: 0 0 34px rgba(200, 255, 46, 0.22); }
.mail-top { color: var(--grigio); display: flex; align-items: center; gap: 7px; font-size: 9px; }
.mail-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ice); flex: none; animation: led 1.4s steps(1) infinite; }
.mail-subj { font-family: var(--display); font-weight: 800; font-size: 15px; line-height: 1.15; margin: 9px 0 11px; text-transform: none; }
.mail-line { height: 6px; border-radius: 3px; background: #21242a; margin-bottom: 7px; transform-origin: left; }
.mail-from { color: var(--ice); font-size: 9px; margin-top: 10px; text-transform: none; }
.mail-badge {
  position: absolute; right: -12px; bottom: -12px;
  background: var(--volt); color: var(--nero); font-weight: 700; font-size: 10px;
  padding: 6px 10px; border-radius: 4px; transform: rotate(-5deg);
  box-shadow: 0 6px 18px rgba(200, 255, 46, 0.35);
}

/* 2 · scanner */
.scanner {
  position: absolute; left: 428px; top: 96px; width: 274px; height: 328px;
  border: 1px solid var(--linea); border-radius: 14px; background: rgba(10, 11, 13, 0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 16px 14px; z-index: 3;
}
.scanner::before, .scanner::after {
  content: ""; position: absolute; width: 26px; height: 26px;
  border: 2px solid var(--volt); pointer-events: none;
}
.scanner::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.scanner::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.scanner-label { color: var(--volt); font-weight: 700; }
.scan-window {
  position: relative; width: 100%; flex: 1; margin: 12px 0; overflow: hidden;
  border: 1px dashed #2c2f36; border-radius: 8px;
  background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 22px 22px;
}
.scan-beam {
  position: absolute; left: 4%; width: 92%; height: 2px; top: 8%;
  background: linear-gradient(90deg, transparent, var(--volt), transparent);
  box-shadow: 0 0 18px 3px rgba(200, 255, 46, 0.45);
  opacity: 0;
}
.scanner-foot { color: var(--grigio); font-size: 9px; }

/* dati estratti */
.chips { position: absolute; left: 0; top: 0; z-index: 5; }
.chip {
  position: absolute; white-space: nowrap;
  background: var(--nero); border: 1px solid var(--ice); color: var(--ice);
  font-size: 10px; text-transform: none; padding: 6px 10px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* 3 · azioni */
.actions { position: absolute; left: 770px; top: 158px; width: 258px; display: flex; flex-direction: column; gap: 12px; z-index: 3; }
.action {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid var(--linea); background: var(--carbone); border-radius: 8px;
  padding: 12px 14px; font-family: var(--mono); font-size: 11px; text-transform: none;
  color: var(--panna); letter-spacing: 0.02em;
}
.a-check {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: var(--volt); color: var(--nero);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
}

/* 4 · telefono */
.phone {
  position: absolute; left: 1052px; top: 70px; width: 172px; height: 330px;
  border: 1.5px solid #34383f; border-radius: 26px; background: #0d0e11;
  padding: 12px 10px; z-index: 3;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.phone-notch { width: 54px; height: 5px; border-radius: 3px; background: #23262c; margin: 2px auto 18px; }
.phone-time { font-family: var(--display); font-weight: 800; font-size: 34px; text-align: center; color: #3d4149; }
.notif {
  margin-top: 16px; background: #16181d; border-left: 3px solid var(--volt);
  border-radius: 8px; padding: 10px 11px;
}
.notif-head { color: var(--volt); font-size: 8.5px; margin-bottom: 6px; }
.notif-body { font-family: var(--mono); font-size: 10px; line-height: 1.45; color: var(--grigio); text-transform: none; letter-spacing: 0.02em; }
.notif-body strong { color: var(--panna); }

/* cronometro */
.elapsed {
  position: absolute; left: 900px; top: 56px; z-index: 5;
  border: 1px solid var(--linea); border-radius: 999px; padding: 7px 13px;
  color: var(--volt); background: var(--nero); font-variant-numeric: tabular-nums;
}

/* didascalie */
.flow-caps { position: relative; min-height: 108px; margin-top: 20px; max-width: 620px; }
.org-cap { position: absolute; top: 0; left: 0; opacity: 0; }
.org-cap h3 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(22px, 3vw, 38px); line-height: 1; margin-bottom: 8px;
}
.org-cap h3 em { color: var(--volt); text-transform: none; }
.org-cap p { color: var(--grigio); font-size: 15px; max-width: 520px; }
.org-progress { color: var(--grigio); text-align: right; }

@media (max-width: 720px) {
  .org-cap h3 { font-size: 24px; }
  .org-cap p { font-size: 14px; }
}

/* ═══ GALLERIA ORIZZONTALE ═══ */
.works { position: relative; }
.works-pin { height: 100vh; height: 100svh; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.works-head { padding: 0 clamp(20px, 4vw, 56px) 4vh; }
.works-head .mono { color: var(--volt); }
.works-track { display: flex; gap: clamp(16px, 2.5vw, 40px); padding: 0 clamp(20px, 5vw, 72px); width: max-content; will-change: transform; }
.panel {
  width: clamp(300px, 38vw, 520px); min-height: 56vh;
  border: 1px solid var(--linea); background: var(--carbone);
  padding: clamp(20px, 2.5vw, 40px);
  display: flex; flex-direction: column; position: relative;
  transition: border-color 0.4s;
}
.panel:hover { border-color: var(--volt); }
.panel-idx { color: var(--grigio); }
.panel-art { width: 100%; height: 150px; margin: 3vh 0; }
.panel h3 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(30px, 3.4vw, 48px); line-height: 0.95; margin-bottom: 16px;
}
.panel h3 em { color: var(--volt); text-transform: none; }
.panel p { color: var(--grigio); font-size: 16px; flex: 1; }
.panel-tags { color: var(--ice); margin-top: 20px; }
.panel-cta { justify-content: center; align-items: flex-start; gap: 4vh; background: transparent; border-style: dashed; }
.panel-cta h3 { font-size: clamp(40px, 4.5vw, 64px); }
.btn-ghost { border: 1px solid var(--volt); color: var(--volt); padding: 14px 22px; transition: background 0.3s, color 0.3s; }
.btn-ghost:hover { background: var(--volt); color: var(--nero); }

/* ═══ FEED LIVE ═══ */
.live { padding: 20vh clamp(20px, 5vw, 72px); border-top: 1px solid var(--linea); }
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(30px, 5vw, 90px); max-width: 1300px; margin: 0 auto; align-items: center; }
.live-copy .mono { color: var(--volt); margin-bottom: 3vh; }
.live-copy h2 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(36px, 4.5vw, 64px); line-height: 0.98; margin-bottom: 3vh;
}
.live-copy h2 em { text-transform: none; }
.live-p { color: var(--grigio); max-width: 480px; }
.live-stats { display: flex; gap: clamp(20px, 3vw, 50px); margin-top: 6vh; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-n {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(38px, 4vw, 60px); line-height: 1; color: var(--volt);
  font-variant-numeric: tabular-nums;
}
.stat-l { color: var(--grigio); }
.terminal { border: 1px solid var(--linea); background: var(--carbone); }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--linea); color: var(--grigio); }
.term-body { padding: 18px 16px; min-height: 320px; font-size: 12px; letter-spacing: 0.04em; text-transform: none; color: var(--grigio); display: flex; flex-direction: column; gap: 8px; }
.term-body .t-time { color: var(--ice); }
.term-body .t-ok { color: var(--volt); }
.term-body .t-line { opacity: 0; }
.term-caret { display: inline-block; width: 8px; height: 13px; background: var(--volt); vertical-align: -2px; animation: led 1s steps(1) infinite; }

@media (max-width: 900px) { .live-grid { grid-template-columns: 1fr; } }

/* ═══ MANIFESTO ═══ */
.manifesto { padding: 24vh clamp(20px, 5vw, 72px); max-width: 1200px; margin: 0 auto; }
.manifesto .mono { color: var(--volt); margin-bottom: 5vh; }
.mani-text { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: clamp(38px, 6.5vw, 96px); line-height: 1.02; letter-spacing: -0.015em; }
.mani-line { display: block; overflow: hidden; }
.mani-line em { color: var(--ice); text-transform: none; }

/* ═══ FINALE ═══ */
.finale {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 12vh clamp(20px, 5vw, 72px) 0;
  border-top: 1px solid var(--linea); overflow: hidden;
}
#finale-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.finale-kicker { color: var(--volt); position: relative; z-index: 2; }
.finale-title {
  position: relative; z-index: 2;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(56px, 13vw, 210px); line-height: 1; letter-spacing: -0.02em;
  margin: 4vh 0; display: inline-block;
  filter: url(#f-warp);
  transition: color 0.3s;
}
.finale-title:hover { color: var(--volt); }
.finale-sub { position: relative; z-index: 2; color: var(--grigio); max-width: 440px; }
.finale-links { position: relative; z-index: 2; display: flex; gap: 18px; margin-top: 6vh; flex-wrap: wrap; justify-content: center; }
.finale-links a { border: 1px solid var(--linea); padding: 13px 20px; transition: all 0.3s; }
.finale-links a:hover { border-color: var(--volt); color: var(--volt); transform: translateY(-3px); }
.finale-foot {
  position: relative; z-index: 2; width: 100%;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--grigio); padding: 10vh 0 28px;
}
.finale-foot a:hover { color: var(--volt); }

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
  body::after, .led, .scroll-line, .term-caret, .mail-dot { animation: none !important; }
  .rail-glow { transform: scaleX(1); }
}
