/* ==========================================================================
   GAS Imports — Dealer Locator
   Theme tokens live here. Swapping brand colours = editing :root, nothing else.
   Dark-only by design: the GAS logo is white-on-transparent.
   ========================================================================== */

:root {
  --bg:            #0B1016;
  --bg-elev:       #121A23;
  --bg-elev-2:     #1D2732;   /* GAS primary */
  --bg-hover:      #243040;
  --line:          #26323f;
  --line-soft:     #1b242e;

  --text:          #EAF0F6;
  --text-dim:      #94A6B8;
  --text-faint:    #64748B;

  --accent:        #FF7A18;
  --accent-soft:   rgba(255, 122, 24, 0.16);
  --accent-line:   rgba(255, 122, 24, 0.45);
  --accent-text:   #FF9448;

  --ok:            #34D399;
  --warn:          #FBBF24;

  --radius:        14px;
  --radius-sm:     9px;
  --sidebar-w:     404px;
  --topbar-h:      64px;

  --shadow:        0 10px 30px rgba(0,0,0,.45);
  --ease:          cubic-bezier(.22,.61,.36,1);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

/* ---------------------------------------------------------------- shell -- */

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100dvh;
}

/* In the WordPress iframe: no duplicate header, and scroll can chain out to the host page. */
.is-embedded .app { grid-template-rows: 1fr; }
.is-embedded .topbar { display: none; }
.is-embedded, .is-embedded body { overscroll-behavior: auto; }
.is-embedded .results { overscroll-behavior: contain; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
  border-bottom: 1px solid var(--line);
  z-index: 900;
}

.topbar__logo { height: 26px; width: auto; display: block; }

.topbar__divider {
  width: 1px; height: 26px;
  background: var(--line);
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.topbar__sub {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 2px 0 0;
}

.topbar__spacer { flex: 1; }

.topbar__count {
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 100px;
  white-space: nowrap;
}
.topbar__count b { color: var(--text); font-variant-numeric: tabular-nums; }

.main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

/* -------------------------------------------------------------- sidebar -- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  z-index: 800;
}

.controls {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* search ------------------------------------------------------------------ */

.search { position: relative; }

.search__field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.search__field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__icon { flex: none; color: var(--text-faint); display: grid; }

.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  padding: 12px 0;
}
.search input::placeholder { color: var(--text-faint); }

.search__clear {
  flex: none;
  background: none; border: 0; padding: 4px;
  color: var(--text-faint); line-height: 0;
  border-radius: 50%;
  opacity: 0; pointer-events: none;
  transition: opacity .15s var(--ease), color .15s var(--ease);
}
.search__clear:hover { color: var(--text); }
.search.is-filled .search__clear { opacity: 1; pointer-events: auto; }

.search__spinner {
  flex: none;
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: none;
  animation: spin .7s linear infinite;
}
.search.is-loading .search__spinner { display: block; }
.search.is-loading .search__clear  { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}
.suggestions:empty { display: none; }

.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.35;
  transition: background .12s var(--ease);
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover,
.suggestion.is-active { background: var(--bg-hover); }
.suggestion b { font-weight: 600; }
.suggestion span { display: block; color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* buttons + filters -------------------------------------------------------- */

.btn-locate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 12px 14px;
  background: var(--accent);
  color: #16100A;
  font-weight: 600;
  font-size: 14px;
  border: 0;
  border-radius: var(--radius-sm);
  transition: transform .14s var(--ease), filter .14s var(--ease);
}
.btn-locate:hover  { filter: brightness(1.08); }
.btn-locate:active { transform: scale(.985); }
.btn-locate[disabled] { opacity: .6; pointer-events: none; }

.filters {
  display: flex;
  gap: 6px;
  align-items: center;
}

.filters__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  margin-right: 2px;
}

.chip {
  flex: 1;
  padding: 7px 4px;
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-dim);
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--text-faint); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-text);
  font-weight: 600;
}

/* results ------------------------------------------------------------------ */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 18px 8px;
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.results-head__origin {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--accent-text);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.results::-webkit-scrollbar { width: 9px; }
.results::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
  border: 3px solid var(--bg-elev);
}

/* icons -------------------------------------------------------------------- */

.ico {
  flex: none;
  width: 14px; height: 14px;
  display: block;
}
.ico--tail { width: 12px; height: 12px; opacity: .5; margin-left: -1px; }
.ico--brand { width: 14px; height: 14px; opacity: 1; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* dealer card -------------------------------------------------------------- */

.card {
  position: relative;
  background: var(--bg-elev-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px 15px 13px;
  margin-bottom: 9px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .18s var(--ease), border-color .18s var(--ease),
              background .18s var(--ease);
  animation: cardIn .38s var(--ease) both;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--line);
  background: var(--bg-hover);
}
.card.is-active {
  border-color: var(--accent-line);
  background: var(--bg-hover);
}
.card.is-active::before {
  content: "";
  position: absolute; left: 0; top: 14px; bottom: 14px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}

/* A dealer with a Google Business Profile carries a little more weight than
   one we only have an address for: warmer tile, brighter glyph, filled CTA. */
.card--basic { background: rgba(255,255,255,.028); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}

.card__top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.card__mark {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  margin-top: 1px;
}
.card__mark .ico { width: 16px; height: 16px; }
.card--profile .card__mark {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-text);
}
.card.is-nearest .card__mark {
  background: var(--accent);
  border-color: var(--accent);
  color: #16100A;
}

.card__head { flex: 1; min-width: 0; }

.card__name {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 3px;
}

.card__addr {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin: 0;
}
.card__street { display: block; }
.card__region { display: block; color: var(--text-faint); }

.card__dist {
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
  white-space: nowrap;
  margin-top: 3px;
}

/* status tags -------------------------------------------------------------- */

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0 41px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag .ico { width: 11px; height: 11px; }
.tag--verified {
  color: var(--ok);
  border-color: rgba(52,211,153,.28);
  background: rgba(52,211,153,.09);
}
.tag--basic {
  color: var(--text-faint);
  border-color: var(--line);
  background: rgba(255,255,255,.03);
}
.tag--approx {
  color: var(--warn);
  border-color: rgba(251,191,36,.3);
  background: rgba(251,191,36,.08);
}

/* inline contact links ----------------------------------------------------- */

.card__contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 9px 0 0 41px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: color .15s var(--ease);
}
.link .ico { color: var(--text-faint); transition: color .15s var(--ease); }
.link:hover { color: var(--text); }
.link:hover .ico { color: var(--accent-text); }

/* the single call to action ------------------------------------------------ */

.card__actions {
  display: flex;
  margin: 11px 0 0 41px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--text-dim);
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.act:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-faint); }
.act:hover .ico--tail { opacity: .9; }

/* profiled dealers: the richer, filled action */
.act--profile {
  background: rgba(255,255,255,.07);
  border-color: var(--line);
  color: var(--text);
}
.act--profile:hover {
  background: rgba(255,255,255,.13);
  border-color: var(--text-faint);
}

/* location-only dealers: routing is all we can honestly offer */
.act--go {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-text);
}
.act--go:hover { background: rgba(255,122,24,.26); color: var(--accent-text); border-color: var(--accent); }

/* skeleton + empty --------------------------------------------------------- */

.skeleton {
  height: 96px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: linear-gradient(100deg, var(--bg-elev-2) 30%, var(--bg-hover) 50%, var(--bg-elev-2) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

.empty {
  text-align: center;
  padding: 46px 26px;
  color: var(--text-dim);
}
.empty svg { color: var(--text-faint); margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); font-weight: 600; }
.empty p { margin: 0; font-size: 13px; line-height: 1.5; }

/* ------------------------------------------------------------------ map -- */

.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }

.map-toast {
  position: absolute;
  top: 16px; left: 50%;
  transform: translate(-50%, -14px);
  z-index: 700;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  font-size: 13px; font-weight: 500;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 100px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .24s var(--ease), transform .24s var(--ease);
}
.map-toast.is-shown { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.map-toast--action { cursor: pointer; }
.map-toast--action:hover { background: var(--bg-hover); }
.map-toast--error { border-color: rgba(248,113,113,.4); color: #FCA5A5; }

/* leaflet overrides -------------------------------------------------------- */

.leaflet-container { background: var(--bg); font-family: var(--font); }

.leaflet-control-zoom a {
  background: var(--bg-elev-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-hover) !important; }

.leaflet-control-attribution {
  background: rgba(11,16,22,.82) !important;
  color: var(--text-faint) !important;
  font-size: 10.5px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* markers ------------------------------------------------------------------ */

.pin {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg);
  background: var(--bg-elev-2);
  border: 2px solid var(--accent);
  box-shadow: 0 3px 9px rgba(0,0,0,.5);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.pin::after {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: rotate(45deg);
}
.pin--approx { border-style: dashed; border-color: var(--warn); }
.pin--approx::after { background: var(--warn); }

.pin-wrap.is-hover .pin,
.pin-wrap.is-active .pin {
  transform: rotate(-45deg) scale(1.28);
  box-shadow: 0 6px 18px rgba(255,122,24,.5);
  z-index: 999;
}
.pin-wrap.is-active .pin { background: var(--accent); }
.pin-wrap.is-active .pin::after { background: #16100A; }

.pin-wrap.is-nearest .pin { animation: pinPulse 2.1s var(--ease) infinite; }
@keyframes pinPulse {
  0%, 100% { box-shadow: 0 3px 9px rgba(0,0,0,.5), 0 0 0 0    rgba(255,122,24,.55); }
  60%      { box-shadow: 0 3px 9px rgba(0,0,0,.5), 0 0 0 14px rgba(255,122,24,0); }
}

/* "you are here" ----------------------------------------------------------- */

.origin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #3B82F6;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 0 rgba(59,130,246,.6);
  animation: radar 2.2s var(--ease) infinite;
}
@keyframes radar {
  0%   { box-shadow: 0 0 0 0    rgba(59,130,246,.55); }
  70%  { box-shadow: 0 0 0 26px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0    rgba(59,130,246,0); }
}

/* clusters ----------------------------------------------------------------- */

.cluster {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(255,122,24,.2);
  border: 1.5px solid var(--accent-line);
  color: var(--accent-text);
  font-weight: 700; font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(2px);
  transition: transform .18s var(--ease);
}
.cluster:hover { transform: scale(1.08); }
.cluster--lg { font-size: 14px; }

/* popups ------------------------------------------------------------------- */

.leaflet-popup-content-wrapper {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 13px 15px; font-size: 13px; line-height: 1.5; }
.leaflet-popup-tip { background: var(--bg-elev-2); border: 1px solid var(--line); }
.leaflet-popup-close-button { color: var(--text-faint) !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }

.pop__name { font-weight: 600; font-size: 14px; margin: 0 0 4px; padding-right: 14px; }
.pop__addr { color: var(--text-dim); margin: 0 0 9px; }
.pop__dist { color: var(--accent-text); font-weight: 600; }
.pop__links { display: flex; gap: 7px; flex-wrap: wrap; }

.list-more { text-align: center; color: var(--text-faint); font-size: 12.5px; padding: 10px 0 0; }

/* ----------------------------------------------------------------- mobile - */

.sheet-handle { display: none; }

@media (max-width: 860px) {
  .app { grid-template-rows: var(--topbar-h) 1fr; }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }

  .map-wrap { position: absolute; inset: 0; }

  .panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    top: 46%;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 34px rgba(0,0,0,.5);
    transition: top .34s var(--ease);
    z-index: 850;
  }
  .panel.is-expanded { top: 0; border-radius: 0; }
  .panel.is-collapsed { top: calc(100% - 152px); }

  .sheet-handle {
    display: block;
    width: 100%;
    background: none; border: 0;
    padding: 9px 0 4px;
    touch-action: none;
  }
  .sheet-handle::before {
    content: "";
    display: block;
    width: 42px; height: 4px;
    margin: 0 auto;
    border-radius: 99px;
    background: var(--line);
  }

  .topbar__sub, .topbar__divider { display: none; }
  .controls { padding: 6px 14px 12px; }
  .results { padding: 0 10px 24px; }
}

@media (max-width: 420px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .topbar__count { display: none; }
}

/* --------------------------------------------------------- reduced motion - */

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

/* Fallback basemap: standard OSM tiles pushed into the dark theme. */
.tiles-darkened {
  filter: invert(1) hue-rotate(185deg) brightness(.82) contrast(.92) saturate(.55);
}

/* Pull Esri's grey canvas down into the app's navy-black palette. */
.tiles-esri { filter: brightness(.58) saturate(.12) contrast(1.06); }
.tiles-esri-labels { filter: brightness(1.15) saturate(0); }

/* Keep Leaflet's controls under the mobile bottom sheet (they default to 1000). */
.leaflet-top, .leaflet-bottom { z-index: 700; }
