/* tūhura — app shell styles.
 *
 * Mobile-first (390 px baseline, DESIGN.md), zero build step: plain CSS,
 * custom properties for the two themes, no preprocessor. Every colour
 * pair below is chosen against a computed WCAG contrast ratio, not by
 * eye — the numbers are in docs/ARCHITECTURE.md's lockstep section and
 * in the session record, so a future palette edit has something to beat.
 */

:root {
  color-scheme: light dark;

  /* Light theme (the default; overridden below for dark). Warm paper,
   * not stark white — DESIGN.md's "calm, high-contrast, map-dominant". */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #16211d;             /* 15.18:1 on --bg */
  --muted: #435049;            /* 7.76:1 on --bg */
  --border: #8c8570;           /* ~2.9:1 on --bg — decorative only */
  --accent: #0b6e57;           /* 5.70:1 on --bg as text/links */
  --accent-on: #ffffff;        /* 6.21:1 on --accent as a button fill */
  --focus: #c94a00;            /* 4.32:1 on --bg — exceeds the 3:1 SC 1.4.11 floor */
}

/* True dark, not a washed grey (CLAUDE.md: "night vision at a campsite
 * is a feature"). Two triggers so a browser without OS-preference
 * support still gets it from an in-app toggle later (`data-theme`) —
 * none exists yet at the shell stage, so only the media query applies
 * today; the attribute selector is here so adding the toggle is a
 * one-line JS change, not a CSS rewrite. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #06090a;
    --surface: #10181b;
    --text: #edf1ef;           /* 17.53:1 on --bg */
    --muted: #a6b3ae;          /* 9.21:1 on --bg */
    --border: #2a3a37;         /* decorative only */
    --accent: #2bd9ab;         /* 11.05:1 on --bg as text/links */
    --accent-on: #04211a;      /* 9.39:1 on --accent as a button fill —
                                 * white-on-accent is only 1.81:1 here, so
                                 * the button text flips dark, not the
                                 * button fill (a bright accent has to
                                 * stay bright to still read as "accent"). */
    --focus: #ff8a3d;          /* 8.52:1 on --bg */
  }
}
:root[data-theme="dark"] {
  --bg: #06090a;
  --surface: #10181b;
  --text: #edf1ef;
  --muted: #a6b3ae;
  --border: #2a3a37;
  --accent: #2bd9ab;
  --accent-on: #04211a;
  --focus: #ff8a3d;
}

* {
  box-sizing: border-box;
}

html {
  /* 100dvh (used below) needs the dynamic viewport unit, not a fallback
   * chain here — every browser current enough to run the vendored map
   * stack (WebGL2) also has dvh. */
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  /* Field use means gloves, glare and one hand — a slightly larger base
   * size than a desktop default reads better at arm's length. */
  font-size: 1.0625rem;
}

/* One-line utility, not a class per hidden label — matches Faves'
 * `sr-only` convention so a shared visual vocabulary carries over. */
.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;
}

/* Skip link: visually hidden until focused, first focusable element in
 * the document (WCAG 2.4.1 Bypass Blocks) — the map viewport is the
 * only thing between the header and the rest of the shell today, but
 * the chrome grows and this stays correct as it does. */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 0.25rem;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0.5rem;
}

/* Visible focus everywhere, never removed (WCAG 2.4.7 / 2.2's 2.4.11) —
 * :focus-visible so a mouse click doesn't draw a ring a keyboard/switch
 * user didn't ask to see, but every keyboard focus gets one. */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: env(safe-area-inset-top, 0) 1rem 0.75rem;
  padding-top: calc(env(safe-area-inset-top, 0) + 0.75rem);
  border-bottom: 1px solid var(--border);
}

.app-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-tagline {
  margin: 0.125rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* The map viewport region. Empty today (P0-C/P0-D bring the render) —
 * this is the one screen where the placeholder text has to be honest
 * about that rather than implying a map is already here (CLAUDE.md:
 * "never present stale or uncertain data as authoritative"). */
.map-viewport {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  text-align: center;
  background:
    repeating-linear-gradient(
      45deg,
      color-mix(in srgb, var(--border) 35%, transparent),
      color-mix(in srgb, var(--border) 35%, transparent) 1px,
      transparent 1px,
      transparent 12px
    );
}

.map-placeholder {
  max-width: 26rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.map-placeholder h2 {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
}

.map-placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.app-footer {
  padding: 0.75rem 1rem calc(env(safe-area-inset-bottom, 0) + 0.75rem);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.app-footer a {
  color: inherit;
}

/* Every interactive target ≥ 44 px (DESIGN.md, CLAUDE.md) — the button
 * base class every control in the shell uses, so the floor is set once
 * rather than re-typed per component. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-on);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn-quiet {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

/* The service-worker update banner (ADR 2026-08-08-0452 carries Faves'
 * split-versioning pattern over; sw-register.js/update-notice.js wire
 * this). Off-screen and inert until a worker is actually waiting — a
 * banner that can appear with nothing behind it is a lie the UI tells. */
.update-notice {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(env(safe-area-inset-bottom, 0) + 0.75rem);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 0.25rem 1rem color-mix(in srgb, var(--bg) 60%, black 40%);
}

.update-notice p {
  margin: 0;
  font-size: 0.9375rem;
}

@media (min-width: 34rem) {
  .app-header {
    padding-inline: 1.5rem;
  }
  .update-notice {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    max-width: 22rem;
  }
}

/* prefers-reduced-motion: the only motion in the shell today is the
 * skip-link slide and the update banner's entrance (added in JS via a
 * class) — both collapse to an instant show rather than being removed
 * outright, so the *state change* is still perceivable. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
