/* Apple-inspired dark theme — pure black canvas, SF system type, frosted glass surfaces. */

:root {
    --bg: #000;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --hairline: rgb(255 255 255 / 10%);
    --surface: #161617;
    --surface-raised: #1d1d1f;
    --accent: #2997ff;
    --accent-strong: #0071e3;
    --ease-apple: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    padding: 0 48px 56px;
    background: var(--bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif;
    line-height: 1.47;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgb(41 151 255 / 32%); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: rgb(255 255 255 / 22%);
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgb(255 255 255 / 36%); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

.container, .city-group, .stats-section, footer {
    width: min(100%, 1240px);
    margin-inline: auto;
}

/* ---------- Hero ---------- */

.main-header {
    position: relative;
    padding: clamp(5.5rem, 12vw, 10rem) 0 4.5rem;
    text-align: center;
}

/* Decorative route-trace mosaic behind the hero copy. */
.main-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100%;
    background: url("assets/hero-routes.png") center top / cover no-repeat;
    pointer-events: none;
}

.eyebrow {
    margin: 0 0 1.1rem;
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 600;
}

.main-header h1 {
    max-width: 900px;
    margin: 0 auto;
    font-size: clamp(3rem, 7vw, 6.2rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.04;
    text-shadow: 0 4px 32px rgb(0 0 0 / 65%);
}

.hero-copy {
    max-width: 580px;
    margin: 1.6rem auto 2rem;
    color: var(--text-secondary);
    font-size: clamp(1.05rem, 1.6vw, 1.25rem);
    line-height: 1.55;
}

/* Year filter — iOS segmented control */

.year-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    width: fit-content;
    margin: 0 auto;
    padding: 4px;
    border-radius: 999px;
    background: rgb(118 118 128 / 24%);
}

.filter-btn {
    padding: 0.42rem 1.05rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.92rem;
    transition: background 0.22s var(--ease-apple), color 0.22s var(--ease-apple);
}

.filter-btn:hover:not(.active) { background: rgb(255 255 255 / 8%); }

.filter-btn.active {
    background: var(--text-primary);
    color: #000;
    font-weight: 600;
}

.filter-status {
    min-height: 1.4rem;
    margin: 1.1rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ---------- Shared section headings ---------- */

.marathon-majors-section h2,
.world-map-section > h2,
.city-group-header {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* ---------- Marathon majors ---------- */

.marathon-majors-section { padding: 2.5rem 0 1rem; }

.marathon-majors-section h2 {
    margin: 0 0 1.4rem;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.marathon-gallery {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.9rem;
}

.marathon-item { min-width: 0; }

.marathon-item a {
    display: block;
    min-height: 100%;
    padding: 1.1rem 0.9rem 1rem;
    border-radius: 22px;
    background: #fff;
    color: #1d1d1f;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
    transition: transform 0.28s var(--ease-apple), box-shadow 0.28s var(--ease-apple);
}

.marathon-item a:hover {
    transform: translateY(-4px) scale(1.015);
    box-shadow: 0 22px 44px rgb(0 0 0 / 55%);
}

.marathon-item img {
    display: block;
    width: 100%;
    height: 76px;
    object-fit: contain;
    mix-blend-mode: multiply; /* merges white logo backgrounds into the tile */
}

.marathon-item p {
    margin: 0.6rem 0 0;
    color: #6e6e73;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
}

.marathon-item p + p {
    margin-top: 0.15rem;
    color: var(--accent-strong);
    font-size: 0.84rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

/* ---------- World map ---------- */

.world-map-section { padding: 3.5rem 0 1rem; }

.world-map-section > h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); }

.world-map-caption {
    margin: 0.55rem 0 1.6rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.world-map-wrap {
    position: relative;
    border: 1px solid var(--hairline);
    border-radius: 26px;
    background: var(--surface);
    padding: 14px;
    overflow: hidden;
}

.world-map { display: block; width: 100%; height: auto; }

.world-map-land { fill: #232326; stroke: rgb(255 255 255 / 6%); stroke-width: 0.6; }

.world-map-marker { cursor: pointer; }

.world-map-marker circle {
    fill: var(--accent);
    stroke: var(--surface);
    stroke-width: 1.2;
    transition: fill 0.18s ease, r 0.18s ease;
}

.world-map-marker:hover circle, .world-map-marker:focus-visible circle,
.world-map-marker.active circle { fill: #64d2ff; }

.world-map-marker text {
    fill: #000;
    font-size: 6px;
    font-weight: 700;
    font-family: inherit;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.world-map-marker:focus-visible { outline: none; }
.world-map-marker:focus-visible circle { stroke: #fff; }

.world-map-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 160px;
    max-width: 230px;
    padding: 0.4rem;
    border: 1px solid var(--hairline);
    border-radius: 14px;
    background: rgb(29 29 31 / 72%);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 16px 40px rgb(0 0 0 / 50%);
    font-size: 0.85rem;
}

.world-map-tooltip[hidden] { display: none; }

.world-map-tooltip a {
    display: block;
    padding: 0.42rem 0.65rem;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.world-map-tooltip a:hover { background: rgb(255 255 255 / 10%); }

/* ---------- Year view ---------- */

.year-view { margin-top: 3.25rem; scroll-margin-top: 1.5rem; }

.year-view-title {
    margin: 0 0 1.4rem;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.year-empty {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

body.year-filtered #sidebar-menu { display: none; }

/* ---------- City groups ---------- */

.city-group { margin-top: 4.5rem; scroll-margin-top: 1.5rem; }

.city-group-header {
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    line-height: 1.1;
}

.city-description {
    margin: 0.55rem 0 1.4rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 0.8rem;
    padding: 0;
}

.map-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--hairline);
    border-radius: 16px;
    /* Route exports use transparent pixels and light route strokes. */
    background: #101013;
    cursor: zoom-in;
    object-fit: contain;
    transition: transform 0.3s var(--ease-apple), border-color 0.3s var(--ease-apple),
        box-shadow 0.3s var(--ease-apple);
}

.map-grid img:hover {
    border-color: rgb(255 255 255 / 22%);
    box-shadow: 0 18px 36px rgb(0 0 0 / 55%);
    transform: scale(1.045);
}

/* ---------- Statistics ---------- */

.stats-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.2rem;
    margin-top: 5.5rem;
}

.stats-panel {
    padding: 1.6rem 1.7rem 1.7rem;
    border: 1px solid var(--hairline);
    border-radius: 26px;
    background: var(--surface);
}

.stats-panel h2 {
    margin: 0 0 1.3rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.3rem 0.9rem;
}

.stat-card { min-width: 0; }

.stat-value {
    display: block;
    color: var(--text-primary);
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stat-unit {
    margin-left: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-label {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

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

.effort-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.62rem 0;
    border-bottom: 1px solid rgb(255 255 255 / 8%);
}

.effort-list li:last-child { border-bottom: none; padding-bottom: 0; }
.effort-list li:first-child { padding-top: 0.1rem; }

.effort-distance { color: var(--text-secondary); font-size: 0.95rem; }

.effort-time {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

/* ---------- Cities drawer (click to open) ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    padding: 4rem 0.85rem 2rem;
    border-right: 1px solid var(--hairline);
    border-radius: 0 28px 28px 0;
    background: rgb(22 22 24 / 76%);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    box-shadow: 40px 0 90px rgb(0 0 0 / 55%);
    overflow-y: auto;
    visibility: hidden;
    transform: translateX(-104%);
    transition: transform 0.42s var(--ease-sheet), visibility 0s linear 0.42s;
    z-index: 50;
}

.sidebar.open {
    visibility: visible;
    transform: translateX(0);
    transition: transform 0.42s var(--ease-sheet), visibility 0s linear 0s;
}

.sidebar-header {
    padding: 0 0.9rem 0.7rem;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sidebar a {
    display: block;
    margin: 1px 0;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    color: rgb(245 245 247 / 72%);
    font-size: 0.88rem;
    font-weight: 450;
    line-height: 1.3;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
}

.sidebar a:hover { background: rgb(255 255 255 / 7%); color: var(--text-primary); }

.sidebar a.active {
    background: rgb(41 151 255 / 22%);
    color: #fff;
    font-weight: 550;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 48%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s var(--ease-apple);
    z-index: 45;
}

.scrim.visible {
    opacity: 1;
    pointer-events: auto;
}

.nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    position: fixed;
    top: 1.1rem;
    left: 1.1rem;
    z-index: 55;
    padding: 0.6rem 1.15rem;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: rgb(29 29 31 / 72%);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s var(--ease-apple);
}

.nav-toggle:hover { background: rgb(44 44 46 / 80%); }
.nav-toggle:active { transform: scale(0.96); }

.nav-toggle svg { width: 15px; height: 15px; flex: none; }

/* ---------- Lightbox ---------- */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: 5rem 1.25rem 1.25rem;
    background: rgb(0 0 0 / 78%);
    backdrop-filter: saturate(160%) blur(26px);
    -webkit-backdrop-filter: saturate(160%) blur(26px);
}

.lightbox-content {
    display: block;
    width: auto;
    max-width: min(92vw, 1100px);
    height: auto;
    max-height: 78vh;
    margin: 0 auto;
    object-fit: contain;
}

.lightbox-caption {
    max-width: 700px;
    margin: 1rem auto;
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.9rem;
}

.lightbox-close {
    position: absolute;
    top: 1.1rem;
    right: 1.4rem;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: rgb(255 255 255 / 12%);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    transition: background 0.18s ease;
}

.lightbox-close:hover { background: rgb(255 255 255 / 22%); }

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

footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 5rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--hairline);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

footer p { margin: 0; }
.footer-title { color: var(--text-secondary); font-weight: 500; }

.footer-links a {
    margin-left: 1.2rem;
    color: var(--accent);
    text-decoration: none;
}

.footer-links a:hover { text-decoration: underline; }

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

@media (max-width: 1050px) {
    body { padding: 0 36px 48px; }
    .marathon-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .stats-section { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    body { padding: 0 20px 36px; }
    .nav-toggle { top: 0.9rem; left: 0.9rem; }
    .main-header { padding-top: 6.5rem; }
    .marathon-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .map-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.55rem; }
    footer { align-items: flex-start; flex-direction: column; }
    .footer-links a { margin: 0 1.2rem 0 0; }
}

@media (max-width: 420px) {
    .marathon-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-header h1 { font-size: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
