:root {
  color-scheme: light;
  --ink: #12221f;
  --ink-soft: #40544f;
  --paper: #f7f2e8;
  --paper-strong: #fffdf7;
  --line: rgba(18, 34, 31, 0.16);
  --route-one: #6d4aff;
  --route-two: #f26b3a;
  --focus: #0e7163;
  --shadow: 0 18px 60px rgba(10, 28, 24, 0.18);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.tour-map {
  position: relative;
  width: 100%;
  min-height: 760px;
  height: 100svh;
  overflow: hidden;
  background: #cbdcd6;
  isolation: isolate;
}

.map { position: absolute; inset: 0; }

.map-tint {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(11, 29, 25, 0.2) 0%, transparent 34%),
    linear-gradient(180deg, rgba(15, 35, 30, 0.08) 0%, transparent 27%, rgba(9, 25, 21, 0.12) 100%);
}

.intro-panel,
.visit-panel,
.timeline-panel,
.route-key,
.map-action {
  z-index: 3;
}

.intro-panel {
  position: absolute;
  top: 26px;
  left: 26px;
  width: min(390px, calc(100% - 52px));
  padding: 24px 26px 26px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 24px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper-strong);
  background: var(--ink);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 22px 0 7px;
  color: #0b7466;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 330px;
  font-size: clamp(2.35rem, 4vw, 4.2rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.75rem;
  line-height: 1.08;
}

.intro-copy {
  max-width: 330px;
  margin: 15px 0 20px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

.mode-switch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(18, 34, 31, 0.075);
}

.mode-button {
  min-height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.mode-button.is-active {
  color: var(--paper-strong);
  background: var(--ink);
  box-shadow: 0 3px 12px rgba(18, 34, 31, 0.16);
}

.route-key {
  position: absolute;
  top: 28px;
  right: 76px;
  display: flex;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: 0 8px 30px rgba(10, 28, 24, 0.12);
  backdrop-filter: blur(14px);
  font-size: 0.72rem;
  font-weight: 700;
}

.route-key span { display: inline-flex; align-items: center; gap: 6px; }
.route-swatch { width: 9px; height: 9px; border-radius: 50%; }
.route-one { background: var(--route-one); }
.route-two { background: var(--route-two); }

.map-action {
  position: absolute;
  top: 76px;
  right: 26px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.88);
  box-shadow: 0 8px 30px rgba(10, 28, 24, 0.12);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
}

.visit-panel {
  position: absolute;
  right: 26px;
  bottom: 142px;
  width: min(350px, calc(100% - 52px));
  max-height: min(430px, calc(100% - 220px));
  overflow: auto;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 22px;
  background: rgba(255, 253, 247, 0.93);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
  transition: transform 240ms ease, opacity 240ms ease;
}

.visit-panel.is-dismissed {
  pointer-events: none;
  opacity: 0;
  transform: translateY(14px);
}

.visit-panel .eyebrow { margin-top: 0; }
.visit-panel p { margin: 9px 0 0; color: var(--ink-soft); line-height: 1.5; }

.panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(18, 34, 31, 0.07);
  cursor: pointer;
  font-size: 1.25rem;
}

.visit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.meta-pill {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(18, 34, 31, 0.075);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
}

.visit-list {
  display: grid;
  gap: 8px;
  margin: 17px 0 0;
  padding: 0;
  list-style: none;
}

.visit-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  align-items: start;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.visit-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; }
.visit-date { display: block; font-size: 0.9rem; font-weight: 700; }
.visit-area {
  margin-left: 7px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 600;
}
.visit-area.is-emphasized { color: var(--ink); font-weight: 800; }
.visit-note { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 0.72rem; }

.timeline-panel {
  position: absolute;
  right: 26px;
  bottom: 24px;
  left: 26px;
  padding: 14px 18px 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 22px;
  background: rgba(18, 34, 31, 0.93);
  color: var(--paper-strong);
  box-shadow: 0 18px 58px rgba(7, 23, 19, 0.28);
  backdrop-filter: blur(18px);
}

.timeline-topline {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.is-embed .intro-panel,
.is-embed .route-key,
.is-embed .reset-view,
.is-embed .visit-panel,
.is-embed .loading-state,
.is-embed .error-state {
  display: none;
}

.is-embed .timeline-panel {
  left: 50%;
}

.play-button {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-strong);
  cursor: pointer;
}

.pause-icon::before,
.pause-icon::after {
  position: absolute;
  top: 14px;
  width: 4px;
  height: 16px;
  border-radius: 3px;
  background: currentColor;
  content: "";
}

.pause-icon::before { left: 16px; }
.pause-icon::after { right: 16px; }

.play-button:not(.is-playing) .pause-icon::before {
  top: 13px;
  left: 17px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
  border-radius: 0;
  background: transparent;
}

.play-button:not(.is-playing) .pause-icon::after { display: none; }

.date-block { min-width: 0; }
.date-label { display: block; font-size: 1rem; font-weight: 700; }
.place-label {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: rgba(255, 253, 247, 0.65);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tour-year-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tour-year { color: rgba(255, 253, 247, 0.68); font-size: 0.78rem; font-weight: 700; }

.year-select {
  min-height: 30px;
  max-width: 92px;
  padding: 0 25px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: var(--paper-strong);
  background-color: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
}

.year-select:focus-visible { outline: 2px solid var(--paper-strong); outline-offset: 2px; }

.date-slider {
  width: 100%;
  height: 5px;
  margin: 0;
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(90deg, var(--paper-strong) var(--progress, 0%), rgba(255,255,255,0.2) var(--progress, 0%));
  cursor: pointer;
}

.date-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  appearance: none;
  background: var(--paper-strong);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.36);
}

.date-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-strong);
}

.timeline-months {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: rgba(255, 253, 247, 0.45);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cast-marker {
  position: relative;
  width: 22px;
  height: 22px;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: var(--marker-colour);
  box-shadow: 0 4px 14px rgba(14, 32, 27, 0.35);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 180ms ease, transform 180ms ease;
}

.cast-marker::before {
  position: absolute;
  inset: -10px;
  border: 2px solid var(--marker-colour);
  border-radius: 50%;
  content: "";
  opacity: 0.35;
  animation: marker-pulse 1.8s ease-out infinite;
}

.cast-marker.is-visible { opacity: 1; transform: scale(1); }
.cast-marker.is-ambiguous::after {
  position: absolute;
  top: -10px;
  right: -10px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-strong);
  content: "?";
  font-size: 10px;
  font-weight: 800;
}

@keyframes marker-pulse {
  from { opacity: 0.4; transform: scale(0.55); }
  to { opacity: 0; transform: scale(1.35); }
}

.loading-state,
.error-state {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  gap: 12px;
  place-content: center;
  justify-items: center;
  color: var(--paper-strong);
  background: var(--ink);
  font-weight: 700;
  letter-spacing: 0.015em;
}

.loading-orbit {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255,255,255,0.22);
  border-top-color: var(--paper-strong);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tour-map.is-ready .loading-state { display: none; }
.error-state[hidden] { display: none; }
.error-state span { color: rgba(255,255,255,0.68); font-size: 0.85rem; font-weight: 400; }

.maplibregl-ctrl-bottom-left { bottom: 128px; }
.maplibregl-ctrl-attrib { font-family: "DM Sans", sans-serif; font-size: 9px; }
.maplibregl-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

.maplibregl-popup-content {
  padding: 8px 11px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper-strong);
  box-shadow: 0 8px 24px rgba(10, 28, 24, 0.2);
  font-family: "DM Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
}
.maplibregl-popup-tip { border-top-color: var(--paper-strong) !important; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .tour-map { min-height: 700px; }
  .intro-panel {
    top: 12px;
    left: 12px;
    width: calc(100% - 24px);
    padding: 16px 18px 17px;
    border-radius: 18px;
  }
  .brand { font-size: 0.66rem; }
  .brand-mark { width: 30px; height: 30px; }
  .eyebrow { margin-top: 13px; }
  h1 { max-width: 270px; font-size: 2.35rem; }
  .intro-copy { display: none; }
  .mode-switch { position: absolute; right: 16px; bottom: 16px; }
  .mode-button { min-height: 34px; padding: 0 11px; font-size: 0.68rem; }
  .route-key { top: 188px; right: 12px; gap: 9px; padding: 8px 10px; font-size: 0.65rem; }
  .map-action { top: 228px; right: 12px; min-height: 34px; }
  .visit-panel {
    right: 12px;
    bottom: 128px;
    left: 12px;
    width: auto;
    max-height: 270px;
    padding: 18px 20px;
    border-radius: 18px;
  }
  .visit-panel:not(.has-selection) { display: none; }
  .timeline-panel { right: 12px; bottom: 12px; left: 12px; border-radius: 18px; }
  .maplibregl-ctrl-bottom-left { bottom: 112px; }
}

@media (max-width: 470px) {
  .intro-panel { padding-bottom: 62px; }
  .mode-switch { right: auto; bottom: 14px; left: 16px; }
  .route-key { top: 231px; }
  .map-action { top: 270px; }
  .timeline-panel { padding: 12px 14px 10px; }
  .timeline-topline { grid-template-columns: 42px minmax(0, 1fr); }
  .tour-year-control { gap: 5px; }
  .year-select { max-width: 78px; padding-left: 8px; font-size: 0.62rem; }
  .play-button { width: 40px; height: 40px; }
  .pause-icon::before, .pause-icon::after { top: 12px; }
  .pause-icon::before { left: 14px; }
  .pause-icon::after { right: 14px; }
  .play-button:not(.is-playing) .pause-icon::before { top: 11px; left: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
