/* ============================================================
   MANDU 3D HERITAGE MAP — STYLESHEET
   Design: instrument-panel controls, cinematic & sandstone themes
   Spacing: 4px/8px scale  |  Animation: 150-300ms transforms only
   ============================================================ */

/* ─── DESIGN TOKENS ──────────────────────────────────────── */
:root {
  /* 8px spacing scale */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Type scale */
  --type-xs:   11px;
  --type-sm:   13px;
  --type-base: 16px;
  --type-lg:   18px;
  --type-xl:   22px;
  --type-2xl:  28px;
  --type-3xl:  38px;

  /* Font stacks — no external CDN (system fonts only) */
  --font-display: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-mono:    'Courier New', Courier, monospace;
  --font-ui:      system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  --panel-width:      380px;
  --panel-transition: 0.38s cubic-bezier(0.4, 0, 0.2, 1);

  /* Animation durations */
  --dur-fast:  150ms;
  --dur-base:  250ms;
  --dur-slow:  380ms;
  --ease-out:  cubic-bezier(0, 0, 0.2, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);

  /* Z-index scale */
  --z-map:      0;
  --z-marker:   10;
  --z-controls: 20;
  --z-panel:    30;
  --z-loading:  40;
  --z-lightbox: 100;
}

/* ─── DRAMATIC THEME — cinematic night ───────────────────── */
.theme-dramatic {
  --bg:             #0a0a0f;
  --surface:        #12121a;
  --surface-raised: #1c1c2a;
  --border:         #252535;
  --border-accent:  #38385a;
  --text-primary:   #e8d5a3;
  --text-secondary: #9b8e75;
  --text-muted:     #504840;
  --accent:         #ffb347;
  --accent-dim:     rgba(255, 179, 71, 0.12);
  --accent-glow:    rgba(255, 179, 71, 0.22);

  /* Marker palette — dark-mode saturated */
  --mk-palace:    #ffb347;
  --mk-mosque:    #7cb9e8;
  --mk-tomb:      #d4aa30;
  --mk-gate:      #cd853f;
  --mk-madrasa:   #a478e0;
  --mk-stepwell:  #52c47a;
  --mk-pavilion:  #ff8c69;

  /* Panel chrome */
  --panel-bg:       #0e0e18;
  --scrollbar:      #252535;
  --scrollbar-bg:   #0e0e18;

  /* Skeleton shimmer */
  --shimmer-a: #1a1a28;
  --shimmer-b: #252540;
}

/* ─── HERITAGE THEME — warm sandstone ───────────────────── */
.theme-heritage {
  --bg:             #261409;
  --surface:        #38200f;
  --surface-raised: #4a2c18;
  --border:         #5e3821;
  --border-accent:  #7d4e30;
  --text-primary:   #f5e6d0;
  --text-secondary: #c9a882;
  --text-muted:     #7a5535;
  --accent:         #c4622d;
  --accent-dim:     rgba(196, 98, 45, 0.14);
  --accent-glow:    rgba(196, 98, 45, 0.28);

  /* Marker palette — warm-mode */
  --mk-palace:    #e89550;
  --mk-mosque:    #7bb8d4;
  --mk-tomb:      #d4aa30;
  --mk-gate:      #c07838;
  --mk-madrasa:   #a07ac8;
  --mk-stepwell:  #5ab888;
  --mk-pavilion:  #e88060;

  --panel-bg:       #2e1508;
  --scrollbar:      #5e3821;
  --scrollbar-bg:   #2e1508;

  --shimmer-a: #4a2c18;
  --shimmer-b: #5c3820;
}

/* ─── GLOBAL RESET ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--type-base);
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur-slow) var(--ease-out);
}

/* ─── MAP ────────────────────────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: var(--z-map);
}

/* ─── ARTISTIC MAP FILTERS ───────────────────────────────── */
/* Warm sepia tone for heritage, cool-dark for dramatic.
   Applied to the MapLibre canvas via the map container.     */
.theme-heritage #map canvas {
  filter: sepia(0.22) saturate(1.12) contrast(1.08) brightness(0.96);
}
.theme-dramatic #map canvas {
  filter: brightness(0.82) contrast(1.18) saturate(0.58);
}

/* Vignette — darkens edges to focus attention on the plateau */
#map::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 52%, transparent 38%, rgba(0,0,0,0.42) 100%);
  z-index: 1;
}

/* ─── MONUMENT MARKERS ───────────────────────────────────── */
/* Icons AND name labels are one MapLibre symbol layer —
   GPU-rendered, terrain-anchored, no DOM, no drift.         */

/* ─── SIDE PANEL ─────────────────────────────────────────── */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100dvh;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  z-index: var(--z-panel);
  transform: translateX(100%);
  transition:
    transform var(--panel-transition),
    background var(--dur-slow) var(--ease-out),
    border-color var(--dur-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#panel.open { transform: translateX(0); }

/* ─── WELCOME / ORIENTATION OVERLAY ──────────────────────── */
#welcome {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}
#welcome.open { opacity: 1; }
#welcome[hidden] { display: none; }
.welcome-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(3px);
}
.welcome-card {
  position: relative;
  width: min(880px, 100%);
  max-height: min(88vh, 720px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  transform: translateY(10px) scale(0.98);
  transition: transform var(--dur-slow) var(--ease-out);
}
#welcome.open .welcome-card { transform: none; }

.welcome-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
}

.welcome-text {
  padding: var(--sp-8) var(--sp-6) var(--sp-6) var(--sp-8);
}
.welcome-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}
.welcome-title {
  font-family: var(--font-display);
  font-size: var(--type-2xl);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: var(--sp-4);
}
.welcome-lede {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: var(--sp-5);
}
.welcome-section-label {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}
.welcome-list {
  list-style: none;
  margin: 0 0 var(--sp-5);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.welcome-list li {
  position: relative;
  padding-left: 18px;
  font-size: var(--type-sm);
  line-height: 1.55;
  color: var(--text-secondary);
}
.welcome-list li::before {
  content: '';
  position: absolute;
  left: 0; top: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
}
.welcome-browser-note {
  font-size: var(--type-xs);
  line-height: 1.55;
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: var(--sp-3);
  margin: 0 0 var(--sp-5);
}
.welcome-browser-note strong { color: var(--text-secondary); font-weight: 600; }
.welcome-dismiss {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
  cursor: pointer;
  user-select: none;
}
.welcome-dismiss input { accent-color: var(--accent); cursor: pointer; }

.welcome-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 3px;
  background: var(--accent);
  color: var(--panel-bg);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  transition: transform var(--dur-fast), opacity var(--dur-fast);
}
.welcome-cta:hover { opacity: 0.9; transform: translateY(-1px); }

.welcome-map {
  padding: var(--sp-8) var(--sp-8) var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.welcome-map svg { width: 100%; max-width: 240px; height: auto; }
.welcome-india {
  fill: var(--text-muted);
  fill-opacity: 0.28;
  stroke: var(--text-secondary);
  stroke-width: 1.3;
  stroke-linejoin: round;
}
.welcome-pin-pulse {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  opacity: 0.7;
  transform-origin: center;
  animation: welcomePulse 2.2s var(--ease-out) infinite;
}
.welcome-pin-dot { fill: var(--accent); }
.welcome-pin-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: bold;
  fill: var(--text-primary);
  letter-spacing: 0.02em;
}
@keyframes welcomePulse {
  0%   { r: 4;  opacity: 0.7; }
  100% { r: 15; opacity: 0; }
}
.welcome-map-caption {
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 720px) {
  .welcome-grid { grid-template-columns: 1fr; }
  .welcome-map { border-left: none; border-top: 1px solid var(--border); padding: var(--sp-6); }
  .welcome-text { padding: var(--sp-6); }
}

@media (prefers-reduced-motion: reduce) {
  #welcome, .welcome-card, .welcome-cta { transition: none; }
  .welcome-pin-pulse { animation: none; }
}

/* ─── ABOUT / CHANGELOG OVERLAY ──────────────────────────── */
#about {
  position: fixed;
  bottom: var(--sp-6);
  right: 72px;
  width: 320px;
  max-height: min(60vh, 480px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  z-index: var(--z-panel);
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#about.open { display: flex; }

.about-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.about-head .panel-close { position: static; }

.about-title {
  font-size: var(--type-sm);
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.about-version {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.about-body {
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
}
.about-entry { margin-bottom: var(--sp-4); }
.about-ver {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, var(--text-muted));
  margin-bottom: 3px;
}
.about-entry ul {
  margin: 0;
  padding-left: 16px;
}
.about-entry li {
  font-size: var(--type-xs);
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 2px;
}

/* Panel header */
.panel-header {
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  /* keep header text clear of the close button's corner */
  padding-right: calc(var(--sp-4) + 40px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.panel-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  /* above the header's in-flow text, which otherwise spans the full
     header width and swallows clicks aimed at the button */
  z-index: 2;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    color var(--dur-fast);
  font-family: var(--font-mono);
}

.panel-close:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.panel-type-tag {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
  opacity: 0.85;
}

.panel-name {
  font-family: var(--font-display);
  font-size: var(--type-2xl);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  padding-right: var(--sp-8);
}

/* Panel scrollable body */
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) var(--scrollbar-bg);
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 2px;
}

/* Thumbnail */
.panel-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  display: block;
  background: var(--surface);
  cursor: zoom-in;
}

.panel-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Metadata grid */
.panel-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.panel-meta-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: var(--sp-3) var(--sp-4);
}

.meta-label {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}

.meta-value {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  color: var(--accent);
  font-weight: bold;
}

/* Divider */
.panel-rule {
  height: 1px;
  background: var(--border);
  margin-bottom: var(--sp-5);
}

/* Photo wrap — allows graceful onerror swap */
.panel-photo-wrap { margin-bottom: var(--sp-5); }
.panel-photo-wrap .panel-thumb { margin-bottom: 0; }
.panel-photo-credit {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}
.panel-photo-credit .credit-cap {
  display: block;
  font-family: var(--font-body, inherit);
  font-size: var(--type-xs);
  letter-spacing: 0;
  color: var(--text);
  opacity: 0.85;
  margin-bottom: 2px;
}

/* Thumbnail strip */
.panel-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 7px;
}
.gal-thumb {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  opacity: 0.62;
  transition: opacity var(--dur-fast), border-color var(--dur-fast);
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-thumb:hover { opacity: 0.9; }
.gal-thumb.active { opacity: 1; border-color: var(--accent, var(--text-muted)); }

/* ═══════════════════════════════════════════════════════════
   SHARED IMAGE LIGHTBOX
   Full-screen viewer for the panel gallery and the timeline's
   hero/gallery figures. Built by lightbox.js on both pages.
   ═══════════════════════════════════════════════════════════ */
body.lb-open { overflow: hidden; }

.lb-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
}
.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 6, 0.92);
}
.lb-dialog {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: 56px 16px;
}
.lb-figure {
  grid-column: 2;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}
.lb-img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.lb-caption {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.72);
  text-align: center;
  max-width: 68ch;
}
.lb-caption .lb-cap-text {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0;
  color: #fff;
  margin-bottom: 4px;
}
.lb-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.lb-btn:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.4); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  font-size: 16px;
}
.lb-prev, .lb-next {
  grid-row: 1;
  width: 44px; height: 44px;
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}
.lb-prev { grid-column: 1; justify-self: start; }
.lb-next { grid-column: 3; justify-self: end; }
.lb-count {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.6);
}

@media (max-width: 640px) {
  .lb-dialog { grid-template-columns: 40px 1fr 40px; padding: 44px 8px; }
  .lb-prev, .lb-next { width: 36px; height: 36px; font-size: 20px; }
}

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

/* Dynasty / provenance line */
.panel-dynasty {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: calc(-1 * var(--sp-2));
  margin-bottom: var(--sp-4);
}

/* Tagline — italic sub-heading before description */
.panel-tagline {
  font-family: var(--font-display);
  font-size: var(--type-lg);
  font-style: italic;
  color: var(--accent);
  margin-bottom: var(--sp-3);
  line-height: 1.3;
}

/* Extract / description */
.panel-extract {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.78;
  color: var(--text-secondary);
}

.panel-extract + .panel-extract { margin-top: var(--sp-4); }

/* Did-you-know callout */
.panel-fact {
  margin-top: var(--sp-5);
  padding: var(--sp-4);
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: 0 2px 2px 0;
}
.panel-fact-label {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}
.panel-fact p {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.68;
  color: var(--text-secondary);
  font-style: italic;
}

/* At-a-glance facts — patron, purpose, dimensions, materials, condition.
   Only the fields a monument's record actually supports are rendered;
   empty rows are never shown. */
.panel-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 7px 14px;
  margin: var(--sp-4) 0 var(--sp-3);
}
.panel-facts dt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}
.panel-facts dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--type-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Panel footer */
.panel-footer {
  padding: var(--sp-3) var(--sp-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur-fast);
}

.wiki-link:hover { color: var(--accent); }

.wiki-link svg { flex-shrink: 0; }

/* ─── SKELETON LOADING ───────────────────────────────────── */
.sk {
  background: linear-gradient(
    90deg,
    var(--shimmer-a) 0%,
    var(--shimmer-b) 50%,
    var(--shimmer-a) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.7s ease-in-out infinite;
  border-radius: 2px;
}

@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

.sk-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: var(--sp-5);
}

.sk-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.sk-meta-cell { height: 58px; }

.sk-rule {
  height: 1px;
  margin-bottom: var(--sp-5);
}

.sk-line {
  height: 14px;
  margin-bottom: var(--sp-3);
}

.sk-line.w-full   { width: 100%; }
.sk-line.w-80     { width: 80%; }
.sk-line.w-65     { width: 65%; }
.sk-line.w-90     { width: 90%; }
.sk-line.w-50     { width: 50%; }

/* ─── UI CONTROLS ────────────────────────────────────────── */
/* Physical instrument-panel aesthetic:
   - Square-cornered (2px radius) flat faces
   - Subtle inset shadow simulating a physical depression
   - Monospaced labels, amber/terracotta glow on hover     */

.ctrl-group {
  position: fixed;
  z-index: var(--z-controls);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.ctrl-group--tr { top: var(--sp-5); right: var(--sp-5); }
.ctrl-group--br { bottom: var(--sp-8); right: var(--sp-5); }

/* Labelled route to the timeline page — top-left, deliberately
   readable rather than another icon in the right-hand stack. */
.tl-entry-btn {
  position: fixed;
  top: var(--sp-5);
  left: var(--sp-5);
  z-index: var(--z-controls);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--panel-bg);
  color: var(--text-primary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 3px 14px rgba(0,0,0,0.35);
  transition: color var(--dur-fast), border-color var(--dur-fast),
              background var(--dur-fast), transform var(--dur-fast);
}
.tl-entry-btn:hover {
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}
.tl-entry-btn:focus-visible {
  outline: 2px solid var(--text-secondary);
  outline-offset: 2px;
}
.tl-entry-btn svg { flex-shrink: 0; }

/* Second labelled route, directly below the timeline button —
   an alternate way into a monument besides hunting for it on
   the terrain. */
.monlist-entry-btn {
  top: calc(var(--sp-5) + 44px + var(--sp-2));
  cursor: pointer;
  font-family: var(--font-mono);
}

/* ─── MONUMENT LIST ──────────────────────────────────────── */
#monlist {
  position: fixed;
  top: var(--sp-5);
  left: var(--sp-5);
  z-index: var(--z-panel);
  width: 320px;
  max-height: min(76vh, 620px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
#monlist.open { opacity: 1; transform: none; pointer-events: auto; }

.monlist-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.monlist-head .panel-close { position: static; }
.monlist-title {
  font-family: var(--font-display);
  font-size: var(--type-lg);
  font-weight: 600;
  color: var(--text-primary);
}
.monlist-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 2px;
}

.monlist-filter {
  margin: var(--sp-3) var(--sp-5);
  min-height: 38px;
  padding: 0 var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  flex-shrink: 0;
}
.monlist-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.monlist-filter::placeholder { color: var(--text-muted); }

.monlist-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-3) var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) var(--scrollbar-bg);
}
.monlist-group { margin-top: var(--sp-4); }
.monlist-group-label {
  padding: 0 var(--sp-2);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.monlist-group-label span { color: var(--text-muted); margin-left: 4px; }
.monlist-items { display: flex; flex-direction: column; gap: 2px; }

.monlist-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  min-height: 36px;
  padding: 0 var(--sp-2);
  background: transparent;
  border: none;
  border-radius: 2px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  transition: background var(--dur-fast), opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
  /* cascade-in state, reversed once the list is open */
  opacity: 0;
  transform: translateX(-8px);
}
#monlist.open .monlist-item { opacity: 1; transform: none; }
.monlist-item:hover, .monlist-item:focus-visible { background: var(--accent-dim); outline: none; }
.monlist-item-name { font-size: var(--type-sm); }
.monlist-item-period {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.monlist-empty {
  padding: var(--sp-6) var(--sp-3);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
}

@media (prefers-reduced-motion: reduce) {
  #monlist, .monlist-item { transition: none; }
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-family: var(--font-mono);
  line-height: 1;
  position: relative;
  /* instrument depression */
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 2px 8px rgba(0,0,0,0.45);
  transition:
    background  var(--dur-fast),
    border-color var(--dur-fast),
    color       var(--dur-fast),
    box-shadow  var(--dur-fast),
    transform   100ms ease-out;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.ctrl-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border-accent);
  color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.07),
    0 2px 12px rgba(0,0,0,0.5),
    0 0 0 1px var(--accent-dim),
    0 0 8px var(--accent-glow);
}

.ctrl-btn:active {
  transform: scale(0.93);
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,0.35),
    0 1px 3px rgba(0,0,0,0.3);
}

/* Tooltip labels (left of button) */
.ctrl-btn[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 9px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px var(--sp-3);
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.ctrl-btn[data-tip]:hover::before { opacity: 1; }

.ctrl-sep {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* Active state for flat-view toggle */
.ctrl-btn.active {
  color: var(--accent);
  border-color: var(--border-accent);
}

/* ─── LOADING OVERLAY ────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: var(--z-loading);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  transition: opacity 0.5s var(--ease-in);
}

#loading.fade {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-family: var(--font-display);
  font-size: var(--type-3xl);
  font-style: italic;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.loading-sub {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: loading-blink 1.6s ease-in-out infinite;
}

@keyframes loading-blink {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1; }
}

/* ─── MAPLIBRE OVERRIDES ─────────────────────────────────── */
.maplibregl-ctrl-logo,
.maplibregl-ctrl-attrib {
  opacity: 0.35 !important;
  filter: grayscale(1) !important;
}

.maplibregl-canvas { outline: none; }

/* Hide default MapLibre controls (we use our own) */
.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right,
.maplibregl-ctrl-bottom-left { display: none; }

.maplibregl-ctrl-bottom-right {
  bottom: 4px !important;
  right: 52px !important;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --panel-width: 100vw;
  }

  #panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .panel-name { font-size: var(--type-xl); }

  .ctrl-group--tr { top: var(--sp-3); right: var(--sp-3); }
  .ctrl-group--br { bottom: var(--sp-5); right: var(--sp-3); }

  /* hide tooltip labels on mobile — no hover */
  .ctrl-btn[data-tip]::before { display: none; }
}

/* ─── MONUMENT PANEL: paper & ink ─────────────────────────────
   The panel is a reading surface sitting over a dark map, so it
   uses the same museum-label system as the timeline (paper.css)
   rather than the map's own dark chrome. Tan-on-brown body copy
   was the single worst legibility problem in the old scheme.
   Scoped to #panel so the map's controls keep their dark styling. */
#panel {
  --paper:        #FAF6EE;
  --paper-raised: #FFFFFF;
  --paper-sunken: #F1EBDD;
  --ink:          #1A1613;
  --ink-2:        #544A3D;
  --ink-3:        #7A6E5E;
  --rule:         #E3DACA;

  background: var(--paper);
  color: var(--ink);
  border-left: 1px solid var(--rule);
  box-shadow: -18px 0 48px rgba(0,0,0,0.45);
}
#panel .panel-header  { background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
#panel .panel-footer  { background: var(--paper-raised); border-top: 1px solid var(--rule); }
#panel .panel-name    { color: var(--ink); }
#panel .panel-type-tag,
#panel .panel-dynasty,
#panel .meta-label,
#panel .panel-facts dt,
#panel .panel-photo-credit { color: var(--ink-3); }
#panel .panel-facts dd { color: var(--ink-2); }
#panel .panel-extract,
#panel .panel-tagline,
#panel .meta-value     { color: var(--ink-2); }
#panel .panel-tagline  { font-style: italic; }
#panel .panel-rule,
#panel .panel-meta     { border-color: var(--rule); }
#panel .panel-thumb,
#panel .gal-thumb      { border-color: var(--rule); background: var(--paper-sunken); }
#panel .panel-thumb-placeholder {
  background: var(--paper-sunken); color: var(--ink-3); border: 1px dashed var(--rule);
}

/* "Did you know" — a quiet inset rather than a coloured block */
#panel .panel-fact {
  background: var(--paper-sunken);
  border-left: 3px solid #A8482A;
  border-radius: 2px;
  padding: var(--sp-4);
}
#panel .panel-fact p          { color: var(--ink-2); }
#panel .panel-fact-label      { color: #8F3A22; }

#panel .panel-close {
  color: var(--ink-2);
  border-color: var(--rule);
  background: var(--paper-raised);
}
#panel .panel-close:hover { color: var(--ink); border-color: var(--ink-3); background: var(--paper-sunken); }

#panel .wiki-link {
  color: var(--ink);
  background: var(--paper-sunken);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
#panel .wiki-link:hover { border-color: var(--ink-3); }
#panel .gal-thumb.active { border-color: #A8482A; }
#panel .panel-body::-webkit-scrollbar-track { background: var(--paper-sunken); }
#panel .panel-body::-webkit-scrollbar-thumb { background: var(--rule-strong, #CFC2AC); }

/* ─── COMPASS ROSE ───────────────────────────────────────────
   Survey-drawing north point. Counter-rotates with the bearing;
   click snaps north. Sits clear of the bottom-right control stack. */
#compass {
  position: fixed;
  left: var(--sp-5);
  bottom: var(--sp-6);
  width: 76px; height: 76px;
  padding: 0;
  border: none;
  background: radial-gradient(circle at 50% 42%, rgba(20,16,10,0.55), rgba(20,16,10,0.15) 70%, transparent 78%);
  border-radius: 50%;
  cursor: pointer;
  z-index: var(--z-controls);
  opacity: 0.72;
  transition: opacity var(--dur-fast), transform var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}
#compass:hover { opacity: 1; transform: scale(1.04); }
#compass:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#compass svg { width: 100%; height: 100%; display: block; overflow: visible; }

#compass .cp-ring    { fill: none; stroke: rgba(240,228,200,0.5); stroke-width: 1.1; }
#compass .cp-ring-in { stroke: rgba(240,228,200,0.26); stroke-dasharray: 2 4; }
#compass .cp-tick    { stroke: rgba(240,228,200,0.66); stroke-width: 1.6; stroke-linecap: round; }
#compass .cp-n-dark  { fill: #c4622d; }
#compass .cp-n-light { fill: #f0e4c8; }
#compass .cp-s       { fill: rgba(240,228,200,0.30); }
#compass .cp-s-light { fill: rgba(240,228,200,0.16); }
#compass .cp-hub     { fill: #f0e4c8; }
#compass .cp-label {
  fill: #f0e4c8;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  letter-spacing: 0.06em;
}
/* nudge when the map is off-north, so the affordance is discoverable */
#compass.cp-off { opacity: 0.95; }

@media (max-width: 768px) {
  #compass { width: 58px; height: 58px; left: var(--sp-3); bottom: var(--sp-5); }
}
@media (prefers-reduced-motion: reduce) {
  #compass, #compass:hover { transition: none; transform: none; }
}

/* ─── PANEL: editorial treatment ──────────────────────────────
   Same "Editorial Grid" devices as the timeline (ui-ux-pro-max
   --domain style) so the two surfaces read as one publication:
   serif long-form, a pull-quote fact, print-style dividers. */
#panel .panel-extract,
#panel .panel-tagline {
  font-family: var(--font-display);
}
#panel .panel-extract {
  font-size: 15.5px;
  line-height: 1.72;
  letter-spacing: 0.005em;
}
#panel .panel-name {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  line-height: 1.14;
}
#panel .panel-tagline {
  font-size: 16px;
  line-height: 1.45;
  font-style: italic;
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--ink);
  margin-bottom: var(--sp-4);
}
/* "Did you know" as a pull quote rather than a tinted box */
#panel .panel-fact {
  background: transparent;
  border: none;
  border-left: 3px solid #A8482A;
  padding: 2px 0 2px 18px;
  margin-top: var(--sp-5);
}
#panel .panel-fact p {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.55;
  font-style: italic;
  color: var(--ink);
}
#panel .panel-fact-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

/* meta cells still carried the map's dark --surface, which put
   ink-2 text at 2.15:1. Repoint them at the paper set. */
#panel .panel-meta-cell {
  background: var(--paper-sunken);
  border: 1px solid var(--rule);
}
/* ink-3 on the sunken surface is 4.19:1 — just under AA. Labels on
   sunken backgrounds step up one level. */
#panel .meta-label { color: var(--ink-2); }
