/* Public leaderboard: the card grid, the ruled list, and the controls. */

/* --- Callouts ----------------------------------------------------------- */

/*
 * Two dismissible hints for a first-time visitor. Set as quiet ruled lines
 * above the eyebrow rather than as boxes, so they read as marginalia and
 * leave the hero as the first real thing on the page.
 */
.callouts { margin-bottom: var(--space-6); }

/* --- Past events -------------------------------------------------------- */

/* Hidden until there is more than one competition, so for the first year of
   the site's life this section does not exist as far as a visitor is
   concerned. */
.past-events { margin-top: var(--space-7); }

.past-events__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.past-events__item {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    padding: 11px 0;
    border-bottom: 1px solid var(--color-border);
}

.past-events__link {
    font-family: var(--font-display);
    font-size: 1.125rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.past-events__badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* --- Controls ----------------------------------------------------------- */

.leaderboard-controls {
    display: flex;
    align-items: center;
    gap: 22px;
}

/* Cards / List, as underlined text rather than a segmented pill. */
.view-toggle { display: inline-flex; gap: 22px; }

.view-toggle__option {
    padding: 4px 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    font: inherit;
    font-family: var(--font-mono);
    font-size: 0.63rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
}
.view-toggle__option:hover { color: var(--color-text); }
.view-toggle__option[aria-pressed="true"] {
    color: var(--color-text);
    border-bottom-color: var(--color-text);
}

.live-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.live-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.live-status[data-state="live"] {
    color: var(--color-success);
}
.live-status[data-state="live"]::before { animation: om-pulse 2s ease-in-out infinite; }
.live-status[data-state="offline"] { color: var(--color-warning); }

@media (prefers-reduced-motion: reduce) {
    .live-status[data-state="live"]::before { animation: none; }
}

.leaderboard__show-more {
    display: flex;
    margin-top: var(--space-5);
}

/* --- Card view ---------------------------------------------------------- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    padding-bottom: 8px;
    list-style: none;
    margin: 0;
}

/*
 * A flat tile: the team's tint behind, its pattern over that, a 5px band of
 * its own colour across the top, and everything else in the ink of that hue.
 * Fixed height so a row of cards is a row rather than a ragged edge.
 */
.team-card {
    position: relative;
    overflow: hidden;
    height: 340px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border: 1px solid var(--color-border);
    border-top: 5px solid var(--team-band);
    transition: transform 320ms cubic-bezier(.16, 1, .3, 1), box-shadow 320ms ease;
}
.team-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 44px rgba(26, 31, 20, 0.22);
}

/* A medal outranks an identity: the podium's band goes metallic while the
   card keeps the team's own tint and pattern. */
.team-card[data-rank="1"] { --team-band: var(--gold); }
.team-card[data-rank="2"] { --team-band: var(--silver); }
.team-card[data-rank="3"] { --team-band: var(--bronze); }

/* Everything written on the card sits above the pattern layer. */
.team-card__head,
.team-card__name,
.team-card__foot { position: relative; }

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

.team-card__rank {
    font-family: var(--font-serif);
    font-size: 1.875rem;
    line-height: 1;
    color: var(--team-band);
    font-variant-numeric: tabular-nums;
}

.team-card__label {
    font-size: 0.56rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--team-ink);
}

.team-card__name {
    font-size: 2rem;
    line-height: 1.02;
    margin-top: 14px;
    color: var(--color-text);
    /* Team names are public input and can be long; never let one blow out
       the card, and never let one push the total off the bottom. */
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.team-card__foot { margin-top: auto; }

.team-card__roster {
    font-size: 0.63rem;
    line-height: 1.6;
    color: var(--team-ink);
    margin-bottom: 14px;
    overflow-wrap: anywhere;
    /* Six full names would crowd the total; the rest are on the list view. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.team-card__total {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.team-card__points {
    font-family: var(--font-serif);
    font-size: 3.625rem;
    line-height: 0.9;
    color: var(--team-ink);
    font-variant-numeric: tabular-nums;
}

.team-card__points-label {
    font-size: 0.63rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--team-ink);
}

@media (max-width: 1100px) {
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .card-grid { grid-template-columns: minmax(0, 1fr); }
    .team-card { height: auto; min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
    .team-card { transition: none; }
    .team-card:hover { transform: none; }
}

/* --- List view ---------------------------------------------------------- */

.team-rows {
    display: flex;
    flex-direction: column;
    list-style: none;
    margin: 0;
}

.team-row {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr) 132px;
    align-items: center;
    gap: 28px;
    padding: 22px 0;
    border-top: 1px solid var(--color-border);
}

.team-row__rank {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--color-border);
    font-variant-numeric: tabular-nums;
}
.team-row__rank--gold { color: var(--gold); }
.team-row__rank--silver { color: var(--silver); }
.team-row__rank--bronze { color: var(--bronze); }

.team-row__identity { min-width: 0; }

.team-row__name {
    font-size: 1.875rem;
    line-height: 1.05;
    margin-bottom: 8px;
    overflow-wrap: anywhere;
}

.team-row__roster {
    font-size: 0.69rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

/* How far this team has come against the leader, in the team's own colour. */
.team-row__bar {
    height: 6px;
    background: var(--color-surface-muted);
    position: relative;
}
.team-row__bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: hsl(var(--team-hue, 100) 45% 42%);
    transform-origin: left;
    animation: om-bar-grow 800ms cubic-bezier(.16, 1, .3, 1) both;
}
.team-row[data-rank="1"] .team-row__bar-fill { background: var(--gold); }
.team-row[data-rank="2"] .team-row__bar-fill { background: var(--silver); }
.team-row[data-rank="3"] .team-row__bar-fill { background: var(--bronze); }

@media (prefers-reduced-motion: reduce) {
    .team-row__bar-fill { animation: none; }
}

.team-row__score { text-align: right; }

.team-row__points {
    display: block;
    font-family: var(--font-serif);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}

.team-row__points-label {
    display: block;
    font-size: 0.63rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-top: 4px;
}

@media (max-width: 640px) {
    .team-row {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 6px 16px;
    }
    .team-row__rank { font-size: 1.75rem; }
    .team-row__name { font-size: 1.5rem; }
    .team-row__score {
        grid-column: 2;
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: var(--space-2);
        margin-top: var(--space-2);
    }
    .team-row__points { font-size: 2rem; }
    .team-row__points-label { margin-top: 0; }
}

/* --- The lap-tier strip on this page ------------------------------------ */

.tier-strip { margin-top: 64px; }

/* --- tests/leaderboard-field.html only ---------------------------------- */

.field-test-count {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.69rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.field-test-count input {
    width: 4.5rem;
    padding: 4px 0;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: 0.8rem;
}

.paint-readout {
    position: fixed;
    inset: auto var(--space-4) var(--space-4) auto;
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-text);
    background: var(--color-bg);
    font-family: var(--font-mono);
    font-size: 0.69rem;
    color: var(--color-text-muted);
    pointer-events: none;
    z-index: 40;
}

.paint-readout[data-state="poor"] {
    color: var(--color-danger);
    border-color: var(--color-danger);
}
