/*! ==========================================================================
    AMAZON PAINT — STORE LOCATOR
    ==========================================================================
    Every class is namespaced .locator-* so nothing can collide with the DNN
    theme. Colours and fonts read from the site's design tokens in
    core.min.css; the fallbacks after each var() are the same values, so this
    file also renders correctly on its own in preview.html.

    Load order matters: this file must come AFTER vendor/leaflet/leaflet.css
    so the popup and control overrides at the bottom win.
    ========================================================================== */

.locator {
  --locator-gap: var(--gap-base, 0.938rem);
  --locator-border: #e2e2e2;
  --locator-muted: #5c5c5c;
  --locator-radius: 2px;
  --locator-map-height: 440px;
  --locator-map-height-stuck: 300px;
  /* Raise this to your theme's fixed-header height if the sticky map slides
     under it — e.g. `.locator { --locator-sticky-top: 80px; }` */
  --locator-sticky-top: 0px;

  font-family: var(--font-body, "Montserrat", sans-serif);
  font-weight: var(--font-weight-normal, 400);
  line-height: var(--line-height-base, 1.2);
  color: var(--color-dark-shade, #141414);
}

.locator *,
.locator *::before,
.locator *::after { box-sizing: border-box; }


/* ==========================================================================
   CONTROLS
   ========================================================================== */

.locator__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--locator-gap);
  margin-bottom: 1.5rem;
}

.locator__field {
  display: flex;
  flex-direction: column;
  gap: var(--gap-small, 0.438rem);
  flex: 1 1 220px;
  min-width: 0;
}

.locator__label {
  font-family: var(--font-subheadline, "Courier Prime", serif);
  font-size: 0.875rem;
  font-weight: var(--font-weight-bold, 700);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-dark-shade, #141414);
}

.locator__input,
.locator select.locator__input {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 15px;
  border: 1px solid var(--locator-border);
  border-radius: var(--locator-radius);
  background: #fff;
  font-family: var(--font-body, "Montserrat", sans-serif);
  font-size: 1rem;
  line-height: var(--line-height-base, 1.2);
  color: var(--color-dark-shade, #141414);
  transition: border-color .3s ease, box-shadow .3s ease;
}

.locator__input:focus {
  outline: none;
  border-color: var(--color-primary, #6EB544);
  box-shadow: 0 0 0 3px rgba(var(--color-primary--rgb, 110, 181, 68), .25);
}

.locator select.locator__input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  /* Inline chevron, so there is no image file to upload or lose */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23141414' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 12px 8px;
  cursor: pointer;
}

/* Mirrors .button / .button--primary from core.min.css */
.locator__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-small, 0.438rem);
  min-height: 50px;
  padding: 15px 30px;
  border: none;
  border-radius: var(--locator-radius);
  background: var(--color-primary, #6EB544);
  font-family: var(--font-body, "Montserrat", sans-serif);
  font-size: 1.042rem;
  font-weight: var(--font-weight-bold, 700);
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  transition: all .3s ease;
}

.locator__button:hover { background: var(--color-secondary, #49B8EA); }

.locator__button:focus-visible {
  outline: 3px solid var(--color-secondary, #49B8EA);
  outline-offset: 2px;
}

.locator__button[disabled] { opacity: .55; cursor: default; }
.locator__button[disabled]:hover { background: var(--color-primary, #6EB544); }

.locator__button-icon { width: 18px; height: 18px; flex: none; fill: currentColor; }

/* Result count + geolocation feedback. Announced via aria-live. */
.locator__status {
  flex: 1 1 100%;
  margin: 0;
  font-family: var(--font-subheadline, "Courier Prime", serif);
  font-size: 0.9375rem;
  color: var(--locator-muted);
}

.locator__status--error { color: #b3261e; }


/* ==========================================================================
   MAP
   ========================================================================== */

/* The map sticks to the top of the viewport while the list scrolls under it,
   so choosing a store never means scrolling back up to see the pin.

   If your DNN theme has a fixed/overlapping header, set --locator-sticky-top
   to its height (see README) or the map will slide underneath it.

   Sticky also silently fails if ANY ancestor has `overflow: hidden`. If the
   map scrolls away instead of sticking, that's the cause — see README. */
/* Needs real area — IntersectionObserver does not reliably report a
   zero-height element. The negative margin cancels the 1px so the layout
   is unchanged. */
#locator-map-sentinel {
  height: 1px;
  margin-bottom: -1px;
}

.locator__map-wrap {
  position: -webkit-sticky;
  position: sticky;
  top: var(--locator-sticky-top, 0px);
       /* above list cards, below Leaflet's own popups (700) */
  padding: var(--gap-small, 0.438rem) 0 var(--locator-gap);
  margin-bottom: var(--gap-small, 0.438rem);
  background: #fff;      /* opaque, or cards show through as they scroll past */
}

.locator__map {
  width: 100%;
  height: var(--locator-map-height);
  border: 1px solid var(--locator-border);
  border-radius: var(--locator-radius);
  background: var(--color-light-shade, #F3F3F3);
  transition: height .25s ease;
}

/* Once stuck, the map gives back some height so the list stays readable.
   locator.js toggles .is-stuck from a scroll listener. */
.locator__map-wrap.is-stuck {
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .35);
}

.locator__map-wrap.is-stuck .locator__map {
  height: var(--locator-map-height-stuck);
}

/* Without JS there is no map, only the list — so don't reserve blank space,
   and don't let an empty box stick to the top of the screen. locator.js
   removes this class as soon as it initialises. */
.locator__map.locator__map--pending { display: none; }
.locator__map-wrap:has(.locator__map--pending) { position: static; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  .locator__map { transition: none; }
}


/* ==========================================================================
   LIST
   ========================================================================== */

.locator__results { margin: 0; }

/* Visually hidden but read aloud — used for the "locations" after each count */
.locator__sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}


/* --- State accordion ------------------------------------------------------
   Native <details>/<summary>: keyboard accessible for free, still works with
   JavaScript off, and indexable while collapsed. */

.locator__group {
  margin: 0 0 var(--gap-small, 0.438rem);
  border-bottom: 1px solid var(--locator-border);
}

.locator__group-summary {
  display: flex;
  align-items: center;
  gap: var(--locator-gap);
  padding: var(--locator-gap) var(--gap-small, 0.438rem);
  font-family: var(--font-headline, "Montserrat", sans-serif);
  font-weight: var(--font-weight-header, 700);
  font-size: 1.25rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--color-primary, #6EB544);
  cursor: pointer;
  list-style: none;                  /* kill the default triangle... */
  transition: color .3s ease, background-color .3s ease;
}

.locator__group-summary::-webkit-details-marker { display: none; }   /* ...in Safari */

/* Custom chevron, rotated when open */
.locator__group-summary::before {
  content: "";
  flex: none;
  width: 12px;
  height: 8px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E") no-repeat center / contain;
  transform: rotate(-90deg);
  transition: transform .3s ease;
}

.locator__group[open] > .locator__group-summary::before { transform: rotate(0deg); }

.locator__group-summary:hover { color: var(--color-secondary, #49B8EA); }

.locator__group-summary:focus-visible {
  outline: 3px solid var(--color-secondary, #49B8EA);
  outline-offset: -3px;
}

.locator__group-name { flex: 1 1 auto; }

.locator__group-count {
  flex: none;
  min-width: 2.25rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(var(--color-tertiary--rgb, 193, 221, 170), .5);
  font-family: var(--font-subheadline, "Courier Prime", serif);
  font-size: 0.875rem;
  letter-spacing: 0;
  text-align: center;
  color: var(--color-dark-shade, #141414);
}

.locator__group[open] > .locator__group-summary {
  color: var(--color-dark-shade, #141414);
  border-bottom: 2px solid var(--color-primary, #6EB544);
}

.locator__group[open] > .locator__group-summary .locator__group-count {
  background: var(--color-primary, #6EB544);
  color: #fff;
}

.locator__group[open] > .locator__list { padding-block: var(--locator-gap); }

@media (prefers-reduced-motion: reduce) {
  .locator__group-summary::before { transition: none; }
}

.locator__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--locator-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.locator__item {
  display: flex;
  flex-direction: column;
  padding: var(--locator-gap);
  border: 1px solid var(--locator-border);
  border-left: 4px solid var(--color-tertiary, #C1DDAA);
  border-radius: var(--locator-radius);
  background: #fff;
  transition: border-color .3s ease, box-shadow .3s ease;
}

.locator__item:hover,
.locator__item--active {
  border-left-color: var(--color-primary, #6EB544);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .09);
}

.locator__item--active { background: rgba(var(--color-tertiary--rgb, 193, 221, 170), .22); }

.locator__name {
  margin: 0 0 var(--gap-small, 0.438rem);
  font-family: var(--font-headline, "Montserrat", sans-serif);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.25;
  color: var(--color-dark-shade, #141414);
}

.locator__address {
  margin: 0 0 var(--gap-small, 0.438rem);
  font-size: 0.9375rem;
  font-style: normal;
  line-height: 1.45;
  color: var(--locator-muted);
}

.locator__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-small, 0.438rem) var(--locator-gap);
  margin-top: auto;
  padding-top: var(--gap-small, 0.438rem);
  font-size: 0.9375rem;
}

.locator__link {
  /* font-weight: var(--font-weight-bold, 700); */
  color: var(--color-primary, #6EB544);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .3s ease, border-color .3s ease;
      word-wrap: anywhere;
}

.locator__link:hover,
.locator__link:focus-visible {
  color: var(--color-secondary, #49B8EA);
  border-bottom-color: currentColor;
}

/* "Show on map" — injected by locator.js, so it never appears without a map */
.locator__show {
  align-self: flex-start;
  margin-top: var(--gap-small, 0.438rem);
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-subheadline, "Courier Prime", serif);
  font-size: 0.875rem;
  font-weight: var(--font-weight-bold, 700);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-secondary, #49B8EA);
  cursor: pointer;
  transition: color .3s ease;
}

.locator__show:hover { color: var(--color-primary, #6EB544); }

.locator__show:focus-visible {
  outline: 2px solid var(--color-secondary, #49B8EA);
  outline-offset: 3px;
}

.locator__distance {
  font-family: var(--font-subheadline, "Courier Prime", serif);
  font-size: 0.8125rem;
  letter-spacing: .5px;
  color: var(--locator-muted);
  white-space: nowrap;
}

.locator__note {
  margin: var(--gap-small, 0.438rem) 0 0;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--locator-muted);
}

.locator__empty {
  padding: 2rem var(--locator-gap);
  border: 1px dashed var(--locator-border);
  border-radius: var(--locator-radius);
  background: var(--color-light-shade, #F3F3F3);
  text-align: center;
  color: var(--locator-muted);
}

.locator__empty[hidden] { display: none; }
.locator__group[hidden],
.locator__item[hidden] { display: none; }


/* ==========================================================================
   LEAFLET OVERRIDES — must come after leaflet.css
   ========================================================================== */

.locator .leaflet-container {
  font-family: var(--font-body, "Montserrat", sans-serif);
  border-radius: var(--locator-radius);
}

.locator .leaflet-popup-content-wrapper {
  border-radius: var(--locator-radius);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .18);
}

.locator .leaflet-popup-content { margin: 15px; min-width: 190px; line-height: 1.45; }

.locator .leaflet-popup__name {
  display: block;
  margin-bottom: var(--gap-small, 0.438rem);
  font-family: var(--font-headline, "Montserrat", sans-serif);
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--color-dark-shade, #141414);
}

.locator .leaflet-popup__address {
  display: block;
  margin-bottom: var(--gap-small, 0.438rem);
  font-size: 0.9375rem;
  color: var(--locator-muted);
}

.locator .leaflet-popup__link {
  display: inline-block;
  margin-right: var(--locator-gap);
  font-weight: var(--font-weight-bold, 700);
  font-size: 0.9375rem;
  color: var(--color-primary, #6EB544);
  text-decoration: none;
}

.locator .leaflet-popup__link:hover {
  color: var(--color-secondary, #49B8EA);
  text-decoration: underline;
}

.locator .leaflet-bar a {
  color: var(--color-dark-shade, #141414);
  transition: background-color .3s ease;
}

.locator .leaflet-bar a:hover { background-color: var(--color-light-shade, #F3F3F3); }

/* Brand map pin, built by locator.js as an inline SVG divIcon */
.locator__pin { background: none; border: none; }

.locator__pin-svg {
  display: block;
  fill: var(--color-primary, #6EB544);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35));
  transition: fill .3s ease, transform .3s ease;
}

.locator__pin:hover .locator__pin-svg { fill: var(--color-secondary, #49B8EA); }

.locator__pin--active .locator__pin-svg {
  fill: var(--color-secondary, #49B8EA);
  transform: scale(1.2);
  transform-origin: 50% 100%;
}

/* Marker for the visitor's own position, drawn as a CSS dot (no image file) */
.locator__me { background: none; border: none; }

.locator__me-dot {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--color-secondary, #49B8EA);
  box-shadow: 0 0 0 2px rgba(var(--color-secondary--rgb, 73, 184, 234), .55);
}


/* Marker for a searched city / ZIP that has no store in it. Deliberately not
   a pin: it is a place the visitor asked about, not somewhere they can shop. */
.locator__searched { background: none; border: none; }

.locator__searched-dot {
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--color-dark-shade, #141414);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25), 0 2px 5px rgba(0, 0, 0, .35);
}

.locator__searched-dot::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  margin: 5px auto;
  border-radius: 50%;
  background: #fff;
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media screen and (max-width: 767px) {
  .locator {
    --locator-map-height: 300px;
    --locator-map-height-stuck: 190px;   /* leaves room for the list on a phone */
  }

  .locator__controls { gap: var(--gap-small, 0.438rem) var(--locator-gap); }
  .locator__field { flex: 1 1 100%; }
  .locator__button { width: 100%; }
  .locator__list { grid-template-columns: 1fr; }

  .locator__group-summary {
    font-size: 1.0625rem;
    letter-spacing: 2px;
    padding: var(--locator-gap) 0;
  }
}

/* Short viewports: a sticky map would eat the whole screen, so let it scroll. */
@media screen and (max-height: 620px) {
  .locator__map-wrap { position: static; box-shadow: none; }
  .locator__map-wrap.is-stuck .locator__map { height: var(--locator-map-height); }
}

@media (prefers-reduced-motion: reduce) {
  .locator * { transition: none !important; }
}
