/* =====================================================================
   css/story-viewer.css
   Scroll-driven story viewer layout.
   Map is fullscreen + sticky; chapters scroll over it.
   ===================================================================== */

/* ── Reset ─────────────────────────────────────────────────────────── */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}

/* ── Top bar ───────────────────────────────────────────────────────── */
#story-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 1000;
  font-size: 0.9rem;
  backdrop-filter: blur(8px);
}

#story-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Progress bar at bottom of topbar */
#story-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
}

#story-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: #3b82f6;
  transition: width 0.4s ease;
}

/* ── Fullscreen sticky map ─────────────────────────────────────────── */
#map {
  position: sticky;
  top: 40px; /* below topbar */
  width: 100%;
  height: calc(100vh - 40px);
  z-index: 0;
}

/* Locator minimap: styles set dynamically by components/locator-map.js */
/* Hide locator on small screens — not enough room */
@media (max-width: 768px) {
  #locator-map {
    display: none !important;
  }
}

/* ── Scroll container (chapters) ───────────────────────────────────── */
#story-scroll {
  position: relative;
  z-index: 1;
  pointer-events: none; /* let clicks pass through to map */
  margin-top: calc(-100vh + 40px); /* pull up over the sticky map */
}

/* ── Chapter sections ──────────────────────────────────────────────── */
.story-chapter {
  min-height: 80vh;
  display: flex;
  align-items: center;
  padding: 2rem 0;
}

/* Spacers (map-only viewport) */
.story-spacer {
  height: 60vh;
}

/* Opening spacer with scroll hint */
.story-opening {
  position: relative;
}

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: auto;
  animation: scroll-pulse 2s ease-in-out infinite;
}

.scroll-hint span {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}

.scroll-hint i {
  font-size: 1.4rem;
  display: block;
}

@keyframes scroll-pulse {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) translateY(0); }
  50% { opacity: 1; transform: translateX(-50%) translateY(6px); }
}

.story-end {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Text cards (floating over map) ────────────────────────────────── */
.story-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  padding: 1.5rem 2rem;
  max-width: 420px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15);
  pointer-events: auto; /* re-enable interactions on the card */
}

.story-card h1,
.story-card h2,
.story-card h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

/* Dark card variant — dark translucent background with white text */
.story-card-dark {
  background: rgba(10, 10, 30, 0.78);
  backdrop-filter: blur(6px);
  color: #f0f0f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.story-card-dark h1,
.story-card-dark h2,
.story-card-dark h3 {
  color: #fff;
}

.story-card-dark .story-body {
  color: rgba(255, 255, 255, 0.88);
}

.story-card-dark .story-body a {
  color: #93c5fd;
}

.story-card-dark .text-muted {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* Dark callout stat number */
.story-card-dark .story-stat {
  color: #60a5fa;
}

/* White text, no card background — for use over dark maps or bg images */
.story-card-white-text {
  background: none;
  box-shadow: none;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.story-card-white-text h1,
.story-card-white-text h2,
.story-card-white-text h3 {
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.story-card-white-text .story-body {
  color: rgba(255, 255, 255, 0.95);
}

.story-card-white-text .story-body a {
  color: #93c5fd;
}

.story-card-white-text .story-stat {
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* Black text, no card background — for use over light maps */
.story-card-black-text {
  background: none;
  box-shadow: none;
  color: #1a1a2e;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.8);
}

.story-card-black-text h1,
.story-card-black-text h2,
.story-card-black-text h3 {
  color: #1a1a2e;
}

.story-card-black-text .story-body {
  color: #222;
}

.story-card-black-text .story-stat {
  color: #1a1a2e;
}

/* ── Background image chapters ─────────────────────────────────────── */
.story-has-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

/* Dark overlay so text stays readable over the background image */
.story-has-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 0;
}

.story-has-bg > .story-card {
  position: relative;
  z-index: 1;
}

/* Stronger overlay when white text is used over background image */
.story-has-bg:has(.story-card-white-text)::before {
  background: rgba(0, 0, 0, 0.55);
}

/* Keep light card opaque over background image */
.story-has-bg > .story-card:not(.story-card-dark):not(.story-card-white-text):not(.story-card-black-text) {
  background: rgba(255, 255, 255, 0.92);
}

.story-card-left {
  margin-left: 5%;
}

.story-card-right {
  margin-left: auto;
  margin-right: 5%;
}

.story-card-center {
  margin: 0 auto;
  text-align: center;
}

.story-card-full {
  max-width: 720px;
  margin: 0 auto;
}

/* ── Chapter type variations ───────────────────────────────────────── */

/* Text-only: full-width opaque background, map hidden */
.story-text-only {
  background: #fff;
  min-height: auto;
  padding: 3rem 0;
}

.story-text-only .story-card {
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.story-text-only .story-card-dark {
  background: rgba(10, 10, 30, 0.92);
  backdrop-filter: blur(6px);
}

.story-text-only:has(.story-card-dark) {
  background: #0a0a1e;
}

/* Title chapter: centered, semi-transparent dark overlay */
.story-title-card,
.story-title-chapter {
  justify-content: center;
  min-height: 90vh;
}

/* Bottom-aligned text position for title chapters */
.story-title-chapter.story-text-bottom {
  justify-content: flex-end;
  padding-bottom: 4rem;
}

/* Title card default style — only when no explicit card style override */
.story-title-card .story-card:not(.story-card-dark):not(.story-card-white-text):not(.story-card-black-text),
.story-title-chapter .story-card:not(.story-card-dark):not(.story-card-white-text):not(.story-card-black-text) {
  background: rgba(10, 10, 30, 0.72);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.story-title-card .story-card,
.story-title-chapter .story-card {
  max-width: 600px;
}

.story-title-card .story-card h1,
.story-title-chapter .story-card h2 {
  color: inherit;
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

/* Title card text colors — only for default (non-overridden) style */
.story-title-card .story-card:not(.story-card-white-text):not(.story-card-black-text) .lead {
  color: rgba(255, 255, 255, 0.85);
}

.story-title-card .story-card:not(.story-card-white-text):not(.story-card-black-text) .text-muted {
  color: rgba(255, 255, 255, 0.6) !important;
}

.story-title-chapter .story-card:not(.story-card-white-text):not(.story-card-black-text) .story-body {
  color: rgba(255, 255, 255, 0.85);
}

/* Data callout: big number with count-up */
.story-callout {
  justify-content: center;
}

.story-callout .story-card {
  max-width: 500px;
}

.story-callout .story-card:not(.story-card-dark):not(.story-card-white-text):not(.story-card-black-text) {
  background: rgba(255, 255, 255, 0.95);
}

.story-stat {
  font-size: 4.5rem;
  font-weight: 800;
  color: #3b82f6;
  line-height: 1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* Stat size variants for data-callout chapters */
.story-stat-medium {
  font-size: 2.5rem;
  font-weight: 700;
}

.story-stat-small {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Stat suffix label (e.g. "miles", "%") displayed after the number */
.story-stat-suffix {
  font-size: 0.4em;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 0.15em;
  vertical-align: baseline;
}

/* ── Media ─────────────────────────────────────────────────────────── */
.story-media {
  margin: 1rem 0 0;
  pointer-events: auto;
}

.story-media img {
  max-width: 100%;
  border-radius: 0.25rem;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
}

/* Full-bleed media chapter */
.story-media-chapter {
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.story-media-chapter .story-media {
  max-width: 90%;
  margin: 0 auto;
}

.story-media-chapter .story-media img {
  max-height: 70vh;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.story-caption {
  text-align: center;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.5rem;
}

/* ── Body text ─────────────────────────────────────────────────────── */
.story-body {
  font-size: 1rem;
  line-height: 1.65;
  color: #333;
  text-align: left;
}

.story-body p {
  margin-bottom: 0.75rem;
}

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

/* ── Survey data cards ─────────────────────────────────────────────── */
.survey-data-card table {
  border-collapse: collapse;
}

.survey-data-card td {
  padding: 2px 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.survey-data-card .survey-photo img {
  max-height: 200px;
  object-fit: cover;
}

/* Dark card variant */
.story-card-dark .survey-data-card {
  border-color: rgba(255, 255, 255, 0.15) !important;
}

.story-card-dark .survey-data-card td {
  color: rgba(255, 255, 255, 0.85);
}

.story-card-dark .survey-data-card .text-muted {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* ── Active chapter indicator ──────────────────────────────────────── */
.story-chapter.active .story-card {
  box-shadow: 0 2px 20px rgba(59, 130, 246, 0.25);
}

/* ── Mobile: bottom-drawer cards ──────────────────────────────────── */
/* Cards anchor to the bottom of the viewport like a map info drawer.
   The map fills the top ~60%, text occupies the bottom ~40%.
   Scrolling advances between chapters; the card slides up from below. */

@media (max-width: 768px) {
  /* On mobile, the story scroll should always win over map interaction.
     Make the map non-interactive so all vertical swipes scroll the story.
     The map is context/backdrop — users don't need to pan/zoom during a story. */
  #map {
    pointer-events: none;
  }
  #story-scroll {
    pointer-events: auto;
  }

  /* Chapters use flex-end so cards sit at the bottom of the viewport */
  .story-chapter {
    min-height: 100vh;
    align-items: flex-end;
    padding: 0;
  }

  /* The card: anchored to bottom, capped height, scrollable if long */
  .story-card {
    max-width: 100%;
    width: 100%;
    margin: 0 !important;
    padding: 1rem 1.25rem 1.5rem;
    font-size: 0.92rem;
    border-radius: 0.75rem 0.75rem 0 0;
    max-height: 55vh;
    overflow-y: auto;
    overscroll-behavior: contain; /* prevent pull-to-refresh interference */
    -webkit-overflow-scrolling: touch;
    /* Subtle top edge */
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
  }

  /* Images inside mobile cards: fit within the card */
  .story-card .story-media img,
  .story-card .story-body img {
    max-height: 28vh;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin: 0.5rem auto;
  }

  /* Grab handle — visual hint that the card is a drawer */
  .story-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(128, 128, 128, 0.3);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
  }

  .story-card-dark::before {
    background: rgba(255, 255, 255, 0.25);
  }

  /* Full-width cards (text-only chapters) */
  .story-card-full {
    max-width: 100%;
  }

  /* Title cards: taller drawer for the opening */
  .story-title-card,
  .story-title-chapter {
    min-height: 100vh;
  }

  .story-title-card .story-card h1,
  .story-title-chapter .story-card h2 {
    font-size: 1.5rem;
  }

  /* Data callouts: shorter drawer */
  .story-callout .story-card {
    text-align: center;
  }

  .story-stat {
    font-size: 2.5rem;
  }
  .story-stat-medium {
    font-size: 2rem;
  }
  .story-stat-small {
    font-size: 1.25rem;
  }

  /* Spacers: shorter on mobile, just enough to show map-only */
  .story-spacer {
    height: 50vh;
  }

  /* Topbar */
  #story-topbar {
    font-size: 0.8rem;
    padding: 0 0.75rem;
  }

  /* Text-only chapters: card fills more since there's no map to show */
  .story-text-only {
    padding: 0;
  }

  .story-text-only .story-card {
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* Video embeds */
  .story-media.ratio {
    pointer-events: auto;
  }

  /* Headings tighter in drawer */
  .story-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
  }

  .story-body {
    line-height: 1.55;
  }

  .story-body p {
    margin-bottom: 0.5rem;
  }
}

/* Small phones: same drawer, slightly tighter */
@media (max-width: 480px) {
  .story-card {
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
  }

  .story-title-card .story-card h1,
  .story-title-chapter .story-card h2 {
    font-size: 1.3rem;
  }

  .story-stat {
    font-size: 2rem;
  }
  .story-stat-medium {
    font-size: 1.5rem;
  }
  .story-stat-small {
    font-size: 1.1rem;
  }
}

/* ── Print styles ──────────────────────────────────────────────────── */
@media print {
  /* Hide map, locator, topbar, progress, share modal */
  #map, #locator-map, #story-topbar, #story-progress,
  #share-modal, #share-btn, .story-spacer {
    display: none !important;
  }

  /* Reset scroll container — undo the negative margin that overlaps the map */
  #story-scroll {
    position: static !important;
    margin-top: 0 !important;
    pointer-events: auto !important;
    z-index: auto !important;
  }

  body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }

  /* Chapters as flowing blocks, not positioned over map */
  .story-chapter {
    min-height: auto !important;
    padding: 1.5rem 0 !important;
    display: block !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Cards fill width, no transparency */
  .story-card {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  /* Dark cards print as black text on white */
  .story-card-dark,
  .story-card-white-text,
  .story-card-black-text {
    background: #fff !important;
    color: #000 !important;
    text-shadow: none !important;
  }

  .story-card-dark h1, .story-card-dark h2, .story-card-dark h3,
  .story-card-white-text h1, .story-card-white-text h2, .story-card-white-text h3 {
    color: #000 !important;
  }

  .story-card-dark .story-body,
  .story-card-white-text .story-body {
    color: #333 !important;
  }

  /* Background images don't print */
  .story-has-bg {
    background-image: none !important;
  }
  .story-has-bg::before {
    display: none !important;
  }

  /* Text-only chapters: no colored background */
  .story-text-only {
    background: #fff !important;
  }

  /* Data callouts print normally */
  .story-stat {
    color: #000 !important;
    font-size: 2.5rem !important;
  }

  /* Title card: clean header style */
  .story-title-card .story-card,
  .story-title-chapter .story-card {
    border-bottom: 2px solid #000 !important;
    padding-bottom: 1rem !important;
    margin-bottom: 1rem !important;
  }

  /* Chapter dividers */
  .story-chapter + .story-chapter {
    border-top: 1px solid #ccc;
    padding-top: 1.5rem;
  }

  /* Media: limit image height for print */
  .story-media img {
    max-height: 300px;
    object-fit: contain;
  }

  /* Survey data tables */
  .survey-data-card td {
    color: #000 !important;
  }

  /* End section */
  .story-end {
    height: auto !important;
    padding: 2rem 0 !important;
  }
  .story-end .story-card {
    text-align: center;
  }

  /* Print footer */
  .story-end::after {
    content: 'Generated from WikiMapping — wikimapping.com';
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
  }
}

/* ═══════════════════════════════════════════════════════════
   GALLERY CHAPTER
   ═══════════════════════════════════════════════════════════ */

.story-gallery-chapter .story-card {
  max-width: 1000px;
}

.story-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.story-gallery-masonry {
  columns: 3 200px;
  column-gap: 1rem;
}

.story-gallery-masonry .story-gallery-thumb {
  break-inside: avoid;
  margin-bottom: 1rem;
}

.story-gallery-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-gallery-thumb:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.story-gallery-thumb img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.story-gallery-masonry .story-gallery-thumb img {
  aspect-ratio: auto;
}

.story-gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   GALLERY LIGHTBOX
   ═══════════════════════════════════════════════════════════ */

.story-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.story-lightbox.open {
  display: flex;
}

.story-lb-img {
  max-width: 90%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}

.story-lb-close,
.story-lb-prev,
.story-lb-next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  padding: 8px 16px;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 1;
}

.story-lb-close:hover,
.story-lb-prev:hover,
.story-lb-next:hover {
  opacity: 1;
}

.story-lb-close {
  top: 1rem;
  right: 1rem;
}

.story-lb-prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.story-lb-next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.story-lb-counter {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

.story-lb-info {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  max-width: 80%;
  color: #fff;
}

.story-lb-title {
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.story-lb-desc {
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.8;
}

@media (max-width: 600px) {
  .story-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .story-gallery-masonry {
    columns: 2;
  }
  .story-lb-prev,
  .story-lb-next {
    font-size: 1.5rem;
  }
}

/* ─── Timeline chapter ──────────────────────────────────────────────── */
.tl-timeline {
  position: relative;
  margin-top: 1.5rem;
  padding-left: 2rem;
  border-left: 3px solid #3b82f6;
}

.tl-event {
  position: relative;
  margin-bottom: 2rem;
  padding-left: 0.5rem;
}

.tl-event:last-child { margin-bottom: 0; }

.tl-marker {
  position: absolute;
  left: -2.45rem;
  top: 0.15rem;
  width: 1.25rem;
  height: 1.25rem;
  background: #fff;
  border: 3px solid #3b82f6;
  border-radius: 50%;
}

.tl-date {
  font-weight: 700;
  color: #3b82f6;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.tl-title {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.tl-body {
  margin: 0;
  color: #555;
  font-size: 0.92rem;
  line-height: 1.5;
}

.tl-image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 6px;
  margin: 0.5rem 0;
}

.tl-has-location .tl-marker {
  background: #3b82f6;
  cursor: pointer;
}
.tl-has-location .tl-marker::after {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Dark card variant */
.story-card-dark .tl-timeline { border-color: #60a5fa; }
.story-card-dark .tl-marker { border-color: #60a5fa; background: #1f2937; }
.story-card-dark .tl-has-location .tl-marker { background: #60a5fa; }
.story-card-dark .tl-date { color: #93c5fd; }
.story-card-dark .tl-body { color: rgba(255,255,255,0.75); }

@media (max-width: 768px) {
  .tl-timeline { padding-left: 1.5rem; }
  .tl-marker { left: -1.95rem; width: 1rem; height: 1rem; }
}

/* ─── Tour chapter ──────────────────────────────────────────────────── */
.story-tour { min-height: 90vh; }

.tour-stops {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 1rem;
}

.tour-stop {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.tour-stop:hover { background: #eff6ff; border-color: #93c5fd; }
.tour-stop.active { background: #dbeafe; border-color: #3b82f6; }

.tour-stop-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.tour-stop-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.85rem;
}
.tour-stop-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tour-stop-cat {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Dark card variant */
.story-card-dark .tour-stop { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
.story-card-dark .tour-stop:hover { background: rgba(255,255,255,0.15); }
.story-card-dark .tour-stop.active { background: rgba(59,130,246,0.3); border-color: #60a5fa; }
.story-card-dark .tour-stop-cat { color: rgba(255,255,255,0.5); }

/* ─── Top Bar Button Group ──────────────────────────────────────────── */
.story-topbar-buttons {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

/* ─── Sections Panel (drops down from top bar) ─────────────────────── */
.story-toc-panel {
  position: fixed;
  top: 40px;
  right: 12px;
  z-index: 999;
  display: none;
}

.story-toc-panel.open { display: block; }

.story-toc-panel .story-toc-list {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 6px 0;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 180px;
  max-width: 260px;
}

.story-toc-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.story-toc-item:hover { background: #f0f4f8; color: #111; }
.story-toc-item.active { color: #3b82f6; font-weight: 600; background: #eff6ff; }

@media (max-width: 768px) {
  .story-toc-panel { right: 8px; }
  .story-toc-panel .story-toc-list { max-width: 200px; }
}

/* ── Policy Context disclosure (chapter.policy_context from viewer) ── */
.story-policy-context {
  margin-top: 0.85rem;
  padding: 0.6rem 0.85rem 0.55rem;
  border: 1px solid rgba(120, 130, 145, 0.25);
  border-left: 3px solid #5b6cf0;
  border-radius: 6px;
  background: rgba(91, 108, 240, 0.05);
  font-size: 0.92em;
}
.story-policy-context > summary {
  cursor: pointer;
  font-weight: 600;
  color: #3b4ad1;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.story-policy-context > summary::-webkit-details-marker { display: none; }
.story-policy-context > summary i { font-size: 0.9em; opacity: 0.8; }
.story-policy-context[open] > summary { margin-bottom: 0.5rem; }
.story-policy-body { line-height: 1.45; color: inherit; }
.story-policy-body p:last-child { margin-bottom: 0; }
.story-policy-list { margin: 0; padding-left: 1.2rem; }
.story-policy-list li { margin-bottom: 0.4rem; }
.story-policy-list li:last-child { margin-bottom: 0; }

/* Dark card variant — softer background, lighter text */
.story-card-dark .story-policy-context,
.story-card-white-text .story-policy-context {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  border-left-color: #a3b0ff;
  color: rgba(255, 255, 255, 0.92);
}
.story-card-dark .story-policy-context > summary,
.story-card-white-text .story-policy-context > summary {
  color: #cdd5ff;
}
