/* ============================================================
   Race results pages. Builds on styles.css tokens
   (--cream, --ink, jersey colors, spacing scale, fonts).
   Mobile-first; widens at 720px.
   ============================================================ */

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

/* ---------- Results layout ---------- */
.results { padding: var(--space-xl) 0 var(--space-6xl); }
.results .container { max-width: 760px; }

/* ---------- Breadcrumb ---------- */
.crumbs {
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: var(--space-lg);
}
.crumbs a { color: var(--accent-active-ink); }
.crumbs a:hover { text-decoration: underline; }
.crumbs span[aria-hidden] { margin: 0 var(--space-xs); color: var(--dust, #a3a3a0); }

/* ---------- Hero ---------- */
.results-hero { margin-bottom: var(--space-2xl); }
.results-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(30px, 7vw, 46px);
    line-height: 1.06;
    letter-spacing: -0.03em;
    font-weight: 700;
    margin: 0 0 var(--space-sm);
}
.results-dates {
    color: var(--ink-soft);
    font-size: 15px;
    margin: 0 0 var(--space-lg);
}
.results-intro {
    font-size: 17px;
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 0 0 var(--space-xl);
    max-width: 62ch;
}
.results-hero .cta-row { margin-bottom: 0; }

/* ---------- Classification tabs ---------- */
.class-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-xs) 0 var(--space-lg);
}
.tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    border: 1px solid var(--border);
    background: var(--card-white, #fff);
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    padding: 8px 13px;
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.tab-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--jersey);
    box-shadow: 0 0 0 1px rgba(26,26,31,0.08) inset;
    flex-shrink: 0;
}
.tab[aria-selected="true"] {
    background: var(--jersey);
    color: var(--jersey-ink);
    border-color: var(--jersey);
}
.tab[aria-selected="true"] .tab-dot {
    background: var(--jersey-ink);
    opacity: 0.55;
}
.tab:hover:not([aria-selected="true"]) { border-color: var(--accent-active); }

.panel { margin-top: var(--space-md); }
.panel[hidden] { display: none; }
.panel:focus-visible { outline: none; }

/* ---------- Leader card (signature component) ---------- */
.leader-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    background: var(--jersey);
    color: var(--jersey-ink);
    border: 1px solid rgba(26, 26, 31, 0.08); /* defines light jerseys (white/polka) on cream */
    border-radius: var(--radius-card);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
}
/* Maillot à Pois / blue polka-dot jersey. Staggered dots matching the app
   (42px grid, 14px dots, 72% opacity), masked to fade out behind the left-hand
   text and concentrate toward the jersey image — same treatment as the app. */
.leader-card--polka {
    position: relative;
    overflow: hidden;
    background-color: var(--jersey);
}
.leader-card--polka::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, color-mix(in srgb, var(--dot) 72%, transparent) 7px, transparent 7.5px),
        radial-gradient(circle, color-mix(in srgb, var(--dot) 72%, transparent) 7px, transparent 7.5px);
    background-size: 42px 42px, 42px 42px;
    background-position: 0 0, 21px 21px;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, transparent 34%, rgba(0, 0, 0, 0.42) 55%, rgba(0, 0, 0, 0.72) 66%, transparent 80%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, transparent 34%, rgba(0, 0, 0, 0.42) 55%, rgba(0, 0, 0, 0.72) 66%, transparent 80%, transparent 100%);
    pointer-events: none;
}
.leader-card--polka > * { position: relative; z-index: 1; }
.leader-jersey {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.78;
    margin: 0 0 6px;
}
.leader-name {
    font-family: var(--font-display);
    font-size: clamp(22px, 5.5vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin: 0;
}
.leader-team {
    font-size: 14px;
    opacity: 0.82;
    margin: 4px 0 0;
}
.leader-metric {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-size: 18px;
    font-weight: 700;
    margin: var(--space-md) 0 0;
}
.leader-unit { font-size: 13px; font-weight: 600; opacity: 0.8; }
.leader-jersey-img { flex-shrink: 0; }

/* Contextual install nudge, sits just under the leader card (engagement peak).
   Calm parchment surface so it supports rather than competes with the card. */
.follow-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
    background: var(--cream-soft, #ede8df);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-lg);
}
.follow-cta-lead {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}
.follow-cta-logo-link {
    display: inline-flex;
    flex-shrink: 0;
    border-radius: 11px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.follow-cta-logo-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -8px rgba(26, 26, 31, 0.4);
}
.follow-cta-logo {
    width: 48px;
    height: 48px;
    border-radius: 11px;
    display: block;
}
.follow-cta-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink);
    max-width: 42ch;
}

/* ---------- Standings list ---------- */
.standings {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--card-white, #fff);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.row {
    display: grid;
    grid-template-columns: 28px 36px 1fr auto;
    align-items: center;
    gap: var(--space-md);
    padding: 11px var(--space-lg);
    border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-pos {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 15px;
    color: var(--ink-soft);
    text-align: right;
}
.row-rider { min-width: 0; }
.row-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.25;
}
.row-team {
    display: block;
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.row-value {
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-align: right;
    white-space: nowrap;
}
.row-value .val-gap { color: var(--ink-soft); font-weight: 500; }
.row-value .unit { font-size: 11px; color: var(--ink-soft); font-weight: 500; }

/* ---------- Jersey thumbnail + fallback chip ---------- */
.row-jersey { display: flex; align-items: center; justify-content: center; }
.jersey {
    display: flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    border-radius: 8px;
    background: var(--parchment, #ede8df);
    object-fit: contain;
}
.jersey--sm { width: 36px; height: 36px; padding: 2px; }
/* Leader-card jersey: fluid square that scales with the viewport. */
.jersey--lg {
    width: clamp(88px, 26vw, 132px);
    height: clamp(88px, 26vw, 132px);
    padding: clamp(5px, 1.6vw, 10px);
    border-radius: clamp(12px, 3.5vw, 18px);
    background: rgba(255, 255, 255, 0.35);
}
.jersey--chip {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    background: hsl(var(--chip-h, 200), 42%, 42%);
    text-transform: uppercase;
}
.jersey--lg.jersey--chip { font-size: clamp(24px, 7vw, 38px); }

/* ---------- Results hub grid ---------- */
.race-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}
.race-card {
    display: flex;
    align-items: stretch;
    background: var(--card-white, #fff);
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.race-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -14px rgba(26,26,31,0.4);
}
.race-card-bar { width: 8px; background: var(--jersey); flex-shrink: 0; }
.race-card-body { padding: var(--space-lg) var(--space-xl); display: flex; flex-direction: column; gap: 4px; }
.race-card-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.race-card-meta { font-size: 13px; color: var(--ink-soft); }
.race-card-winner { font-size: 13px; color: var(--accent-active-ink); font-weight: 600; }

/* ---------- Back to top ---------- */
.to-top {
    position: fixed;
    right: var(--space-lg);
    bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card-white, #fff);
    color: var(--ink);
    box-shadow: 0 4px 12px rgba(26, 26, 31, 0.12);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.to-top[hidden] { display: none; }
.to-top:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(26, 26, 31, 0.16); }

/* ---------- Wider screens ---------- */
@media (min-width: 720px) {
    .results { padding-top: var(--space-2xl); }
    .leader-card { padding: var(--space-2xl); }
    .follow-cta { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-2xl); }
    .follow-cta .app-store-badge { flex-shrink: 0; }
    .row { grid-template-columns: 36px 40px 1fr auto; padding: 13px var(--space-xl); }
    .row-name { font-size: 16px; }
    .race-grid { grid-template-columns: 1fr 1fr; }
}
