/* ── Design tokens ────────────────────────────────────────────────────────
 *
 * Stories look (#2308). Palette: a near-neutral ground with ink, a hairline
 * and ONE orange accent, plus an "on dark" set for dark bands. Type: Bricolage
 * Grotesque (display), Source Serif 4 (story prose), Inter (interface).
 * Every colour token is defined in the light :root block and again in the
 * dark override (LOOK-4); sizes, spacing, radii and type tokens are
 * theme-independent. The names are documented in
 * docs/invariants/look-and-feel.md.
 */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --ground:         #F5F6F3;   /* page background */
  --surface:        #FFFFFF;   /* cards, header, sheets */
  --surface-alt:    #F0F2EE;   /* hover / selected / quiet blocks */
  --surface-sunken: #ECEEE9;   /* inset wells, inputs on a surface */

  /* Hairlines. Decorative dividers only: they are not 3:1 against the
     surface, so a control's own edge uses --border-control. */
  --hairline:        #DDE1DC;
  --hairline-strong: #C9CFC9;
  --hairline-subtle: #ECEEE9;
  --border-control:  #7C8B8F;  /* edge of an input, checkbox, outlined button (3:1) */

  /* Ink (text) */
  --ink:            #12171A;   /* titles, figures, primary text */
  --ink-body:       #232B2F;   /* story prose */
  --ink-muted:      #566267;   /* secondary text, labels */
  --ink-subtle:     #5F6C72;   /* tertiary text, still 4.5:1 on every surface */

  /* The one accent: route line, current item, primary action. */
  --accent:         #C2410C;
  --accent-hover:   #9A3412;   /* also the text colour on --accent-soft */
  --accent-soft:    #FCF4F0;
  --on-accent:      #FFFFFF;   /* text and icons on an --accent fill */
  --focus-ring:     var(--accent);

  /* On dark: bands that stay dark in both themes (story hero, header band). */
  --band-bg:        #171E22;
  --on-dark:        #F5F6F3;
  --on-dark-muted:  #B9C4C1;
  --on-dark-border: #3E4C52;
  --on-dark-accent: #FFB38A;   /* kicker / route highlight on a dark band */

  /* Semantic. Distinct hues so state is never read as "the accent" (LOOK-2
     still applies: pair with an icon or text). */
  --danger:         #B3261E;
  --danger-hover:   #8C1D18;
  --danger-soft:    #FBEEEC;
  --success:        #2E7D4F;
  --warning:        #8A5A00;

  /* Way classes in the route editor's surface band. Spread across hue so the
     runs stay tellable apart in a strip only a few pixels tall; colour is
     never the only channel (each run is labelled in the legend). */
  --way-trail:      #C0703A;
  --way-track:      #D9A93C;
  --way-cycleway:   #4A7A5C;
  --way-road:       #6B7A72;
  --way-water:      #3A79A8;
  --way-other:      #A8B0A8;

  /* The Map tab's row/line link (#944): the tint and the ring a panel row
     takes while it — or its line on the map — is pointed at. Two pairs
     because there are two layers, and a row has to say WHICH line it lit.
     The values echo the layer colours the bridge paints with (the traces'
     #e05c1a, the routes' #1a6ee0) so a lit row and the line it lit read as
     one object; they are not derived from them, and must not be. Those are
     the map's own paint and are the same in either theme, while these sit on
     --surface and have to follow it — hence the lighter hues and the higher
     alphas below, without which the tint disappears into a dark panel. */
  --map-trace-tint: rgba(224, 92, 26, 0.12);
  --map-trace-edge: rgba(224, 92, 26, 0.5);
  --map-route-tint: rgba(26, 110, 224, 0.1);
  --map-route-edge: rgba(26, 110, 224, 0.55);

  /* A story read along its route (#2314): the current part's stretch, drawn
     over the activity's orange trace, and the chapter markers. The bridge
     reads --map-story-stretch as a literal colour (map_bridge.js
     setStoryRoute), so it is written out rather than var()'d: ink on the
     light map, and the dark theme's ink on its dark map. */
  --map-story-stretch: #12171A;
  --map-story-pin-size: 1.75rem;
  --map-story-pin-current-size: 2.25rem;

  /* The whole trip's elevation profile on an adventure's page (#2318). */
  --trip-profile-height: 10rem;

  /* Chrome (header + tab bar). Surface-coloured with a hairline border so
     the accent is reserved for actions and the current tab. */
  --header-bg:      var(--surface);
  --header-text:    var(--ink);

  /* Chrome heights (#2309). --chrome-top is the app bar, the same at every
     width. --chrome-bottom is the bottom tab bar a phone has under 768px,
     the safe area under it included; from 768px up the tabs sit in the app
     bar and it is 0. --chrome-h is the two together: what every full-height
     view (map, route editor, detail map pane) leaves room for, instead of
     hard-coded px. Anything pinned to the bottom of the window sits above
     --chrome-bottom. */
  --chrome-top:     61px;
  --tabbar-h:       57px;   /* the bottom bar above the safe area, hairline included */
  --chrome-bottom:  calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  --chrome-h:       calc(var(--chrome-top) + var(--chrome-bottom));

  /* Effects */
  --shadow-sm:      0 1px 4px rgba(18, 23, 26, 0.08);
  --shadow-md:      0 4px 16px rgba(18, 23, 26, 0.12);
  --shadow-lg:      0 12px 40px rgba(18, 23, 26, 0.35);   /* menus, popovers */

  /* Typography: families */
  --font-sans:    "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-prose:   "Source Serif 4", Georgia, "Times New Roman", serif;

  /* Typography: sizes (rem, so they follow the user's text size) */
  --fs-kicker:   0.75rem;                       /* 12px, uppercase label */
  --fs-small:    0.875rem;                      /* 14px, captions, meta */
  --fs-body:     1rem;                          /* 16px, interface text */
  --fs-lead:     1.0625rem;                     /* 17px, intro / aside text */
  --fs-prose:    1.25rem;                       /* 20px, story paragraphs */
  --fs-heading:  1.5rem;                        /* 24px, section heading in the app */
  --fs-quote:    1.625rem;                      /* 26px, pull quote */
  --fs-title:    2.25rem;                       /* 36px, chapter / page title */
  --fs-figure:   2.75rem;                       /* 44px, key figure */
  --fs-stat:     4.5rem;                        /* 72px, big stat */
  --fs-hero:     clamp(2.5rem, 6vw, 5.25rem);   /* 40-84px, story title */

  /* Typography: line heights, weights, tracking */
  --lh-hero:     0.98;
  --lh-heading:  1.1;
  --lh-snug:     1.4;
  --lh-body:     1.5;
  --lh-prose:    1.65;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --tracking-display: -0.02em;
  --tracking-hero:    -0.025em;
  --tracking-kicker:  0.09em;

  /* Spacing scale */
  --space-1: 0.25rem;   /*  4px */
  --space-2: 0.5rem;    /*  8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */

  /* Radius */
  --radius-sm:    6px;     /* photos, thumbnails, chips */
  --radius-md:    8px;     /* inputs, menu items */
  --radius-lg:    12px;    /* cards, sheets, maps */
  --radius-pill:  999px;   /* buttons, tags */
  --radius-round: 50%;     /* avatars */
}

/* Retired names. Components written before the Stories look still read these;
   they now resolve to the new tokens (and so follow the dark override
   automatically). New CSS uses the new names. */
:root {
  --bg:             var(--ground);
  --border:         var(--hairline);
  --border-strong:  var(--hairline-strong);
  --border-subtle:  var(--hairline-subtle);
  --text:           var(--ink);
  --text-muted:     var(--ink-muted);
  --text-subtle:    var(--ink-subtle);
  --brand:          var(--accent);
  --brand-hover:    var(--accent-hover);
  --brand-soft:     var(--accent-soft);
  --font-brand:     var(--font-display);
}

@media (min-width: 768px) {
  :root {
    --chrome-bottom: 0px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:         #0F1417;
    --surface:        #171E22;
    --surface-alt:    #1D262B;
    --surface-sunken: #12181B;

    --hairline:        #28343A;
    --hairline-strong: #3A4850;
    --hairline-subtle: #1D262B;
    --border-control:  #66757D;

    --ink:            #E9EEEC;
    --ink-body:       #D5DDDA;
    --ink-muted:      #A9B5B2;
    --ink-subtle:     #8896A0;

    --accent:         #FF8A57;
    --accent-hover:   #FFA377;
    --accent-soft:    rgba(255, 138, 87, 0.16);
    --on-accent:      #12171A;

    --band-bg:        #0A0F12;
    --on-dark:        #F5F6F3;
    --on-dark-muted:  #B9C4C1;
    --on-dark-border: #3E4C52;
    --on-dark-accent: #FFB38A;

    --danger:         #F0786E;
    --danger-hover:   #F59A92;
    --danger-soft:    rgba(240, 120, 110, 0.16);
    --success:        #6FCB92;
    --warning:        #E3B341;

    --way-trail:      #E0955F;
    --way-track:      #EBC46A;
    --way-cycleway:   #8BC9A0;
    --way-road:       #93A399;
    --way-water:      #6FAAD4;
    --way-other:      #7E887E;

    /* Lifted off the layer colours the way --way-trail and --way-water are,
       and carried at a higher alpha: #e05c1a at 12% over #18211b is not a
       highlight, it is a smudge. */
    --map-trace-tint: rgba(240, 138, 79, 0.18);
    --map-trace-edge: rgba(240, 138, 79, 0.6);
    --map-route-tint: rgba(106, 168, 245, 0.18);
    --map-route-edge: rgba(106, 168, 245, 0.6);
    --map-story-stretch: #E9EEEC;

    --shadow-sm:      0 1px 4px rgba(0, 0, 0, 0.4);
    --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg:      0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

/* The kicker: the small uppercase label above a title or under a figure. */
.kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-kicker);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */

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

body {
  font-family: var(--font-sans);
  background: var(--ground);
  color: var(--ink);
  min-height: 100vh;
}

/* Shared spinner keyframe used by photo upload and the Pending component. */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Inline SVG icons (activity types, sync, brand) ─────────────────────── */

.at-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  flex-shrink: 0;
}

.sync-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Build provenance line rendered on the auth and settings pages.
 * Users compare the displayed commit + WASM hash against published
 * release notes to verify the served build matches audited source.
 * See SECURITY.md and BUILD.md. */
.build-info {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: center;
  word-break: break-all;
}

.build-info code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.build-info a {
  color: var(--text-muted);
  text-decoration: underline;
}
