/* =========================================================
   Pallacanestro Varese — Statistiche Storiche
   Colori: rosso #C8102E, bianco #FFFFFF, grigio #F4F4F4
   ========================================================= */

:root {
    --red:        #C8102E;
    --red-dark:   #A00D24;
    --red-light:  #F5E0E4;
    --win-green:  #1B7F3B;
    --white:      #FFFFFF;
    --gray-50:    #F8F8F8;
    --gray-100:   #F0F0F0;
    --gray-200:   #E0E0E0;
    --gray-600:   #666666;
    --gray-900:   #1A1A1A;
    --font:       system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    --radius:     6px;
    --shadow:     0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: var(--font);
    font-size: 15px;
    color: var(--gray-900);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */

.site-header {
    background: var(--red);
    color: var(--white);
    padding: 16px 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.header-logo {
    height: 56px;
    width: auto;
    object-fit: contain;
}

.header-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
}

.palmares-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--red);
    display: flex;
    flex-wrap: nowrap;
    justify-content: safe center;
    align-items: center;
    gap: 0 20px;
    padding: 8px 24px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
    overflow-x: auto;
}

.palmares-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    flex-shrink: 0;
    white-space: nowrap;
}

.palmares-item strong {
    font-size: 14px;
    font-weight: 700;
}

.palmares-icon {
    height: 18px;
    width: auto;
    max-width: 24px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.palmares-icon--circle {
    background: var(--white);
    border-radius: 50%;
    padding: 1px;
}

/* ---- Trophies strip ---- */

.trophies-strip {
    margin: 0 auto 12px;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px 12px;
    align-items: center;
    justify-content: safe center;
    overflow-x: auto;
}

.trophy-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.trophy-icons {
    display: flex;
    gap: 3px;
    align-items: center;
}

.trophy-icon {
    height: 26px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* Trofei cliccabili (issue #10): vanno alle statistiche di quella competizione/stagione */
.trophy-icon--link { cursor: pointer; transition: transform 0.1s ease; }
.trophy-icon--link:hover { transform: scale(1.18); }
.trophy-icon--link:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
    border-radius: 2px;
}

.trophy-year {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.3px;
}

.trophy-sep {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    align-self: center;
}

.trophy-icon--circle {
    background: var(--white);
    border-radius: 50%;
    padding: 2px;
}

/* ---- Nav ---- */

.site-nav {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--white);
    border-bottom: 2px solid var(--red);
    box-shadow: var(--shadow);
}

.site-nav__inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 0 16px;
}

.site-nav__link {
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.site-nav__link:hover {
    color: var(--red);
    background: var(--gray-50);
}

.site-nav__link.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

/* hamburger: nascosto su desktop, mostrato in media query mobile */
.site-nav__toggle { display: none; }
.site-nav__bars,
.site-nav__bars::before,
.site-nav__bars::after {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--red);
    border-radius: 2px;
    content: '';
}
.site-nav__bars { position: relative; }
.site-nav__bars::before { position: absolute; top: -7px; }
.site-nav__bars::after  { position: absolute; top: 7px; }

/* ---- Main ---- */

.site-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 32px;
}

/* ---- Intro ---- */

.page-intro {
    margin-bottom: 20px;
}

.stats-summary {
    color: var(--gray-600);
    font-size: 14px;
}

/* ---- Filtri ---- */

/* Tab competizione (issue #38) */
.comp-tabs {
    display: flex;
    gap: 2px;
    margin: 0 0 14px;
    border-bottom: 2px solid var(--gray-200);
    overflow-x: auto;
    scrollbar-width: none;
}
.comp-tabs::-webkit-scrollbar { display: none; }
.comp-tab {
    flex: 0 0 auto;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-600);
    white-space: nowrap;
    cursor: pointer;
}
.comp-tab:hover { color: var(--red); }
.comp-tab.active { color: var(--red); border-bottom-color: var(--red); }

/* Pagina Partite YouTube (issue #39) */
.ytp-intro { margin-bottom: 18px; }
.ytp-intro__title { font-size: 22px; font-weight: 800; color: var(--red); margin: 0 0 8px; }
.ytp-intro__lead { font-size: 14px; color: var(--gray-900); line-height: 1.6; margin: 0 0 6px; }
.ytp-intro__meta { font-size: 13px; color: var(--gray-600); margin: 0; }
.ytp-group { margin-bottom: 10px; }
.ytp-group__title {
    font-size: 15px; font-weight: 700; color: var(--gray-900);
    border-bottom: 2px solid var(--red); padding: 8px 0 6px 22px;
    margin: 0; cursor: pointer; list-style: none; position: relative;
    user-select: none;
}
.ytp-group__title::-webkit-details-marker { display: none; }
.ytp-group__title::before {
    content: '▸'; position: absolute; left: 4px; color: var(--red);
    transition: transform 0.12s ease; display: inline-block;
}
.ytp-group[open] > .ytp-group__title::before { transform: rotate(90deg); }
.ytp-group__title:hover { color: var(--red); }
.ytp-group__count {
    font-size: 12px; font-weight: 700; color: var(--white); background: var(--red);
    border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: middle;
}
.yt-games__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-top: 10px; }
.yt-game {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius);
    text-decoration: none; color: var(--gray-900); background: var(--gray-50);
}
.yt-game:hover { border-color: var(--red); background: var(--red-light); }
.yt-game__play {
    flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
    background: var(--red); color: var(--white); font-size: 11px;
    display: flex; align-items: center; justify-content: center; padding-left: 2px;
}
.yt-game__txt { min-width: 0; display: flex; flex-direction: column; }
.yt-game__opp { font-weight: 600; font-size: 13px; }
.yt-game__meta { font-size: 11px; color: var(--gray-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--white);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--red);
}

.filter-group select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.filter-search { min-width: 200px; }

/* ---- Tabella: toolbar + colonne avanzate ---- */

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* Segmented control Totali / Medie */
.mode-switch {
    display: inline-flex;
    border: 1px solid var(--red);
    border-radius: var(--radius);
    overflow: hidden;
}
.mode-btn {
    padding: 8px 16px;
    background: var(--white);
    color: var(--red);
    border: none;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.mode-btn + .mode-btn { border-left: 1px solid var(--red); }
.mode-btn.active { background: var(--red); color: var(--white); }
.mode-btn:not(.active):hover { background: var(--red-light); }

/* Colonne tiro: cifre allineate (mostrano R/T in Totali, % in Medie) */
.stats-table .col-pct { font-variant-numeric: tabular-nums; }

.btn-adv {
    padding: 8px 14px;
    background: var(--white);
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.btn-adv:hover { background: var(--red-light); }

/* Colonne avanzate: nascoste finché non si preme "Mostra avanzate" */
.col-adv { display: none; }
.stats-table.show-adv .col-adv { display: table-cell; }

/* Colonna "Stagioni" solo in vista carriera */
.stats-table:not(.view-career) [data-col="seasons_count"] { display: none; }

/* Colonna interamente vuota nel filtro corrente: nascosta (vince su tutto) */
.stats-table .col-empty { display: none !important; }

/* ---- Tabella ---- */

.table-wrapper {
    overflow-x: auto;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
}

.stats-table thead {
    background: var(--red);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-table th {
    padding: 12px 14px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
    user-select: none;
}

.stats-table th.col-name { text-align: left; }

.stats-table th.sortable { cursor: pointer; }

.stats-table th.sortable:hover { background: var(--red-dark); }

.stats-table th.sort-asc::after  { content: ' ↑'; opacity: 0.9; }
.stats-table th.sort-desc::after { content: ' ↓'; opacity: 0.9; }

.stats-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}

.stats-table tbody tr:hover { background: var(--red-light); }

.stats-table tbody tr:last-child { border-bottom: none; }

.stats-table td {
    padding: 10px 14px;
    text-align: right;
    color: var(--gray-900);
}

.stats-table td.col-name {
    text-align: left;
    font-weight: 500;
}

.stats-table td.col-note {
    text-align: left;
    white-space: normal;
    max-width: 420px;
    line-height: 1.4;
}

.stats-table td.col-pct { color: var(--gray-600); }

.stats-table td.null { color: var(--gray-200); }

.loading {
    text-align: center !important;
    padding: 32px !important;
    color: var(--gray-600);
}

/* ---- Dati mancanti (gruppi) ---- */

/* pagina Dati mancanti: colonna centrata e contenuta (pochi dati) */
.dm { max-width: 100%; margin: 0 auto; }

.dm-intro { margin-bottom: 28px; }
.dm-intro__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 10px;
}
.dm-intro__lead { line-height: 1.6; color: var(--gray-900); }
.dm-intro__meta {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    line-height: 1.6;
    color: var(--gray-600);
}

.gap-group { margin-bottom: 28px; }
.gap-group .stats-table th.col-num,
.gap-group .stats-table td.col-num { width: 90px; }

.gap-group__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gap-group__count {
    background: var(--red);
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 9px;
}

.gap-group .stats-table td.col-name a { color: var(--red); text-decoration: none; font-weight: 600; }
.gap-group .stats-table td.col-name a:hover { text-decoration: underline; }

/* ---- About ---- */

.about-block { margin-bottom: 22px; }
.about-block h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 6px;
}
.about-block p { line-height: 1.6; color: var(--gray-900); }
.about-block p.info-note { margin-top: 16px; }
.about-block ul.info-list { margin: 0; padding-left: 20px; }
.about-block ul.info-list li { line-height: 1.6; color: var(--gray-900); margin-bottom: 10px; }
.about-block ul.info-list li:last-child { margin-bottom: 0; }
.about-wish { margin-top: 10px; color: var(--gray-600); }

.btn-home {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 18px;
    background: var(--red);
    color: var(--white);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
}
.btn-home:hover { background: var(--red-dark); }
.about-block a { color: var(--red); font-weight: 600; text-decoration: none; }
.about-block a:hover { text-decoration: underline; }

/* Ko-fi (#35): badge self-contained, nessuno script esterno */
.about-block a.kofi-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 18px;
    background: #FF5E5B;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.12s, box-shadow 0.12s;
}
.about-block a.kofi-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    text-decoration: none;
}
.kofi-button__ico { font-size: 18px; }

.contact-links { display: flex; flex-wrap: wrap; gap: 10px; }
.about-block .contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: var(--white);
    color: var(--gray-900);
    font-weight: 600;
    text-decoration: none;
}
.about-block .contact-chip:hover { border-color: var(--red); text-decoration: none; }
.contact-chip__ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.about-disclaimer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-600);
    font-style: italic;
}

/* ---- Footer ---- */

.site-footer {
    text-align: center;
    padding: 16px;
    /* la palmares-bar è fixed in fondo: lasciamo lo spazio per non finirci sotto */
    margin-bottom: 64px;
    font-size: 12px;
    color: var(--gray-600);
    border-top: 1px solid var(--gray-200);
}

.site-footer a { color: var(--red); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---- Modal ---- */

.modal { display: flex; align-items: center; justify-content: center;
         position: fixed; inset: 0; z-index: 100; }
.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal-box {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: min(860px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 28px 24px;
    z-index: 1;
}

.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none;
    font-size: 24px; color: var(--gray-600);
    cursor: pointer; line-height: 1;
    padding: 4px 8px; border-radius: var(--radius);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }

.modal-name {
    font-size: 22px; font-weight: 700;
    color: var(--red); margin-bottom: 4px;
    padding-right: 40px;
}

.modal-meta {
    font-size: 13px; color: var(--gray-600); margin-bottom: 24px;
}

.modal-section-title {
    font-size: 13px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--red);
    padding-bottom: 6px;
    margin: 20px 0 12px;
}

/* ===== Modal "Ledger Impact" ===== */

/* Pulsante chiudi sopra l'hero rosso */
.modal-close { color: var(--white); z-index: 3; }
.modal-close:hover { background: rgba(255,255,255,0.22); color: var(--white); }

/* Hero rosso a tutta larghezza (sfonda il padding del modal-box) */
.modal-hero {
    background: var(--red); color: var(--white);
    margin: -28px -28px 0;
    padding: 24px 28px 22px;
    border-radius: var(--radius) var(--radius) 0 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 16px));
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px; align-items: center;
}

/* Identità: nome, meta, totale punti (tutte le info ben leggibili) */
.hero-id { min-width: 0; }
.hero-id .modal-name { color: var(--white); font-size: 23px; font-weight: 800; margin: 0; display: inline; }
.hero-id .modal-meta { color: var(--red-light); font-size: 13px; margin: 7px 0 0; }
.hero-totals { display: flex; gap: 24px; margin-top: 14px; flex-wrap: wrap; }
.hero-stat { color: var(--red-light); font-size: 13px; display: flex; align-items: baseline; gap: 5px; }
.hero-stat__val {
    font-size: 30px; font-weight: 800; color: var(--white);
    line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums;
}

/* Statistiche a destra: medie (punti, rimbalzi, assist) accanto agli anelli del tiro */
.hero-stats { display: flex; align-items: flex-start; gap: 18px; flex-shrink: 0; }
.hero-avgs { display: flex; gap: 12px; }
.hero-avg { display: flex; flex-direction: column; align-items: center; width: 50px; }
.hero-avg__val {
    height: 58px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
    border-bottom: 3px solid rgba(255,255,255,0.45);
}
.hero-avg__lbl { font-size: 10.5px; font-weight: 700; color: var(--white); margin-top: 4px; white-space: nowrap; }

.hero-rings { display: flex; gap: 14px; flex-shrink: 0; }
.ring { display: flex; flex-direction: column; align-items: center; width: 60px; }
.ring__svg { width: 58px; height: 58px; }
.ring__track { stroke: rgba(255,255,255,0.28); }
.ring__fill  { stroke: var(--white); }
.ring__text  { fill: var(--white); font-size: 8.5px; font-weight: 700; }
.ring__label { font-size: 11px; font-weight: 700; color: var(--white); margin-top: 4px; }
.ring__sub   { font-size: 10px; color: var(--red-light); font-variant-numeric: tabular-nums; }

/* Badge storico su hero rosso */
.modal-badge {
    display: inline-block; vertical-align: middle; margin-left: 8px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--white); background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: 999px; padding: 2px 9px;
}
.modal-badge[hidden] { display: none; }

/* Grafico a barre raggruppate punti+partite per stagione */
.modal-chart-wrap { margin-top: 18px; position: relative; }
.modal-chart-wrap[hidden] { display: none; }
.chart-tip {
    position: absolute; pointer-events: none; z-index: 5;
    transform: translate(-50%, -100%);
    background: var(--gray-900); color: var(--white);
    font-size: 11px; padding: 5px 9px; border-radius: 5px;
    white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.chart-tip[hidden] { display: none; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-head .modal-section-title { margin-bottom: 8px; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--gray-600); }
.leg { display: inline-flex; align-items: center; gap: 5px; }
.leg__sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.leg__sw--pts { background: var(--red); }
.leg__sw--gms { background: #9aa0a6; }

.bar-chart { display: flex; align-items: flex-end; gap: 5px; padding-top: 6px; overflow-x: auto; }
.bar-group { flex: 1 1 0; min-width: 20px; display: flex; flex-direction: column; align-items: center; }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 90px; }
.bar2 { width: 7px; min-height: 2px; border-radius: 2px 2px 0 0; }
.bar2--pts { background: var(--red); }
.bar2--gms { background: #9aa0a6; }
.bar-group:hover .bar2--pts { background: var(--red-dark); }
.bar-group:hover .bar2--gms { background: #71777c; }
.bar-group--empty { opacity: 0.5; }
.bar__year { font-size: 9px; color: var(--gray-600); margin-top: 4px; }

/* Riga extra carriera */
.career-extras { font-size: 13px; color: var(--gray-900); margin: 16px 0 4px; line-height: 1.6; }
.career-extras:empty { display: none; }
.career-extras b { color: var(--red); }

/* Intestazione sezione dettaglio con toggle a destra */
.modal-detail-head { display: flex; align-items: center; gap: 12px; }
.modal-detail-head .modal-section-title { flex: 1; margin-bottom: 0; }
.mode-switch.modal-mode .mode-btn { padding: 5px 14px; font-size: 12px; }

/* Tabelle dettaglio: numeri allineati, scroll orizzontale */
.modal-table-scroll { overflow-x: auto; }
.modal-table th.col-num, .modal-table th.col-pct,
.modal-table td.col-pct { text-align: right; }
.modal-table td:not(.col-name) { font-variant-numeric: tabular-nums; }

/* Immagine trofeo accanto alla competizione vinta */
.trophy-win {
    vertical-align: middle; margin-left: 6px;
    height: 18px; width: 18px; object-fit: contain;
}

/* Pagina Allenatori (issue #17) */
.coach-hero { display: block !important; }
.coach-hero .modal-name { color: var(--white); font-size: 24px; font-weight: 800; margin: 0; }
.coach-hero .modal-meta { color: var(--red-light); font-size: 13px; margin: 6px 0 0; }
.coach-titles { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.coach-titles .trophy-win { height: 30px; width: 30px; margin: 0; }
.coach-titles .null { color: var(--red-light); }
.coach-cups .trophy-win { height: 20px; width: 20px; margin: 0 3px 0 0; }
#coaches-table td.col-name.coach-cups { white-space: nowrap; }
/* Anno-per-anno e modal (formato tabellare): le celle testuali vanno a capo così
   la tabella sta nel contenitore (modal-box / schermo) senza sforare; le colonne
   lunghe (Piazzamento, Coppe) si impilano invece di allargare la riga. */
#seasons-table td,
.modal-table td { white-space: normal; line-height: 1.5; }
/* Raggruppamento per stagione: la cella Stagione usa rowspan (anno una volta sola,
   centrato verticalmente accanto ai suoi allenatori); linea marcata a inizio di
   ogni stagione, nessuna riga tra i coach dello stesso anno. */
#seasons-table tbody tr td { border-bottom: none; }
#seasons-table tbody tr.season-first td { border-top: 2px solid var(--gray-200); }
#seasons-table td.season-cell { vertical-align: middle; font-weight: 600; border-right: 1px solid var(--gray-100); }

/* Pagina "Come migliorare la LBA" (issue #58) */
.lba-intro { margin-bottom: 18px; }
.lba-intro__title { font-size: 22px; font-weight: 800; color: var(--red); margin: 0 0 8px; }
.lba-intro__lead { font-size: 15px; color: var(--gray-900); line-height: 1.6; margin: 0 0 6px; }
.lba-intro__meta { font-size: 13px; color: var(--gray-600); margin: 0; }
.lba-item {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    border-left: 4px solid var(--red); padding: 16px 18px; margin-bottom: 12px;
}
.lba-item__num {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    background: var(--red); color: var(--white); font-weight: 800; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.lba-item__body { min-width: 0; }
.lba-block { margin: 0; font-size: 14px; line-height: 1.6; color: var(--gray-900); }
.lba-block--sol { margin-top: 8px; }
.lba-label {
    display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; margin-right: 8px; border-radius: 4px; padding: 1px 7px; vertical-align: 1px;
}
.lba-label--prob { color: var(--white); background: var(--red); }
.lba-label--sol { color: var(--red); background: var(--red-light); border: 1px solid var(--red); }

/* Riga totale carriera in fondo alla tabella per stagione */
.season-total-row td {
    font-weight: 700; background: var(--gray-50);
    border-top: 2px solid var(--red);
}

.modal-table { font-size: 13px; margin-bottom: 8px; }
.modal-comp-sub { font-size: 11px; color: #888; font-weight: normal; }

.season-group-row td { font-weight: 600; border-top: 1px solid var(--gray-200); }
.season-group-row:first-child td { border-top: none; }

.phase-sub-row td { font-size: 11.5px; color: var(--gray-600); background: var(--gray-50); }
.phase-sub-row td.phase-label { padding-left: 20px; font-style: italic; }

/* ---- Riga cliccabile ---- */

.stats-table tbody tr { cursor: pointer; }

/* ---- Responsive ---- */

/* strisce trofei/palmares: scorrono a swipe ma senza scrollbar visibile */
.trophies-strip,
.palmares-bar {
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* Edge legacy */
}
.trophies-strip::-webkit-scrollbar,
.palmares-bar::-webkit-scrollbar { display: none; }   /* Chrome/Safari */

@media (max-width: 768px) {
    /* parte alta più compatta su mobile */
    .site-header     { padding: 12px 14px; }
    .header-logo     { height: 38px; }
    .header-title    { font-size: 18px; }
    .header-subtitle { font-size: 11px; }
    .trophies-strip  { gap: 6px 8px; margin-bottom: 8px; }
    .trophy-icon     { height: 20px; }
    .trophy-year     { font-size: 9px; }
    .trophy-sep      { height: 26px; }

    /* palmares in basso: solo icona + numero; il nome compare al tap (toggle) */
    .palmares-label  { display: none; }
    .palmares-item   { outline: none; cursor: pointer; }
    .palmares-item.show-name .palmares-label { display: inline; }

    /* filtri compatti: griglia 2x2 con etichette piccole */
    .filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 12px;
    }
    .filter-group { min-width: 0; gap: 3px; }
    .filter-search { min-width: 0; grid-column: 1 / -1; }
    .comp-tab { padding: 13px 14px; font-size: 13px; }
    .filter-group label { font-size: 10px; }
    .filter-group select,
    .filter-group input { width: 100%; }
    .stats-table   { font-size: 13px; }
    .stats-table th,
    .stats-table td { padding: 9px 10px; }

    /* nascondi le colonne secondarie: dettaglio completo nel modal (tap riga) */
    .stats-table .col-opt { display: none; }

    /* touch target sui filtri */
    .filter-group select,
    .filter-group input { min-height: 44px; }

    /* nav: hamburger + menu a tendina */
    .site-nav__inner { padding: 0 8px; }
    .site-nav__toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: 2px 6px;
        padding: 0;
        background: none;
        border: none;
        cursor: pointer;
    }
    .site-nav__inner {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
    }
    .site-nav.is-open .site-nav__inner { display: flex; }
    .site-nav__link {
        padding: 14px 18px;
        min-height: 44px;
        border-bottom: 1px solid var(--gray-100);
        border-left: 3px solid transparent;
        margin-bottom: 0;
    }
    .site-nav__link.active {
        border-bottom-color: var(--gray-100);
        border-left-color: var(--red);
    }

    /* modal a tutta larghezza utile */
    .modal-box { width: 95vw; padding: 22px 18px 20px; }

    /* hero impilato su mobile (margini allineati al padding ridotto del modal-box) */
    .modal-hero {
        margin: -22px -18px 0;
        padding: 20px 18px 18px;
        grid-template-columns: 1fr;
        text-align: center;
        gap: 14px;
    }
    .hero-stat__val { font-size: 26px; }
    .hero-totals { justify-content: center; }
    .hero-id .modal-name { font-size: 20px; }
    .hero-stats { justify-content: center; flex-wrap: wrap; }

    /* la pagina Dati mancanti non resta troppo stretta su mobile */
    .dm { max-width: 100%; }
}

/* Eventi di stagione: frecce promozione/retrocessione (#65) — pagina allenatori e modal giocatore */
.season-event {
    font-size: 0.72rem;
    vertical-align: middle;
    cursor: help;
}
.season-event--up   { color: #1a7f37; }
.season-event--down { color: var(--red); }

/* Focus visibile per navigazione da tastiera (#68) */
th.sortable:focus-visible,
#stats-tbody tr:focus-visible,
#coaches-tbody tr:focus-visible,
#seasons-tbody tr:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: -2px;
}

/* Tooltip custom sui trofei (pagina allenatori): bolla immediata all'hover */
.tip {
    position: relative;
    display: inline-block;
}
.tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1A1A1A;
    color: #fff;
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease-in;
    z-index: 60;
}
.tip:hover::after,
.tip:focus-visible::after {
    opacity: 1;
}

/* Pagina Fonti & Info (#15): tabelle testuali compatte */
.info-table td, .info-table th { font-size: 0.85rem; }
.info-table td { white-space: normal; }

/* Pagina Primati (#42) */
.rec-group { margin-bottom: 30px; }
.rec-group__title {
    font-size: 15px; font-weight: 800; color: var(--red);
    margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.rec-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.rec-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    border-left: 4px solid var(--red); padding: 16px 18px;
}
.rec-card__big { font-size: 40px; font-weight: 800; color: var(--red); line-height: 1; }
.rec-card__label { font-size: 15px; font-weight: 700; color: var(--gray-900); margin-top: 4px; }
.rec-card__detail { font-size: 13px; line-height: 1.55; color: var(--gray-600); margin: 8px 0 0; }
/* gruppi in evidenza: card a tutta larghezza, numero enorme */
.rec-group--hl .rec-cards { grid-template-columns: 1fr; }
.rec-group--hl .rec-card { border-left-width: 6px; background: var(--red-light); }
.rec-group--hl .rec-card__big { font-size: 60px; }

/* Pagina Timeline (#50) */
.tl-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 4px 0 14px; }
.tl-leg {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600; color: var(--gray-900);
    background: none; border: 1px solid var(--gray-200); border-radius: 999px;
    padding: 4px 12px; cursor: pointer; transition: opacity 0.15s, background 0.15s;
}
.tl-leg:hover { background: var(--gray-50); }
.tl-leg--off { opacity: 0.4; }
.tl-leg--off .tl-leg__dot { background: var(--gray-200) !important; }
.tl-leg__dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl-svg { display: block; }
.tl-grid { stroke: var(--gray-100); stroke-width: 1; }
.tl-sep { stroke: #b4b4b4; stroke-width: 1.5; stroke-dasharray: 5 4; }
.tl-a2lab { fill: #999; font-style: italic; }
.tl-po { stroke: var(--gray-900); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: 0.5; }
.tl-polab { font-size: 10px; font-weight: 700; fill: var(--gray-900); opacity: 0.7; }
.tl-ylab { font-size: 12px; fill: var(--gray-600); }
.tl-xlab { font-size: 10px; fill: var(--gray-600); }
.tl-line { stroke-width: 2; opacity: 0.5; }
.tl-dot { stroke: #fff; stroke-width: 1.5; cursor: pointer; }
.tl-dot.tl-won { stroke: var(--gray-900); stroke-width: 1.5; }
.tl-pt:focus { outline: none; }
.tl-pt:focus .tl-dot { stroke: var(--gray-900); stroke-width: 2.5; }
.tl-tip {
    position: absolute; transform: translate(-50%, -100%);
    background: var(--gray-900); color: #fff; font-size: 12px; line-height: 1.4;
    padding: 6px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none;
    z-index: 100; box-shadow: var(--shadow);
}
.info-source { display: flex; align-items: center; gap: 10px; }
.info-source--center { justify-content: center; text-align: center; }
.info-cover {
    height: 64px;
    width: 46px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    flex-shrink: 0;
}
/* Loghi (non copertine): quadrati/trasparenti — stessa larghezza di slot, senza ombra né crop */
.info-cover--logo {
    height: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
}

/* =========================================================
   Pagina Finali (#78)
   Ogni finale e' una card a tre zone: identita' | dettagli | risultato.
   Le serie (playoff, spareggi, andata/ritorno) portano dentro la tabella
   gara-per-gara. Fascia laterale e badge: verde = vinta, rosso = persa.
   ========================================================= */

.fin { max-width: 100%; margin: 0 auto; padding: 0 16px; }

.fin-intro { margin: 24px 0 20px; }
.fin-intro__title { font-size: 26px; color: var(--red); margin-bottom: 10px; }
.fin-intro__lead { color: var(--gray-900); line-height: 1.6; margin-bottom: 10px; }
.fin-intro__meta { color: var(--gray-600); font-size: 14px; }
.fin-win  { color: var(--win-green); }
.fin-loss { color: var(--red); }

.fin-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}
.fin-filters__sep {
    width: 1px;
    height: 20px;
    background: var(--gray-200);
    margin: 0 4px;
}
.fin-filter {
    font: inherit;
    font-size: 13px;
    padding: 6px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
}
.fin-filter:hover { border-color: var(--red); color: var(--red); }
.fin-filter.is-active {
    background: var(--red);
    border-color: var(--red);
    color: var(--white);
}

.fin-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 28px; }

.fin-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    border-left: 5px solid var(--gray-200);
}
.fin-card[hidden] { display: none; }
.fin-card--vinta { border-left-color: var(--win-green); }
.fin-card--persa { border-left-color: var(--red); }

/* tre zone: identita' a sinistra, dettagli al centro, risultato ancorato a destra */
.fin-card__top {
    display: grid;
    grid-template-columns: minmax(300px, 34%) minmax(0, 1fr) minmax(120px, auto);
    align-items: center;
    gap: 20px;
}

.fin-card__id { display: flex; align-items: center; gap: 12px; }
.fin-card__icon {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    object-fit: contain;
}
.fin-card__icon--empty { display: block; }
.fin-card__labels { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.fin-card__season { font-weight: 700; font-size: 17px; }
.fin-card__comp { color: var(--gray-600); font-size: 14px; }
.fin-card__venue { color: var(--gray-900); font-size: 14px; font-weight: 600; }
.fin-card__tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 2px 8px;
    border-radius: 999px;
}

.fin-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    font-size: 14px;
    color: var(--gray-600);
}
.fin-card__opp strong { color: var(--gray-900); }

.fin-card__result {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 12px;
}
.fin-card__badge {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.fin-card--vinta .fin-card__badge { background: var(--win-green); color: var(--white); }
.fin-card--persa .fin-card__badge { background: var(--red); color: var(--white); }
.fin-card__score {
    font-size: 19px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fin-card__note {
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--red-light);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}

/* tabella gara-per-gara: colonne strette a sinistra, risultato ancorato a destra */
.fin-games { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.fin-games th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    padding: 4px 8px;
}
.fin-games td { padding: 6px 8px; border-bottom: 1px solid var(--gray-100); }
.fin-games .fin-col-game  { width: 90px; }
.fin-games .fin-col-date  { width: 170px; }
.fin-games .fin-col-venue { width: auto; }
.fin-games .col-num { text-align: right; font-variant-numeric: tabular-nums; width: 130px; }
.fin-game--w td:first-child { box-shadow: inset 3px 0 0 var(--win-green); }
.fin-game--l td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.fin-ha {
    font-size: 11px;
    color: var(--gray-600);
    background: var(--gray-100);
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 6px;
}

.fin-note {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 32px;
}
.fin-note h3 { font-size: 16px; color: var(--red); margin-bottom: 8px; }
.fin-note p { line-height: 1.6; margin-bottom: 8px; }

/* su schermi stretti la tabella gara-per-gara scorre invece di andare a capo:
   senza questo "Gara 1" e "6 maggio 1999" si spezzavano su 2-3 righe */
.fin-games-wrap { overflow-x: auto; }

@media (max-width: 900px) {
    .fin-card__top { grid-template-columns: 1fr; gap: 8px; }
    .fin-card__result { justify-content: flex-start; }
    .fin-games { min-width: 0; font-size: 13px; }
    .fin-games td, .fin-games th { white-space: nowrap; padding: 6px 4px; }
    .fin-games .fin-col-game { width: 58px; }
    .fin-games .fin-col-date { width: auto; }
    .fin-games .col-num { width: 84px; }
    /* la pillola casa/trasferta e' ridondante con il nome della sede: su mobile
       lo spazio serve alla colonna risultato */
    .fin-ha { display: none; }
}

/* Video non integrali nel catalogo YouTube (#79): secondo tempo, sintesi.
   Restano a catalogo quando la partita e' storicamente rilevante, ma vanno
   distinti a colpo d'occhio dalle partite intere. */
.yt-game__partial {
    display: inline-block;
    margin-left: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    padding: 1px 7px;
    vertical-align: middle;
}

/* Risultato cliccabile quando la partita e' nel catalogo YouTube (#78) */
.fin-card__score--video,
.fin-game__score {
    color: inherit;
    text-decoration: none;
    border-bottom: 2px solid var(--red);
    white-space: nowrap;
}
.fin-card__score--video:hover,
.fin-game__score:hover { color: var(--red); }
.fin-play {
    font-size: .62em;
    color: var(--red);
    margin-left: 5px;
    vertical-align: middle;
}
