:root {
  --bg-obsidian: rgba(9, 14, 24, 0.78);
  --bg-obsidian-deep: rgba(7, 11, 20, 0.92);
  --border-gold: rgba(226, 182, 98, 0.34);
  --border-subtle: rgba(240, 232, 214, 0.16);
  --gold: #e6ba63;
  --gold-bright: #f6d58e;
  --ivory: #f5efe2;
  --stone-muted: #bfb5a2;
  --attested-teal: #5ec7b5;
  --uncertain-amber: #f0ad4e;
  --font-display: 'Cinzel', Georgia, serif;
  --font-caption: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #060a14;
  color: var(--ivory);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================================================
   CINEMA LETTERBOX BARS & VIGNETTE (Tour Mode)
   ========================================================================= */
.letterbox {
  position: fixed;
  left: 0;
  right: 0;
  height: 44px;
  background: #03060c;
  z-index: 10;
  pointer-events: none;
}

.letterbox-top {
  top: 0;
}

.letterbox-bottom {
  bottom: 0;
}

body[data-mode="explore"] .letterbox-top {
  transform: translateY(-100%);
}

body[data-mode="explore"] .letterbox-bottom {
  transform: translateY(100%);
}

.cinema-vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(4, 7, 15, 0.55) 0%, transparent 18%, transparent 72%, rgba(4, 7, 15, 0.78) 100%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(3, 6, 12, 0.42) 100%);
}

body[data-mode="explore"] .cinema-vignette {
  opacity: 0.45;
}

/* =========================================================================
   TOP NAVIGATION BAR
   ========================================================================= */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  pointer-events: none;
}

body[data-mode="tour"] .top-bar {
  padding-top: 10px;
}

.brand-block {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--ivory);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--stone-muted);
  text-transform: uppercase;
}

body[data-mode="tour"] .brand-sub {
  display: none;
}

.top-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-obsidian);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ivory);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.22s ease;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.btn:hover {
  border-color: var(--gold);
  background: rgba(20, 28, 44, 0.9);
  color: var(--gold-bright);
  transform: translateY(-1px);
}

.btn-primary {
  border-color: var(--border-gold);
  background: linear-gradient(135deg, rgba(46, 36, 18, 0.86), rgba(18, 24, 38, 0.9));
  color: var(--gold-bright);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(72, 54, 24, 0.95), rgba(26, 34, 52, 0.95));
  border-color: var(--gold-bright);
}

.btn.is-active {
  border-color: var(--gold-bright);
  background: rgba(230, 186, 99, 0.2);
  color: var(--gold-bright);
}

.tour-only,
.explore-only {
  transition: opacity 0.35s ease;
}

body[data-mode="explore"] .tour-only {
  display: none !important;
}

body[data-mode="tour"] .explore-only {
  display: none !important;
}

/* Time of Day Segmented Control in Explore Mode */
.lighting-pills {
  display: inline-flex;
  background: var(--bg-obsidian);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.light-pill {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--stone-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.light-pill:hover {
  color: var(--ivory);
}

.light-pill.is-active {
  background: rgba(230, 186, 99, 0.22);
  color: var(--gold-bright);
}

/* =========================================================================
   TOUR CINEMATIC CAPTIONS & TIMELINE SCRUBBER
   ========================================================================= */
.tour-hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 44px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 28px 18px;
  pointer-events: none;
}

.tour-chapter-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
}

.tour-caption-text {
  max-width: 780px;
  min-height: 36px;
  text-align: center;
  font-family: var(--font-caption);
  font-size: clamp(21px, 2.5vw, 28px);
  font-weight: 500;
  font-style: italic;
  line-height: 1.32;
  color: #fbf7ee;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.95), 0 1px 4px rgba(0, 0, 0, 0.95);
}

.tour-caption-text:empty {
  opacity: 0;
}

.tour-timeline-wrap {
  pointer-events: auto;
  margin-top: 14px;
  width: min(560px, 86vw);
  display: flex;
  align-items: center;
  gap: 12px;
}

.tour-time-readout {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--stone-muted);
  min-width: 68px;
  text-align: right;
}

.tour-progress-track {
  flex: 1;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.tour-progress-bg {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.tour-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: 3px;
}

.chapter-tick {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 1px;
  background: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

/* =========================================================================
   EXPLORE MODE: 3D HOTSPOT PINS, SIDE DOSSIER CARD & BOTTOM INDEX
   ========================================================================= */
#hotspot-layer {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

.hotspot-pin {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  appearance: none;
  border: 1.5px solid rgba(245, 239, 226, 0.75);
  background: rgba(9, 15, 28, 0.84);
  backdrop-filter: blur(6px);
  color: var(--ivory);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.65);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.hotspot-pin[data-certainty="reconstruction"] {
  border-color: rgba(240, 173, 78, 0.88);
}

.hotspot-pin:hover,
.hotspot-pin.is-selected {
  background: var(--gold);
  color: #090e18;
  border-color: #fff6dc;
  box-shadow: 0 0 0 5px rgba(230, 186, 99, 0.28), 0 4px 18px rgba(0, 0, 0, 0.8);
  z-index: 5;
}

.hotspot-pin .pin-tooltip {
  position: absolute;
  left: 34px;
  white-space: nowrap;
  background: var(--bg-obsidian-deep);
  border: 1px solid var(--border-gold);
  color: var(--ivory);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: all 0.18s ease;
}

.hotspot-pin:hover .pin-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Side Inspection Card */
.inspect-card {
  position: fixed;
  left: 24px;
  top: 76px;
  width: min(375px, calc(100vw - 48px));
  max-height: calc(100vh - 175px);
  overflow-y: auto;
  z-index: 18;
  background: var(--bg-obsidian-deep);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

.inspect-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.inspect-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.inspect-close {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--stone-muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inspect-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--ivory);
}

.inspect-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.28;
  color: var(--ivory);
  margin-bottom: 10px;
}

.certainty-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.certainty-badge.attested {
  background: rgba(94, 199, 181, 0.14);
  border: 1px solid rgba(94, 199, 181, 0.42);
  color: var(--attested-teal);
}

.certainty-badge.reconstruction {
  background: rgba(240, 173, 78, 0.15);
  border: 1px solid rgba(240, 173, 78, 0.45);
  color: var(--uncertain-amber);
}

.inspect-desc {
  font-size: 13px;
  line-height: 1.58;
  color: #e4dccd;
  margin-bottom: 12px;
}

.inspect-sources {
  font-size: 11px;
  line-height: 1.45;
  color: var(--stone-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.inspect-sources strong {
  color: var(--ivory);
  font-weight: 600;
}

.inspect-inline-link {
  margin-top: 10px;
  display: inline-block;
  background: none;
  border: none;
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Bottom Explore Navigator Strip */
.explore-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  pointer-events: none;
}

.explore-hint {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(245, 239, 226, 0.75);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

.hotspot-strip {
  pointer-events: auto;
  max-width: min(1080px, 95vw);
  overflow-x: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-obsidian);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  scrollbar-width: none;
}

.hotspot-strip::-webkit-scrollbar {
  display: none;
}

.strip-chip {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--stone-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.strip-chip:hover {
  color: var(--ivory);
  background: rgba(255, 255, 255, 0.11);
}

.strip-chip.is-selected {
  background: rgba(230, 186, 99, 0.22);
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* =========================================================================
   HISTORICAL RECORD & UNCERTAINTIES MODAL DRAWER
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 7, 15, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop[hidden],
.inspect-card[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: rgba(10, 15, 26, 0.96);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 26px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--gold-bright);
}

.modal-lead {
  font-size: 13.5px;
  line-height: 1.6;
  color: #ddd4c3;
  margin-bottom: 18px;
}

.uncertainty-list {
  display: grid;
  gap: 12px;
}

.uncertainty-item {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(240, 232, 214, 0.12);
  border-radius: 10px;
  padding: 13px 15px;
}

.uncertainty-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
}

.uncertainty-aspect {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ivory);
}

.uncertainty-choice {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--uncertain-amber);
}

.uncertainty-detail {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--stone-muted);
}

@media (max-width: 760px) {
  .lighting-pills {
    display: none;
  }
  .inspect-card {
    left: 14px;
    right: 14px;
    width: auto;
    top: auto;
    bottom: 84px;
    max-height: 44vh;
  }
}
