/* Store locator — styled to match redcactus-usa.com (Square Online theme):
   white background, black primary, pill buttons, Inter, red brand accent. */

:root {
  --ink: #111111;
  --ink-soft: #555555;
  --line: #e6e6e6;
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --brand-red: #c8102e;
  --brand-red-dark: #a30d26;
  --radius-pill: 100px;
  --radius-card: 14px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

/* Visible to screen readers only — used for extra link/button context. */
.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;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

.locator {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Header ---------- */

.locator-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

/* ---------- Brand / back-to-site ---------- */

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo-link {
  display: block;
  flex-shrink: 0;
  border-radius: 8px;
}
.brand-logo-link:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 3px; }

.brand-logo {
  display: block;
  width: auto;
  height: 116px; /* dense emblem with internal lettering - needs size to read */
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 2px;
  border-radius: 4px;
}
.back-link:hover { color: var(--brand-red); }
.back-link:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; }
.back-link svg { width: 15px; height: 15px; }

.footer-home {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.footer-home:hover { color: var(--brand-red); border-color: var(--brand-red); }
.footer-home:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; border-radius: 2px; }

.footer-links { display: inline-flex; gap: 16px; flex-wrap: wrap; }

.locator-heading h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-soft);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 11px 16px 11px 38px;
  font: 500 14px var(--font);
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  outline: none;
}

#search-input:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

#radius-select {
  padding: 11px 14px;
  font: 500 13px var(--font);
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  font: 600 14px var(--font);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn:focus-visible,
#radius-select:focus-visible,
.locator-footer a:focus-visible {
  outline: 3px solid var(--brand-red);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-red); border-color: var(--brand-red); }

.btn-outline {
  background: transparent;
  color: var(--ink);
}
.btn-outline:hover { border-color: var(--brand-red); color: var(--brand-red); }

/* ---------- Body layout ---------- */

.locator-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.results-panel {
  width: 380px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.results-status {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.results-status.error { color: var(--brand-red); }

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.result-item {
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}

.result-item:hover { background: var(--bg-soft); }
.result-item.active { background: #fdf2f4; box-shadow: inset 3px 0 0 var(--brand-red); }

/* The selectable area is a real <button> so it is keyboard operable and
   announced as a control. It carries the pin, name, distance, and address. */
.result-select {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
  padding: 16px 20px 6px;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.result-select:focus-visible { outline: 3px solid var(--brand-red); outline-offset: -3px; }

.result-pin {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.result-info { display: flex; flex-direction: column; min-width: 0; }

.result-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 3px;
}

.result-distance {
  font-weight: 600;
  color: var(--brand-red);
  font-size: 12.5px;
  margin-left: 6px;
}

.result-address {
  display: block;
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.result-links {
  display: flex;
  gap: 14px;
  font-size: 13px;
  flex-wrap: wrap;
  padding: 6px 20px 16px 60px; /* indent under the store name (26px pin + 14px gap + 20px pad) */
}

.result-links a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.result-links a:hover { color: var(--brand-red); border-color: var(--brand-red); }
.result-links a:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 3px; border-radius: 2px; }

.empty-hint {
  padding: 32px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- Map ---------- */

.map-wrap { position: relative; flex: 1; display: flex; min-width: 0; }
.map { flex: 1; min-width: 0; }

/* Overview-mode legend explaining the cluster counts. Hidden once the visitor
   searches (the map switches to numbered result pins). */
.map-caption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: 300px;
  margin: 0;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  z-index: 2;
  pointer-events: none; /* never blocks map panning/clicks */
}
.map-caption strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-weight: 700;
}
.locator.searched .map-caption { display: none; }

.store-popup .maplibregl-popup-content {
  font-family: var(--font);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 200px;
}

.popup-name { font-weight: 700; font-size: 14px; margin: 0 0 4px; padding-right: 12px; }
.popup-address { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 8px; line-height: 1.45; }
.popup-links { display: flex; gap: 12px; font-size: 12.5px; }
.popup-links a { color: var(--brand-red); font-weight: 600; text-decoration: none; }

.marker-user {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--ink), 0 2px 6px rgba(0,0,0,0.3);
}

.marker-result {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--brand-red);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.marker-result span {
  transform: rotate(45deg);
  color: #fff;
  font: 700 12px var(--font);
}

.marker-result-root { cursor: pointer; }
.marker-result-root:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Footer ---------- */

.locator-footer {
  padding: 8px 24px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.locator-footer a { color: inherit; }

/* ---------- Mobile ---------- */

@media (max-width: 820px) {
  .locator-header { padding: 16px; }
  .locator-heading h1 { font-size: 22px; }
  .search-bar { width: 100%; }

  .brand-block { gap: 12px; }
  .brand-logo { height: 81px; }
  /* Back link moves above the search bar and spans the width on small screens. */
  .header-right { width: 100%; align-items: stretch; }
  .back-link { align-self: flex-start; }

  /* iOS Safari auto-zooms the viewport when a focused input's font is < 16px.
     Bumping to 16px on touch layouts stops the page jumping on ZIP search. */
  #search-input, #radius-select { font-size: 16px; }
  .btn { padding: 11px 16px; }
  /* "Near me" is a secondary alternative to typing, so give it its own
     full-width row below the search controls rather than crowding them inline.
     Full width also makes a comfortable thumb target. */
  #locate-btn { flex-basis: 100%; justify-content: center; }

  /* Mobile: stop pinning everything into one 100dvh screen. A tall header plus
     a fixed-height map was squeezing the results panel down to a sliver. Let
     the whole page scroll instead — map on top at a fixed height, the full
     results list flowing naturally below it. */
  .locator { height: auto; min-height: 100dvh; }
  .locator-body { flex: 1 0 auto; flex-direction: column-reverse; }
  /* Size the WRAPPER (the flex child of locator-body), not the inner #map.
     .map-wrap keeps its desktop flex:1 otherwise and collapses in this column
     layout, leaving the map with no rendering height — MapLibre then shows a
     blank canvas with no tiles. #map fills the wrapper via its own flex:1. */
  .map-wrap { flex: none; height: 46vh; min-height: 300px; }
  .results-panel {
    width: 100%;
    flex: none;
    min-height: 0;
    border-right: none;
    border-top: 1px solid var(--line);
  }
  /* Results grow to natural height so the page scrolls, rather than trapping
     the list in its own short inner scroll. */
  .results-list { overflow-y: visible; flex: none; }
}

/* ---------- Legal / privacy page ---------- */

.legal {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  line-height: 1.6;
  color: var(--ink);
}

.legal-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.legal-head .brand-logo { height: 72px; }
.legal-head h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.legal-updated { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }

.legal h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 32px 0 8px;
}
.legal p { margin: 0 0 14px; }
.legal ul { margin: 0 0 14px; padding-left: 22px; }
.legal li { margin-bottom: 8px; }
.legal a { color: var(--brand-red); text-decoration: underline; text-underline-offset: 2px; }
.legal a:hover { text-decoration: none; }
.legal a:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; border-radius: 2px; }

.legal-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

@media (max-width: 820px) {
  .legal-head { gap: 14px; }
  .legal-head .brand-logo { height: 56px; }
  .legal-head h1 { font-size: 22px; }
}

/* ---------- Reduced motion ---------- */

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