/* ============================================================
   BetBrain — theme.css
   Sorgente unica dei token. Nessuna pagina deve piu' dichiarare
   il proprio :root: se un colore non e' qui, non esiste.

   Direzione: quotidiano dei numeri. Carta neutra, inchiostro
   quasi nero, filetti al posto delle ombre, numeri in mono
   tabellare. L'ottone e' un sigillo, non una vernice: si usa
   SOLO per il valore. Mai per decorare.
   ============================================================ */

/* ---------- 0. Caratteri, ospitati da noi ----------
   Niente chiamata a Google: il visitatore europeo non deve finire
   sui server di un terzo per leggere una pagina (e la nostra
   informativa privacy ringrazia). Piu' veloce, e senza dipendenze.  */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;              /* variabile */
  font-display: swap;
  src: url('/fonts/newsreader-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/newsreader-italic-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;              /* variabile */
  font-display: swap;
  src: url('/fonts/instrument-sans-var.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/dm-mono-500.woff2') format('woff2');
}

/* ---------- 1. Token: tema chiaro (default) ---------- */
:root {
  /* superfici */
  --paper:        #FBFBF9;   /* fondo pagina, carta neutra (non crema) */
  --surface:      #FFFFFF;   /* schede, tabelle */
  --surface-2:    #F3F2EE;   /* fasce, zone quiete */
  --surface-ink:  #0E0F0D;   /* blocchi invertiti (masthead, bottone primario) */

  /* inchiostri */
  --ink:          #0E0F0D;   /* testo primario */
  --ink-2:        #3B3C36;   /* testo secondario */
  --muted:        #71736B;   /* metadati, didascalie */
  --on-ink:       #FBFBF9;   /* testo sopra --surface-ink */

  /* filetti: il vero elemento di stile di questo sistema */
  --rule:         #E3E2DB;   /* hairline standard */
  --rule-2:       #CFCEC5;   /* hairline marcata */
  --rule-ink:     #0E0F0D;   /* filetto d'inchiostro (regola di testata) */

  /* accento unico — il sigillo */
  --brass:        #8A6A22;
  --brass-2:      #6E5419;   /* stato attivo/hover */
  --brass-wash:   rgba(138, 106, 34, .09);

  /* semantici: distinti dall'accento, per non confondere
     "valore" con "vinta" */
  --win:          #16624A;
  --win-wash:     rgba(22, 98, 74, .09);
  --loss:         #A03826;
  --loss-wash:    rgba(160, 56, 38, .09);
  --pending:      #71736B;

  /* tipografia */
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans:  'Instrument Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:  'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* scala tipografica */
  --t-kicker:  .6875rem;
  --t-meta:    .75rem;
  --t-small:   .8125rem;
  --t-body:    1rem;
  --t-lead:    1.125rem;
  --t-h3:      1.25rem;
  --t-h2:      clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
  --t-h1:      clamp(2.1rem, 1.4rem + 3.2vw, 3.5rem);
  --t-display: clamp(2.6rem, 1.5rem + 5vw, 4.75rem);

  /* ritmo */
  --sp-1: .25rem;  --sp-2: .5rem;   --sp-3: .75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4.5rem;

  /* forma: spigoli quasi vivi. Il raggio grande e' l'impronta
     digitale del template generico; qui non serve. */
  --r-1: 2px;
  --r-2: 3px;
  --r-pill: 999px;

  --maxw: 1160px;
  --maxw-read: 68ch;   /* misura di lettura per la prosa */

  /* ombre: quasi assenti. La profondita' la fanno i filetti. */
  --lift: 0 1px 0 rgba(14,15,13,.04), 0 8px 24px -16px rgba(14,15,13,.28);

  --ease: cubic-bezier(.2, .6, .2, 1);
  color-scheme: light;
}

/* ---------- 2. Token: tema scuro ---------- */
/* Automatico dalle preferenze di sistema... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:       #0B0C0A;
    --surface:     #131410;
    --surface-2:   #1C1D18;
    --surface-ink: #F2F1EA;

    --ink:         #F2F1EA;
    --ink-2:       #C7C6BC;
    --muted:       #8C8D84;
    --on-ink:      #0B0C0A;

    --rule:        rgba(242, 241, 234, .13);
    --rule-2:      rgba(242, 241, 234, .26);
    --rule-ink:    #F2F1EA;

    --brass:       #D9B366;
    --brass-2:     #EBC985;
    --brass-wash:  rgba(217, 179, 102, .12);

    --win:         #57A585;
    --win-wash:    rgba(87, 165, 133, .13);
    --loss:        #DC7B64;
    --loss-wash:   rgba(220, 123, 100, .13);
    --pending:     #8C8D84;

    --lift: 0 1px 0 rgba(0,0,0,.4), 0 12px 28px -18px rgba(0,0,0,.9);
    color-scheme: dark;
  }
}
/* ...e forzato dall'interruttore (deve vincere sulla media query) */
:root[data-theme="dark"] {
  --paper:       #0B0C0A;
  --surface:     #131410;
  --surface-2:   #1C1D18;
  --surface-ink: #F2F1EA;

  --ink:         #F2F1EA;
  --ink-2:       #C7C6BC;
  --muted:       #8C8D84;
  --on-ink:      #0B0C0A;

  --rule:        rgba(242, 241, 234, .13);
  --rule-2:      rgba(242, 241, 234, .26);
  --rule-ink:    #F2F1EA;

  --brass:       #D9B366;
  --brass-2:     #EBC985;
  --brass-wash:  rgba(217, 179, 102, .12);

  --win:         #57A585;
  --win-wash:    rgba(87, 165, 133, .13);
  --loss:        #DC7B64;
  --loss-wash:   rgba(220, 123, 100, .13);
  --pending:     #8C8D84;

  --lift: 0 1px 0 rgba(0,0,0,.4), 0 12px 28px -18px rgba(0,0,0,.9);
  color-scheme: dark;
}

/* ---------- 2b. Ponte di compatibilita' ----------
   Le pagine nate prima di questo file chiedono ancora i vecchi nomi
   (--gold, --ground, --bd, --cream...). Qui li alimentiamo con i token
   nuovi, cosi' la migrazione non deve riscrivere migliaia di regole.

   Gli alias puntano a var(--token), non a un colore: quindi seguono
   da soli il tema chiaro e quello scuro.

   NB: e' un ponte, non una casa. Man mano che le pagine vengono
   ripulite, i nomi legacy vanno sparendo — e questa sezione con loro.  */
:root {
  /* superfici */
  --ground:      var(--paper);
  --ground-2:    var(--surface-2);
  --paper-alt:   var(--surface-2);
  --paper-hi:    var(--surface-2);
  --paper-muted: var(--surface-2);

  /* inchiostri */
  --ink-soft:    var(--ink-2);
  --ink-mute:    var(--muted);
  --ink-light:   var(--muted);

  /* filetti e bordi */
  --bd:          var(--rule);
  --bd-lt:       var(--rule);
  --bd-dk:       var(--rule-2);
  --line:        var(--rule);
  --line-soft:   var(--rule);
  --line-md:     var(--rule-2);

  /* oro -> ottone. I tre toni collassano su due: il sistema nuovo non
     ha bisogno di un oro chiaro decorativo. */
  --gold:        var(--brass);
  --gold-lt:     var(--brass);
  --gold-dk:     var(--brass-2);
  --gold-deep:   var(--brass-2);
  --gold-bg:     var(--brass-wash);
  --gold-wash:   var(--brass-wash);
  --gold-bd:     var(--brass);
  --amber:       var(--brass);

  /* semantici */
  --green:       var(--win);
  --green-bg:    var(--win-wash);
  --red:         var(--loss);
  --red-bg:      var(--loss-wash);

  /* pagine legali: usavano --cream/-2/-3 come i tre livelli di TESTO
     su fondo scuro. Ora sono pagine normali: stessi tre livelli,
     ma di inchiostro. */
  --cream:       var(--ink);
  --cream-2:     var(--ink-2);
  --cream-3:     var(--muted);

  /* varie */
  --shadow:      var(--lift);
  --btn-ink:     var(--on-ink);
}

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

/* Grana di carta: appena percettibile, tiene il fondo dal sembrare
   plasticoso. Se da' fastidio, si spegne da qui e sparisce ovunque. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::before { opacity: .13; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { opacity: .13; }
}

/* Tutti i numeri della UI hanno la stessa larghezza: le colonne di
   quote e percentuali non devono "ballare" mentre si aggiornano. */
.num, td.num, .stat-value, .odds, .prob {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.011em;
  margin: 0 0 var(--sp-3);
  font-optical-sizing: auto;
  text-wrap: balance;   /* niente titoli con una parola orfana in fondo */
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); line-height: 1.25; }

p { margin: 0 0 var(--sp-4); }

a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--brass), var(--brass));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size .3s var(--ease), color .2s var(--ease);
}
a:hover { color: var(--brass-2); background-size: 100% 1px; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

hr, .rule { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-5) 0; }
.rule-ink { border: 0; border-top: 1.5px solid var(--rule-ink); margin: var(--sp-4) 0; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-5); position: relative; z-index: 1; }
.read { max-width: var(--maxw-read); }

/* ---------- 4. Tipografia editoriale ---------- */

/* L'occhiello: mono maiuscolo spaziato. E' il segnale "giornale"
   che sostituisce il serif svolazzante di prima. */
.kicker {
  font-family: var(--mono);
  font-size: var(--t-kicker);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.kicker::before {
  content: "";
  width: 1.75rem;
  height: 1px;
  background: var(--brass);
}
.kicker--bare::before { display: none; }

.headline { font-family: var(--serif); font-weight: 600; letter-spacing: -.015em; line-height: 1.08; }
.display  { font-family: var(--serif); font-size: var(--t-display); font-weight: 600; letter-spacing: -.022em; line-height: 1.02; }

/* Il sommario in corsivo: la voce del giornale, senza la pergamena. */
.standfirst {
  font-family: var(--serif);
  font-size: var(--t-lead);
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-2);
}

.dateline {
  font-family: var(--mono);
  font-size: var(--t-meta);
  color: var(--muted);
  letter-spacing: .02em;
}

.byline { font-size: var(--t-small); color: var(--muted); }

.lede::first-letter {
  float: left;
  font-family: var(--serif);
  font-size: 3.4em;
  line-height: .82;
  font-weight: 600;
  padding: .06em .09em 0 0;
  color: var(--ink);
}

.prose { max-width: var(--maxw-read); }
.prose p { color: var(--ink-2); }

/* ---------- 5. Schede ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: var(--sp-5);
  position: relative;
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card:hover { border-color: var(--rule-2); }
.card--link:hover { transform: translateY(-2px); box-shadow: var(--lift); }

/* La scheda con il valore porta il sigillo: un filo d'ottone in alto.
   E' l'unico posto, con il badge, in cui l'accento compare. */
.card--value { border-color: var(--rule-2); }
.card--value::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 2px;
  background: var(--brass);
  border-radius: var(--r-2) var(--r-2) 0 0;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* ---------- 6. Bottoni ---------- */
.btn {
  --btn-bg: transparent;
  --btn-ink: var(--ink);
  --btn-rule: var(--rule-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--sans);
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: .01em;
  padding: .625rem 1.125rem;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-rule);
  border-radius: var(--r-2);
  cursor: pointer;
  transition: transform .16s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary { --btn-bg: var(--surface-ink); --btn-ink: var(--on-ink); --btn-rule: var(--surface-ink); }
.btn--primary:hover { --btn-bg: var(--ink-2); --btn-rule: var(--ink-2); }

.btn--ghost:hover { --btn-rule: var(--ink); }

.btn--sm { padding: .375rem .75rem; font-size: var(--t-meta); }

/* ---------- 7. Chip, badge, verdetto ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--mono);
  font-size: var(--t-meta);
  padding: .1875rem .5rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  color: var(--ink-2);
  background: var(--surface-2);
  white-space: nowrap;
}

/* Il sigillo del valore. Unico uso legittimo dell'ottone pieno. */
.seal {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--mono);
  font-size: var(--t-kicker);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .25rem .5rem;
  color: var(--brass-2);
  background: var(--brass-wash);
  border: 1px solid var(--brass);
  border-radius: var(--r-1);
}
:root[data-theme="dark"] .seal { color: var(--brass); }

/* Verdetto: giocarla / lasciarla / niente valore.
   Deterministico, mai sfumato. */
.verdict {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--sans);
  font-size: var(--t-small);
  font-weight: 600;
  padding: .3125rem .625rem;
  border-radius: var(--r-1);
  border: 1px solid transparent;
}
.verdict--play  { color: var(--win);  background: var(--win-wash);  border-color: var(--win); }
.verdict--pass  { color: var(--loss); background: var(--loss-wash); border-color: var(--loss); }
.verdict--none  { color: var(--muted); background: var(--surface-2); border-color: var(--rule-2); }
.verdict__dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }

/* Fascia di rischio: testo, non semaforo. Il colore lo merita
   solo il valore. */
.tier { font-family: var(--mono); font-size: var(--t-meta); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- 8. Numeri ---------- */
.stat { display: flex; flex-direction: column; gap: var(--sp-1); }
.stat-value {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--ink);
}
.stat-label {
  font-family: var(--sans);
  font-size: var(--t-meta);
  color: var(--muted);
  letter-spacing: .01em;
}
.stat--win .stat-value { color: var(--win); }

/* Barra di probabilita': un filetto, non una barra da videogioco. */
.meter { height: 3px; background: var(--rule); border-radius: var(--r-pill); overflow: hidden; }
.meter__fill { height: 100%; background: var(--ink); border-radius: inherit; transform-origin: left; }
.meter--brass .meter__fill { background: var(--brass); }

/* ---------- 9. Tabella editoriale ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
.table thead th {
  font-family: var(--mono);
  font-size: var(--t-kicker);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  text-align: left;
  padding: 0 var(--sp-3) var(--sp-2);
  border-bottom: 1.5px solid var(--rule-ink);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: middle;
}
.table tbody tr { transition: background-color .18s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-right { text-align: right; }
.table .t-team { color: var(--ink); font-weight: 500; }

.outcome { font-family: var(--mono); font-weight: 500; }
.outcome--win  { color: var(--win); }
.outcome--loss { color: var(--loss); }
.outcome--open { color: var(--pending); }

/* Contenitore per tabelle larghe: scorre lei, non la pagina. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 10. Contenuto riservato ---------- */
/* Il lucchetto non deve mentire: si mostra che il dato esiste,
   non un finto blur su contenuto vuoto. */
.locked { position: relative; }
.locked__veil {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  gap: var(--sp-2);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(3px);
  border-radius: var(--r-2);
  text-align: center;
  padding: var(--sp-4);
}
.locked__veil .kicker { color: var(--ink-2); }

/* ---------- 11. Testata ---------- */
.masthead { border-bottom: 1.5px solid var(--rule-ink); background: var(--paper); }
.masthead__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding-block: var(--sp-4);
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
  background: none;
}
.wordmark:hover { color: inherit; }
.nav { display: flex; gap: var(--sp-5); font-size: var(--t-small); }
.nav a { color: var(--ink-2); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- 11b. Interruttore del tema ----------
   Vive qui e non nelle pagine: prima esisteva solo in home, e chi
   accendeva il tema scuro non poteva piu' spegnerlo da dentro l'app. */
.tgl {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.tgl:hover { border-color: var(--brass); color: var(--brass); }

/* ---------- 12. Movimento ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .6s var(--ease) both; }
.rise-1 { animation-delay: .04s } .rise-2 { animation-delay: .1s }
.rise-3 { animation-delay: .16s } .rise-4 { animation-delay: .22s }
.rise-5 { animation-delay: .28s } .rise-6 { animation-delay: .34s }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 13. Utilita' ---------- */
.grid { display: grid; gap: var(--sp-4); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: var(--t-small); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
