/* BlipTrail design tokens and shared components. No framework.

   Tokens are CSS custom properties ("variables"): --text, --accent, ...
   They are defined once here and used everywhere as var(--text). The
   point: a colour is decided in one place. The light theme (further down,
   :root[data-theme="light"]) only redefines the tokens; no component needs
   its own light-mode rules. The meaning of every token, and the rule never
   to introduce colours outside them, is in docs/design-system.md.

   :root is the <html> element: variables set there are visible on every
   element of the page. */
:root {
  --bg: #0a0d12;
  --bg-2: #10151d;
  --panel: rgba(14, 18, 25, 0.86);
  --panel-solid: #11161f;
  --raise: rgba(255, 255, 255, 0.045);
  --raise-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eef6;
  --muted: #8a95a8;
  --faint: #5b6577;
  --accent: #c6ff3d;        /* brand lime: fills (buttons, step numbers), with dark ink on top */
  --accent-ink: #10150a;
  --accent-hover: #d6ff6b;
  --accent-text: #c6ff3d;   /* accent for text, icons, thin lines, focus rings */
  --cyan: #38d6ff;
  --ok: #4dffb8;
  --warn: #ffb020;
  --danger: #ff5d5d;
  /* Map and content colours. MapLibre cannot read CSS variables, so
     static/js/live/map.js repeats --course, --accent, --cyan and --section as
     hex values: change them in both places. */
  --course: #8d9bb5;    /* the route line, elevation profile */
  --section: #ff9f1c;   /* mandatory sections */
  --blip: #ffd23f;      /* blips in the feed */
  --message: #ff8fc0;   /* supporter messages in the feed */
  --warn-ink: #ffd58a;  /* text inside a warning notice */
  --field: rgba(0, 0, 0, 0.28);
  --scrollbar: #2a3342;
  --bar: linear-gradient(90deg, #8fd61f, #c6ff3d);  /* progress bars */
  --halo: #000;         /* text halo for labels drawn on the map */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

/* Light theme: day, travel, warmth, readable in sunlight (ADR 0020).
   Not an inversion: a warm paper background instead of white glare, near-black
   warm text, and darker partners of every semantic colour so each still
   reaches WCAG AA. Fills (primary buttons, step numbers) use the same deep
   olive as the accent text ("Trail", "Live."), with white ink on top
   (5.3 : 1): bright lime looked glaring on the pale background (ADR 0022). */
:root[data-theme="light"] {
  --bg: #f3f1eb;
  --bg-2: #e9e6de;
  --panel: rgba(251, 250, 246, 0.9);
  --panel-solid: #fbfaf6;
  --raise: rgba(27, 32, 40, 0.045);
  --raise-2: rgba(27, 32, 40, 0.085);
  --line: rgba(27, 32, 40, 0.13);
  --text: #1b2028;
  --muted: #565f6d;
  --faint: #7c8491;
  --accent: #3d7a08;        /* fills: the accent text's olive, with white ink */
  --accent-ink: #ffffff;
  --accent-hover: #336a06;  /* a step darker on hover (white ink 6.6 : 1) */
  --accent-text: #3d7a08;
  --cyan: #0a7799;
  --ok: #0a7650;
  --warn: #a65300;
  --danger: #c22a2a;
  --course: #6a7385;
  --section: #c25f00;
  --blip: #946000;
  --message: #b02f69;
  --warn-ink: #8a4505;
  --field: #ffffff;
  --scrollbar: #c9c5bb;
  --bar: linear-gradient(90deg, #5a9e12, #3d7a08);
  --halo: #fbfaf6;
  --shadow: 0 14px 40px rgba(60, 50, 30, 0.16), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
[hidden] { display: none !important; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em; font-size: 17px; text-decoration: none; }
.brand b { color: var(--accent-text); font-weight: 700; }
/* The mark: earlier blips, the ring and the current blip, all in the accent
   (one colour, like "Trail"). */
.brand-mark { width: 31px; height: 28px; flex: none; color: var(--accent-text); overflow: visible; }
.brand-past, .brand-dot { fill: currentColor; }
.brand-ring { fill: none; stroke: currentColor; stroke-width: 1.7; opacity: 0.4; }

/* Pills and badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--raise-2); color: var(--muted); white-space: nowrap;
}
.pill--live { background: color-mix(in srgb, var(--accent-text) 14%, transparent); color: var(--accent-text); }
.pill--live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.pill--sim { background: color-mix(in srgb, var(--cyan) 13%, transparent); color: var(--cyan); }
.pill--warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.pill--danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
@keyframes blink { 50% { opacity: 0.25; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--raise); font-weight: 600; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s; white-space: nowrap;
}
.btn:hover { background: var(--raise-2); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--danger { color: var(--danger); }
.btn--sm { height: 30px; padding: 0 11px; border-radius: 9px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--raise-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-on { color: var(--accent-text); }

/* Form fields */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--field);
}
.textarea { min-height: 76px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent-text) 60%, transparent); }

.card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); }
.notice { padding: 11px 13px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.notice--warn { border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn-ink); background: color-mix(in srgb, var(--warn) 7%, transparent); }

/* Toasts */
.toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 12px 14px; border-radius: 14px; background: var(--panel-solid);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start;
}
.toast b { display: block; }
.toast--warning { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.toast--error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

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

/* Theme switch: Auto · Light · Dark (static/js/theme.js) */
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--raise); border: 1px solid var(--line); }
.theme-switch button { width: 28px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-checked="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.theme-switch svg { width: 15px; height: 15px; }
