/* =====================================================
   areas-map.css
   Service-areas map hub: persistent Leaflet map + area
   list on top, swappable area content region below.
   Loaded only on /areas/ (the hub). Subpages are
   unaffected.
   ===================================================== */

/* ── Hub shell ───────────────────────────────────────── */
.amap-hub {
  background: #ffffff;
  border-bottom: 1px solid var(--evergreen-08);
}

.amap-hub__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.1rem, 4vw, 2.5rem) clamp(2.25rem, 5vw, 3.5rem);
}

.amap-hub__head {
  max-width: 720px;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.amap-hub__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.05;
  color: var(--evergreen);
  margin: 0 0 0.65rem;
}

.amap-hub__sub {
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 1.6;
  color: var(--charcoal);
  opacity: 0.85;
  margin: 0;
}

/* ── Two-column layout: list panel + map ─────────────── */
.amap-hub__layout {
  display: grid;
  grid-template-columns: minmax(310px, 390px) 1fr;
  gap: clamp(1.75rem, 3.5vw, 3rem);
  align-items: start;
}

/* ── List panel ──────────────────────────────────────── */
.amap-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.amap-search {
  position: relative;
  margin-bottom: 0.85rem;
}

.amap-search__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--evergreen-mid);
  pointer-events: none;
}

.amap-search__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--charcoal);
  padding: 0.8rem 0.9rem 0.8rem 2.5rem;
  border: 1px solid var(--evergreen-12);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.amap-search__input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(82, 104, 111, 0.2);
}

/* ── Region filter pills ─────────────────────────────── */
.amap-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.amap-pill {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--evergreen);
  background: #fff;
  border: 1px solid var(--evergreen-12);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.amap-pill:hover {
  border-color: var(--evergreen-mid);
}

.amap-pill--active {
  background: var(--evergreen);
  color: #fff;
  border-color: var(--evergreen);
}

/* ── Area list ───────────────────────────────────────── */
.amap-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 540px;
  overflow-y: auto;
  border: 1px solid var(--evergreen-08);
  border-radius: 12px;
  background: #fff;
  scrollbar-width: thin;
}

.amap-list__item {
  margin: 0;
}

.amap-list__btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--evergreen-06);
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--charcoal);
  transition: background 0.14s ease;
}

/* Left accent bar in the area's region colour on hover/active */
.amap-list__btn {
  position: relative;
  border-left: 3px solid transparent;
}

.amap-list__btn.is-active {
  border-left-color: var(--amap-dot, var(--evergreen));
}

.amap-list__item:last-child .amap-list__btn {
  border-bottom: none;
}

.amap-list__btn:hover,
.amap-list__btn:focus-visible {
  background: #f7f9fa;
  outline: none;
}

.amap-list__btn.is-active {
  background: var(--color-gold-light);
}

.amap-list__btn.is-active .amap-list__name {
  color: var(--evergreen);
}

.amap-list__name {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--evergreen);
  line-height: 1.2;
}

/* Region-colour dot, keyed to the matching map pin colour */
.amap-list__name::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--amap-dot, var(--evergreen));
  vertical-align: middle;
}

/* Region colours — mirrored in js/areas-map.js (REGION_COLORS) */
.amap-list__btn[data-region="downtown"]  { --amap-dot: #52686F; }
.amap-list__btn[data-region="westside"]  { --amap-dot: #6B6473; }
.amap-list__btn[data-region="east"]      { --amap-dot: #7A5E5A; }
.amap-list__btn[data-region="north"]     { --amap-dot: #4F6A64; }
.amap-list__btn[data-region="burnaby"]   { --amap-dot: #7A6B58; }
.amap-list__btn[data-region="tricities"] { --amap-dot: #6A7058; }
.amap-list__btn[data-region="richmond"]  { --amap-dot: #735F6B; }
.amap-list__btn[data-region="fraser"]    { --amap-dot: #5E6F5B; }

.amap-list__region {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--evergreen-mid);
  margin-top: 0.15rem;
}

.amap-list__empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--evergreen-mid);
  font-size: 0.92rem;
}

/* ── Map ─────────────────────────────────────────────── */
.amap-map {
  position: sticky;
  top: calc(var(--nav-height, 72px) + 1rem);
  height: clamp(420px, 70vh, 640px);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--evergreen-12);
  background: #e8eef0;
  z-index: 1; /* keep below sticky nav */
}

/* Leaflet fills the container */
.amap-map .leaflet-container {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  background: #e8eef0;
}

/* ── Custom map pins (colour set inline per region) ──── */
.amap-pin {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--evergreen);
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(16, 38, 50, 0.5);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.leaflet-marker-icon:hover .amap-pin {
  transform: scale(1.18);
}

/* Active keeps its region colour, gains a white halo + lift */
.amap-pin--active {
  transform: scale(1.45);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 2px 9px rgba(16, 38, 50, 0.55);
}

/* ── Pin labels (permanent tooltips) ─────────────────── */
.leaflet-tooltip.amap-tip {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--evergreen-12);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(16, 38, 50, 0.18);
  color: var(--evergreen);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 2px 7px;
  white-space: nowrap;
}

.leaflet-tooltip.amap-tip::before { display: none; } /* no callout arrow */

/* ── Area coverage highlight circle ──────────────────── */
.amap-area {
  stroke-dasharray: 5 4;
  pointer-events: none;
}

.leaflet-popup-content {
  margin: 0.6rem 0.85rem;
  font-family: var(--font-body);
}

.amap-popup__name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--evergreen);
  margin: 0 0 0.15rem;
}

.amap-popup__link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--evergreen);
  text-decoration: none;
}

.amap-popup__link:hover {
  text-decoration: underline;
}

/* ── Swappable content region ────────────────────────── */
.amap-content {
  min-height: 200px;
}

.amap-content[data-loading="true"] {
  position: relative;
  min-height: 320px;
}

.amap-content__spinner {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--evergreen-mid);
  font-size: 0.9rem;
}

.amap-content[data-loading="true"] .amap-content__spinner {
  display: flex;
}

.amap-content__spin {
  width: 22px;
  height: 22px;
  border: 2px solid var(--evergreen-12);
  border-top-color: var(--evergreen);
  border-radius: 50%;
  animation: amap-spin 0.7s linear infinite;
}

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

/* Default (no area selected) intro shown in the content slot */
.amap-default {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.1rem, 4vw, 2.5rem);
  text-align: center;
}

.amap-default__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--evergreen);
  margin: 0 0 0.6rem;
}

.amap-default__sub {
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--charcoal);
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .amap-hub__layout {
    grid-template-columns: 1fr;
  }

  .amap-map {
    position: relative;
    top: 0;
    order: -1; /* map first on mobile */
    height: clamp(320px, 50vh, 420px);
  }

  .amap-list {
    max-height: none;
  }
}

/* ── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .amap-pin,
  .leaflet-marker-icon:hover .amap-pin,
  .amap-content__spin {
    transition: none;
    animation: none;
  }
}

/* =====================================================
   Homepage embed — #areas section on index.html.
   Reuses the .amap-* layout but the map is not sticky and
   sits a touch shorter to fit between homepage sections.
   ===================================================== */
.amap-hub__layout--home {
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.amap-map--home {
  position: relative;
  top: 0;
  height: clamp(380px, 56vh, 540px);
}

.amap-hub__layout--home .amap-list {
  max-height: 520px;
}

@media (max-width: 900px) {
  .amap-map--home {
    height: clamp(320px, 50vh, 420px);
  }

  .amap-hub__layout--home .amap-list {
    max-height: none;
  }
}
