/* ── 24/7 Day theme
   Colors & writing rules: Logo & Brand/style-guide.md
   Official brand PDF: Logo & Brand/NACS Foundation Brand Identity + Messaging Guidelines FINAL.pdf
   Palette: 24/7 Red #DD2F28, Safety Orange #F9A11B, Steel Gray #333, Bright White #FFF
   Web typography: Arial (Gotham substitute), Georgia (Mercury substitute for body copy) */

:root {
  --day-red: #dd2f28;
  --day-red-dark: #b82420;
  --day-orange: #f9a11b;
  --steel-gray: #333333;
  --bright-white: #ffffff;
  --day-mid: #e85a22;
  --nacs-text: var(--steel-gray);
  --nacs-text-muted: #5c5c5c;
  --nacs-border: #c8ced8;
  --nacs-surface: #ffffff;
  --nacs-surface-subtle: #faf8f6;
  --font-brand: Arial, Helvetica, sans-serif;
  --font-body: Georgia, "Times New Roman", serif;
  --header-gradient: linear-gradient(
    105deg,
    var(--day-red) 0%,
    var(--day-mid) 48%,
    var(--day-orange) 100%
  );
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-brand);
  background: #ffffff;
  color: var(--nacs-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header (24/7 Day white artwork on red→orange gradient) ── */
.site-header {
  background: var(--header-gradient);
  padding: 14px 0 16px;
  box-shadow: 0 4px 18px rgba(221, 47, 40, 0.35);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px 20px;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-lockup:hover .brand-text {
  opacity: 0.95;
}

.brand-logo {
  display: block;
  height: clamp(52px, 10vw, 80px);
  width: auto;
  max-width: min(420px, 55vw);
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-product-title {
  font-family: var(--font-brand);
  font-size: clamp(15px, 2vw, 22px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-tagline {
  font-family: var(--font-brand);
  font-size: clamp(12px, 1.6vw, 16px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.brand-tagline em {
  font-style: italic;
  font-weight: 600;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ── Header banner (Laura map header artwork) ── */
.site-header--banner {
  background: #ffffff;
  padding: 0;
  box-shadow: none;
  line-height: 0;
}

.header-banner-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2400 / 260;
}

/* ── Map intro copy ── */
.map-intro {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 20px 4px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--steel-gray);
  background: #ffffff;
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: center;
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: none;
  box-shadow: none;
}

.filter-bar input,
.filter-bar select {
  padding: 8px 14px;
  border: 1px solid #c8ced8;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fafbfc;
  color: #2c3e50;
}

.filter-bar input {
  width: min(340px, 90vw);
}

.filter-bar select {
  width: min(220px, 90vw);
  cursor: pointer;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--day-red);
  background: var(--nacs-surface);
}

.store-count-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: min(420px, 92vw);
  text-align: right;
}

.store-count {
  font-size: 13px;
  color: var(--nacs-text-muted);
  line-height: 1.35;
}

.store-count-sub {
  font-size: 11px;
  color: #7a8494;
  line-height: 1.35;
  max-width: 100%;
}

.store-count-sub a {
  color: var(--day-red-dark);
  font-weight: 600;
}

/* ── Near me ── */
.near-me-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.near-me-retry {
  padding: 6px 12px;
  border: 1px solid rgba(221, 47, 40, 0.45);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: #fafbfc;
  color: var(--day-red-dark);
  cursor: pointer;
  white-space: nowrap;
}

.near-me-retry:hover {
  background: rgba(221, 47, 40, 0.06);
}

.near-me-retry:disabled {
  opacity: 0.65;
  cursor: wait;
}

.near-me-status {
  font-size: 12px;
  color: var(--nacs-text-muted);
  max-width: min(280px, 90vw);
  line-height: 1.35;
}

.near-me-status--error {
  color: var(--day-red-dark);
  font-weight: 600;
}

.map-user-location-divicon {
  background: transparent;
  border: none;
}

.map-user-location {
  position: relative;
  width: 24px;
  height: 24px;
}

.map-user-location__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #1a73e8;
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.map-user-location__pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: rgba(26, 115, 232, 0.25);
  animation: user-loc-pulse 2s ease-out infinite;
  z-index: 1;
}

@keyframes user-loc-pulse {
  0% {
    transform: scale(0.5);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.map-popup-block-distance .map-popup-distance {
  font-weight: 600;
  color: #1a5c8a;
}

/* ── Map ── */
#map-container {
  position: relative;
  width: 100%;
  height: 72vh;
  padding: 12px 16px;
  background: #ffffff;
}

#map {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.18);
}

/* ── Map loading overlay (spinner shown until /api/stores resolves) ── */
.map-loading {
  position: absolute;
  inset: 12px 16px; /* matches #map-container padding so it covers #map exactly */
  z-index: 1200; /* above Leaflet panes + controls while loading */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  text-align: center;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.map-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.map-loading__spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(221, 47, 40, 0.18);
  border-top-color: var(--day-red);
  animation: nacs-spin 0.8s linear infinite;
}

.map-loading__text {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--nacs-text-muted);
}

.map-loading--error .map-loading__spinner {
  display: none;
}

.map-loading__retry {
  font-family: var(--font-brand);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--day-red);
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.map-loading__retry:hover {
  background: var(--day-red-dark);
}

@keyframes nacs-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-loading__spinner {
    animation-duration: 2.4s;
  }
}

/* Filter controls are disabled until the store data finishes loading */
.filter-bar input:disabled,
.filter-bar select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #eef1f4;
}

/* ── Info Section ── */
.info-section {
  background: #fff;
  border-top: none;
  padding: 60px 20px;
}

.info-content {
  max-width: 860px;
  margin: 0 auto;
}

.info-content h2 {
  color: var(--day-red);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

/* Two-column layout: copy on the left, photo collage on the right */
.info-content--split {
  max-width: 1080px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
}

.info-content--split h2 {
  text-align: left;
}

.info-media-img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .info-content--split {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .info-content--split h2 {
    text-align: center;
  }

  .info-media {
    order: -1;
    max-width: 420px;
    margin: 0 auto;
  }
}

.info-content p {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--steel-gray);
  margin-bottom: 16px;
}

.info-content ul {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--steel-gray);
  margin: 0 0 16px 1.25rem;
  padding: 0;
}

.info-content li {
  margin-bottom: 8px;
}

.info-content a {
  color: var(--day-red);
  font-weight: 600;
}

.info-content .donate-btn,
.info-content .donate-btn:hover {
  color: var(--bright-white);
}

.donate-btn {
  display: inline-block;
  margin-top: 24px;
  padding: 13px 32px;
  background: var(--day-red);
  color: var(--bright-white);
  text-decoration: none;
  border-radius: 999px;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 16px;
  transition: background 0.2s, transform 0.1s;
}

.donate-btn:hover {
  background: var(--day-red-dark);
  transform: translateY(-1px);
}

/* ── Map markers (divIcon) ── */
.leaflet-div-icon.map-pin-divicon {
  background: transparent !important;
  border: none !important;
}

.map-pin {
  position: relative;
  width: 36px;
  height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(221, 47, 40, 0.4));
}

.map-pin-shape {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(
    145deg,
    var(--day-red) 0%,
    var(--day-mid) 50%,
    var(--day-orange) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.95);
}

.leaflet-marker-icon.map-pin-divicon {
  transition: transform 0.15s ease;
}

/* ── Marker clusters (24/7 Day red → orange; overrides MarkerCluster.Default.css greens) ── */
.leaflet-div-icon.nacs-cluster-marker {
  background: transparent !important;
  border: none !important;
  overflow: visible !important;
}

/* Default plugin classes (if present) — neutralize green/yellow from MarkerCluster.Default.css */
.leaflet-marker-icon[class*="marker-cluster-"] {
  background: transparent !important;
}

.leaflet-marker-icon[class*="marker-cluster-"] > div {
  background: transparent !important;
}

.nacs-cluster {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: #fff;
  font-family: var(--font-brand);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.94);
  box-shadow:
    0 0 0 1px rgba(221, 47, 40, 0.25),
    0 0 0 5px rgba(249, 161, 27, 0.18),
    0 8px 22px rgba(180, 40, 25, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Small clusters: red-forward */
.nacs-cluster--sm {
  background: linear-gradient(
    145deg,
    var(--day-red) 0%,
    var(--day-red) 28%,
    var(--day-mid) 72%,
    var(--day-orange) 100%
  );
}

/* Medium: balanced red → orange */
.nacs-cluster--md {
  background: linear-gradient(
    145deg,
    var(--day-red) 0%,
    var(--day-mid) 48%,
    var(--day-orange) 100%
  );
}

/* Large: orange-forward */
.nacs-cluster--lg {
  background: linear-gradient(
    145deg,
    var(--day-mid) 0%,
    var(--day-orange) 55%,
    var(--day-orange) 100%
  );
}

.nacs-cluster__count {
  position: relative;
  z-index: 1;
  font-size: 15px;
  text-shadow:
    0 1px 2px rgba(90, 20, 10, 0.55),
    0 0 8px rgba(221, 47, 40, 0.35);
}

.nacs-cluster--compact .nacs-cluster__count {
  font-size: 12px;
  letter-spacing: -0.04em;
}

.nacs-cluster--sm .nacs-cluster__count {
  font-size: 14px;
}

.nacs-cluster--md .nacs-cluster__count {
  font-size: 15px;
}

.nacs-cluster--lg .nacs-cluster__count {
  font-size: 16px;
}

/* ── Map marker: brand logo (when logoUrl is set) ── */
.map-pin--brand {
  width: 44px;
  height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(221, 47, 40, 0.4));
}

.map-pin-brand-ring {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow:
    0 2px 8px rgba(51, 51, 51, 0.2),
    inset 0 0 0 1px rgba(221, 47, 40, 0.2);
  background: #fff;
}

.map-pin-brand-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

/* Override Leaflet’s marker-pane img reset (width:auto; max-width:none !important) so logos fit the ring */
.leaflet-container .leaflet-marker-pane img.map-pin-brand-img,
.leaflet-container .leaflet-shadow-pane img.map-pin-brand-img {
  width: 100%;
  height: 100%;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  object-position: center;
  display: block;
}

/* ── Popup shell (Leaflet) ── */
.leaflet-popup.map-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  box-shadow:
    0 12px 40px rgba(51, 51, 51, 0.16),
    0 4px 12px rgba(51, 51, 51, 0.08);
  border: 1px solid rgba(221, 47, 40, 0.15);
}

.leaflet-popup.map-popup-wrap .leaflet-popup-content {
  margin: 0;
  min-width: 280px;
}

.leaflet-popup.map-popup-wrap .leaflet-popup-tip {
  box-shadow: 0 4px 12px rgba(51, 51, 51, 0.12);
  border: 1px solid rgba(221, 47, 40, 0.1);
}

.leaflet-popup.map-popup-wrap a.leaflet-popup-close-button {
  top: 10px !important;
  right: 10px !important;
  width: 28px;
  height: 28px;
  padding: 0;
  font: 600 18px/28px system-ui, sans-serif;
  color: #8a9ab0 !important;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.leaflet-popup.map-popup-wrap a.leaflet-popup-close-button:hover {
  background: #f0f4f8;
  color: #1a2a3a !important;
}

/* ── Popup card ── */
.map-popup-card {
  font-family: var(--font-brand);
  padding: 18px 40px 18px 18px;
  background: linear-gradient(180deg, #fafcfe 0%, #ffffff 28%);
}

.map-popup-brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--steel-gray);
  line-height: 1.25;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eef5;
}

.map-popup-block {
  margin-bottom: 14px;
}

.map-popup-block:last-child {
  margin-bottom: 0;
}

.map-popup-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a7a8c;
  margin-bottom: 4px;
}

.map-popup-block:first-of-type .map-popup-label {
  color: var(--day-red);
}

.map-popup-block-offer .map-popup-label {
  color: var(--day-orange);
}

.map-popup-body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.55;
  color: var(--steel-gray);
}

.map-popup-offer-text {
  color: #1e3a4d;
}

.map-popup-offer-empty {
  font-style: italic;
  color: #8a9ab0;
  font-size: 12px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .brand-lockup {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .site-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  #map-container {
    height: 60vh;
    padding: 8px;
  }

  .map-loading {
    inset: 8px; /* keep the overlay aligned with the smaller mobile map padding */
  }
}

/* ── Popup banner & site label (multi-banner retailers) ── */
.map-popup-banner {
  font-weight: 600;
  color: var(--day-red, #dd2f28);
  letter-spacing: 0;
}

.map-popup-sublabel {
  font-size: 12px;
  font-weight: 600;
  color: #5a6a7a;
  margin-top: 2px;
  margin-bottom: 4px;
}
