/* =========================================================
   dumaguete.uk — map.css
   Mobile-first. The map fills viewport minus top banner.
   Chips scroll horizontally on narrow screens. POI detail
   opens as a bottom sheet on mobile, side panel on desktop.
   ========================================================= */

.page-map {
  overscroll-behavior: none;
}

.page-map .topbar { position: sticky; }

.page--map {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--bar-h));
  gap: 8px;
  padding-bottom: 16px !important;
}

/* Hero band inside .page wrapper — .page handles horizontal padding, hero just resets its own */
.hero-band {
  width: 100%;
  padding: 0;
  margin-bottom: 4px;
}
.hero-band .hero__row { width: 100%; margin: 0 auto; }

/* ---------- CHIPS (horizontal scroll on narrow screens) ---------- */
.map-chips {
  display: flex;
  gap: 6px;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}
.map-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 13px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  --chip-accent: var(--accent);
  transition: color 0.15s var(--ease), background 0.15s var(--ease),
              border-color 0.15s var(--ease);
}
.chip:hover { color: var(--chip-accent); border-color: var(--chip-accent); }
.chip.is-on {
  color: #FFFFFF;
  background: var(--chip-accent);
  border-color: var(--chip-accent);
}
.chip.is-empty {
  color: var(--ink-faint);
  opacity: 0.55;
}
.chip.is-empty:hover { opacity: 0.85; }
.chip__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-faint);
  background: var(--surface-alt);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.chip.is-on .chip__count {
  color: var(--chip-accent);
  background: color-mix(in srgb, #FFFFFF 90%, transparent);
}

/* Home page embeds the map as a section instead of the whole
   page — give the split a fixed height so it doesn't fight the
   surrounding page layout. */
.section--map .map-split {
  flex: none;
  min-height: 0;
  height: 70vh;
}
.map-split {
  flex: 1;
  min-height: 500px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0;
}

.map-list {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: width 0.25s var(--ease);
}
.map-list.is-collapsed .map-list__scroll,
.map-list.is-collapsed .map-list__find,
.map-list.is-collapsed .map-list__empty { display: none; }

/* The panel's own search line. It sits above the names and
   drives the same filter as the search at the top of the page,
   so a name typed here narrows the list and the pins together. */
.map-list__find {
  flex: 0 0 auto;
  margin: 8px 42px 6px 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
}
.map-list__find::placeholder { color: var(--ink-faint); }
.map-list__find:focus { border-color: var(--accent); }

.map-list__toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
/* On mobile the list sits above the map (row layout, not column),
   so the corner-right toggle looks off-axis. Center it instead. */
@media (max-width: 900px) {
  .map-list__toggle {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  .map-list.is-collapsed .map-list__toggle {
    right: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
.map-list__toggle:hover { color: var(--accent); background: var(--surface-alt); }
.map-list__toggle-icon { transition: transform 0.25s var(--ease); }
.map-list:not(.is-collapsed) .map-list__toggle-icon { transform: rotate(180deg); }
.map-list.is-collapsed .map-list__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}
.map-list__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 4px 8px;
  -webkit-overflow-scrolling: touch;
}
.map-list__empty {
  margin: 0;
  padding: 20px 16px;
  font-size: 0.88rem;
  color: var(--ink-faint);
  text-align: center;
}

.list-group {
  margin: 0;
  padding: 0;
}
.list-group__header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 14px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.list-group__header:first-child { margin-top: 0; }

.list-item {
  display: block;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s var(--ease);
}
.list-item:hover,
.list-item.is-active {
  background: var(--surface-alt);
}
.list-item__row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.list-item__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.list-item__name {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item__meta {
  margin: 3px 0 0 18px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.list-item__meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item__cat {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.verified-check {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.list-item__starrow {
  margin: 2px 0 0 18px;
}
.list-item__stars {
  color: #E9B23A;
  font-size: 0.82rem;
  letter-spacing: 1px;
}
.poi-sheet__stars {
  text-align: center;
  color: #E9B23A;
  font-size: 1.15rem;
  letter-spacing: 3px;
  margin: 4px 0 12px;
}
.poi-sheet__stars[hidden] { display: none; }

/* Highlighted from map or list hover */
.poi.is-hover .poi__dot {
  filter: drop-shadow(0 0 6px currentColor);
}
.poi.is-active .poi__dot {
  filter: drop-shadow(0 0 4px currentColor);
}

/* ---------- MAP FRAME (now inside split) ---------- */
.map-frame {
  position: relative;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.map-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  --tx: 0px;
  --ty: 0px;
  --tz: 1;
}
.map-canvas.is-panning { cursor: grabbing; }

#basemap,
.poi-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translate(var(--tx), var(--ty)) scale(var(--tz));
  transform-origin: 0 0;
  transition: transform 0.25s var(--ease);
  pointer-events: none;
}
.map-canvas.is-panning #basemap,
.map-canvas.is-panning .poi-layer { transition: transform 0.02s linear; }
.poi-layer { pointer-events: auto; touch-action: none; }
.poi-layer .poi { pointer-events: auto; }

.map-canvas.is-ready #basemap { pointer-events: none; }

/* ---------- ZOOM CONTROLS ---------- */
.map-zoom {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}
.zoom-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.zoom-btn:hover { color: var(--accent); background: var(--surface-alt); }
.zoom-btn:active { transform: scale(0.95); }

/* ---------- ATTRIBUTION ---------- */
.map-attrib {
  position: absolute;
  bottom: 6px;
  left: 10px;
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
  pointer-events: auto;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.map-attrib a { color: var(--ink-soft); }

/* ---------- POI SHEET (mobile: bottom; desktop: side) ---------- */
.poi-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 250;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px var(--shadow-b);
  transform: translateY(100%);
  transition: transform 0.28s var(--ease);
  max-height: 60vh;
  overflow-y: auto;
}
.poi-sheet:not([hidden]) { transform: translateY(0); }
.poi-sheet[hidden] { display: block; visibility: hidden; }

.poi-sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.poi-sheet__close:hover { color: var(--ink); background: var(--surface-alt); }

.poi-sheet__tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-wash);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.poi-sheet__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 10px;
  color: var(--ink);
}
.poi-sheet__lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 14px;
}
.poi-sheet__line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.poi-sheet__line svg {
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--ink-faint);
}
.poi-sheet__line span { flex: 1; min-width: 0; }
.poi-sheet__line--contact {
  font-size: 0.75rem;
  padding: 1px;
  margin: 1px;
}
.poi-sheet__line--contact svg { margin-top: 2px; }
.poi-sheet__line--contact a {
  color: inherit;
  text-decoration: none;
  word-break: break-word;
}
.poi-sheet__line--contact a:hover { text-decoration: underline; }
#poi-sheet-verified-line { color: var(--accent); font-weight: 500; }
#poi-sheet-verified-line svg { color: currentColor; }

.poi-sheet__actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.poi-sheet__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 10px;
  text-decoration: none;
  transition: filter 0.15s var(--ease);
}
.poi-sheet__btn:hover { text-decoration: none; filter: brightness(0.95); }
.poi-sheet__btn svg { flex-shrink: 0; }

/* ---------- POI MARKERS ---------- */
.poi {
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.2s var(--ease);
  transform-origin: center;
  transform-box: fill-box;
}
.poi__dot {
  transition: r 0.15s var(--ease);
}
.poi:hover .poi__dot,
.poi.is-active .poi__dot,
.poi.is-hover .poi__dot { r: 8; }
.poi__label {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease);
}
.poi:hover .poi__label,
.poi.is-active .poi__label,
.poi.is-hover .poi__label {
  opacity: 1;
}
.poi.is-dim { opacity: 0.15; }
.poi.is-dim .poi__label { opacity: 0; }

/* Verified badge stays visible when its POI is */
.poi__badge {
  filter: drop-shadow(0 0 1px var(--surface));
}

/* ---------- DESKTOP: SIDE PANEL ---------- */
@media (min-width: 900px) {
  .page--map { gap: 12px; }
  .map-chips { flex-wrap: wrap; overflow: visible; }
  .map-split {
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 14px;
    transition: grid-template-columns 0.25s var(--ease);
  }
  .map-split.list-collapsed { grid-template-columns: 44px minmax(0, 1fr); }
  .poi-sheet {
    top: calc(var(--bar-h) + 12px);
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 340px;
    max-height: none;
    border-radius: 16px;
    border: 1px solid var(--line);
    border-top: 1px solid var(--line);
    box-shadow: var(--shadow-lift);
    transform: translateX(16px);
    opacity: 0;
    transition: transform 0.28s var(--ease), opacity 0.28s var(--ease);
  }
  .poi-sheet:not([hidden]) { transform: translateX(0); opacity: 1; }
}

/* Mobile: collapsed removes list row entirely */
@media (max-width: 899px) {
  .map-split.list-collapsed { grid-template-rows: 44px minmax(0, 1fr); }
}

/* ---------- MAP-COLOUR VARIABLES (per theme) ---------- */
:root {
  --map-land:       var(--surface);
  --map-brgy-line:  var(--line-strong);
  --map-brgy-fill:  transparent;
  --map-water:      color-mix(in srgb, var(--accent) 15%, transparent);
  --map-coast:      var(--accent);
  --map-green:      color-mix(in srgb, var(--accent-2) 12%, transparent);
  --map-road-major: var(--surface-alt);
  --map-road-minor: var(--surface-alt);
  --map-label:     var(--ink-soft);
}
[data-theme="night-slate"] {
  --map-land:       var(--surface);
  --map-water:      color-mix(in srgb, var(--accent-2) 20%, transparent);
  --map-green:      color-mix(in srgb, var(--accent-2) 18%, transparent);
  --map-road-major: var(--surface-alt);
  --map-road-minor: var(--surface-alt);
}

/* Rails visible on every page (including map) */

@media (prefers-reduced-motion: reduce) {
  .poi-sheet, #basemap, .poi-layer, .poi { transition: none !important; }
}
