/* ============================================================================
   frankie.css — shared design system for "Where's Frankie?"  (plan §4b)
   v2 "Night Prowl" (owner-approved 2026-11-15): dark, glassy, warm amber glow.
   Lead-owned. Pages use ONLY these tokens/components. Fonts are self-hosted
   (I9 — no outside host). Token NAMES are kept from v1 so every page keeps
   working; their VALUES are the Night Prowl palette.
   Contrast (WCAG) measured on --bg #0B0E13 unless noted.
   ============================================================================ */

/* ---- Self-hosted font (public/vendor/fonts/, fontsource 5.2.8, OFL-1.1) ---- */
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("./fonts/plus-jakarta-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("./fonts/plus-jakarta-sans-500.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("./fonts/plus-jakarta-sans-600.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("./fonts/plus-jakarta-sans-700.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("./fonts/plus-jakarta-sans-800.woff2") format("woff2"); }

/* ---- Tokens ---- */
:root {
  color-scheme: dark;

  --bg: #0B0E13;            /* page */
  --bg-2: #11151C;          /* slightly lifted page areas */
  --surface: #161B23;       /* solid cards, popups, sheets */
  --raised: #1C222C;        /* selected segment, hover */
  --glass: rgba(255,255,255,0.06);       /* frosted fill on --bg */
  --glass-strong: rgba(20,24,31,0.86);   /* floating panels over the map */
  --line: rgba(255,255,255,0.10);        /* hairline edges (decorative) */
  --line-strong: rgba(255,255,255,0.28); /* input edges (must be SEEN: 3:1+) */
  --border: var(--line);    /* v1 name, kept */

  --ink: #F4F4F5;           /* body text — 17.6:1 */
  --ink-soft: #A1A1AA;      /* secondary text — 7.6:1 */
  --ink-faint: #8B8B94;     /* tertiary text, still AA — 5.6:1 */
  --heading: #F4F4F5;

  --primary: #FFB547;       /* amber: main button fill, pins, focus — 11.3:1 as text */
  --on-primary: #1A1206;    /* text ON amber — 11:1 */
  --primary-deep: #FFB547;  /* v1 name: amber AS text/links/outlines */
  --primary-wash: rgba(255,181,71,0.12);
  --primary-line: rgba(255,181,71,0.40);

  --accent: #7DD3FC;        /* sky: tracker point */
  --on-accent: #082F49;
  --ok: #4ADE80;            /* live / done — 11:1 */
  --on-ok: #052E16;
  --ok-wash: rgba(74,222,128,0.12);
  --danger: #F87171;        /* errors, delete — 6.9:1 */
  --on-danger: #2A0808;
  --danger-wash: rgba(248,113,113,0.12);
  --danger-line: rgba(248,113,113,0.40);

  /* Type */
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 0.8125rem; /* 13 */
  --fs-sm: 0.875rem;  /* 14 */
  --fs-base: 1rem;    /* 16 — body minimum */
  --fs-md: 1.0625rem; /* 17 */
  --fs-lg: 1.375rem;  /* 22 */
  --fs-xl: 2.25rem;   /* 36 */
  --lh: 1.5;
  --track-tight: -0.035em;

  /* Shape & spacing (steps of 4 and 8) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 12px;
  --radius: 14px;
  --radius-card: 20px;
  --radius-sheet: 26px;
  --radius-pill: 999px;

  /* One elevation scale + the single amber glow (main button only) */
  --shadow-rest: 0 0 0 1px var(--line), 0 12px 28px -18px rgba(0,0,0,0.7);
  --shadow-raised: 0 0 0 1px var(--line), 0 24px 48px -20px rgba(0,0,0,0.75);
  --shadow-pressed: inset 0 2px 6px rgba(0,0,0,0.35);
  --glow: 0 10px 30px -10px rgba(255,181,71,0.55);

  --press-time: 160ms;
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --tap-min: 44px;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { font-family: var(--font-head); color: var(--heading); line-height: 1.1;
  letter-spacing: var(--track-tight); font-weight: 800; margin: 0 0 var(--space-3); text-wrap: balance; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--space-3); }
a { color: var(--primary-deep); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }

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

/* ---- Cards ---- */
.fh-card {
  background: var(--glass);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: var(--space-4);
}
.fh-card--raised { background: var(--surface); box-shadow: var(--shadow-raised); }

/* ---- Buttons ---- */
.fh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 52px; padding: 0 var(--space-5);
  font-family: var(--font-body); font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em;
  border: 0; border-radius: var(--radius); cursor: pointer; text-decoration: none;
  background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--press-time) var(--ease-out), background-color var(--press-time) ease,
              box-shadow var(--press-time) ease, opacity var(--press-time) ease;
}
.fh-btn:active:not([disabled]) { transform: scale(0.98); }
.fh-btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--glow); }
.fh-btn--primary:hover { background: #FFC266; }
.fh-btn--accent  { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.fh-btn--ok      { background: var(--ok); color: var(--on-ok); box-shadow: none; }
.fh-btn--danger  { background: var(--danger-wash); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-line); }
.fh-btn--quiet   { background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.fh-btn--quiet:hover { background: rgba(255,255,255,0.09); }
.fh-btn--sm      { min-height: var(--tap-min); font-size: var(--fs-sm); padding: 0 var(--space-4); border-radius: var(--radius-sm); }
.fh-btn--block   { display: flex; width: 100%; }
.fh-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Inputs ---- */
.fh-label { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--space-2); color: var(--ink); }
.fh-label__hint { font-weight: 500; color: var(--ink-soft); }
.fh-input, .fh-textarea {
  width: 100%; min-height: 48px; padding: var(--space-3) var(--space-4);
  font: inherit; font-size: var(--fs-base); color: var(--ink);
  background: rgba(255,255,255,0.04);
  border: 0; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: box-shadow var(--press-time) ease;
}
.fh-input::placeholder, .fh-textarea::placeholder { color: var(--ink-faint); opacity: 1; }
.fh-input:focus, .fh-textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.fh-textarea { min-height: 96px; resize: vertical; }
.fh-help { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: var(--space-1); }
.fh-error { font-size: var(--fs-sm); color: var(--danger); margin-top: var(--space-1); }

/* ---- Callouts: icon + words, never colour alone ---- */
.fh-callout {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-sm); color: var(--ink);
}
.fh-callout > .fh-icon { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.fh-callout--warn { background: var(--primary-wash); box-shadow: inset 0 0 0 1px var(--primary-line); }
.fh-callout--warn > .fh-icon { color: var(--primary); }
.fh-callout--error { background: var(--danger-wash); box-shadow: inset 0 0 0 1px var(--danger-line); }
.fh-callout--error > .fh-icon { color: var(--danger); }
.fh-callout--ok { background: var(--ok-wash); box-shadow: inset 0 0 0 1px rgba(74,222,128,0.35); }
.fh-callout--ok > .fh-icon { color: var(--ok); }

/* ---- Badges / pills (always carry text) ---- */
.fh-badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 4px var(--space-3); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700;
  background: rgba(0,0,0,0.45); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.fh-badge--home { background: var(--ink); color: var(--bg); }
.fh-badge--far  { background: var(--glass-strong); color: var(--ink); }
.fh-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(74,222,128,0.25); flex: none; }

/* ---- Brand mark ---- */
.fh-mark {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: var(--primary); color: var(--on-primary);
  display: inline-grid; place-items: center;
}
.fh-mark .fh-icon { width: 18px; height: 18px; }

/* ---- Icons (Lucide, currentColor via mask so they follow text colour) ---- */
.fh-icon { width: 24px; height: 24px; display: inline-block; vertical-align: middle; flex: none; }
span.fh-icon, i.fh-icon {
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
.i-paw     { --icon: url("/vendor/icons/paw-print.svg"); }
.i-locate  { --icon: url("/vendor/icons/locate-fixed.svg"); }
.i-map     { --icon: url("/vendor/icons/map.svg"); }
.i-pin     { --icon: url("/vendor/icons/map-pin.svg"); }
.i-camera  { --icon: url("/vendor/icons/camera.svg"); }
.i-pencil  { --icon: url("/vendor/icons/pencil.svg"); }
.i-house   { --icon: url("/vendor/icons/house.svg"); }
.i-send    { --icon: url("/vendor/icons/send.svg"); }
.i-check   { --icon: url("/vendor/icons/check.svg"); }
.i-x       { --icon: url("/vendor/icons/x.svg"); }
.i-alert   { --icon: url("/vendor/icons/circle-alert.svg"); }
.i-wifi-off{ --icon: url("/vendor/icons/wifi-off.svg"); }
.i-loader  { --icon: url("/vendor/icons/loader-circle.svg"); }
.i-refresh { --icon: url("/vendor/icons/refresh-cw.svg"); }
.i-trash   { --icon: url("/vendor/icons/trash-2.svg"); }
.i-eye     { --icon: url("/vendor/icons/eye.svg"); }
.i-eye-off { --icon: url("/vendor/icons/eye-off.svg"); }
.i-lock    { --icon: url("/vendor/icons/lock.svg"); }
.i-upload  { --icon: url("/vendor/icons/upload.svg"); }
.i-back    { --icon: url("/vendor/icons/chevron-left.svg"); }
.i-up      { --icon: url("/vendor/icons/chevron-up.svg"); }
.i-image   { --icon: url("/vendor/icons/image.svg"); }
.i-undo    { --icon: url("/vendor/icons/arrow-left.svg"); }
.i-info    { --icon: url("/vendor/icons/info.svg"); }
.i-video   { --icon: url("/vendor/icons/video.svg"); }
.i-play    { --icon: url("/vendor/icons/play.svg"); }
/* <img> icons (black strokes) are inverted to read on dark */
img.fh-icon { filter: invert(1); }

.fh-spin { animation: fh-rotate 900ms linear infinite; }
@keyframes fh-rotate { to { transform: rotate(360deg); } }

.fh-muted { color: var(--ink-soft); }
.fh-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;
}
.fh-skip {
  position: absolute; left: var(--space-3); top: -80px; z-index: 2000;
  min-height: var(--tap-min); display: inline-flex; align-items: center;
  padding: 0 var(--space-4); border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary); font-weight: 700; text-decoration: none;
}
.fh-skip:focus { top: var(--space-3); }

/* ---- Leaflet, dark: same OpenStreetMap tiles, tinted in CSS only ---- */
.leaflet-container { background: #10141A; font-family: var(--font-body); }
.fh-darkmap .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.88) saturate(0.55); }
.leaflet-touch .leaflet-bar, .leaflet-bar { border: 0; border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-rest); }
.leaflet-container.leaflet-touch .leaflet-bar a, .leaflet-container .leaflet-bar a {
  width: 44px; height: 44px; line-height: 44px; font-size: 22px;
  background: var(--glass-strong); color: var(--ink); border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.leaflet-bar a:hover { background: var(--raised); color: var(--ink); }
.leaflet-container .leaflet-control-attribution {
  background: rgba(11,14,19,0.75); color: var(--ink-soft);
  font-size: 11px; padding: 0 var(--space-2); border-radius: 6px 0 0 0;
}
.leaflet-container .leaflet-control-attribution a { color: var(--ink); }
/* Attribution links stay visible (OSM policy) AND meet the 44px tap minimum. */
.leaflet-container .leaflet-control-attribution a { display: inline-flex; align-items: center; min-height: var(--tap-min); vertical-align: middle; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-raised);
}
.leaflet-popup-content-wrapper { border-radius: var(--radius-card); }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-soft); width: 44px; height: 44px; font-size: 22px; line-height: 44px; }

/* ---- Admin: same tokens, a little calmer ---- */
.fh-admin .fh-btn--primary { box-shadow: none; }

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

/* ---- Red-case hook for gate:a11y (forces a contrast failure; never use in real pages) ---- */
.fh-a11y-redcase { color: #2A2F38 !important; }
