/* =========================================================================
   Driven Across Canada
   -------------------------------------------------------------------------
   Brand tokens are lifted from drivenmidland.ca so this app reads as part of
   the same family: the red #BE1D2C, Source Sans Pro, and square corners
   (the parent site sets border-radius: 0 on almost everything).

   Everything visual is defined by the custom properties in :root. A reskin —
   including Joe's final design — is a change to that block, not a sweep
   through the file.
   ========================================================================= */

:root {
    /* Brand ---------------------------------------------------------------- */
    --brand:            #BE1D2C;
    --brand-dark:       #97161F;
    --brand-light:      #E8404F;
    --brand-wash:       rgba(190, 29, 44, .08);
    --brand-wash-mid:   rgba(190, 29, 44, .16);

    --ink:              #3A3737;   /* headings, dark surfaces */
    --ink-deep:         #262323;
    --text:             #333333;
    --text-soft:        #6D6D6D;
    --text-faint:       #8C8C8C;

    /* Surfaces ------------------------------------------------------------- */
    --surface:          #FFFFFF;
    --surface-muted:    #F5F5F5;
    --surface-sunk:     #F0F0F0;
    --line:             #E0E0E0;
    --line-soft:        #EBEBEB;

    /* Status --------------------------------------------------------------- */
    --success:          #2E7D32;
    --success-wash:     #E8F3E9;
    --warning:          #EF6C00;
    --warning-wash:     #FDF0E3;
    --danger:           var(--brand);
    --danger-wash:      var(--brand-wash);
    --info-wash:        #EEF3F8;

    /* Map ------------------------------------------------------------------ */
    --map-land:         #E4E1DD;
    --map-land-line:    #CFCAC4;
    --map-water:        #F5F5F3;
    --route-remaining:  #C9C4BE;
    --route-done:       var(--brand);

    /* Type ----------------------------------------------------------------- */
    --font: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Geometry ------------------------------------------------------------- */
    --radius:       0;
    --radius-pill:  999px;
    --shadow:       0 1px 3px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-lift:  0 6px 18px rgba(0, 0, 0, .10);
    --container:    72rem;
    --gutter:       1.25rem;
}

/* ---------------------------------------------------------------- reset ---- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--surface-muted);
    -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
    margin: 0 0 .5rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
    letter-spacing: -.01em;
}

h1 { font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.1vw, 2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 1.75rem 0; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; top: -4rem; left: 1rem; z-index: 200;
    padding: .7rem 1.1rem;
    background: var(--brand); color: #fff; font-weight: 600;
    transition: top .15s ease;
}
.skip-link:focus { top: 1rem; text-decoration: none; color: #fff; }

/* ------------------------------------------------------------ structure ---- */

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}
.container--narrow { max-width: 34rem; }
.container--mid    { max-width: 52rem; }

.page { padding: 2rem 0 4rem; }
.section { margin-bottom: 2.5rem; }
.section:last-child { margin-bottom: 0; }

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-bottom: 1rem;
}
.section-head h2 { margin: 0; }

/* ----------------------------------------------------------------- site ---- */

/* Light bar: the Driven wordmark is dark artwork and needs to sit on it. */
.site-header {
    background: var(--surface);
    color: var(--text);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.25rem;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    color: var(--ink);
    text-decoration: none;
    padding: .5rem 0;
    min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand__logo {
    /* Intrinsic 300x42; height-locked so the wordmark keeps its proportions. */
    height: 1.6rem;
    width: auto;
    flex: none;
    align-self: center;
}

.brand__text {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--brand);
    align-self: center;
    padding-left: .65rem;
    border-left: 1px solid var(--line);
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    color: var(--ink);
    padding: .5rem .7rem;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}

.site-nav { display: flex; align-items: center; gap: .25rem; }

.site-nav a {
    color: var(--text-soft);
    padding: .55rem .8rem;
    font-weight: 600;
    font-size: .95rem;
    border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--line); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.site-nav a.btn { border-bottom: 2px solid transparent; }
.site-nav a.btn--primary { color: #fff; }
.site-nav a.btn--primary:hover { color: #fff; border-bottom-color: transparent; }

.site-nav__divider {
    width: 1px; height: 1.5rem;
    background: var(--line);
    margin: 0 .5rem;
}

.site-footer {
    background: var(--ink-deep);
    color: rgba(255, 255, 255, .6);
    padding: 2.5rem 0;
    font-size: .9rem;
    margin-top: auto;
}
.site-footer a { color: rgba(255, 255, 255, .85); }
.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    justify-content: space-between;
    align-items: center;
}

.site-footer__right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .55rem;
}

/* "Powered by Mediasuite" — present but quiet; it is a credit, not a call to
   action, so it sits back until hovered. */
.credit {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: rgba(255, 255, 255, .45);
    transition: color .18s ease;
}
.credit:hover,
.credit:focus-visible { color: rgba(255, 255, 255, .9); text-decoration: none; }

.credit__label {
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .11em;
    text-transform: uppercase;
    white-space: nowrap;
}

.credit__logo {
    /* Height-locked; the file is 1585x353 so the width follows. */
    height: 1.05rem;
    width: auto;
    opacity: .55;
    transition: opacity .18s ease;
}
.credit:hover .credit__logo,
.credit:focus-visible .credit__logo { opacity: 1; }

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1 0 auto; }

/* -------------------------------------------------------------- buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.4rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
    /* Comfortable thumb target — most logging happens on a phone (§19). */
    min-height: 2.9rem;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn--dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--dark:hover { background: var(--ink-deep); border-color: var(--ink-deep); color: #fff; }

.btn--outline { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn--outline:hover { background: var(--ink); color: #fff; }

.btn--outline-light { background: transparent; border-color: rgba(255,255,255,.6); color: #fff; }
.btn--outline-light:hover { background: #fff; border-color: #fff; color: var(--ink); }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-soft); }
.btn--ghost:hover { border-color: var(--text-soft); color: var(--ink); }

.btn--danger { background: transparent; border-color: var(--brand); color: var(--brand); }
.btn--danger:hover { background: var(--brand); color: #fff; }

.btn--sm { padding: .4rem .8rem; font-size: .875rem; min-height: 2.2rem; border-width: 1px; }
.btn--lg { padding: .9rem 1.9rem; font-size: 1.075rem; min-height: 3.25rem; }
.btn--block { display: flex; width: 100%; }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.btn-row--end { justify-content: flex-end; }

/* ---------------------------------------------------------------- cards ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}
.card--flush { padding: 0; }
.card--pad-sm { padding: 1rem; }

.card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem 1rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
}
.card__head h2, .card__head h3 { margin: 0; }
.card__body { padding: 1.5rem; }
.card__foot {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
}

/* ---------------------------------------------------------------- stats ---- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
}

.stat {
    background: var(--surface);
    padding: 1.25rem 1.4rem;
    text-align: center;
}
.stat__value {
    display: block;
    font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.stat__value--brand { color: var(--brand); }
.stat__label {
    display: block;
    margin-top: .3rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-soft);
}
.stat__note { display: block; margin-top: .2rem; font-size: .8rem; color: var(--text-faint); }

/* ----------------------------------------------------------------- hero ---- */

.hero {
    background: var(--ink);
    color: #fff;
    padding: 2.5rem 0 3rem;
    position: relative;
    overflow: hidden;
}
.hero::after {
    /* A slim brand rule along the bottom edge, echoing the parent site. */
    content: "";
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 4px;
    background: var(--brand);
}
.hero h1 { color: #fff; margin-bottom: .35rem; }
.hero__lede {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, .75);
    max-width: 42rem;
    margin-bottom: 0;
}
.hero__eyebrow {
    display: inline-block;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--brand-light);
    margin-bottom: .6rem;
}

/* The collective total — the single most important number on the site. */
.odometer {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: .5rem;
    margin: 1.5rem 0 .25rem;
    text-align: center;
    flex-wrap: wrap;
}
.odometer__value {
    font-size: clamp(2.8rem, 1.6rem + 6vw, 5.5rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.03em;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.odometer__unit {
    font-size: clamp(1.1rem, .9rem + 1vw, 1.6rem);
    font-weight: 600;
    color: var(--brand-light);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.odometer__caption {
    text-align: center;
    color: rgba(255, 255, 255, .65);
    font-size: .95rem;
    margin: 0;
}

/* --------------------------------------------------------- progress bar ---- */

.progress {
    margin: 1.5rem 0 .5rem;
}
.progress__track {
    position: relative;
    height: .9rem;
    background: rgba(255, 255, 255, .15);
    overflow: hidden;
}
.progress__fill {
    height: 100%;
    background: var(--brand);
    transition: width .8s cubic-bezier(.2, .7, .3, 1);
}
.progress__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .5rem;
    font-size: .88rem;
    color: rgba(255, 255, 255, .7);
    font-variant-numeric: tabular-nums;
}
.progress__meta strong { color: #fff; }

/* Light-background variant, used on the dashboard and admin. */
.progress--light .progress__track { background: var(--surface-sunk); }
.progress--light .progress__meta { color: var(--text-soft); }
.progress--light .progress__meta strong { color: var(--ink); }

/* --------------------------------------------------- milestone messaging ---- */

.milestone-banner {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.milestone-banner__reached {
    font-size: clamp(1.35rem, 1.1rem + 1.3vw, 2rem);
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 .35rem;
    line-height: 1.15;
}
.milestone-banner__next {
    font-size: 1.05rem;
    color: var(--text-soft);
    margin: 0;
}
.milestone-banner__next strong { color: var(--brand); }
.milestone-banner__togo {
    display: inline-block;
    margin-top: .75rem;
    padding: .35rem .9rem;
    background: var(--brand-wash);
    color: var(--brand-dark);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.milestone-banner--complete { border-top-color: var(--success); }
.milestone-banner--pre { border-top-color: var(--ink); }

/* ------------------------------------------------------------ Canada map ---- */

.map {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1rem;
}
.map__figure { margin: 0; }
.map__frame { position: relative; }
.map__svg { width: 100%; height: auto; display: block; }

/* Real coastline detail, so the outline takes only a hairline stroke — a
   heavier one turns the Arctic islands into noise. */
.map__land       { fill: var(--map-land); stroke: var(--map-land-line); stroke-width: 0.7; stroke-linejoin: round; }
/* The route is the only saturated colour on the map, and it carries the whole
   story, so it is weighted to read at a glance against the full country. */
.map__route-base { fill: none; stroke: var(--route-remaining); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1.5 7.5; stroke-linejoin: round; }
.map__route-done { fill: none; stroke: var(--route-done); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }

.map__pin          { fill: var(--surface); stroke: var(--route-remaining); stroke-width: 2; }
.map__pin--done    { fill: var(--brand); stroke: var(--brand); }
.map__pin--current { fill: #fff; stroke: var(--brand); stroke-width: 3.2; }

.map__label {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    fill: var(--text-soft);
    /* Halo the text so a label crossing the coastline stays readable. */
    paint-order: stroke;
    stroke: var(--surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}
.map__label--done    { fill: var(--ink); }
.map__label--current { fill: var(--brand); font-size: 13px; font-weight: 700; }

.map__marker-halo { fill: var(--brand); opacity: .22; }
.map__marker-dot  { fill: var(--brand); stroke: #fff; stroke-width: 2; }

.map__endpoint {
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    fill: var(--text-faint);
    paint-order: stroke;
    stroke: var(--surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}

/*
 * On a narrow screen the whole 1000-unit map scales down to phone width, which
 * would render these labels at three or four pixels — present but unreadable,
 * and they clutter the route while they are at it. Drop them there and let the
 * milestone list below the map carry the names; it is already on the page, in
 * order, with the same reached/current/upcoming states.
 */
@media (max-width: 48rem) {
    /*
     * Zoom to wherever the group currently is.
     *
     * The whole country still renders; the frame windows it onto a region
     * around the live progress marker. On a 390px screen the full map leaves
     * the route a hairline and the part that matters — the milestone just
     * reached and the one coming next — a few pixels across.
     *
     * The four values are computed per render by Challenge::mobileZoom() and
     * arrive as custom properties on .map__frame, because they change with
     * progress but must only apply at this breakpoint, and an inline style
     * cannot be media-scoped. The fallbacks below are the whole-route band, so
     * the map degrades to something sensible rather than breaking if the
     * properties are ever missing.
     */
    .map__frame {
        overflow: hidden;
        padding-bottom: var(--map-zoom-pad, 28.6%);
    }
    .map__svg {
        position: absolute;
        top: 0;
        left: 0;

        /*
         * max-width MUST be cleared. The reset sets `img, svg { max-width:100% }`,
         * which is lower specificity than this rule so it does not override the
         * width — but max-width still CLAMPS it, silently capping the zoom at
         * 100% while the translate applied as normal. The map then looked
         * correctly panned and wrongly scaled, which is a confusing way to fail.
         */
        max-width: none;
        width: var(--map-zoom-w, 102%);
        transform: translate(var(--map-zoom-x, -2%), var(--map-zoom-y, -54.3%));
    }

    /*
     * No stroke or label overrides here on purpose.
     *
     * An earlier version thickened everything and hid the labels, because the
     * whole country squeezed into 390px rendered them at a few pixels. Zoomed
     * to ~400 viewBox units across a ~390px screen the scale is about 0.98px
     * per unit — near-identical to desktop's 0.93 — so the desktop weights are
     * already right, and the city names are readable again. Thickening now
     * would make a phone look heavier than a laptop.
     */
}

/* Fallback shown when JavaScript is unavailable — the map still communicates
   progress, just as a bar rather than a route. */
.map__fallback {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
}

.map__legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
    font-size: .82rem;
    color: var(--text-soft);
}
.map__legend span { display: inline-flex; align-items: center; gap: .4rem; }
.map__legend i {
    width: .7rem; height: .7rem;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}
.map__legend i.is-done { background: var(--brand); }
.map__legend i.is-current { background: #fff; border: 2.5px solid var(--brand); }
.map__legend i.is-upcoming { background: var(--surface); border: 2px solid var(--route-remaining); }

/* ------------------------------------------------- milestone list (mobile) -- */

.milestone-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
}
.milestone-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    background: var(--surface);
    font-size: .92rem;
}
.milestone-list li.is-complete { color: var(--text-soft); }
.milestone-list li.is-current {
    background: var(--brand-wash);
    font-weight: 700;
    color: var(--ink);
}
.milestone-list li.is-upcoming { color: var(--text-faint); }
.milestone-list__dot {
    width: .7rem; height: .7rem; flex: none; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--route-remaining);
}
.is-complete .milestone-list__dot { background: var(--brand); border-color: var(--brand); }
.is-current  .milestone-list__dot { background: #fff; border-color: var(--brand); border-width: 3px; }
/*
 * "Sault Ste. Marie, ON" plus the LATEST MILESTONE badge is wider than a phone.
 * Letting the name cell shrink and wrap keeps that row on two lines instead of
 * pushing the whole page into a horizontal scroll. min-width:0 is the part that
 * matters — a flex item defaults to min-width:auto and refuses to shrink below
 * its content.
 */
.milestone-list__name { min-width: 0; }

.milestone-list__km {
    margin-left: auto;
    padding-left: .5rem;
    flex: none;
    font-variant-numeric: tabular-nums;
    font-size: .85rem;
}

/* ---------------------------------------------------------------- forms ---- */

.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }

.label {
    display: block;
    margin-bottom: .35rem;
    font-weight: 600;
    font-size: .92rem;
    color: var(--ink);
}
.label .req { color: var(--brand); }

.input, .select, .textarea {
    display: block;
    width: 100%;
    padding: .7rem .85rem;
    font: inherit;
    /* 16px minimum: anything smaller makes iOS Safari zoom on focus, which is
       jarring in the middle of logging an activity. */
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-height: 2.9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-wash-mid);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--brand); }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236D6D6D' d='M0 0h12L6 8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .9rem center;
    padding-right: 2.4rem;
}

.help { display: block; margin-top: .3rem; font-size: .85rem; color: var(--text-soft); }
.field-error {
    display: block;
    margin-top: .35rem;
    font-size: .87rem;
    font-weight: 600;
    color: var(--brand);
}

.form-grid {
    display: grid;
    gap: 0 1rem;
    grid-template-columns: 1fr 1fr;
}
.form-grid > .form-group--full { grid-column: 1 / -1; }

/* Honeypot: hidden from people, present for bots (§5). Deliberately not
   `display:none` — some bots skip those; this is off-screen but focusable-safe. */
.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px;
    overflow: hidden;
}

/* --------------------------------------------------------------- alerts ---- */

.alert {
    padding: .9rem 1.1rem;
    margin-bottom: 1.25rem;
    border-left: 4px solid;
    background: var(--surface);
    font-size: .95rem;
}
.alert:last-child { margin-bottom: 0; }
.alert--success { border-color: var(--success); background: var(--success-wash); color: #1B5E20; }
.alert--error   { border-color: var(--brand);   background: var(--brand-wash);   color: var(--brand-dark); }
.alert--warning { border-color: var(--warning); background: var(--warning-wash); color: #B35300; }
.alert--info    { border-color: var(--ink);     background: var(--info-wash);    color: var(--ink); }

.flash-stack { margin-bottom: 1.5rem; }

/* A very loud banner: the challenge clock is being overridden for testing.
   Impossible to leave switched on without noticing. */
.time-override {
    background: repeating-linear-gradient(45deg, #B35300, #B35300 12px, #8F4200 12px, #8F4200 24px);
    color: #fff;
    text-align: center;
    padding: .6rem 1rem;
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .02em;
}

/* --------------------------------------------------------------- tables ---- */

.table-wrap {
    /* Wide tables scroll inside their own box; the page body never scrolls
       sideways on a phone. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}
.table th, .table td {
    padding: .8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.table thead th {
    background: var(--surface-muted);
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-soft);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------- leaderboard ---- */

.lb__rank {
    width: 4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-soft);
}
.lb__rank--medal { color: var(--brand); font-size: 1.05rem; }

.lb__name { font-weight: 600; }
.lb__name a { color: var(--ink); }
.lb__name a:hover { color: var(--brand); }

.lb__km { font-weight: 700; color: var(--ink); }

/* The signed-in participant's own row (§10). */
.table tbody tr.is-you,
.table tbody tr.is-you:hover {
    background: var(--brand-wash);
    box-shadow: inset 3px 0 0 var(--brand);
}
.you-badge {
    display: inline-block;
    margin-left: .5rem;
    padding: .1rem .45rem;
    background: var(--brand);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* --------------------------------------------------------- activity list --- */

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

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.5rem;
    border-bottom: 1px solid var(--line-soft);
}
.activity-item:last-child { border-bottom: 0; }

.activity-item__icon {
    width: 2.5rem; height: 2.5rem;
    flex: none;
    display: grid;
    place-items: center;
    background: var(--brand-wash);
    color: var(--brand);
}
.activity-item__icon svg { width: 1.35rem; height: 1.35rem; }

.activity-item__main { min-width: 0; flex: 1; }
.activity-item__type { font-weight: 600; color: var(--ink); display: block; }
.activity-item__date { font-size: .87rem; color: var(--text-soft); }
.activity-item__km {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.activity-item__actions { display: flex; gap: .4rem; flex: none; }

/* ---------------------------------------------------------------- empty ---- */

.empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-soft);
}
.empty h3 { color: var(--ink); margin-bottom: .4rem; }
.empty p { margin-bottom: 1rem; max-width: 30rem; margin-inline: auto; }

/* --------------------------------------------------------------- badges ---- */

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    border: 1px solid;
}
.badge--active   { color: var(--success); border-color: var(--success); background: var(--success-wash); }
.badge--inactive { color: var(--text-soft); border-color: var(--line); background: var(--surface-muted); }
.badge--admin    { color: var(--brand); border-color: var(--brand); background: var(--brand-wash); }

/* ---------------------------------------------------------------- modal ---- */

/* Desktop: a centred dialog. Mobile: a full-height sheet, because the activity
   form is the one thing people will use standing in a parking lot. */
.modal[hidden] { display: none; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(38, 35, 35, .6);
}
.modal__panel {
    width: 100%;
    max-width: 30rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-lift);
}
.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; font-size: 1.2rem; }
.modal__close {
    background: none; border: 0; padding: .25rem .5rem;
    font-size: 1.5rem; line-height: 1; color: var(--text-soft); cursor: pointer;
}
.modal__close:hover { color: var(--brand); }
.modal__body { padding: 1.5rem; }

/* --------------------------------------------------------------- admin ----- */

.admin-bar {
    background: var(--brand);
    color: #fff;
    font-size: .88rem;
}
.admin-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem 1rem;
    min-height: 2.75rem;
}
.admin-bar strong {
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: .74rem;
    padding-right: .75rem;
    border-right: 1px solid rgba(255, 255, 255, .3);
    margin-right: .25rem;
}
.admin-bar a { color: rgba(255, 255, 255, .85); padding: .5rem .25rem; font-weight: 600; }
.admin-bar a:hover, .admin-bar a[aria-current="page"] { color: #fff; text-decoration: none; }
.admin-bar a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1 1 12rem; }

/* ----------------------------------------------------------- utilities ----- */

.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 56rem) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-2--wide-left { grid-template-columns: 1.6fr 1fr; }
}

.stack > * + * { margin-top: 1.5rem; }
.stack-sm > * + * { margin-top: .75rem; }

.text-center  { text-align: center; }
.text-soft    { color: var(--text-soft); }
.text-small   { font-size: .875rem; }
.text-brand   { color: var(--brand); }
.nums         { font-variant-numeric: tabular-nums; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

/* --------------------------------------------------------------- mobile ---- */

@media (max-width: 52rem) {
    .nav-toggle { display: block; }

    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--surface);
        border-top: 1px solid var(--line);
        padding: .5rem 0 1rem;
        box-shadow: var(--shadow-lift);
    }
    .site-nav.is-open { display: flex; }
    .site-nav a {
        padding: .85rem var(--gutter);
        border-bottom: 0;
        border-left: 3px solid transparent;
    }
    .site-nav a[aria-current="page"] { border-left-color: var(--brand); border-bottom-color: transparent; }
    .site-nav__divider { width: auto; height: 1px; margin: .5rem var(--gutter); }
    .site-nav .btn { margin: .5rem var(--gutter) 0; }

    .site-header__inner { position: relative; }
}

@media (max-width: 40rem) {
    :root { --gutter: 1rem; }

    /* Once the footer wraps to one column, a right-aligned credit under
       left-aligned text reads as a mistake. */
    .site-footer__right { align-items: flex-start; }

    /* The wordmark plus "Across Canada" plus the Menu button do not fit on a
       phone — the strapline is what gives way, since the page it links to says
       the same thing in the hero. */
    .brand__logo { height: 1.35rem; }
    .brand__text {
        border-left: 0;
        padding-left: 0;
        font-size: .7rem;
    }
}

@media (max-width: 26rem) {
    .brand__text { display: none; }
}

@media (max-width: 40rem) {

    .form-grid { grid-template-columns: 1fr; }

    /*
     * Once .form-grid collapses to one column its last field is no longer
     * beside another — it lands directly on top of the submit button, because
     * .form-group:last-child zeroes the bottom margin. Fine side by side,
     * cramped when stacked. Put the gap back.
     */
    .form-grid > .form-group:last-child { margin-bottom: 1.25rem; }

    /*
     * Three stats in a two-column grid leaves a dead fourth cell. Give the
     * leading figure — total kilometres — the full width and let the other two
     * sit beneath it.
     *
     * :first-child:nth-last-child(3) matches only when there are exactly three
     * stats, so the four-stat homepage grid keeps its 2x2 and no extra class is
     * needed on the markup.
     */
    .stat-grid > .stat:first-child:nth-last-child(3) { grid-column: 1 / -1; }

    /*
     * ...except where the second stat should lead instead.
     *
     * The dashboard reads kilometres, rank, activities — the right order on a
     * desktop row, but on a phone the rank is the figure people open the page
     * for. `order` promotes it visually without touching the DOM, so the
     * desktop row and the reading order for screen readers stay as they are.
     *
     * Matched at the same specificity as the rule above and placed after it, so
     * it wins; the first stat is handed back its single column.
     */
    .stat-grid--lead-second > .stat:first-child:nth-last-child(3) { grid-column: auto; }
    .stat-grid--lead-second > .stat:nth-child(2) {
        order: -1;
        grid-column: 1 / -1;
    }

    .card { padding: 1.25rem; }
    .card__head, .card__body, .card__foot { padding-left: 1.25rem; padding-right: 1.25rem; }

    .activity-item { padding: .9rem 1.25rem; flex-wrap: wrap; }
    .activity-item__actions { width: 100%; justify-content: flex-end; }

    /* Full-height sheet on phones. */
    .modal { padding: 0; place-items: stretch; }
    .modal__panel { max-width: none; max-height: none; height: 100%; }

    .table th, .table td { padding: .7rem .75rem; }

    .btn-row .btn { flex: 1 1 100%; }
    .section-head { flex-direction: column; align-items: flex-start; }
}

/* ----------------------------------------------------------------- print --- */

@media print {
    .site-header, .site-footer, .admin-bar, .btn, .nav-toggle { display: none !important; }
    body { background: #fff; }
    .card { border: 1px solid #ccc; box-shadow: none; }
}
