/* ==========================================================================
   Classifica Time Trial
   ==========================================================================

   Due colonne: a sinistra l'elenco delle piste, a destra la classifica della
   pista scelta. Sotto i 1100px diventano una colonna sola e l'elenco si accorcia
   per non spingere la classifica troppo in basso.

   Oro, argento e bronzo compaiono sempre insieme al numero della posizione,
   mai da soli: il colore rinforza, non porta l'informazione.
   ========================================================================== */

:root {
    --tt-gold: #ffd34d;
    --tt-silver: #c9d3e6;
    --tt-bronze: #e39a5f;
    --tt-active-bg: rgba(0, 64, 255, 0.18);
    --tt-active-border: rgba(64, 120, 255, 0.7);
    --tt-row-border: rgba(var(--tint), 0.05);
}

.tt-page {
    padding: 9rem 0 4rem;
}

/* Piu' larga del resto del sito (1200px): con l'elenco piste a fianco, la
   tabella a 1200px non ci stava e mostrava la barra di scorrimento. */
.tt-page .container {
    max-width: 1440px;
}

.tt-intro {
    margin-bottom: 2.5rem;
}

.tt-intro .hero-subtitle {
    margin-bottom: 2rem;
}

/* ---------- layout ---------- */

.tt-layout {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

/* min-width: 0 serve alla tabella: senza, la sua larghezza minima allarga la
   colonna della griglia e su telefono tutta la pagina scorre di lato. */
.tt-sidebar,
.tt-board {
    min-width: 0;
    border: 1px solid var(--glass-border);
    padding: 1.25rem;
}

.tt-sidebar {
    position: sticky;
    top: 6.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: calc(100vh - 8rem);
}

/* ---------- ricerca e filtri dell'elenco ---------- */

.tt-search {
    position: relative;
}

.tt-search i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.tt-search input {
    width: 100%;
    padding: 0.7rem 0.9rem 0.7rem 2.4rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(var(--tint), 0.04);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.92rem;
    outline: none;
    transition: var(--transition);
}

.tt-search input:focus {
    border-color: var(--tt-active-border);
    background: rgba(var(--tint), 0.07);
}

.tt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tt-chip {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.tt-chip:hover {
    color: var(--text-main);
    border-color: rgba(var(--tint), 0.25);
}

.tt-chip.is-active {
    background: var(--tt-active-bg);
    border-color: var(--tt-active-border);
    color: var(--text-main);
}

.tt-sidebar-count {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- elenco piste ---------- */

.tt-track-list {
    list-style: none;
    overflow-y: auto;
    margin: 0 -0.35rem;
    padding: 0 0.35rem;
    min-height: 0;
    flex: 1 1 auto;
}

.tt-track-list::-webkit-scrollbar {
    width: 6px;
}

.tt-track-list::-webkit-scrollbar-thumb {
    background: rgba(var(--tint), 0.15);
    border-radius: 10px;
}

.tt-track-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.tt-track-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.tt-track-btn:hover {
    background: rgba(var(--tint), 0.05);
}

.tt-track-btn.is-active {
    background: var(--tt-active-bg);
    border-color: var(--tt-active-border);
}

.tt-track-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-track-wr {
    flex: 0 0 auto;
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: var(--tt-gold);
}

.tt-track-wr--none {
    color: var(--text-muted);
    opacity: 0.6;
}

.tt-track-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* ---------- intestazione della classifica ---------- */

.tt-board-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 2rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}

.tt-board-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tt-board-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    line-height: 1.15;
}

.tt-board-records {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tt-record {
    min-width: 150px;
    padding: 0.7rem 1rem;
    border-radius: 14px;
    background: rgba(var(--tint), 0.04);
    border: 1px solid var(--glass-border);
}

.tt-record-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tt-record-value {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.tt-record-value--gold {
    color: var(--tt-gold);
}

.tt-record-holder {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.tt-tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255, 221, 0, 0.15);
    color: #ffe066;
    border: 1px solid rgba(255, 221, 0, 0.3);
}

.tt-tag--custom {
    background: rgba(255, 0, 85, 0.15);
    color: #ff6b8b;
    border-color: rgba(255, 0, 85, 0.3);
}

.tt-tag--retro {
    background: rgba(0, 64, 255, 0.15);
    color: #6b9eff;
    border-color: rgba(0, 64, 255, 0.3);
}

/* ---------- filtri della classifica ---------- */

.tt-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}

.tt-control {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tt-control[hidden] {
    display: none;
}

.tt-control-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tt-segment {
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(var(--tint), 0.03);
}

.tt-segment button {
    padding: 0.35rem 0.8rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.tt-segment button:hover {
    color: var(--text-main);
}

.tt-segment button.is-active {
    background: var(--tt-active-bg);
    color: var(--text-main);
    box-shadow: inset 0 0 0 1px var(--tt-active-border);
}

/* ---------- elenco dei tempi ---------- */
.tt-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}

.tt-row {
    display: grid;
    grid-template-columns: 52px minmax(110px, 1.15fr) minmax(130px, 1fr) minmax(65px, 0.5fr) minmax(140px, 1fr) auto 32px;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--tt-row-border);
    border-radius: 14px;
    background: rgba(var(--tint), 0.025);
}

.tt-row:hover { background: rgba(var(--tint), 0.045); }
.tt-row.tt-rank-1 { border-color: rgba(255, 216, 75, 0.25); }

.tt-avatar {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(var(--tint), 0.06);
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-muted);
    overflow: hidden;
}

.tt-avatar img { width: 100%; height: 100%; object-fit: contain; }
.tt-player-info, .tt-result, .tt-combo-cell { min-width: 0; }
.tt-position, .tt-detail-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.tt-rank-1 .tt-position { color: var(--tt-gold); }
.tt-rank-2 .tt-position { color: var(--tt-silver); }
.tt-rank-3 .tt-position { color: var(--tt-bronze); }
.tt-player-name { overflow-wrap: anywhere; }

.tt-table-status {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.tt-table-status i {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 1.6rem;
    opacity: 0.6;
}

.tt-player {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    white-space: normal;
}

.tt-flag {
    width: 20px;
    height: auto;
    border-radius: 2px;
    flex: 0 0 auto;
}

.tt-flag--none {
    display: inline-block;
    width: 20px;
    height: 14px;
    border-radius: 2px;
    background: rgba(var(--tint), 0.08);
}

.tt-time-main {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tt-rank-1 .tt-time-main {
    color: var(--tt-gold);
}

.tt-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.45rem;
    border-radius: 6px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
    background: rgba(var(--tint), 0.08);
    color: var(--text-muted);
}

.tt-splits {
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tt-splits .is-best {
    color: #3dd68c;
    font-weight: 600;
}

.tt-gap {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Personaggio sopra, veicolo sotto: su una riga sola la colonna era la piu'
   larga della tabella. */
.tt-combo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-main);
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: nowrap;
}

.tt-combo i {
    width: 1.1rem;
    color: var(--text-muted);
    text-align: center;
}

.tt-combo-vehicle {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.tt-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.tt-ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.tt-ghost-link:hover {
    background: rgba(var(--tint), 0.1);
    color: var(--text-main);
}

/* ---------- paginazione ---------- */

.tt-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.tt-pager[hidden] {
    display: none;
}

.tt-pager button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.tt-pager button:hover:not(:disabled) {
    border-color: var(--tt-active-border);
}

.tt-pager button:disabled {
    opacity: 0.35;
    cursor: default;
}

.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;
}

/* ---------- schermi stretti ---------- */

@media (max-width: 1100px) {
    .tt-page {
        padding-top: 7rem;
    }

    .tt-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .tt-sidebar {
        position: static;
        max-height: none;
    }

    .tt-track-list {
        max-height: 280px;
    }

    .tt-board-title {
        font-size: 1.6rem;
    }
}

@media (max-width: 520px) {
    .tt-sidebar,
    .tt-board {
        padding: 1rem;
    }

    .tt-board-records {
        width: 100%;
    }

    .tt-record {
        flex: 1 1 130px;
        min-width: 0;
    }


}

/* Keep each entry readable without horizontal scrolling. */
@media (max-width: 1350px) and (min-width: 1101px), (max-width: 900px) {
    .tt-row {
        grid-template-columns: 52px minmax(0, 1fr) auto 32px;
        gap: 0.65rem 0.85rem;
    }
    .tt-result { grid-column: 3; grid-row: 1; text-align: right; }
    .tt-ghost-link { grid-column: 4; grid-row: 1; }
    .tt-combo-cell { grid-column: 2; grid-row: 2; }
    .tt-gap { grid-column: 3; grid-row: 2; text-align: right; font-size: 0.8rem; }
    .tt-detail-label { display: inline; margin-right: 0.4rem; }
    .tt-date { grid-column: 2 / 4; grid-row: 3; font-size: 0.75rem; }
}

@media (max-width: 520px) {
    .tt-row { grid-template-columns: 44px minmax(0, 1fr) 32px; padding: 0.85rem; }
    .tt-avatar { width: 44px; height: 44px; }
    .tt-ghost-link { grid-column: 3; }
    .tt-result { grid-column: 2 / 4; grid-row: 2; text-align: left; }
    .tt-combo-cell { grid-column: 2 / 4; grid-row: 3; }
    .tt-combo { white-space: normal; }
    .tt-gap { grid-column: 2 / 4; grid-row: 4; text-align: left; }
    .tt-date { grid-column: 2 / 4; grid-row: 5; }
    .tt-badge { margin-left: 0; margin-right: 0.35rem; }
}

/* ---------- tema chiaro ----------
   Oro, argento e bronzo scuriti: le tinte chiare sparirebbero sul fondo. */

:root[data-theme="light"] {
    --tt-gold: #a87d00;
    --tt-silver: #66728a;
    --tt-bronze: #a85a1c;
    --tt-active-bg: rgba(0, 64, 255, 0.1);
    --tt-active-border: rgba(0, 64, 255, 0.45);
}

[data-theme="light"] .tt-tag {
    color: #8a6d00;
}

[data-theme="light"] .tt-tag--custom {
    color: #c4123f;
}

[data-theme="light"] .tt-tag--retro {
    color: #1f4fd6;
}

[data-theme="light"] .tt-splits .is-best {
    color: #128a52;
}
