/* Hallmark · macrostructure: App Tool (spyglass) · tone: white liquid-glass · designed-as-app
 * genre: modern-minimal · theme: custom "white glass" over map (OKLCH tokens)
 * Note: lens masks use #000/transparent as alpha stops, not palette. */
:root {
  /* white glass surfaces (frosted, floats over the maps) */
  --glass: oklch(1 0 0 / 0.55);
  --glass-strong: oklch(1 0 0 / 0.82);
  --glass-soft: oklch(1 0 0 / 0.36);
  --glass-active: oklch(0.22 0.02 255 / 0.9);   /* dark "selected" */
  --glass-active-ink: oklch(0.97 0.005 250);
  --overlay: oklch(0.18 0.03 255 / 0.45);

  /* hairlines + sheen */
  --line: oklch(0.15 0.02 255 / 0.12);
  --line-strong: oklch(0.15 0.02 255 / 0.26);
  --sheen: oklch(1 0 0 / 0.75);

  /* text */
  --ink: oklch(0.22 0.02 255);
  --ink-dim: oklch(0.42 0.02 255);
  --ink-faint: oklch(0.52 0.02 255);

  /* accent (antique gold) */
  --gold: oklch(0.72 0.12 80);
  --gold-ink: oklch(0.45 0.09 75);
  --gold-line: oklch(0.72 0.12 80 / 0.55);

  /* map paper (behind tiles) */
  --paper: oklch(0.92 0.012 90);

  /* shadows */
  --shadow: 0 16px 40px oklch(0.15 0.03 255 / 0.28);
  --shadow-sm: 0 6px 20px oklch(0.15 0.03 255 / 0.2);

  /* radii */
  --r-sm: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* type + motion */
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.18s;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--paper); color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------- glass base */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--sheen);
}

/* ---------------------------------------------------------------- stage */
#stage { position: fixed; inset: 0; z-index: 0; background: var(--paper); }
#stage, #stage * { cursor: none !important; }
.map { position: absolute; inset: 0; }
#mapB { z-index: 1; }
#mapA {
  z-index: 2; pointer-events: none; opacity: 0; transition: opacity var(--dur) var(--ease-out);
  --lx: 50%; --ly: 50%; --r0: 80px; --r1: 95px; --r2: 110px;
  -webkit-mask-image: radial-gradient(circle at var(--lx) var(--ly),
      #000 var(--r0), rgba(0, 0, 0, .55) var(--r1), transparent var(--r2));
  mask-image: radial-gradient(circle at var(--lx) var(--ly),
      #000 var(--r0), rgba(0, 0, 0, .55) var(--r1), transparent var(--r2));
  /* the lens uses one gradient per edge (set from JS); intersect them */
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
body.lens-on #mapA { opacity: 1; }
.leaflet-container { background: var(--paper); font: inherit; }
.leaflet-container.historic-map {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(135deg, transparent 0 7px,
    oklch(0.58 0.025 85 / 0.22) 7px 8px);
}

#mapFlash {
  z-index: 4; opacity: 0; pointer-events: none; background: transparent !important;
  --fr: 0px; --fr2: 0px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%,
      #000 var(--fr), transparent var(--fr2));
  mask-image: radial-gradient(circle at 50% 50%,
      #000 var(--fr), transparent var(--fr2));
}

/* ------------------------------------------------------------------ years */
.year-controls {
  position: fixed; left: 14px; top: 14px; z-index: 100;
  display: flex; align-items: flex-end; gap: 12px; max-width: 70vw;
}
.years {
  position: relative; display: flex; padding: 3px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--glass); box-shadow: var(--shadow-sm), inset 0 1px 0 var(--sheen);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
}
.year-indicator {
  position: absolute; top: 3px; left: 0; height: calc(100% - 6px);
  border-radius: var(--r-pill); background: var(--glass-active); pointer-events: none;
}
.years.ready .year-indicator {
  transition: transform .35s var(--ease-out), width .35s var(--ease-out);
}
.year-controls > .glass-btn { flex: none; }
.years button {
  position: relative; z-index: 1; border: 1px solid transparent; background: transparent; color: var(--ink);
  border-radius: var(--r-pill); padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}
.years button:hover { background: var(--glass-strong); }
.years button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.years button.on { background: transparent; color: var(--glass-active-ink); }
.years button.previewing { border-color: var(--gold-line); }

/* -------------------------------------------------------------- controls */
.controls {
  position: fixed; right: 14px; bottom: 14px; z-index: 100;
  display: flex; gap: 6px;
}
.year-controls::before, .controls::before {
  content: ""; position: absolute; inset: -18px; z-index: -1; cursor: default;
}
.glass-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--glass); color: var(--ink); cursor: pointer;
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--sheen);
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}
.glass-btn:hover { background: var(--glass-strong); }
.glass-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.glass-btn svg { width: 20px; height: 20px; }
.glass-btn.on { background: var(--glass-active); border-color: var(--glass-active);
  color: var(--glass-active-ink); }
.zoom-control { display: flex; margin-left: 10px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--sheen); }
.zoom-control .glass-btn { box-shadow: none; }
.zoom-control .glass-btn:first-child {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.zoom-control .glass-btn:last-child {
  border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px;
}
.zoom-control .glass-btn:focus-visible { position: relative; z-index: 1; }

/* ---------------------------------------------------------- year preview */
#yearPreview {
  position: fixed; z-index: 200; width: 252px; padding: 6px 6px 2px;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  opacity: 0; visibility: hidden;
  transition: opacity .24s ease, visibility 0s linear .24s;
  pointer-events: none;
}
#yearPreview.on { opacity: 1; visibility: visible; transition-delay: 0s; }
#yearPreview .mini { width: 240px; height: 240px; border-radius: 14px; overflow: hidden; background: var(--paper); }
#yearPreview .cap { display: flex; justify-content: space-between; gap: 8px; padding: 6px 3px 3px; font-size: 11px; color: var(--ink-dim); }
#yearPreview .cap b { color: var(--gold-ink); font-weight: 600; }
#yearPreview::after {
  content: ""; position: absolute; top: -7px; left: var(--arrow-x, 50%); margin-left: -7px;
  border: 7px solid transparent; border-bottom-color: var(--line); border-top: 0;
}

/* ------------------------------------------------------------------ info */
#info { position: fixed; inset: 0; z-index: 300; background: var(--overlay);
  display: grid; place-items: center; padding: 20px; }
#info.hidden { display: none; }
.info-card {
  position: relative; width: min(560px, 92vw); max-height: 84vh; overflow: auto;
  padding: 28px 30px 24px; border-radius: var(--r-lg);
  animation: info-in .24s var(--ease-out);
}
@keyframes info-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.info-card .close { position: absolute; right: 14px; top: 14px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 650; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-ink); }
.info-card h2 { margin: 0 0 12px; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.info-card h3 { margin: 20px 0 8px; font-size: 13px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint); }
.info-card p { margin: 0 0 12px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.info-card ul { margin: 0; padding-left: 18px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.info-card li { margin-bottom: 7px; }
.info-card b { color: var(--ink); font-weight: 600; }
.info-card .credits { list-style: none; padding-left: 0; }
.info-card .credits li { position: relative; padding-left: 16px; }
.info-card .credits li::before { content: ""; position: absolute; left: 0; top: .6em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.info-card .fine { margin: 18px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.info-card a { color: var(--gold-ink); text-decoration: none; border-bottom: 1px solid var(--gold-line); }
.info-card a:hover { color: var(--ink); }

/* ---------------------------------------------------------- attribution */
.attribution {
  position: fixed; bottom: 14px; left: 14px; z-index: 100;
  font-size: 11px; color: var(--ink-dim);
  text-shadow: 0 1px 3px oklch(1 0 0 / 0.85);
  pointer-events: none; white-space: nowrap;
}

/* ---------------------------------------------------------------- notice */
.notice {
  position: fixed; top: 40px; left: 50%; transform: translateX(-50%); z-index: 150;
  max-width: calc(100vw - 28px); padding: 7px 14px; border-radius: var(--r-pill);
  font-size: 12.5px; color: var(--ink); text-align: center; pointer-events: none;
}
.notice[hidden] { display: none; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 560px) {
  .year-controls { max-width: calc(100vw - 28px); gap: 8px; }
  .years { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .years::-webkit-scrollbar { display: none; }
  .years button { padding: 7px clamp(3px, 1.5vw, 10px); font-size: 12px; }
  .controls { gap: 4px; }
  .glass-btn { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  #mapA, #yearPreview, .info-card { transition: none; animation: none; }
  .years button, .years.ready .year-indicator, .glass-btn { transition: none; }
}

/* ------------------------------------------------------ historical places */
.poi-layer { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.poi-layer[hidden], .poi-marker[hidden], .poi-image-button[hidden] { display: none; }
.poi-marker {
  position: absolute; top: 0; left: 0; width: 44px; height: 44px;
  display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: transparent; pointer-events: auto; cursor: pointer;
}
.poi-dot {
  display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #fff;
  border-radius: 50%; background: #a74d14; color: #fff; font: 700 12px/1 var(--font-ui);
  box-shadow: 0 1px 4px #25201555; pointer-events: none;
}
.poi-image-marker .poi-dot { background: #245b76; border-radius: 5px; }
.poi-group-marker .poi-dot { width: 30px; height: 30px; background: #333239; }
.poi-marker:hover .poi-dot, .poi-marker.is-highlighted .poi-dot { box-shadow: 0 0 0 3px #fff, 0 1px 6px #25201588; }
.poi-marker:focus-visible { outline: 2px solid #252b32; outline-offset: -3px; box-shadow: inset 0 0 0 5px #fff; }

.poi-toggle { position: fixed; top: 14px; right: 14px; z-index: 120; }
.poi-x-icon, .poi-toggle.on .poi-scroll-icon { display: none; }
.poi-toggle.on .poi-x-icon { display: block; }
.poi-toggle.on, .poi-toggle.on:hover {
  background: transparent; border-color: transparent; box-shadow: none; color: var(--ink);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.poi-panel {
  position: fixed; inset: 0 0 0 auto; z-index: 90;
  width: min(240px, 72vw); overflow-y: auto;
  color: var(--ink); background: oklch(0.98 0.008 85 / 0.95);
  border-left: 1px solid var(--line); box-shadow: 0 12px 38px #29231b33;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  visibility: hidden; pointer-events: none; transform: translateX(100%);
  transition: transform .35s var(--ease-out), visibility 0s linear .35s;
}
.poi-panel.is-open { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
.poi-panel-header {
  display: flex; flex-direction: column; align-items: flex-start; gap: 15px;
  min-height: 58px; padding: 14px 70px 0 17px;
}
.poi-panel-header span { font-size: 9px; font-weight: 700; letter-spacing: .09em; color: var(--ink-dim); line-height: 1.4; }
.poi-back {
  width: 44px; height: 44px; margin-left: -8px; padding: 0; border: 0; border-radius: 50%;
  font: 22px var(--font-ui); background: transparent; color: var(--ink); cursor: pointer;
}
.poi-back:hover { background: #252b3212; }
.poi-back[hidden] { display: none; }
.poi-content { padding: 21px 17px 22px; }
.poi-panel-header:has(.poi-back:not([hidden])) + .poi-content { padding-top: 14px; }
.poi-content h2 { margin: 0 0 12px; font-size: 21px; line-height: 1.14; letter-spacing: -.025em; }
.poi-period { margin: 0 0 10px; color: #8a5b17; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.poi-list-intro { margin: 0 0 20px; font-size: 12px; line-height: 1.5; color: var(--ink-dim); }
.poi-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 44px; padding: 10px 2px; border: 0; background: transparent;
  text-align: left; color: var(--ink); font: 13px/1.35 var(--font-ui); cursor: pointer;
}
.poi-list-item:hover { color: #8a5b17; }
.poi-story { margin: 0; font-size: 13px; line-height: 1.55; }
.poi-location { margin-top: 12px; }
.poi-content a { color: #79500f; font-size: 11px; line-height: 1.4; text-decoration: underline; text-underline-offset: 3px; }
.poi-content a:hover { color: var(--ink); }
.poi-image-link { display: inline-block; margin-top: 5px; }
.poi-sources-title { margin: 23px 0 9px; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.poi-sources { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.poi-map-action {
  display: block; min-height: 44px; margin-top: 8px; padding: 0 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer;
}

.poi-figure { margin: 18px 0 5px; }
.poi-figure img { display: block; width: 100%; height: auto; border-radius: 9px; }
.poi-figure figcaption { margin-top: 7px; color: var(--ink-dim); font-size: 10px; line-height: 1.4; }
.poi-figure figcaption span { display: block; }
.poi-image-button { display: block; width: 100%; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: zoom-in; }
.poi-lightbox {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 56px 16px 24px;
  border: 0; background: transparent; color: #fff;
}
.poi-lightbox[open] { display: grid; place-items: center; }
.poi-lightbox::backdrop { background: #101217ed; }
.poi-lightbox-content { display: grid; justify-items: center; gap: 10px; max-width: 100%; }
.poi-lightbox img { max-width: 100%; max-height: calc(100dvh - 115px); object-fit: contain; }
.poi-lightbox a { color: #fff; }
.poi-lightbox-close {
  position: absolute; right: 16px; top: 10px; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: #ffffff30; color: #fff; font-size: 30px; cursor: pointer;
}

#stage { transition: filter .3s ease; }
body.poi-open #stage { filter: grayscale(1); }
body.poi-open #stage, body.poi-open #stage * { cursor: auto !important; }
body.poi-open #mapA { opacity: 0; }
body.poi-open .controls { right: calc(min(240px, 72vw) + 14px); }
body:not(.lens-on) #lensCredit, body.poi-open #lensCredit { display: none; }
#yearPreview .cap { flex-wrap: wrap; }
#pvNotice { flex-basis: 100%; color: #8a3218; }
@media (max-width: 760px) {
  .poi-panel { top: 64px; }
}
@media (max-width: 560px) {
  .year-controls { max-width: calc(100vw - 78px); }
  body.poi-open .controls { flex-direction: column; bottom: 70px; }
  body.poi-open .zoom-control { flex-direction: column; margin-left: 0; }
  body.poi-open .zoom-control .glass-btn:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
  body.poi-open .zoom-control .glass-btn:last-child { border-radius: 0 0 var(--r-sm) var(--r-sm); margin: -1px 0 0; }
  body.poi-open .attribution {
    max-width: calc(max(28vw, 100vw - 240px) - 24px); white-space: normal;
  }
  body.poi-open .notice {
    top: 68px; left: 8px; transform: none; border-radius: 8px; padding: 5px;
    max-width: calc(max(28vw, 100vw - 240px) - 16px); overflow-wrap: anywhere;
  }
}
@media (prefers-reduced-motion: reduce) {
  #stage, .poi-panel { transition: none; }
}

/* Individual historical points */
.poi-marker { width: 22px; height: 22px; cursor: default; }
.poi-dot, .poi-image-marker .poi-dot { width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(235, 121, 31, .85); box-shadow: none; transition: transform .6s ease, opacity .6s ease; }
.poi-marker:hover .poi-dot, .poi-marker.is-highlighted .poi-dot { transform: scale(1.3); opacity: 0; box-shadow: none; }
.poi-ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(235, 121, 31, .85); opacity: 0; pointer-events: none; }
.poi-marker:hover .poi-ring, .poi-marker.is-highlighted .poi-ring { animation: poi-pulse 2.4s ease-out infinite; }
.poi-marker:hover .poi-ring-two, .poi-marker.is-highlighted .poi-ring-two { animation-delay: 1.2s; }
@keyframes poi-pulse { 0% { transform: scale(.25); opacity: .7; } 100% { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .poi-marker:hover .poi-dot, .poi-marker.is-highlighted .poi-dot { opacity: 1; transform: none; } .poi-marker:hover .poi-ring, .poi-marker.is-highlighted .poi-ring { animation: none; } }

/* Align the panel label with the centre of its close control. */
.poi-panel-header { padding-top: 29px; }
@media (max-width: 560px) { .poi-panel-header { padding-top: 27px; } }

/* Compact navigation and desktop map previews. */
.poi-list-item { min-height: 0; padding: 5px 2px; }
.poi-list-item span { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #9a8b77; }
.poi-next { display: block; width: 100%; margin-top: 26px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.poi-next:hover { background: #252b3212; }
.poi-tooltip { display: none; }
@media (hover: hover) and (pointer: fine) {
 .poi-marker .poi-tooltip { position: absolute; bottom: 31px; left: 50%; transform: translateX(-50%); width: 164px; padding: 6px; border-radius: 10px; background: #faf8f2; color: #252b32; box-shadow: 0 5px 18px #0003; pointer-events: none; text-align: left; font: 11px/1.35 var(--font-ui); z-index: 2; }
 .poi-marker:hover { z-index: 5; }
 .poi-marker:hover .poi-tooltip { display: block; }
 .poi-tooltip img { display: block; width: 100%; height: 100px; object-fit: contain; background: #e9e5dc; border-radius: 6px; margin-bottom: 5px; }
}

.poi-list-item span { text-decoration: none; }
body.poi-open .poi-marker { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
 .poi-marker .poi-tooltip { display: block; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s; }
 .poi-marker:hover .poi-tooltip { opacity: 1; visibility: visible; transition-delay: 0s; }
}
@media (prefers-reduced-motion: reduce) { .poi-marker .poi-tooltip { transition: none; } }

/* Navigation: titles lead, dates and locations support them. */
.poi-list-item { display: block; padding: 9px 2px; }
.poi-list-text { display: block; }
.poi-list-name { display: block; font-weight: 600; line-height: 1.35; }
.poi-list-meta { display: block; margin-top: 3px; color: var(--ink-dim); font-size: 11px; line-height: 1.35; font-weight: 400; }
.poi-list-item:hover .poi-list-name { color: #79500f; }
.poi-next { display: inline-block; width: auto; min-height: 44px; margin-top: 18px; padding: 0; border: 0; border-radius: 0; background: transparent; color: #79500f; font: 11px/1.4 var(--font-ui); text-decoration: underline; text-underline-offset: 3px; }
.poi-next:hover { background: transparent; color: var(--ink); }
.poi-next:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.poi-next { display: table; margin-top: 18px; }

/* Panel navigation aligns with the close control. */
.poi-panel-header { min-height: 58px; padding: 14px 70px 0 17px; gap: 0; }
.poi-toggle.on { color: var(--ink-dim); opacity: .55; }
.poi-toggle.on:hover, .poi-toggle.on:focus-visible { opacity: 1; }
.poi-next { margin-left: auto; margin-right: 0; text-align: right; }
@media (max-width: 760px) { .poi-toggle.on { top: 78px; } }
