/* Explore Historic Halifax, preview visitor map.
   Layout follows Aimee's Warrenton and holiday maps (Leaflet, dock + map,
   breakpoints <720, 720-899, >=900). Palette: navy #314259, brick #8C3037,
   steel blue #4679A6, and white. */
@font-face {
  font-family: "Cormorant SC";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/cormorant-sc-600.woff2) format("woff2");
}
:root {
  --navy: #314259;
  --navy-dark: #243245;
  --brick: #8C3037;
  --steel: #4679A6;
  --white: #ffffff;
  --mist: #F3F5F8;
  --line: #D9DEE6;
  --ink: #314259;
  --ink-soft: #5B6878;
  --c-historic: #8C3037;
  --c-markers: #314259;
  --c-food: #4679A6;
  --c-shops: #3C7F86;
  --c-outdoors: #557A47;
  --c-churches: #7A6650;
  --c-civic: #6B7583;
  --serif: "Cormorant SC", "Cormorant Garamond", "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 6px 20px rgba(36, 50, 69, 0.18);
  --app-height: 100svh;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: var(--app-height, 100svh); }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--white);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.1; color: var(--navy); }
a { color: var(--steel); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 2000; background: #fff; padding: 6px 10px; }

.preview-banner {
  flex: 0 0 auto;
  background: var(--brick);
  color: #fff;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px;
}

/* Header with a thin brick stripe under it */
header.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--navy);
  color: #fff;
  padding: 8px 12px 9px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 3px solid var(--brick);
  box-shadow: inset 0 -5px 0 -4px rgba(255,255,255,0.0);
  position: relative;
  z-index: 500;
}
header.app-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  border-bottom: 1px solid var(--navy);
  opacity: 0.35;
}
header.app-header h1 { color: #fff; font-size: 1.55rem; letter-spacing: 0.02em; }
header.app-header .sub { margin: 1px 0 0; font-size: 0.74rem; color: #DCE3EC; }
header.app-header .sep { color: #E7B9BC; font-size: 0.6rem; vertical-align: 1px; margin: 0 3px; }
.info-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.7);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font: 600 0.82rem var(--sans);
  cursor: pointer;
  flex-shrink: 0;
}
.info-btn:hover, .info-btn:focus-visible { background: rgba(255,255,255,0.14); }

#map { flex: 1 1 auto; min-height: 0; position: relative; background: #e9edf2; }
.leaflet-container { font-family: var(--sans); }
.locate-btn {
  position: absolute; z-index: 800; right: 10px; top: 86px;
  width: 34px; height: 34px; border-radius: 6px;
  border: 2px solid rgba(0,0,0,0.2); background: #fff; color: var(--navy);
  font-size: 1.1rem; line-height: 1; cursor: pointer; background-clip: padding-box;
}
.leaflet-top.leaflet-right .leaflet-control-zoom { margin-top: 10px; }

/* Pins */
.pin-icon { background: none; border: 0; }
.pin {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.12s ease;
}
.pin svg { width: 15px; height: 15px; fill: #fff; display: block; }
.pin.square { border-radius: 5px; }
.pin.is-selected { transform: scale(1.3); box-shadow: 0 0 0 3px rgba(140,48,55,0.35), 0 2px 6px rgba(0,0,0,0.4); }
.pin .soon {
  position: absolute; top: -6px; right: -8px;
  background: var(--brick); color: #fff; font: 700 8px/1 var(--sans);
  padding: 2px 3px; border-radius: 4px; border: 1px solid #fff;
}
.pin-wrap { position: relative; width: 26px; height: 26px; }
.hx-cluster {
  background: var(--navy); color: #fff; border: 2px solid #fff; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px var(--sans);
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}

/* Legend (bottomleft L.Control) */
.map-legend {
  background: rgba(255,255,255,0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px 8px;
  font-size: 0.74rem;
  color: var(--navy);
  max-width: 240px;
}
.map-legend .legend-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  appearance: none; border: 0; background: none; padding: 2px 2px 4px; width: 100%;
  font: 600 0.95rem var(--serif); color: var(--navy); cursor: pointer;
}
.map-legend .legend-head .chev::after { content: "\25BE"; font-family: var(--sans); font-size: 0.7rem; }
.map-legend.is-collapsed .legend-head { padding-bottom: 2px; }
.map-legend.is-collapsed .legend-head .chev::after { content: "\25B8"; }
.map-legend.is-collapsed .legend-items { display: none; }
.legend-items { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 4px; }
.legend-item {
  appearance: none; border: 0; background: none; text-align: left;
  display: flex; align-items: center; gap: 7px; padding: 3px 2px; cursor: pointer;
  font: 500 0.74rem var(--sans); color: var(--navy); border-radius: 4px;
}
.legend-item:hover { background: var(--mist); }
.legend-item .sw { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.18); flex-shrink: 0; }
.legend-item .sw.square { border-radius: 3px; }
.legend-item .n { margin-left: auto; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.legend-item[aria-pressed="false"] { opacity: 0.45; }
.legend-item[aria-pressed="false"] .label { text-decoration: line-through; }

/* Dock: filters + list */
.dock {
  flex: 0 0 auto;
  background: var(--white);
  border-top: 3px solid var(--navy);
  display: flex; flex-direction: column;
  min-height: 0;
  z-index: 600;
}
.filters { padding: 8px 10px 4px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  border-radius: 999px; padding: 6px 11px; font: 600 0.78rem var(--sans); cursor: pointer;
  white-space: nowrap;
}
.chip .sw { width: 10px; height: 10px; border-radius: 50%; }
.chip .sw.square { border-radius: 2px; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip[aria-pressed="true"] .sw { box-shadow: 0 0 0 1.5px #fff; }
.chip.all[aria-pressed="true"] { background: var(--brick); border-color: var(--brick); }

.list-toggle {
  appearance: none; border: 0; border-top: 1px solid var(--line); background: var(--mist);
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; font: 600 0.82rem var(--sans); color: var(--navy); cursor: pointer;
}
.list-toggle .chev::after { content: "Show list \25B4"; font-weight: 500; color: var(--steel); }
.list-toggle[aria-expanded="true"] .chev::after { content: "Hide list \25BE"; }
.results { display: none; min-height: 0; overflow: hidden; }
.dock.list-open .results { display: block; }
.results-list { overflow-y: auto; max-height: 38vh; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  font: 600 1.02rem var(--serif); color: var(--navy);
  padding: 10px 14px 4px;
}
.group-head::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.group-sub { font: 500 0.72rem var(--sans); color: var(--ink-soft); padding: 0 14px 4px; }
.row {
  appearance: none; border: 0; background: none; width: 100%; text-align: left;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 7px 14px; cursor: pointer; font: inherit; color: var(--navy);
}
.row:hover, .row:focus-visible { background: var(--mist); }
.row.is-selected { background: #EEF3F9; box-shadow: inset 3px 0 0 var(--brick); }
.row .sw { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.row .sw.square { border-radius: 3px; }
.row .nm { font-weight: 600; font-size: 0.86rem; line-height: 1.25; }
.row .ty { display: block; font-size: 0.74rem; color: var(--ink-soft); margin-top: 1px; }
.tag {
  display: inline-block; font: 700 0.62rem/1 var(--sans); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 5px; border-radius: 4px; vertical-align: 2px; margin-left: 4px;
  background: #F4E6E7; color: var(--brick);
}
.tag.id { background: #E8ECF2; color: var(--navy); text-transform: none; }
.empty { padding: 12px 14px; color: var(--ink-soft); font-size: 0.85rem; }

footer.credit {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 4px 10px; padding-bottom: max(4px, env(safe-area-inset-bottom));
  background: var(--white); border-top: 1px solid var(--line);
  font-size: 0.72rem; color: var(--navy);
}
footer.credit img { width: 22px; height: 22px; }

/* Popups: sized by chromePadding()/popupOptions(); content scrolls */
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: var(--shadow); }
.leaflet-popup-content {
  margin: 12px 14px 12px 14px;
  max-width: var(--popup-max-w, 280px);
  max-height: var(--popup-max-h, none);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  font-size: 0.84rem; line-height: 1.42; color: var(--navy);
}
.leaflet-container a.leaflet-popup-close-button { width: 28px; height: 28px; font-size: 20px; color: var(--navy); top: 2px; right: 2px; }
.pop .kicker {
  display: flex; align-items: center; gap: 6px;
  font: 700 0.64rem var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
  padding-right: 18px;
}
.pop .kicker .sw { width: 9px; height: 9px; border-radius: 50%; }
.pop .kicker .sw.square { border-radius: 2px; }
.pop h3 { font-size: 1.32rem; margin: 3px 18px 2px 0; }
.pop .group { font-size: 0.74rem; color: var(--brick); font-weight: 600; margin: 0 0 4px; }
.pop .ty { font-size: 0.76rem; color: var(--ink-soft); margin: 0 0 6px; }
.pop .blurb { margin: 0 0 8px; }
.pop .alert { margin: 0 0 8px; padding: 6px 8px; border-left: 3px solid var(--brick); background: #FBF3F3; font-size: 0.8rem; }
.pop .approx { margin: 0 0 8px; font-size: 0.78rem; color: var(--steel); font-style: italic; }
.pop dl { margin: 0 0 8px; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 0.8rem; }
.pop dt { font-weight: 700; color: var(--ink-soft); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
.pop dd { margin: 0; }
.pop .verify { display: block; font-size: 0.72rem; color: var(--ink-soft); font-style: italic; }
.pop blockquote {
  margin: 0 0 8px; padding: 8px 10px; background: var(--mist); border-radius: 6px;
  font-family: Georgia, "Times New Roman", serif; font-size: 0.84rem; line-height: 1.4;
}
.pop .small { font-size: 0.72rem; color: var(--ink-soft); margin: 0 0 8px; }
.pop .related { margin: 0 0 8px; font-size: 0.78rem; }
.pop .related button, .pop .linkish {
  appearance: none; border: 0; background: none; padding: 0; color: var(--steel); font: inherit; text-decoration: underline; cursor: pointer;
}
.pop .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.pop .links a, .pop .links button {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--steel);
  border-radius: 999px; padding: 4px 10px; font: 600 0.74rem var(--sans); text-decoration: none; cursor: pointer;
}
.pop .links a:hover, .pop .links button:hover { border-color: var(--steel); }

/* Info drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(36,50,69,0.4); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 1500; }
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1600;
  max-height: 86%; display: flex; flex-direction: column;
  background: #fff; border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  transform: translateY(105%); transition: transform 0.25s ease; visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; border-bottom: 3px solid var(--brick); }
.drawer-head h2 { font-size: 1.5rem; }
.drawer .close { appearance: none; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--navy); cursor: pointer; padding: 0 4px; }
.drawer .body { overflow-y: auto; padding: 10px 16px 18px; font-size: 0.88rem; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.drawer .body h3 { font-size: 1.15rem; margin: 12px 0 4px; }
.drawer .body ul { padding-left: 18px; margin: 4px 0; }
.drawer .lede { font-size: 0.95rem; }
.drawer .note { font-size: 0.76rem; color: var(--ink-soft); }
.drawer .rule { height: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-top: 2px; margin: 12px 0; }
.drawer .site-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.drawer .site-links a, .drawer .site-links button { appearance: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font: 600 0.78rem var(--sans); color: var(--steel); text-decoration: none; background: #fff; cursor: pointer; }
.drawer-credit { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 0.8rem; }
.drawer-credit img { width: 40px; height: 40px; }
code { font-size: 0.8em; background: var(--mist); padding: 1px 4px; border-radius: 3px; }

.leaflet-control-attribution { font-size: 10px; }

/* < 720: phone */
@media (max-width: 719px) {
  header.app-header h1 { font-size: 1.32rem; }
  header.app-header .sub { font-size: 0.68rem; }
  .leaflet-bottom.leaflet-left .map-legend { margin: 0 0 22px 8px; }
  .map-legend { font-size: 0.7rem; max-width: 200px; }
  .results-list { max-height: 34vh; }
  .locate-btn { top: 84px; }
}
@media (max-width: 719px) {
  header.app-header .sub .tail { display: none; }
}
/* 720-899: tablet */
@media (min-width: 720px) {
  header.app-header { padding: 10px 18px; }
  header.app-header h1 { font-size: 1.8rem; }
  header.app-header .sub { font-size: 0.8rem; }
  .results-list { max-height: 30vh; }
  .drawer {
    left: auto; right: 16px; bottom: 16px; width: 400px; max-height: calc(100% - 32px);
    border-radius: 16px; transform: translateX(110%);
  }
  .drawer.is-open { transform: none; }
}
/* >= 900: desktop, list beside the map */
@media (min-width: 900px) {
  body {
    display: grid;
    grid-template-columns: minmax(320px, 360px) 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "banner banner" "header header" "dock map" "footer footer";
  }
  .preview-banner { grid-area: banner; }
  header.app-header { grid-area: header; }
  #map { grid-area: map; height: auto; }
  .dock { grid-area: dock; border-top: 0; border-right: 3px solid var(--navy); }
  .chips { flex-wrap: wrap; overflow: visible; }
  .list-toggle { display: none; }
  .results { display: flex !important; flex-direction: column; flex: 1 1 auto; }
  .results-list { flex: 1 1 auto; max-height: none; }
  footer.credit { grid-area: footer; }
  header.app-header h1 { font-size: 2rem; }
}
/* Welcome pop-up: modeled on the Warrenton map's welcome modal
   (shown on every page load, no remembered dismissal). */
.welcome-backdrop { display: none; position: fixed; inset: 0; background: rgba(36, 50, 69, 0.55); z-index: 5000; }
.welcome-backdrop.is-open { display: block; }
.welcome-modal {
  display: none; position: fixed; z-index: 5001; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px); max-width: 440px; max-height: calc(var(--app-height, 100svh) - 32px); overflow: auto;
  background: #fff; color: var(--navy); border-radius: 14px; box-shadow: var(--shadow);
  border-top: 5px solid var(--navy); padding: 18px 22px 16px; box-sizing: border-box;
}
.welcome-modal::before { content: ""; display: block; border-top: 1px solid var(--brick); margin: -12px -8px 12px; }
.welcome-modal.is-open { display: block; }
.welcome-kicker { text-align: center; margin: 0; font: 700 0.7rem var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--steel); }
.welcome-modal h2 { text-align: center; font-size: 1.9rem; line-height: 1.1; margin: 2px 0 4px; }
.welcome-tagline { text-align: center; margin: 0; font: 600 1.05rem var(--serif); color: var(--brick); letter-spacing: 0.02em; }
.welcome-rule { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; color: var(--brick); font-size: 0.6rem; }
.welcome-rule::before, .welcome-rule::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.welcome-copy p { margin: 0 0 10px; font-size: 0.92rem; line-height: 1.5; }
.welcome-link a { color: var(--steel); font-weight: 600; }
.welcome-cta {
  display: block; width: 100%; appearance: none; border: 0; cursor: pointer; text-align: center;
  background: var(--brick); color: #fff; font: 700 1rem var(--sans); padding: 12px 16px; border-radius: 10px; margin-top: 4px;
}
.welcome-cta:hover, .welcome-cta:focus-visible { background: #72262c; outline: 2px solid var(--steel); outline-offset: 2px; }
.welcome-credit { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 0.76rem; color: var(--navy); }
.welcome-credit img { width: 28px; height: 28px; }
body.welcome-open { overflow: hidden; }
@media (max-width: 719px) {
  .welcome-modal { padding: 16px 18px 14px; }
  .welcome-modal h2 { font-size: 1.6rem; }
  .welcome-copy p { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop, .pin { transition: none; }
}
