/* ==========================================================================
   Alevon Green — Service Area Map (V1 prototype)
   Visual direction: Alevon Blue, lime green, and white (provisional,
   screenshot-derived palette), clean modern typography, generous spacing,
   subtle motion. map.js STYLES mirrors these :root token values.
   ========================================================================== */

:root {
  --green-950: #00145C;
  --green-900: #001B72;
  --green-800: #001B72;
  --green-700: #00145C;
  --green-600: #001B72;
  --green-100: #EAF5D2;
  --cream: #F8F8F8;
  --cream-deep: #F8F8F8;
  --gold: #7CB313;
  --gold-soft: #98CC30;
  --ink: #001B72;
  --ink-soft: #3D4A7A;
  --line: #E3E6EF;
  --radius: 14px;
  --shadow-soft: 0 10px 30px rgba(20, 39, 24, 0.10);
  --shadow-lift: 0 14px 40px rgba(20, 39, 24, 0.16);
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Demo banner ---------- */

.demo-banner {
  background: #4a3a10;
  color: #f6e8bd;
  border-bottom: 2px solid var(--gold);
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  text-align: center;
  letter-spacing: 0.01em;
}

/* ---------- Map + panel shell ---------- */

.map-shell {
  margin: 0;
  padding: 0.5rem 20px 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.25rem;
  align-items: stretch;
}

.map-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
  background: var(--cream-deep);
  min-height: 1050px;
}

#map {
  position: absolute;
  inset: 0;
  background: #dde8e3; /* water-ish tone while tiles load */
}

/* Toolbar overlay: back button + breadcrumb */

.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 60px;
  z-index: 800; /* above map panes, below Leaflet controls' 1000 */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.map-toolbar > * { pointer-events: auto; }

.map-back {
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--green-900);
  font: 600 0.85rem var(--font-body);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: background-color 160ms ease, transform 160ms ease;
}

.map-back:hover { background: #fff; transform: translateY(-1px); }
.map-back:focus-visible { outline: 3px solid var(--green-900); outline-offset: 2px; }

.map-breadcrumb {
  background: rgba(250, 247, 239, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-breadcrumb strong { color: var(--green-900); font-weight: 600; }
.map-breadcrumb .crumb-sep { margin: 0 0.35rem; color: var(--gold); }

.tile-notice {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  background: rgba(34, 48, 31, 0.92);
  color: var(--cream);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  max-width: 90%;
}

/* Leaflet chrome adjustments */

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

.leaflet-control-zoom a {
  color: var(--green-900) !important;
}

.leaflet-control-attribution {
  background: rgba(250, 247, 239, 0.85) !important;
  color: var(--ink-soft) !important;
  font-size: 0.65rem !important;
}

/* Area labels (Leaflet tooltips) */

.area-label {
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--green-950);
  text-shadow:
    0 1px 3px rgba(250, 247, 239, 0.95),
    0 0 10px rgba(250, 247, 239, 0.9);
  pointer-events: none;
}

.area-label.region-label { font-size: 0.95rem; letter-spacing: 0.06em; text-transform: uppercase; }
.area-label.local-label { font-size: 0.8rem; letter-spacing: 0.02em; }
.area-label::before { display: none; }

/* Focus ring for keyboard-focused map polygons */

.leaflet-interactive:focus-visible {
  outline: 3px solid var(--green-900);
  outline-offset: 1px;
}

/* ---------- Info panel ---------- */

.info-panel {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 1.75rem 1.6rem;
  overflow-y: auto;
  max-height: 1050px;
}

.panel-loading { color: var(--ink-soft); }

.panel-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green-900);
  margin: 0 0 0.4rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--green-900);
  margin: 0 0 0.6rem;
}

.panel-desc {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.25rem;
}

.panel-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green-800);
  margin: 1.5rem 0 0.6rem;
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

/* Area list (regions on overview, local areas in region view) */

.area-list { list-style: none; margin: 0; padding: 0; }

.area-list li + li { margin-top: 0.5rem; }

.area-list-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font: 600 0.92rem var(--font-body);
  color: var(--green-900);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.area-list-btn:hover {
  background: #fff;
  border-color: var(--gold-soft);
  transform: translateX(2px);
}

.area-list-btn:focus-visible { outline: 3px solid var(--green-900); outline-offset: 2px; }

.area-list-btn .meta {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.badge-active { background: var(--green-100); color: var(--green-800); }
.badge-planned { background: #f4e9cd; color: #7a5e14; }
.badge-nomap { background: #eee9dc; color: var(--ink-soft); }

/* Services list */

.service-list { list-style: none; margin: 0; padding: 0; }

.service-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
}

.service-list li:last-child { border-bottom: none; }

.service-list .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  flex: 0 0 auto;
  transform: translateY(-1px);
}

.service-list .service-name { color: var(--ink); font-weight: 600; }
.service-list .service-cat { font-size: 0.72rem; color: var(--ink-soft); }

.service-list .service-link {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  text-decoration: none;
}

.service-list .service-link:hover {
  text-decoration: underline;
}

.service-list .service-link:focus-visible {
  outline: 3px solid var(--green-900);
  outline-offset: 2px;
  border-radius: 3px;
}

.panel-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0.75rem 0 0;
}

/* Panel actions */

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  font: 600 0.95rem var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.btn:focus-visible { outline: 3px solid var(--green-900); outline-offset: 2px; }

.btn-primary {
  background: var(--green-800);
  color: #fdfbf4;
  border: 1px solid var(--green-900);
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover { background: var(--green-700); transform: translateY(-1px); box-shadow: var(--shadow-lift); }

.btn-secondary {
  background: transparent;
  color: var(--green-800);
  border: 1px solid var(--green-600);
}

.btn-secondary:hover { background: var(--green-100); }

.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Directory ---------- */

.directory {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.directory h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.7rem;
  color: var(--green-900);
  margin: 0 0 0.25rem;
}

.directory-sub { color: var(--ink-soft); margin: 0 0 1.5rem; }

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.directory-region {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.2rem;
  box-shadow: var(--shadow-soft);
}

.directory-region h3 { margin: 0 0 0.75rem; }

.directory-region h3 a {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
  color: var(--green-900);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-soft);
}

.directory-region h3 a:hover { color: var(--green-700); border-bottom-color: var(--gold); }
.directory-region h3 a:focus-visible { outline: 3px solid var(--green-900); outline-offset: 2px; }

.directory-region ul { list-style: none; margin: 0; padding: 0; }

.directory-region li { padding: 0.3rem 0; font-size: 0.92rem; }

.directory-region li a {
  color: var(--ink);
  text-decoration: none;
}

.directory-region li a:hover { color: var(--green-700); text-decoration: underline; }
.directory-region li a:focus-visible { outline: 3px solid var(--green-900); outline-offset: 2px; }

.directory-region li .dir-note { font-size: 0.75rem; color: var(--ink-soft); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--green-900);
  color: var(--cream);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lift);
  max-width: min(90vw, 480px);
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 920px) {
  .map-shell {
    grid-template-columns: 1fr;
    padding: 0.5rem 0 1.5rem;
  }

  .map-stage { min-height: 58vh; }

  .info-panel { max-height: none; }

  .directory { padding: 0.5rem 1rem 2.5rem; }
}

@media (max-width: 480px) {
  .map-stage { min-height: 62vh; }
  .map-toolbar { right: 12px; flex-wrap: wrap; }
  .info-panel { padding: 1.4rem 1.2rem; }
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
