/*
    FFZ Games — superficie pubblica indicizzabile (§4.7).

    Zero JavaScript, per contratto: queste pagine sono static SSR e non aprono nessun circuito.
    Tutto ciò che sembra interattivo qui — menu, filtri, stati — è CSS o un normale GET.

    Il tema segue quello di sistema. Le due palette sono definite entrambe: una pagina indicizzata
    viene aperta tanto da chi ha il browser chiaro quanto da chi ce l'ha scuro, e "leggibile solo in
    uno dei due" non è un dettaglio estetico.
*/

:root {
    color-scheme: light dark;

    --bg: #fbfbfd;
    --surface: #ffffff;
    --surface-2: #f4f5f8;
    --ink: #14161a;
    --ink-soft: #4a5058;
    --ink-faint: #767d87;
    --line: #e3e6ec;
    --line-strong: #cfd4dd;

    --accent: #1d4ed8;
    --accent-ink: #ffffff;
    --accent-soft: #eaf0ff;

    /* Il colore del marchio: fisso, fuori dai temi dei giochi, così il logo è lo stesso su ogni pagina. */
    --brand: #4f46e5;
    --brand-ink: #ffffff;

    --ok: #0f7a3d;
    --ok-soft: #e6f5ec;
    --warn: #9a6700;
    --warn-soft: #fdf3d8;
    --bad: #b3261e;
    --bad-soft: #fceceb;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 20, 28, .05), 0 8px 24px -12px rgba(16, 20, 28, .18);
    --shadow-lift: 0 2px 6px rgba(16, 20, 28, .07), 0 18px 40px -20px rgba(16, 20, 28, .28);

    --wrap: 1120px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1014;
        --surface: #151a21;
        --surface-2: #1b222b;
        --ink: #eef1f5;
        --ink-soft: #b3bcc8;
        --ink-faint: #8891a0;
        --line: #262f3a;
        --line-strong: #35404e;

        --accent: #7aa2ff;
        --accent-ink: #0d1014;
        --accent-soft: #17233d;

        --brand: #818cf8;
        --brand-ink: #0d1014;

        --ok: #5ed08a;
        --ok-soft: #12281c;
        --warn: #e5b23c;
        --warn-soft: #2a2314;
        --bad: #ff8a80;
        --bad-soft: #2c1817;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .7);
        --shadow-lift: 0 2px 6px rgba(0, 0, 0, .45), 0 18px 40px -20px rgba(0, 0, 0, .8);
    }
}

/*
    Il tema del gioco dei pronostici è la palette di base, dichiarata di nuovo per nome: la sua scheda
    nell'intestazione deve restare blu anche quando la pagina intorno ha il tema di un altro gioco.
*/
.theme-prediction {
    --accent: #1d4ed8;
    --accent-ink: #ffffff;
    --accent-soft: #eaf0ff;
}

@media (prefers-color-scheme: dark) {
    .theme-prediction {
        --accent: #7aa2ff;
        --accent-ink: #0d1014;
        --accent-soft: #17233d;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.public {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Il contenitore di pagina porta il tema del gioco corrente: le variabili ridefinite lì valgono per
   intestazione, contenuto e piè di pagina insieme. */
.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -.015em; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); font-weight: 700; }
h2 { font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem); font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 620; }
p { margin: 0 0 1rem; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- intestazione ---------- */

.site-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.head-top {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: 62px;
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: .45rem;
    font-weight: 700;
    font-size: 1.06rem;
    letter-spacing: -.02em;
    color: var(--ink);
    text-decoration: none;
    flex: none;
}

.brand:hover { text-decoration: none; }

.brand .mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--brand);
    color: var(--brand-ink);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: -.04em;
    align-self: center;
}

/* ---------- prima riga: un gioco per scheda ---------- */

.game-tabs {
    display: flex;
    gap: .35rem;
    margin-left: auto;
    padding: .25rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.game-tabs::-webkit-scrollbar { display: none; }

.game-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .42rem .95rem;
    border-radius: 999px;
    color: var(--ink-soft);
    font-size: .95rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

/* Il pallino è il colore del gioco: la scheda porta la classe del suo tema, quindi --accent è il suo. */
.game-tab::before {
    content: "";
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--accent);
    flex: none;
}

.game-tab:hover { color: var(--ink); background: var(--surface); text-decoration: none; }

.game-tab.on {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 4px 14px -6px var(--accent);
}

.game-tab.on::before { background: var(--accent-ink); }

/* ---------- seconda riga: il menu del gioco corrente ---------- */

.sub-nav { border-top: 1px solid var(--line); }

.sub-nav .wrap {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.sub-nav .wrap::-webkit-scrollbar { display: none; }

.sub-nav a {
    padding: .62rem .8rem;
    color: var(--ink-soft);
    font-size: .92rem;
    font-weight: 550;
    white-space: nowrap;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.sub-nav a:hover { color: var(--ink); text-decoration: none; }
.sub-nav a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }

@media (max-width: 560px) {
    .head-top { flex-wrap: wrap; gap: .5rem; padding-top: .55rem; padding-bottom: .55rem; }
    .game-tabs { margin-left: 0; width: 100%; }
    .game-tab { flex: 1; justify-content: center; }
}

/* ---------- pulsanti e CTA ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .58rem 1.05rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { text-decoration: none; border-color: var(--ink-faint); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover { filter: brightness(1.07); border-color: var(--accent); }

.btn-sm { padding: .34rem .7rem; font-size: .86rem; }

/*
    Il pulsante di pronostico sulla superficie pubblica è SEMPRE disabilitato e mostra comunque il
    prezzo in punti (§1.5 punto 8): l'utente deve vedere esattamente cosa si perde. La conversione la
    fa la CTA, non la censura.
*/
.btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- struttura di pagina ---------- */

main { flex: 1; padding: 2rem 0 3.5rem; }

.page-head { margin-bottom: 1.75rem; }
.page-head p { color: var(--ink-soft); max-width: 62ch; margin-bottom: 0; }

.eyebrow {
    display: inline-block;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: .3rem;
}

.section { margin-top: 2.75rem; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.section-head h2 { margin: 0; }

/* ---------- hero ---------- */

.hero {
    background: linear-gradient(160deg, var(--accent-soft), transparent 70%), var(--surface);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 4px);
    padding: clamp(1.5rem, 1rem + 3vw, 3rem);
    box-shadow: var(--shadow);
    margin-bottom: 2.5rem;
}

.hero h1 { max-width: 20ch; }
.hero p { color: var(--ink-soft); max-width: 58ch; font-size: 1.06rem; }
.hero .actions { display: flex; gap: .65rem; flex-wrap: wrap; margin-top: 1.25rem; }

.hero-stats {
    display: flex;
    gap: 2.25rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.hero-stats div { display: flex; flex-direction: column; }
.hero-stats .n { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; }
.hero-stats .l { font-size: .84rem; color: var(--ink-faint); }

/* ---------- griglia di card evento ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.1rem;
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--line-strong); }

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    margin-bottom: .7rem;
}

.card h3 { margin: 0 0 .75rem; font-size: 1.06rem; letter-spacing: -.01em; }
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: auto;
    padding-top: .9rem;
    border-top: 1px solid var(--line);
    font-size: .85rem;
    color: var(--ink-faint);
}

/* ---------- etichette ---------- */

.tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-soft);
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .01em;
    text-decoration: none;
    white-space: nowrap;
}

a.tag:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.tag-open { background: var(--ok-soft); color: var(--ok); }
.tag-closing { background: var(--warn-soft); color: var(--warn); }
.tag-closed, .tag-cancelled { background: var(--bad-soft); color: var(--bad); }
.tag-resolved { background: var(--accent-soft); color: var(--accent); }

/* ---------- quote / esiti ---------- */

.outcomes { display: flex; flex-direction: column; gap: .42rem; margin: 0 0 .3rem; padding: 0; list-style: none; }

.outcome {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem .7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
    font-size: .93rem;
}

/*
    La barra è la probabilità corrente, disegnata con un gradiente su una custom property: niente JS,
    e la larghezza resta un dato leggibile anche a CSS spento.
*/
.outcome::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--p, 0%);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    pointer-events: none;
}

.outcome > * { position: relative; }
.outcome .name { font-weight: 550; }
.outcome .odds { display: flex; align-items: baseline; gap: .55rem; white-space: nowrap; }
.outcome .prob { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.outcome .mult { font-weight: 700; font-variant-numeric: tabular-nums; }
.outcome.is-winner { border-color: var(--ok); background: var(--ok-soft); }
.outcome.is-winner::before { background: color-mix(in srgb, var(--ok) 18%, transparent); }

/* ---------- tabelle (classifiche, albo) ---------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

table { border-collapse: collapse; width: 100%; font-size: .95rem; }

thead th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    text-align: left;
    padding: .7rem .9rem;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td { padding: .68rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { font-weight: 700; font-variant-numeric: tabular-nums; width: 3.5rem; }
.rank-1 { color: #b8860b; }
.rank-2 { color: #7d8590; }
.rank-3 { color: #a1663a; }

.player { display: inline-flex; align-items: center; gap: .55rem; }

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--line);
    flex: none;
}

.avatar-fallback {
    display: inline-grid;
    place-items: center;
    font-size: .78rem;
    font-weight: 700;
    color: var(--ink-faint);
}

.delta-up { color: var(--ok); }
.delta-down { color: var(--bad); }
.delta-flat { color: var(--ink-faint); }

/* ---------- filtri (solo GET, nessun JS) ---------- */

.filters {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1.5rem;
}

.field { display: flex; flex-direction: column; gap: .28rem; min-width: 9rem; }
.field label { font-size: .78rem; font-weight: 600; color: var(--ink-faint); letter-spacing: .02em; }

.field input, .field select {
    font: inherit;
    font-size: .93rem;
    padding: .45rem .6rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* ---------- paginazione ?pagina=N ---------- */

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin-top: 2rem;
}

.pager .position { color: var(--ink-faint); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ---------- dettaglio evento ---------- */

.detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.75rem;
    align-items: start;
}

@media (max-width: 900px) {
    .detail { grid-template-columns: minmax(0, 1fr); }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.panel + .panel { margin-top: 1.1rem; }
.panel h2, .panel h3 { margin-top: 0; }

.aside-cta { position: sticky; top: 80px; }

.meta { display: flex; flex-direction: column; gap: .55rem; margin: 0; font-size: .92rem; }
.meta div { display: flex; justify-content: space-between; gap: 1rem; }
.meta dt { color: var(--ink-faint); }
.meta dd { margin: 0; font-weight: 550; text-align: right; }

/* Variante incolonnata, per le coppie in cui il valore è lungo quanto l'etichetta — le date, che
   nella colonna laterale sono «11 settembre 2026 alle 18:15 UTC». Su due colonne andavano a capo
   entrambe e non si capiva più quale riga fosse l'etichetta e quale la data: qui l'etichetta sta
   sopra, più piccola e più leggera, e la data ha tutta la larghezza del pannello. */
.meta-stack { gap: .85rem; }
.meta-stack div { flex-direction: column; gap: .1rem; }
.meta-stack dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.meta-stack dd { text-align: left; font-weight: 550; }

.lead { font-size: 1.05rem; color: var(--ink-soft); }

/* ---------- profilo ---------- */

.profile-head { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.profile-head .avatar { width: 64px; height: 64px; font-size: 1.4rem; }
.profile-head h1 { margin: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .9rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow);
}

.stat .n { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .82rem; color: var(--ink-faint); }
.stat .n.none { color: var(--ink-faint); font-size: 1.25rem; font-weight: 600; }

/* ---------- stati vuoti e avvisi ---------- */

.empty {
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink-soft);
}

.empty h2 { color: var(--ink); }

.callout {
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: .85rem 1rem;
    font-size: .93rem;
    color: var(--ink-soft);
}

.callout.warn { border-left-color: var(--warn); }

.muted { color: var(--ink-faint); }
.small { font-size: .85rem; }

/* ---------- home: un gioco per scheda ---------- */

.hero-hub { margin-bottom: 1.25rem; }

.games-hub {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1rem;
}

/* Ogni scheda porta la classe del tema del suo gioco: --accent e --accent-soft sono i suoi. */
.game-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: 1.5rem 1.5rem 1.3rem;
    border-radius: calc(var(--radius) + 4px);
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
        linear-gradient(160deg, var(--accent-soft), var(--surface) 75%);
    color: var(--ink);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}

.game-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.game-card h2 { margin: 0; }
.game-card p { margin: 0; color: var(--ink-soft); max-width: 42ch; }

.game-emblem {
    font-size: 2.4rem;
    line-height: 1;
    margin-bottom: .35rem;
    filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--accent) 35%, transparent));
}

.game-go { margin-top: .8rem; font-weight: 700; color: var(--accent); }

/* ---------- piè di pagina ---------- */

.site-foot {
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 2rem 0;
    font-size: .89rem;
    color: var(--ink-faint);
}

.site-foot .wrap { display: flex; gap: 1.5rem; justify-content: space-between; flex-wrap: wrap; }
.site-foot nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-foot a { color: var(--ink-soft); }

/* Il disclaimer di §4 della spec funzionale: non è un sito di scommesse, e va detto. */
.disclaimer { max-width: 48ch; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .card:hover, .game-card:hover { transform: none; }
}
