/* ==========================================================================
   SAFEBOX find-app — interactive site map
   ========================================================================== */

/* SAFEBOX brand stack — Ridley Grotesk → Archivo free fallback */
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800;900&display=swap');

@font-face {
  font-family: 'Ridley Grotesk';
  src:
    local('Ridley Grotesk'),
    url('/fonts/RidleyGrotesk-SemiBold.woff2') format('woff2'),
    url('/fonts/RidleyGrotesk-SemiBold.woff')  format('woff');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Ridley Grotesk';
  src:
    url('/fonts/RidleyGrotesk-ExtraBold.woff2') format('woff2'),
    url('/fonts/RidleyGrotesk-ExtraBold.woff')  format('woff');
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --safebox-green: #61993B;
  --safebox-green-dk: #406E33;
  --safebox-green-lt: #B7DC8E;
  --ink: #0E2A11;
  --ink-2: #3D5238;
  --paper: #FAFAF6;
  --paper-2: #F1EFE7;
  --line: #C9D6BB;
  --warn: #D32F2F;
  --warn-2: #FFEB3B;
  --shadow: 0 8px 32px rgba(0,0,0,.18);
  --rad: 14px;
  --rad-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Ridley Grotesk', 'Archivo', 'Inter var', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-feature-settings: "ss01", "cv11";
  color: var(--ink);
  background: var(--paper);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.muted { color: #7C8772; font-size: 12px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--safebox-green);
  color: white; box-shadow: var(--shadow); z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--safebox-green); color: white;
  font-weight: 900; font-size: 20px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.10), 0 4px 14px rgba(97,153,59,.35);
}
.brand-name {
  font-weight: 900;
  letter-spacing: 0.10em;
  font-size: 16px;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.search-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  max-width: 540px; margin: 0 auto;
  position: relative;
}
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  pointer-events: none; font-size: 16px; color: var(--ink-2);
  z-index: 1;
}
.search-wrap input {
  flex: 1; padding: 11px 14px 11px 38px;
  border: 2px solid #FFFFFF;
  border-radius: 999px;
  background: #FFFFFF; color: var(--ink);
  font-size: 15px; font-weight: 600;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.search-wrap input::placeholder { color: #6B7B5E; font-weight: 500; }
.search-wrap input:focus {
  border-color: var(--safebox-green-lt);
  box-shadow: 0 0 0 4px rgba(183,220,142,.45), 0 4px 14px rgba(0,0,0,.22);
}
.search-wrap button {
  width: 40px; height: 40px; border-radius: 999px; border: none;
  background: var(--safebox-green); color: white; cursor: pointer;
  font-size: 18px; line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.search-wrap button:hover { background: var(--safebox-green-dk); }
.help { color: rgba(255,255,255,.85); text-decoration: none; font-size: 13px; font-weight: 500; }
.help:hover { color: white; }

/* ---------- stage ---------- */
#stage {
  position: relative; flex: 1; overflow: hidden;
  background: linear-gradient(180deg, #EEF2E6 0%, #DDE6CB 100%);
}
#canvas {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  cursor: grab;
}
#canvas.panning { cursor: grabbing; }
#map-svg {
  width: min(100%, 100vh * 3.4);  /* aspect ~ 1820/540 ≈ 3.37 */
  max-height: 100%;
  pointer-events: auto;
  user-select: none;
  filter: drop-shadow(0 6px 24px rgba(0,0,0,.12));
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
  transform-origin: center center;
}
#overlay {
  position: absolute; inset: 0; pointer-events: none;
  width: 100%; height: 100%;
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
  transform-origin: center center;
}

/* ---------- legend ---------- */
#legend {
  position: absolute; top: 16px; left: 16px; z-index: 4;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  padding: 10px 14px; border-radius: var(--rad);
  box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.5;
}
.lg-row { display: flex; align-items: center; gap: 8px; }
.sw {
  width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2);
  flex: none;
}
.sw-yours { background: var(--warn); box-shadow: 0 0 0 2px rgba(211,47,47,.3); }
.sw-pod { background: #61993B; }
.sw-cube { background: #FFFFFF; }
.sw-main { background: #F4A742; }
.sw-route {
  background: repeating-linear-gradient(90deg, var(--warn) 0 4px, transparent 4px 8px);
  border: none;
}

/* ---------- zoom controls ---------- */
#zoom-controls {
  position: absolute; right: 16px; bottom: 80px; z-index: 4;
  display: flex; flex-direction: column; gap: 6px;
}
#zoom-controls button {
  width: 40px; height: 40px; border-radius: 999px; border: none;
  background: white; color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
  font-size: 20px; font-weight: 700;
}
#zoom-controls button:hover { background: var(--safebox-green); color: white; }

/* ---------- info panel ---------- */
#info {
  position: absolute; right: 16px; top: 16px; z-index: 5;
  width: min(360px, calc(100% - 32px));
  background: white; border-radius: var(--rad);
  box-shadow: var(--shadow); padding: 18px 20px 16px;
  transform: translateX(20px); opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
#info:not(.hidden) { transform: translateX(0); opacity: 1; pointer-events: auto; }
#info-close {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 999px; border: none;
  background: transparent; color: var(--ink-2); cursor: pointer;
  font-size: 20px; line-height: 1;
}
#info-close:hover { background: var(--paper-2); }
#info h2 {
  margin: 0 0 4px; font-size: 18px; font-weight: 800;
  letter-spacing: -0.01em;
}
#info .pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: white; margin-bottom: 10px;
}
#info dl { margin: 8px 0 0; display: grid; grid-template-columns: 90px 1fr; gap: 4px 12px; font-size: 13px; }
#info dt { color: var(--ink-2); font-weight: 600; }
#info .actions { margin-top: 14px; display: flex; gap: 8px; }
#info .btn {
  flex: 1; padding: 9px 12px; border-radius: var(--rad-sm); border: none;
  background: var(--safebox-green); color: white; font-weight: 700; font-size: 13px;
  cursor: pointer; text-decoration: none; text-align: center;
}
#info .btn.ghost { background: var(--paper-2); color: var(--ink); }
#info .btn:hover { filter: brightness(1.05); }

/* ---------- hint ---------- */
.hint {
  position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 3;
  margin: 0 auto; max-width: 480px;
  padding: 10px 14px; background: rgba(14,42,17,.88); color: white;
  border-radius: var(--rad-sm); font-size: 12px; line-height: 1.45;
  text-align: center; backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  transform: translateY(0); transition: transform .3s, opacity .3s;
}
.hint.dismiss { transform: translateY(80px); opacity: 0; }
.hint code {
  background: rgba(255,255,255,.18); padding: 1px 6px; border-radius: 4px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11px;
}

/* ---------- bottombar ---------- */
.bottombar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 14px; background: var(--safebox-green);
  border-top: 1px solid var(--safebox-green-dk); font-size: 11px; color: white;
}
.bottombar .muted { color: rgba(255,255,255,.85); }
.bottom-search { display: none; }   /* footer search hidden on desktop */
.footer-credit { display: inline; }

/* Make the bottom (mobile) search bar much more prominent — was too easy to miss.
   Constrain width and center so it sits as a compact pill under the site plan,
   not a full-width strip. */
body.portrait .bottom-search {
  max-width: 360px !important;
  margin: 0 auto !important;
}
body.portrait .bottom-search input {
  border-color: var(--safebox-green) !important;
  border-width: 3px !important;
  box-shadow: 0 -2px 12px rgba(97,153,59,.35), 0 4px 14px rgba(0,0,0,.22) !important;
}
body.portrait .bottom-search input::placeholder {
  color: var(--safebox-green-dk) !important;
  font-weight: 700 !important;
}
body.portrait .bottom-search button {
  background: var(--safebox-green) !important;
  width: 44px !important; height: 44px !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,.6), 0 4px 12px rgba(0,0,0,.3) !important;
}

/* ---------- pulses + highlight ---------- */
.hl-pulse {
  fill: rgba(211,47,47,0.4);
  stroke: var(--warn);
  stroke-width: 3;
  animation: pulse 1.6s cubic-bezier(0.22,0.61,0.36,1) infinite;
}
@keyframes pulse {
  0%   { stroke-opacity: 1;   fill-opacity: 0.5; transform: scale(1); }
  60%  { stroke-opacity: 0.0; fill-opacity: 0;   transform: scale(1.6); }
  100% { stroke-opacity: 0;   fill-opacity: 0;   transform: scale(1.6); }
}
.hl-base {
  fill: rgba(211,47,47,0.15);
  stroke: var(--warn);
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 8px rgba(211,47,47,0.4));
}
.hl-route {
  fill: none;
  stroke: var(--warn);
  stroke-width: 3;
  stroke-dasharray: 7 5;
  stroke-linecap: round;
  animation: dash 0.6s linear infinite;
}
@keyframes dash { from { stroke-dashoffset: 12; } to { stroke-dashoffset: 0; } }
.hl-marker {
  fill: var(--warn);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .brand-name { font-size: 14px; letter-spacing: 0.08em; }
  .help { display: none; }
  #legend { font-size: 11px; padding: 8px 10px; right: 16px; left: auto; }
  #legend .lg-row:nth-child(n+4) { display: none; }
  #info { right: 8px; left: 8px; top: 8px; width: auto; }
  #zoom-controls { bottom: 100px; }
  .hint { font-size: 11px; }
}

/* ---------- portrait phones ----------
   Mobile customers get the 290×1820 portrait SVG: tall, thin, scrolls
   vertically. The west end (entrance) is at the BOTTOM near their hand,
   PODs extend UPWARD as they scroll. Minimal UI — just map, highlight,
   route and a small info pill. */
body.portrait #stage {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: auto;        /* Firefox: show full-width scrollbar */
  scrollbar-color: #61993B rgba(0,0,0,0.06);
}
/* WebKit (Safari, Chrome, iOS) — make the scrollbar always visible and brand-coloured */
body.portrait #stage::-webkit-scrollbar { width: 12px; background: rgba(0,0,0,0.04); }
body.portrait #stage::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 6px; }
body.portrait #stage::-webkit-scrollbar-thumb {
  background: #61993B;
  border-radius: 6px;
  border: 2px solid rgba(0,0,0,0.04);
  min-height: 40px;
}
body.portrait #stage::-webkit-scrollbar-thumb:hover { background: #4a7a2a; }
body.portrait #canvas {
  display: block; place-items: initial;
  /* On phone, fill viewport width. On desktop, cap to a phone-width column
     centred on the page so the portrait map stays readable. */
  width: min(100vw, 480px);
  margin: 0 auto;
  height: calc(min(100vw, 480px) * 1820 / 290);
  position: relative;
  cursor: default;
}
body.portrait #map-svg {
  width: 100%;
  height: 100%;
  max-height: none;
  display: block;
  filter: none;     /* drop the drop-shadow on phone — saves render budget */
  transition: none; /* no JS pan, so no transition */
  transform: none !important;
}
body.portrait #overlay {
  width: 100%;
  height: 100%;
  transition: none;
  transform: none !important;
}
/* Strip every chrome that doesn't belong on a "find your unit" mobile flow */
body.portrait #legend,
body.portrait #zoom-controls,
body.portrait #info,
body.portrait .hint { display: none !important; }
/* Mobile: nice big SAFEBOX header, hide top search, show search in footer */
body.portrait .topbar {
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, var(--ink) 0%, #1A3120 100%);
  justify-content: center;
}
body.portrait .top-search,
body.portrait .help { display: none; }
body.portrait .brand { gap: 12px; }
body.portrait .brand-mark {
  width: 42px; height: 42px; border-radius: 11px; font-size: 24px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.10), 0 6px 20px rgba(97,153,59,.45);
}
body.portrait .brand-name {
  font-size: 22px;
  letter-spacing: 0.14em;
  font-weight: 900;
}
body.portrait .brand-tag {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.65);
  margin-top: 2px;
}
.brand-tag { display: none; }   /* hide tagline on desktop */

/* Sticky search-in-footer for mobile */
body.portrait .bottombar {
  position: sticky;
  bottom: 0;
  padding: 10px 12px;
  background: rgba(14, 42, 17, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.10);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
body.portrait .bottom-search {
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
}
body.portrait .bottom-search input { font-size: 17px; padding: 14px 14px 14px 40px; }
body.portrait .footer-credit {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,.45);
}

/* ---------- accessibility ---------- */
.hidden { display: none !important; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--safebox-green-lt); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .hl-pulse, .hl-route { animation: none; }
  #map-svg, #overlay, #info { transition: none; }
}
