/* WhatsNear - Citrus Cartography.
 *
 * A printed street map reprinted with fluorescent inks: warm press paper,
 * deep navy ink, saturated mandarin / lime / teal / amber. Full rationale
 * and named rules: DESIGN.md.
 *
 * Graduated from mockups/d.css + mockups/theme-citrus.css once the direction
 * was approved (3 Sep 2026). Riso Pop, the direction not picked, stays in
 * mockups/ undocumented rather than living on here as a dead theme switch.
 *
 * The --map-* tokens are read at runtime by js/map.js and mapped onto the
 * Protomaps flavor, so the basemap and the UI are literally the same
 * palette - the reason Protomaps was chosen over CARTO. If you add a map
 * colour here, wire it into mapFlavorFromCss() in js/map.js too. */

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--c-ink);
  background: var(--c-paper-deep);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------- tokens */
:root {
  color-scheme: light;

  /* --- surfaces --- */
  --c-paper:        #F7F0E1;   /* dominant surface, matches --map-earth */
  --c-paper-deep:   #EDE4D2;
  --c-panel:        #FFFFFF;
  --c-panel-sunk:   #FAF6EC;
  --c-hairline:     #E0D4BA;
  --c-hairline-soft:#EDE4D2;

  /* --- ink --- */
  --c-ink:          #1A2238;
  --c-ink-mid:      #55524A;
  --c-ink-soft:     #7A6E58;
  --c-ink-faint:    #A79A82;

  /* --- accents. Each is paired with an icon shape and a text label in the
         UI, never used as the only channel. One hue, one job: never reuse
         an accent for a second category or purpose. --- */
  --c-mandarin:     #F4700A;   /* origin, primary action, on-foot */
  --c-lime:         #6DA300;   /* grocery */
  --c-teal:         #0B7285;   /* transit, driving */
  --c-amber:        #E09000;   /* pharmacy */
  --c-plum:         #8B4A9C;   /* gyms */
  --c-red:          #D93636;   /* unwalkable, empty */

  --c-mandarin-wash: #FDE9D5;
  --c-lime-wash:     #E8F0D2;
  --c-teal-wash:     #D9EBEF;
  --c-amber-wash:    #FBEDCF;
  --c-plum-wash:     #EFE2F2;
  --c-red-wash:      #FADEDE;

  /* --- brand marks. Recognisable brand hues, pulled toward the palette so
         they sit inside the design rather than fighting it. --- */
  --c-brand-woolworths: #2E7D32;
  --c-brand-coles:      #D93636;
  --c-brand-aldi:       #1B4F8F;
  --c-brand-aldi-arc:   #F4A300;
  --c-brand-chemist:    #E0A500;
  --c-brand-other:      #A79A82;

  /* --- focus --- */
  --c-focus:        #0B7285;

  /* --- shadows. Hard offset, no blur - a press-sheet look, not a soft UI. */
  --shadow-card:  2px 2px 0 var(--c-ink);
  --shadow-float: 3px 3px 0 var(--c-ink);

  /* --- basemap. Key names mirror the Protomaps flavor keys. --- */
  --map-earth:        #F7F0E1;
  --map-background:   #EDE4D2;
  --map-water:        #8FCEDB;
  --map-park-pale:    #DCE7BE;
  --map-park-deep:    #B4CE84;
  --map-built:        #EBE0CB;
  --map-road:         #FFFFFF;
  --map-road-minor:   #FCF8EF;
  --map-casing:       #E6DBC2;
  --map-casing-minor: #EFE6D2;
  --map-railway:      #C9BCA0;
  --map-label-road:   #7A6E58;
  --map-label-place:  #1A2238;
  --map-label-faint:  #C2B49A;
  --map-halo:         #F7F0E1;
  --map-boundary:     #D6C9AE;
  --map-neutral-warm: #EFE6D4;   /* industrial / hospital / school / military */

  --map-lc-grassland: #DCE7BE;
  --map-lc-forest:    #C9DDA4;
  --map-lc-farmland:  #E8EFCB;
  --map-lc-scrub:     #E2E8C4;
  --map-lc-barren:    #F2E9D2;
  --map-lc-urban:     #F2EADA;

  /* --- type --- */
  --font-ui:   'Bricolage Grotesque', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
  --ui-weight-display: 700;
  --ui-tracking-display: -0.02em;
  --label-transform: uppercase;
  --label-tracking: 0.08em;

  /* radius scale - one scale, documented, used everywhere */
  --r-pill: 999px;
  --r-card: 14px;
  --r-tile: 12px;
  --r-sm: 8px;
  --r-xs: 5px;

  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 28px;

  /* type scale */
  --t-meta: 11px;
  --t-label: 11px;
  --t-body: 13px;
  --t-name: 14px;
  --t-section: 12px;
  --t-time: 19px;
  --t-display: 17px;

  /* The rail clears the floating search bar. Both read these rather than a
     hardcoded top offset. */
  --bar-h: 52px;
  --bar-gap: 14px;
  --rail-w: 348px;
  --edge: 16px;
}

/* ---------------------------------------------------------------- map */
#map {
  position: fixed; inset: 0; z-index: 0;
  background: var(--map-background);
  cursor: crosshair;
}
.leaflet-control-zoom { margin: var(--edge) 0 0 var(--edge) !important; }
.leaflet-control-zoom a {
  background: var(--c-panel) !important;
  color: var(--c-ink) !important;
  border-color: var(--c-hairline) !important;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--c-panel) 88%, transparent) !important;
  font-family: var(--font-mono) !important;
  font-size: 9px !important;
  color: var(--c-ink-soft) !important;
}
.leaflet-control-attribution a { color: var(--c-teal) !important; }

/* Strips Leaflet's own tooltip chrome so .callout is the only visible
   thing - a vendor override, not part of the design system's own shapes. */
.leaflet-tooltip.wn-tip {
  background: none; border: 0; box-shadow: none; padding: 0;
  white-space: nowrap;
}
.leaflet-tooltip.wn-tip::before { display: none; }

/* --------------------------------------------------------- search bar */
.bar {
  position: fixed; z-index: 600;
  top: var(--bar-gap); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s2);
  height: var(--bar-h);
  padding: 0 var(--s2) 0 var(--s4);
  width: min(560px, calc(100vw - 2 * var(--edge)));
  background: var(--c-panel);
  border: 1.5px solid var(--c-ink);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-float);
}
.bar .wordmark {
  font-weight: var(--ui-weight-display);
  letter-spacing: var(--ui-tracking-display);
  font-size: var(--t-display);
  white-space: nowrap;
}
.bar .wordmark i { color: var(--c-mandarin); font-style: normal; }
.bar .rule { width: 1.5px; height: 22px; background: var(--c-hairline); flex: none; }
.bar input {
  flex: 1; min-width: 0;
  font: inherit; font-size: var(--t-body);
  border: 0; outline: 0; background: transparent; color: var(--c-ink);
}
.bar input::placeholder { color: var(--c-ink-faint); }
.bar:focus-within { box-shadow: var(--shadow-float), 0 0 0 3px var(--c-teal-wash); }
.bar .go {
  flex: none; cursor: pointer;
  height: 36px; padding: 0 var(--s4);
  border: 1.5px solid var(--c-ink); border-radius: var(--r-pill);
  background: var(--c-mandarin); color: var(--c-panel);
  font-size: var(--t-label); font-weight: 700;
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
}
.bar .go:hover { background: var(--c-ink); }
.bar .go:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: 2px; }

.tagline {
  position: fixed; z-index: 600;
  top: calc(var(--bar-gap) + var(--bar-h) + var(--s2));
  left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--t-meta);
  color: var(--c-ink-soft);
  background: var(--c-paper);
  border: 1px solid var(--c-hairline);
  padding: 3px var(--s3); border-radius: var(--r-pill);
  white-space: nowrap; pointer-events: none;
}

/* Says why a search did nothing, so a failed lookup doesn't read as a dead
   button. */
.search-note {
  position: fixed; z-index: 620;
  top: calc(var(--bar-gap) + var(--bar-h) + var(--s1));
  left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100vw - 2 * var(--edge)));
  margin: 0; padding: var(--s2) var(--s4);
  background: var(--c-panel);
  border: 1.5px solid var(--c-red); border-radius: var(--r-card);
  box-shadow: var(--shadow-float);
  font-size: var(--t-body); line-height: 1.35;
}
.search-note[hidden] { display: none; }

/* ------------------------------------------------------ autocomplete */
.suggest {
  position: fixed; z-index: 620;
  top: calc(var(--bar-gap) + var(--bar-h) + var(--s1));
  left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100vw - 2 * var(--edge)));
  background: var(--c-panel);
  border: 1.5px solid var(--c-ink); border-radius: var(--r-card);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.suggest[hidden] { display: none; }
.suggest button {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: var(--s2) var(--s4);
  border: 0; border-bottom: 1px solid var(--c-hairline-soft);
  background: var(--c-panel);
}
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover,
.suggest button[aria-selected="true"] { background: var(--c-mandarin-wash); }
.suggest button:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: -2px; }
/* Two lines, matching what Autocomplete (New) actually returns:
   structuredFormat.mainText bold, secondaryText below in mono. These are
   spans inside a button, so without display:block they render on one line. */
.suggest .main { display: block; font-size: var(--t-body); font-weight: 600; }
.suggest .sub {
  display: block;
  font-family: var(--font-mono); font-size: var(--t-meta);
  color: var(--c-ink-soft); margin-top: 1px;
}

/* ---------------------------------------------------------------- rail */
.rail {
  position: fixed; z-index: 600;
  top: calc(var(--bar-gap) + var(--bar-h) + var(--s6));
  right: var(--edge); bottom: var(--edge);
  width: var(--rail-w); max-width: calc(100vw - 2 * var(--edge));
  display: flex; flex-direction: column;
  background: var(--c-panel);
  border: 1.5px solid var(--c-ink); border-radius: var(--r-card);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.rail .head {
  padding: var(--s3) var(--s4);
  border-bottom: 1.5px solid var(--c-ink);
  background: var(--c-paper);
  flex: none;
}
.rail .head .where {
  font-weight: var(--ui-weight-display);
  letter-spacing: var(--ui-tracking-display);
  font-size: var(--t-display); line-height: 1.15;
}
.rail .head .meta {
  font-family: var(--font-mono); font-size: var(--t-meta);
  color: var(--c-ink-soft); margin-top: 2px;
}
.rail .scroll {
  overflow-y: auto; overscroll-behavior: contain; flex: 1;
  scrollbar-color: var(--c-hairline) var(--c-panel-sunk);
}
.rail .scroll::-webkit-scrollbar { width: 8px; }
.rail .scroll::-webkit-scrollbar-track { background: var(--c-panel-sunk); }
.rail .scroll::-webkit-scrollbar-thumb { background: var(--c-hairline); border-radius: var(--r-pill); }
.rail .scroll::-webkit-scrollbar-thumb:hover { background: var(--c-ink-faint); }

.block { padding: var(--s4); border-bottom: 1px solid var(--c-hairline-soft); }
.block:last-child { border-bottom: 0; }
.block > .legend {
  font-family: var(--font-mono); font-size: var(--t-label);
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
  color: var(--c-ink-soft); margin-bottom: var(--s2);
}

/* --------------------------------------------------- selection tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.tile {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3) var(--s2) var(--s2);
  cursor: pointer; text-align: left;
  background: var(--c-panel-sunk);
  border: 1.5px solid var(--c-hairline);
  border-radius: var(--r-tile);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.tile .ico { flex: none; width: 20px; height: 20px; display: block; }
.tile .txt { font-size: var(--t-body); font-weight: 600; line-height: 1.2; }
.tile:hover { border-color: var(--c-ink); }
.tile[aria-pressed="true"] {
  background: var(--tile-wash);
  border-color: var(--c-ink);
  box-shadow: var(--shadow-card);
}
.tile:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: 2px; }

/* Subcategory tiles - smaller, indented under their parent. */
.subs {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s1);
  margin: var(--s2) 0 var(--s1) var(--s3);
  padding-left: var(--s3);
  border-left: 1.5px dashed var(--c-hairline);
}
.subs[hidden] { display: none; }
.subs .subs-label {
  grid-column: 1 / -1; margin: 0 0 2px;
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px;
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
  color: var(--c-ink-soft);
}
.subs .subs-label .ico { width: 13px; height: 13px; }
.sub-tile {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px var(--s2);
  background: var(--c-panel);
  border: 1.5px solid var(--c-hairline);
  border-radius: var(--r-pill);
  font-size: var(--t-meta); font-weight: 600;
  text-align: left;
}
.sub-tile .mark { flex: none; width: 15px; height: 15px; }
.sub-tile:hover { border-color: var(--c-ink); }
.sub-tile[aria-pressed="true"] { border-color: var(--c-ink); background: var(--c-paper); }
.sub-tile[aria-pressed="false"] { opacity: .45; }
.sub-tile:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: 2px; }

/* -------------------------------------------------------- mode toggles */
.modes { display: flex; gap: var(--s2); }
.mode {
  flex: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: var(--s2);
  background: var(--c-panel-sunk);
  border: 1.5px solid var(--c-hairline);
  border-radius: var(--r-pill);
  font-size: var(--t-body); font-weight: 600;
}
.mode .ico { width: 17px; height: 17px; flex: none; }
.mode:hover { border-color: var(--c-ink); }
.mode[aria-pressed="true"] {
  border-color: var(--c-ink); box-shadow: var(--shadow-card);
  background: var(--mode-wash);
}
/* The last active mode cannot be turned off - there is no zero-mode state -
   so it reads as locked rather than looking broken when it will not respond. */
.mode[data-locked="true"] { cursor: default; }
.mode:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: 2px; }

/* ------------------------------------------------------------ results */
.group { border-bottom: 1px solid var(--c-hairline-soft); }
.group:last-child { border-bottom: 0; }
.group > .gh {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4) var(--s2);
}
.group > .gh .ico { width: 17px; height: 17px; flex: none; }
.group > .gh .name {
  font-family: var(--font-mono); font-size: var(--t-section);
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
  font-weight: 500;
}
.group > .gh .hr { flex: 1; height: 1.5px; background: var(--c-hairline); }

.row {
  display: grid; grid-template-columns: 20px 1fr auto;
  gap: var(--s2); align-items: start;
  width: 100%; text-align: left; cursor: pointer;
  padding: var(--s2) var(--s4);
  background: transparent; border: 0;
  border-left: 3px solid transparent;
}
.row:hover { background: var(--c-panel-sunk); }
.row[aria-current="true"] {
  background: var(--c-paper);
  border-left-color: var(--c-mandarin);
}
.row:focus-visible { outline: 2.5px solid var(--c-focus); outline-offset: -2px; }
.row .mark { width: 20px; height: 20px; margin-top: 1px; }
/* These are spans, so they are inline by default and the name, distance and
 * quip would run together on one line without this. */
.row .who { min-width: 0; }
.row .who > * { display: block; }
.row .who .n {
  font-size: var(--t-name); font-weight: 600; line-height: 1.25;
  /* Real names are long and messy: "Chemist Warehouse Swan Street Richmond".
     Wrap, never ellipsise - ellipsis makes real place names unreadable. */
  overflow-wrap: anywhere;
}
.row .who .d {
  font-family: var(--font-mono); font-size: var(--t-meta);
  color: var(--c-ink-soft); margin-top: 1px;
}
.row .times { text-align: right; }
.row .t { display: flex; align-items: baseline; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.row .t + .t { margin-top: 1px; }
.row .t .v {
  font-family: var(--font-mono); font-size: var(--t-time);
  font-weight: 500; line-height: 1.1; letter-spacing: -0.02em;
  white-space: nowrap;
}
.row .t .u {
  font-family: var(--font-mono); font-size: 9px;
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
  color: var(--c-ink-soft);
}
.row .t[data-mode="walking"] .v { color: var(--c-mandarin); }
.row .t[data-mode="driving"] .v { color: var(--c-teal); }
/* Over the threshold the real time is still shown, greyed - never hidden. */
.row .t[data-far="true"] .v { color: var(--c-ink-faint); }
.row .t[data-none="true"] .v { color: var(--c-ink-faint); font-size: var(--t-body); }

.quip {
  font-family: var(--font-mono); font-size: var(--t-meta);
  color: var(--c-red); margin-top: 2px;
}
.quip[data-tone="soft"] { color: var(--c-ink-soft); }

.empty {
  margin: 0 var(--s4) var(--s3);
  padding: var(--s3);
  background: var(--c-paper);
  border: 1.5px dashed var(--c-hairline);
  border-radius: var(--r-sm);
  font-size: var(--t-body); line-height: 1.35;
}
.empty b { display: block; font-weight: 700; margin-bottom: 1px; }
.empty span { font-family: var(--font-mono); font-size: var(--t-meta); color: var(--c-ink-soft); }

.nothing {
  padding: var(--s6) var(--s4); text-align: center;
  font-size: var(--t-body); color: var(--c-ink-soft); line-height: 1.4;
}

/* In-flight state. A lookup is several network round trips, so the wait has
   to look like work rather than like a stuck panel - that misreading was the
   whole "it freezes" bug report. Keeps the press-sheet language: a hard
   travelling rule, no soft spinner glow. */
.pending {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4);
  font-family: var(--font-mono); font-size: var(--t-meta);
  text-transform: var(--label-transform); letter-spacing: var(--label-tracking);
  color: var(--c-ink-soft);
}
.pending-bar {
  flex: none; position: relative; overflow: hidden;
  width: 34px; height: 3px;
  background: var(--c-hairline);
}
.pending-bar::after {
  content: ''; position: absolute; inset: 0;
  background: var(--c-mandarin);
  animation: wn-sweep 1s linear infinite;
}
@keyframes wn-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
/* The Go button says what it is doing mid-lookup. */
.bar .go[data-busy="true"] {
  background: var(--c-paper-deep); color: var(--c-ink-soft); cursor: default;
}
@media (prefers-reduced-motion: reduce) {
  .pending-bar::after { animation: none; transform: none; opacity: .55; }
  .tile, .mode { transition: none; }
}

/* ------------------------------------------------------- map markers */
.pin-origin {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-mandarin);
  border: 3px solid var(--c-paper);
  box-shadow: 0 0 0 2px var(--c-ink);
}
.pin-poi {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-panel);
  border: 2px solid var(--c-ink);
  box-shadow: 1.5px 1.5px 0 var(--c-ink);
}
.pin-poi svg { width: 14px; height: 14px; display: block; }
.pin-poi[data-far="true"] { opacity: .55; }
.pin-poi[data-active="true"] { background: var(--c-mandarin); }
.pin-poi[data-active="true"] svg { color: var(--c-panel); }

/* Callout appears on hover or selection only - showing them permanently
   collides badly wherever several results share an intersection. */
.callout {
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
  padding: 4px var(--s2);
  background: var(--c-panel);
  border: 1.5px solid var(--c-ink); border-radius: var(--r-pill);
  box-shadow: 1.5px 1.5px 0 var(--c-ink);
  font-size: var(--t-meta); font-weight: 600;
}
.callout .v { font-family: var(--font-mono); color: var(--c-mandarin); }
.callout .v[data-mode="driving"] { color: var(--c-teal); }

/* ---------------------------------------------------------- utilities */
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------- narrow width */
/* Formatting integrity only, per the brief: must not break, overlap, overflow
   or need horizontal scrolling. Not a touch-first or oversized-type regime. */
@media (max-width: 900px) {
  :root { --rail-w: auto; }
  html, body { height: auto; }
  body { background: var(--c-paper-deep); }
  #map { position: relative; height: 52vh; min-height: 300px; }
  .bar {
    position: relative; top: 0; left: 0; transform: none;
    width: auto; margin: var(--s3) var(--s3) 0;
    height: auto; flex-wrap: wrap; row-gap: var(--s2);
    padding: var(--s2) var(--s3); border-radius: var(--r-card);
  }
  .bar .rule { display: none; }
  .bar input { flex: 1 1 100%; order: 3; }
  .tagline {
    position: relative; top: 0; left: 0; transform: none;
    display: block; text-align: center; margin: var(--s2) var(--s3) 0;
    background: transparent; white-space: normal;
  }
  .suggest, .search-note {
    position: relative; top: 0; left: 0; transform: none;
    width: auto; margin: var(--s1) var(--s3) 0;
  }
  .rail {
    position: relative; top: 0; right: 0; bottom: 0;
    width: auto; margin: var(--s3); max-width: none;
  }
  .rail .scroll { overflow: visible; }
}
@media (max-width: 430px) {
  .tiles, .subs { grid-template-columns: 1fr; }
  .row { grid-template-columns: 20px 1fr; }
  .row .times { grid-column: 2; text-align: left; margin-top: 2px; }
  .row .t { justify-content: flex-start; }
  .bar .wordmark { font-size: var(--t-body); }
}

/* --------------------------------------------------------------- focus */
::selection { background: var(--c-mandarin-wash); color: var(--c-ink); }
:focus-visible { outline-color: var(--c-focus); }
