/**
 * Lap boards, pole tables and track cards (inc/track-laps.php). Enqueued on
 * /tracks/{slug}/ and on any page using [raw_track_records]. Site tokens from
 * src/styles.css. The global table rules there use !important, so the few
 * overrides here do too.
 */

/* Tables ----------------------------------------------------------------- */
.tl-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border: 1px solid rgba(71, 199, 252, 0.2);
    border-radius: 8px;
    margin: 0 0 var(--space-md);
}

.tl-scroll:focus-visible {
    outline: 2px solid var(--raw-cyan);
    outline-offset: 2px;
}

.tl-table {
    width: 100%;
    min-width: 520px;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.tl-table th,
.tl-table td {
    padding: 10px 14px;
    white-space: nowrap;
    vertical-align: middle;
}

.tl-table td.tl-driver {
    white-space: normal;
    min-width: 10rem;
}

.tl-table .tl-rank {
    width: 3.5rem;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-muted);
}

.tl-table .tl-time {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--raw-cyan);
}

.tl-table .tl-gap {
    color: var(--text-muted);
}

.tl-num,
.tl-sub {
    color: var(--text-dim);
    font-size: var(--text-sm);
}

.tl-sub {
    display: block;
}

.tl-row--leader td {
    background-color: rgba(255, 128, 0, 0.12) !important;
}

.tl-table .tl-row--leader .tl-rank,
.tl-table .tl-row--leader .tl-time {
    color: var(--raw-orange);
}

.tl-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--raw-orange);
    color: var(--raw-navy);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tl-more {
    margin: 0 0 var(--space-md);
}

.tl-more summary {
    cursor: pointer;
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    margin-bottom: var(--space-sm);
    border: 1px solid rgba(71, 199, 252, 0.4);
    border-radius: 999px;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--raw-cyan);
}

.tl-more summary:hover {
    border-color: var(--raw-orange);
    color: var(--raw-orange);
}

.tp-lead {
    max-width: 44rem;
    color: var(--text-muted);
    margin: calc(-1 * var(--space-sm)) 0 var(--space-lg);
}

/* Track cards ------------------------------------------------------------ */
.tl-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
}

@media (min-width: 700px) {
    .tl-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1100px) {
    .tl-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

.tl-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-card, var(--bg-secondary));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-top: 4px solid var(--raw-orange);
    border-radius: 8px;
}

.tl-card__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-sm);
}

.tl-card__track {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.15;
    text-transform: uppercase;
}

.tl-card .tl-card__track a {
    color: var(--text-primary);
    text-decoration: none;
}

.tl-card .tl-card__track a:hover {
    color: var(--raw-orange);
}

.tl-card__len {
    flex: none;
    font-size: var(--text-sm);
    color: var(--text-dim);
}

.tl-card__record {
    display: flex;
    flex-direction: column;
}

.tl-card__label {
    font-size: var(--text-xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.tl-card__time {
    font-size: clamp(2.5rem, 9vw, 3.25rem);
    font-weight: 700;
    line-height: 1.05;
    color: var(--raw-cyan);
    font-variant-numeric: tabular-nums;
}

.tl-card__by {
    font-weight: 600;
}

/* A quiet underline keeps a profile link recognizable without hover (touch included) */
.tl-card__by a,
.tl-card__who a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.25);
    text-underline-offset: 3px;
}

.tl-card__by a:hover,
.tl-card__who a:hover {
    text-decoration-color: var(--raw-orange);
}

.tl-card__list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tl-card__row {
    display: grid;
    grid-template-columns: 1.75rem 1fr auto;
    align-items: baseline;
    gap: var(--space-sm);
    margin: 0;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tl-card__pos {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-dim);
}

.tl-card__row--leader .tl-card__pos {
    color: var(--raw-orange);
}

.tl-card__who {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-card__lap {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--raw-cyan);
    font-variant-numeric: tabular-nums;
}

.tl-card__more {
    margin-top: auto;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--raw-orange);
    text-decoration: none;
}

.tl-card__more:hover {
    color: var(--raw-cyan);
}

@media (max-width: 600px) {
    .tl-table th,
    .tl-table td {
        padding: 8px 10px;
    }

    .tl-card {
        padding: var(--space-md);
    }
}
