:root {
  --bg: #1b2a1d;            /* dark green field at the image edges */
  --panel-bg: #101912;
  --tooltip-bg: rgba(14, 22, 16, 0.94);
  --panel-border: rgba(214, 228, 216, 0.14);
  --text: #e9efe7;
  --text-muted: #a9b8aa;
  --accent: #8fa6d6;        /* Lumon window blue, lightened */
  --navy: #223446;          /* Lumon logo fill */
  --light-blue: #cfdce2;    /* Salt's Neck sign border */
  --green: var(--bg);
  --dim: 0.5;               /* dimming around a selected (clicked) location */
  --dim-hover: 0.25;        /* lighter dimming while just hovering */
  /* SF Pro on Apple devices (via the system font); SF Pro can't be served
     as a web font, so other platforms get their own UI font */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ratio: calc(1512 / 982);  /* base image aspect ratio */
  --panel-min: 340px;         /* side panel never gets narrower than this */
  --panel-min-h: 260px;       /* stacked panel never gets shorter than this */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body { overflow: hidden; }

/* ---------- Layout: map pinned left, panel fills the rest ----------
   The map is always as tall as the window. The panel takes whatever width
   is left, but at least --panel-min; if that leaves too little room for the
   whole map, the map scrolls sideways instead of shrinking (so there's
   never empty space around it). On tall/narrow screens the panel moves
   below the map instead. */

.app {
  display: grid;
  grid-template-columns: min(calc(100dvh * var(--ratio)), calc(100vw - var(--panel-min))) 1fr;
  height: 100dvh;
}

.stage {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 228, 216, 0.3) transparent;
}

.art {
  position: relative;
  height: 100dvh;
  aspect-ratio: 1512 / 982;
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-aspect-ratio: 3 / 2) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: min(calc(100vw / var(--ratio)), calc(100dvh - var(--panel-min-h))) 1fr;
  }
  .stage {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .art {
    width: 100vw;
    height: auto;
  }
}

.hotspots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Buffer around the lit area: the stroke extends half its width outside
   each shape, so 36px ≈ 18px of breathing room (in base-image pixels) */
#spotlight-cutout {
  stroke-width: 36px;
  stroke-linejoin: round;
}

/* Everything outside the active section darkens */
.dim {
  fill: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.hotspots.has-spotlight .dim { opacity: var(--dim-hover); }
.hotspots.is-selected-spotlight .dim { opacity: var(--dim); }

.hotspot {
  fill: transparent;   /* invisible but still clickable */
  cursor: pointer;
  outline: none;
}

/* ---------- Hover label ---------- */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  padding: 6px 10px;
  border-radius: 4px;
  background: var(--tooltip-bg);
  border: 1px solid var(--panel-border);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

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

/* Three sections stacked: the main one on top (fills the remaining space,
   scrolls if its content is long), then locations, then sources. When the
   panel itself is narrow (phones, or a squeezed side panel) the whole panel
   scrolls as one column instead. */
.panel {
  --pad-y: clamp(24px, 4vw, 48px);
  --pad-x: clamp(20px, 3vw, 40px);
  container-type: inline-size;
  min-width: 0;
  font-weight: 700;         /* all panel text is bold */
  /* Droplet icon used in place of arrows; drawn with currentColor */
  --droplet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 26'%3E%3Cpath d='M10 0C10 0 0 11.6 0 16.6A10 9.4 0 0 0 20 16.6C20 11.6 10 0 10 0Z'/%3E%3C/svg%3E");
  min-height: 0;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
}


.panel-inner {
  display: grid;
  /* Bottom sections take the height of their content, so they're never
     cut off; the top section gets the rest and scrolls if it must */
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  overflow-y: auto;  /* safety net if the bottom content alone is taller */
}

/* Each section sets its own colors; the text styles below read --text,
   --text-muted and --panel-border, so they follow automatically */
.panel-main {
  --text: #fff;
  --text-muted: #b4c0cf;
  --panel-border: rgba(255, 255, 255, 0.16);
  min-height: 0;
  overflow-y: auto;
  padding: calc(var(--pad-y) * 0.5) var(--pad-x);
  background: var(--navy);
  color: var(--text);
}
.panel-main > * { max-width: 560px; }

/* Center the intro/details vertically. Auto margins (rather than
   justify-content) fall back to top-aligned when the text is taller than
   the section, so the start of long text never gets cut off. */
.panel-main { display: flex; flex-direction: column; }
.panel-intro,
.panel-detail { margin-block: auto; }
.panel-intro[hidden],
.panel-detail[hidden] { display: none; }

.panel-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.panel-cell {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px var(--pad-x);
  color: var(--text);
}
.panel-cell-places {
  --text: var(--navy);
  --text-muted: #4a5d70;
  --accent: #0d4273;        /* lake blue from the art: readable on light blue */
  --panel-border: rgba(34, 52, 70, 0.2);
  background: var(--light-blue);
}
@container (max-width: 400px) {
  /* One scrolling column: navy grows to fill, then places, then sources */
  .panel-inner {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .panel-main { flex: 1 0 auto; overflow: visible; }
  .panel-bottom { flex: none; }
  .panel-cell { overflow: visible; padding-block: 24px; }
}

.panel-cell-sources {
  --text: #fff;
  --text-muted: #c3cfc4;
  --panel-border: rgba(255, 255, 255, 0.16);
  background: var(--green);
}

@media (max-aspect-ratio: 3 / 2) {
  .panel { border-left: 0; border-top: 1px solid var(--panel-border); }
}

.intro-title,
.panel-title {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.panel-title:focus { outline: none; }

.intro-body p:last-child { margin-bottom: 0; }

/* Hidden on screen (the title is in the art) but read by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.intro-body:empty { display: none; }

.panel-subtitle {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: 15px;
}
.panel-subtitle:empty { display: none; }
.panel-title + .panel-subtitle:empty + .panel-body { margin-top: 20px; }

.intro-body p,
.panel-body p {
  margin: 0 0 1em;
  color: var(--text);
  font-size: 16px;
}

.list-heading {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 20px;
  text-transform: uppercase;
}

.list-description {
  margin: -4px 0 10px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}

.place-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.place-list button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
/* Droplet icons (the shape is --droplet on .panel) */
.place-list button::after,
.link-list a::after {
  content: "";
  flex: none;
  display: inline-block;
  width: 0.6em;
  height: 0.78em;
  background: currentColor;
  -webkit-mask: var(--droplet) center / contain no-repeat;
  mask: var(--droplet) center / contain no-repeat;
}
.place-list button { align-items: center; }
.place-list button::after { color: var(--text-muted); }
.place-list button:hover,
.place-list button:focus-visible { color: var(--accent); }
.place-list button:hover::after,
.place-list button:focus-visible::after { color: var(--accent); }
.place-list button[aria-current] { color: var(--accent); }
.place-list button[aria-current]::after { color: var(--accent); }

.sources-body p {
  margin: 0 0 0.75em;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.panel-links {
  margin-top: 20px;
}

.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.link-list li {
  padding: 5px 0;
  color: var(--text-muted);
  font-size: 15px;
}
.link-list a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--panel-border);
  text-underline-offset: 3px;
}
.link-list a::after { margin-left: 0.4em; color: var(--text-muted); vertical-align: -0.05em; }
.link-list a:hover,
.link-list a:focus-visible { color: var(--accent); text-decoration-color: currentColor; }

@media (max-width: 640px) {
  .intro-title, .panel-title { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .dim { transition: none; }
}

/* Links inside panel text ([text](url) in sections.js) */
.intro-body a,
.panel-body a,
.sources-body a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 3px;
}
.intro-body a:hover,
.panel-body a:hover,
.sources-body a:hover,
.intro-body a:focus-visible,
.panel-body a:focus-visible,
.sources-body a:focus-visible { text-decoration-color: currentColor; }

/* ---------- Image viewer ---------- */

/* Positioned over the map by main.js (--area-* = the map's visible box) */
.lightbox {
  position: fixed;
  inset: auto;
  left: var(--area-x, 50vw);
  top: var(--area-y, 50vh);
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  max-width: calc(var(--area-w, 100vw) - 48px);
  max-height: calc(var(--area-h, 100dvh) - 48px);
  margin: 0;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  overflow: visible;
}
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.6); }

.lightbox-img {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: calc(var(--area-h, 100dvh) - 48px - 24px - 40px);
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-caption {
  margin: 10px 4px 0;
  font-size: 14px;
}
.lightbox-caption:empty { display: none; }

.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.lightbox-close:hover,
.lightbox-close:focus-visible { background: var(--light-blue); color: var(--navy); }

/* ---------- ?debug ---------- */

.is-debug .hotspot polygon,
.is-debug .hotspot path {
  fill: rgba(255, 0, 200, 0.18);
  stroke: #ff3bd4;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.is-debug .debug-label {
  fill: #fff;
  font: 600 18px var(--font);
  paint-order: stroke;
  stroke: #000;
  stroke-width: 4px;
  pointer-events: none;
}
