/* Base: colori, tipografia, impaginazione, apertura scura, chiusura, pulsanti, animazioni. */

:root {
  --black: #0B0B0D;
  --white: #FFFFFF;
  --gold: #D4A251;
  --gold-light: #F0CB82;
  --gold-dark: #9C6A25;
  --gold-ink: #8A5D1F;           /* oro leggibile su bianco */

  --ink: #0B0B0D;
  --ink-soft: rgba(11, 11, 13, .62);
  --ink-mute: rgba(11, 11, 13, .38);
  --line: rgba(11, 11, 13, .09);
  --on-dark: #FFFFFF;
  --on-dark-soft: rgba(255, 255, 255, .64);
  --on-dark-mute: rgba(255, 255, 255, .38);
  --line-dark: rgba(255, 255, 255, .14);

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --dur: 1.2s;

  --container: 72rem;
  --pad: clamp(1.25rem, 4vw, 3rem);
  --radius: 1.25rem;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html.present { font-size: 20px; }
@media (min-width: 1800px) { html.present { font-size: 22px; } }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: var(--black);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--pad); }
.dark { background: var(--black); color: var(--on-dark); }
.light { background: var(--white); color: var(--ink); }

/* Tipografia */
.display {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: .98;
  margin: 0;
}
.display em, .section-title em { font-style: italic; color: var(--gold); }
.light .section-title em { color: var(--gold-ink); }
.eyebrow {
  margin: 0 0 1.25rem;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}
.light .eyebrow { color: var(--gold-ink); }
.lead { font-size: clamp(1.05rem, 1.6vw, 1.3rem); font-weight: 300; line-height: 1.5; max-width: 38rem; color: var(--on-dark-soft); margin: 1.75rem 0 0; }
.num { font-variant-numeric: tabular-nums; }

/* Header */
.site-header {
  position: absolute; inset: 0 0 auto 0; z-index: 10;
  padding: clamp(1.25rem, 3vw, 2rem) var(--pad);
}
.wordmark {
  font-size: .8rem; font-weight: 500; letter-spacing: .42em;
  color: var(--white); text-decoration: none;
}

/* Apertura scura */
.hero {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 8rem 0 5rem;
  overflow: hidden;
}
body[data-state="loading"] .hero, body[data-state="report"] .hero { min-height: 0; padding: 7.5rem 0 3rem; }
.hero-glow {
  position: absolute; inset: -20% -10% auto auto; width: 70vw; height: 90vh;
  background: radial-gradient(closest-side, rgba(212, 162, 81, .16), rgba(212, 162, 81, .04) 55%, transparent 75%);
  pointer-events: none;
}
.hero .display { font-size: clamp(3.1rem, 8vw, 7.25rem); }
.hero-intro { position: relative; }

/* Modulo */
.analyze-form {
  margin-top: clamp(2.5rem, 5vw, 3.75rem);
  display: grid;
  grid-template-columns: 1.15fr 1fr auto;
  gap: 1rem;
  align-items: end;
  max-width: 62rem;
}
.analyze-form .field-code { grid-column: 1 / 2; grid-row: 2; }
.analyze-form > .btn { grid-column: 3; grid-row: 1; }
.field label {
  display: block; margin-bottom: .6rem;
  font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--on-dark-mute);
}
.input-wrap {
  display: flex; align-items: center;
  height: 4rem; padding: 0 1.25rem;
  border: 1px solid var(--line-dark); border-radius: 999px;
  background: rgba(255, 255, 255, .03);
  transition: border-color .4s var(--ease-soft), background .4s var(--ease-soft);
}
.input-wrap:focus-within { border-color: var(--gold); background: rgba(255, 255, 255, .05); }
.input-wrap .prefix { font-size: 1.25rem; color: var(--gold); margin-right: .15rem; }
.input-wrap input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: 1.25rem; font-weight: 300; color: var(--white);
}
.input-wrap input::placeholder { color: var(--on-dark-mute); }
.form-error {
  grid-column: 1 / -1; margin: .25rem 0 0;
  color: var(--gold-light); font-size: 1rem;
}

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .75rem;
  height: 4rem; padding: 0 2rem;
  border: 0; border-radius: 999px; cursor: pointer;
  font-size: 1.05rem; font-weight: 500; letter-spacing: .01em; white-space: nowrap;
  transition: transform .5s var(--ease), background .4s var(--ease-soft), box-shadow .5s var(--ease), opacity .3s;
}
.btn:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
.btn-gold { background: var(--gold); color: var(--black); box-shadow: 0 10px 30px -12px rgba(212, 162, 81, .55); }
.btn-gold:hover { background: var(--gold-light); transform: translateY(-1px); }
.btn-gold[disabled] { opacity: .7; cursor: progress; }
.btn-ghost { background: transparent; color: var(--white); border: 1px solid var(--line-dark); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: #1c1c20; transform: translateY(-1px); }
.btn-arrow { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform .5s var(--ease); }
.btn:hover .btn-arrow { transform: translateX(3px); }
.btn.is-busy .btn-arrow { animation: nudge 1s var(--ease-soft) infinite alternate; }
@keyframes nudge { to { transform: translateX(5px); } }

/* Passaggi morbidi scuro → bianco → scuro, senza riga visibile */
.fade-band { height: clamp(7rem, 14vw, 11rem); display: none; }
.fade-to-light { background: linear-gradient(to bottom, #0B0B0D 0%, #141416 14%, #2e2e31 28%, #5d5d60 44%, #9a9a9c 60%, #d2d2d3 76%, #f4f4f4 90%, #FFFFFF 100%); }
.fade-to-dark { background: linear-gradient(to bottom, #FFFFFF 0%, #f4f4f4 10%, #d2d2d3 24%, #9a9a9c 40%, #5d5d60 56%, #2e2e31 72%, #141416 86%, #0B0B0D 100%); }
body[data-state="loading"] .fade-band, body[data-state="report"] .fade-band { display: block; }

/* Chiusura */
.closing { padding: clamp(4rem, 9vw, 7rem) 0 clamp(3rem, 6vw, 5rem); text-align: center; }
.closing-title { font-size: clamp(2.6rem, 6vw, 5rem); }
.closing-text { margin: 1.5rem auto 0; color: var(--on-dark-soft); font-size: 1rem; letter-spacing: .02em; }
.site-footer { padding: 2rem var(--pad) 2.5rem; text-align: center; border-top: 1px solid rgba(255, 255, 255, .06); }
.site-footer p { margin: 0; font-size: .8rem; letter-spacing: .06em; color: var(--on-dark-mute); }
.site-footer a { text-decoration: none; color: var(--on-dark-soft); transition: color .3s; }
.site-footer a:hover { color: var(--gold); }

/* Animazioni: poche, lente, morbide */
.title-lines .line { display: block; overflow: hidden; padding-bottom: .08em; }
.title-lines .line > span { display: inline-block; transform: translateY(105%); animation: line-up 1.1s var(--ease) forwards; }
.title-lines .line:nth-child(2) > span { animation-delay: .14s; }
.title-lines .line:nth-child(3) > span { animation-delay: .28s; }
@keyframes line-up { to { transform: none; } }

.fade-up { opacity: 0; transform: translateY(14px); animation: fade-up var(--dur) var(--ease) var(--d, 0s) forwards; }
@keyframes fade-up { to { opacity: 1; transform: none; } }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity var(--dur) var(--ease) var(--d, 0s), transform var(--dur) var(--ease) var(--d, 0s); }
.reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 760px) {
  .analyze-form { grid-template-columns: 1fr; }
  .analyze-form .field-code, .analyze-form > .btn { grid-column: auto; grid-row: auto; }
  .analyze-form .btn { width: 100%; margin-top: .5rem; }
  .input-wrap { height: 3.6rem; }
  .hero { padding: 7rem 0 4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .fade-up, .reveal { opacity: 1; transform: none; }
  .title-lines .line > span { transform: none; }
}
