/* PresentationPlayer styles — two-panel layout, click-to-play stage,
   cross-dissolve image transitions, TOC overlay. Civic palette throughout. */

.vp {
  margin: 32px 0;
  border: 1px solid var(--rule);
  background: var(--paper-alt);
  overflow: hidden;
  position: relative;
}
.vp.compact { margin: 16px 0; }

/* ----- Header ----- */
.vp-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.vp-eyebrow {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--highlight); margin-bottom: 8px;
}
.vp-title h3,
.vp-title .vp-current-slide {
  margin: 0; font-weight: 600; font-size: 22px;
  letter-spacing: -0.018em; color: var(--ink);
}
.vp-progress-text {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-50); margin-top: 6px; letter-spacing: 0.04em;
}
.vp-toc-toggle {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 12px;
  background: var(--paper); border: 1px solid var(--rule);
  color: var(--ink); cursor: pointer;
  align-self: flex-start;
}
.vp-toc-toggle:hover { background: var(--paper-alt); }

/* ----- Overall bar ----- */
.vp-overall {
  height: 3px; background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.vp-overall-fill {
  height: 100%; background: var(--accent);
  transition: width .25s ease;
}

/* ----- Two-panel body ----- */
.vp-body.two-panel {
  display: grid; grid-template-columns: 1fr;
}
.vp-body.two-panel.text-panel {
  grid-template-columns: 1fr 380px;
}

/* Stage (left panel) — dark, image-friendly */
.vp-stage-wrap {
  position: relative;
  background: #1b1c1b;
  min-height: 320px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 28px 28px 24px;
  overflow: hidden;
}
.vp.compact .vp-stage-wrap { min-height: 200px; padding: 18px; }

.vp-slide-index {
  position: absolute; top: 12px; left: 14px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.82);          /* ≥4.5:1 on #1b1c1b */
  pointer-events: none;
}

.vp-stage {
  width: 100%;
  max-width: 100%;
  color: var(--paper);
}

/* Pre-loaded image layer. Every image slide sits in the DOM concurrently;
   switching slides only changes the .is-active class, so transitions are
   true cross-dissolves rather than swap-and-mount. */
.vp-stage-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  background: #0f0e0c;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 600ms ease, transform 8000ms ease-out;
  pointer-events: none;
}
.vp-stage-img.is-active {
  opacity: 1;
  transform: scale(1.0);
}
@media (prefers-reduced-motion: reduce) {
  .vp-stage-img {
    transition-duration: 0ms;
    transform: none;
  }
  .vp-stage-img.is-active { transform: none; }
}

/* Light readability defaults for stage content on dark background */
.vp-stage .vs-eyebrow { color: var(--highlight); }
.vp-stage .vs-title h3,
.vp-stage .vs-list h3,
.vp-stage .vs-compare h3 { color: var(--paper); }
.vp-stage .vs-title .vs-sub { color: #ffc350; }
.vp-stage .vs-stat .vs-stat-value { color: #ffc350; }
.vp-stage .vs-stat .vs-stat-label { color: rgba(255,255,255,0.85); }  /* ≥4.5:1 */
.vp-stage .vs-stat .vs-stat-body  { color: rgba(255,255,255,0.9); }
.vp-stage .vs-list li { color: rgba(255,255,255,0.92); border-bottom-color: rgba(255,255,255,0.16); }
.vp-stage .vs-list li .vl-label { color: var(--paper); }
.vp-stage .vs-list li .vl-desc  { color: rgba(255,255,255,0.82); }    /* ≥4.5:1 */
.vp-stage .vs-quote blockquote { color: var(--paper); border-left-color: var(--highlight); }
.vp-stage .vs-quote .vs-cite { color: rgba(255,255,255,0.82); }       /* ≥4.5:1 */
.vp-stage .vs-compare-col { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
.vp-stage .vs-compare-col .vs-c-lbl { color: #ffc350; }
.vp-stage .vs-compare-col .vs-c-body { color: rgba(255,255,255,0.92); }
.vp-stage .vs-image img { box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.vp-stage .vs-image .vs-caption { color: rgba(255,255,255,0.85); }    /* ≥4.5:1 */

/* Big YouTube-style play overlay when paused */
.vp-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0.85;
  transition: opacity .2s;
}
.vp-stage-wrap:hover .vp-overlay { opacity: 1; }
.vp-overlay-btn {
  width: 72px; height: 72px;
  background: rgba(26,58,110,0.85);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  border-radius: 50%;
  padding-left: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.vp.compact .vp-overlay-btn { width: 52px; height: 52px; font-size: 20px; }

/* Friendly error / regen panel */
.vp-error-panel {
  position: absolute; inset: 0;
  background: rgba(27,28,27,0.94);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  pointer-events: auto;
}
.vp-error-l {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--highlight-on-dark);             /* on dark error panel */
  margin-bottom: 10px;
}
.vp-error-body {
  color: rgba(255,255,255,0.85); font-size: 14px;
  line-height: 1.5; max-width: 42ch; margin-bottom: 14px;
}
.vp-error-cmd {
  font-family: var(--font-mono); font-size: 11px;
  background: #0f0e0c; color: #ffc350;
  padding: 8px 12px; border-radius: 0;
  max-width: 100%; overflow-x: auto; margin: 0;
}

/* Text panel (right) */
.vp-text-panel {
  padding: 28px 28px 24px;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  overflow-y: auto;
  max-height: 520px;
}
.vp-text-caption {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--highlight); margin-bottom: 8px;
}
.vp-text-title {
  font-weight: 600; font-size: 22px; line-height: 1.2;
  letter-spacing: -0.018em; color: var(--ink); margin: 0 0 8px;
}
.vp-text-sub {
  font-weight: 500; font-size: 15px; line-height: 1.4;
  color: var(--accent); margin: 0 0 14px;
  letter-spacing: -0.008em;
}
.vp-text-body {
  font-size: 14px; line-height: 1.65;
  color: var(--ink-70); margin: 0;
  letter-spacing: -0.003em;
}

/* ----- Controls bar ----- */
.vp-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  background: var(--paper-alt);
}
.vp-btn {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer; transition: background .12s;
}
.vp-btn:hover:not(:disabled) { background: var(--paper-alt); }
.vp-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.vp-btn.vp-play {
  background: var(--accent); color: var(--paper); border-color: var(--accent);
}
.vp-btn.vp-play:hover:not(:disabled) { background: var(--accent-soft); }

.vp-scrub {
  flex: 1 1 200px; display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.vp-time {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-50); white-space: nowrap; flex: 0 0 auto;
  letter-spacing: 0.04em; font-variant-numeric: tabular-nums;
}
.vp-track {
  flex: 1; height: 6px; background: var(--rule); cursor: pointer; position: relative;
}
.vp-fill { height: 100%; background: var(--highlight); transition: width .15s linear; }

.vp-auto {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-50); cursor: pointer;
}
.vp-auto input { accent-color: var(--accent); }

.vp-hint {
  text-align: center; padding: 10px 16px 14px;
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-50); margin: 0;
}

/* ----- TOC overlay ----- */
.vp-toc-overlay {
  position: absolute; inset: 0;
  background: rgba(247,244,237,0.96);
  backdrop-filter: blur(4px);
  z-index: 30;
  padding: 24px;
  overflow-y: auto;
}
.vp-toc-panel {
  max-width: 640px; margin: 0 auto;
}
.vp-toc-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-50);
}
.vp-toc-close {
  background: none; border: 0; font-size: 22px; cursor: pointer;
  color: var(--ink-50); line-height: 1;
}
.vp-toc-item {
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 0;
  padding: 10px 12px; display: flex; gap: 14px;
  border-bottom: 1px dotted var(--rule);
  font-size: 13px; color: var(--ink-70);
  align-items: baseline; line-height: 1.4;
}
.vp-toc-item:hover { background: var(--paper); }
.vp-toc-item.on   { background: var(--ink); color: var(--paper); }
.vp-toc-item.on .n { color: var(--highlight); }
.vp-toc-item.done .n { color: var(--ok); }
.vp-toc-item .n {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--highlight); flex: 0 0 auto; min-width: 24px;
}
.vp-toc-item .t { flex: 1; }
/* has-media pill: green dot when audio is generated and reachable */
.vp-toc-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex: 0 0 auto;
  align-self: center;
}
.vp-toc-item.on .vp-toc-dot { background: #6ee7b7; }

/* ----- Stage visual variants (kept from previous version) ----- */
.vp-slide { width: 100%; }

.vs-eyebrow {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--highlight); margin-bottom: 12px;
}
.vs-title h3 {
  font-weight: 600; font-size: 38px; line-height: 1.05;
  letter-spacing: -0.025em; margin: 0;
}
.vs-title .vs-sub {
  font-weight: 500; font-size: 18px; line-height: 1.4;
  margin: 14px 0 0; max-width: 50ch; letter-spacing: -0.012em;
}
.vs-image img { max-width: 100%; max-height: 60vh; object-fit: contain; }
.vs-image .vs-caption { margin-top: 10px; font-style: italic; font-size: 13px; line-height: 1.5; }
.vs-stat .vs-stat-value { font-weight: 600; font-size: 96px; line-height: 1; letter-spacing: -0.04em; }
.vs-stat .vs-stat-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 10px; }
.vs-stat .vs-stat-body  { margin-top: 14px; font-size: 15px; line-height: 1.55; max-width: 56ch; }
.vs-list h3 { font-weight: 600; font-size: 22px; margin: 0 0 14px; letter-spacing: -0.018em; }
.vs-list ul { list-style: none; padding: 0; margin: 0; }
.vs-list li { padding: 10px 0; display: grid; grid-template-columns: 200px 1fr; gap: 18px; font-size: 14px; line-height: 1.5; }
.vs-list li .vl-label { font-weight: 600; }
.vs-quote blockquote { margin: 0; padding: 0 0 0 22px; font-weight: 500; font-size: 26px; line-height: 1.3; letter-spacing: -0.022em; max-width: 38ch; border-left: 3px solid var(--highlight); }
.vs-quote .vs-cite { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 14px; }
.vs-compare h3 { font-weight: 600; font-size: 22px; margin: 0 0 14px; letter-spacing: -0.018em; }
.vs-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.vs-compare-col { border: 1px solid var(--rule); padding: 16px 18px; }
.vs-compare-col .vs-c-lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 8px; }
.vs-compare-col .vs-c-body { font-size: 14px; line-height: 1.55; }
.vs-fallback { color: var(--ink-70); font-size: 14px; }

.vp.compact .vp-stage h3 { font-size: 22px; }
.vp.compact .vs-stat .vs-stat-value { font-size: 60px; }

/* ----- Locale switch in nav ----- */
.nav-trail { display: flex; align-items: center; gap: 18px; }
.locale-switch { display: flex; border: 1px solid var(--rule); }
.locale-switch button {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.12em; padding: 4px 10px;
  background: transparent; color: var(--ink); border: 0; cursor: pointer;
  border-left: 1px solid var(--rule);
}
.locale-switch button:first-child { border-left: 0; }
.locale-switch button.on { background: var(--ink); color: var(--paper); }

/* ----- Transitions ----- */
.vp-fade-enter-active, .vp-fade-leave-active {
  transition: opacity 200ms ease;
}
.vp-fade-enter-from, .vp-fade-leave-to { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .vp-fade-enter-active, .vp-fade-leave-active { transition-duration: 0ms; }
  .vp-overall-fill, .vp-fill, .vp-overlay { transition: none; }
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .vp { margin: 22px 0; }
  .vp-head { padding: 14px 16px; }
  .vp-title h3,
  .vp-title .vp-current-slide { font-size: 18px; }
  .vp-toc-toggle { font-size: 10px; padding: 8px 12px; min-height: 36px; }

  .vp-body.two-panel.text-panel { grid-template-columns: 1fr; }
  .vp-text-panel {
    border-left: 0; border-top: 1px solid var(--rule);
    max-height: none; padding: 20px 18px;
  }
  .vp-stage-wrap { min-height: 220px; padding: 18px; }
  .vp-overlay-btn { width: 56px; height: 56px; font-size: 22px; }
  .vp-text-title { font-size: 18px; }
  .vp-text-sub { font-size: 14px; }
  .vp-text-body { font-size: 13.5px; }

  .vs-stat .vs-stat-value { font-size: 56px; }
  .vs-title h3 { font-size: 26px; }
  .vs-list li { grid-template-columns: 1fr; gap: 4px; }
  .vs-compare-grid { grid-template-columns: 1fr; }
  .vs-quote blockquote { font-size: 20px; max-width: none; }

  /* Controls bar reflows: prev/play/next on row 1, scrubber on row 2, auto on row 3 */
  .vp-controls {
    gap: 8px;
    padding: 10px 12px;
  }
  .vp-btn { padding: 10px 12px; font-size: 10px; min-height: 40px; min-width: 56px; }
  .vp-btn.vp-play { min-width: 88px; }
  .vp-scrub {
    flex: 1 1 100%; order: 10;
    margin-top: 4px;
  }
  .vp-auto { flex: 1 1 100%; order: 11; }
  .vp-time { font-size: 10px; }
  .vp-track { height: 8px; }            /* easier to tap */

  .vp-hint { font-size: 9px; padding: 8px 12px 12px; }

  /* TOC overlay → fuller viewport */
  .vp-toc-overlay { padding: 16px; }
  .vp-toc-item { padding: 14px 12px; min-height: 44px; }
}

/* Large phones (≤430px) */
@media (max-width: 430px) {
  .vp { margin: 20px 0; }
  .vp-head { padding: 12px 14px; }
  .vp-stage-wrap { min-height: 200px; }
  .vs-stat .vs-stat-value { font-size: 48px; }
  .vs-title h3 { font-size: 24px; }
}

/* Standard phones (≤520px) */
@media (max-width: 520px) {
  .vp { margin: 18px 0; }
  .vp-head { padding: 12px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .vp-toc-toggle { align-self: flex-end; }
  .vp-stage-wrap { min-height: 200px; padding: 16px; }
  .vp-overlay-btn { width: 48px; height: 48px; font-size: 18px; }
  .vp-slide-index { font-size: 9px; }
  .vp-text-panel { padding: 16px 14px; }
  .vs-stat .vs-stat-value { font-size: 44px; }
  .vs-title h3 { font-size: 22px; }
  .vs-title .vs-sub { font-size: 15px; }
  .vp-btn { padding: 9px 10px; min-width: 48px; }
  .vp-btn.vp-play { min-width: 76px; }
  .vp-error-cmd { font-size: 9.5px; }
}

/* Small phones (≤390px) — iPhone SE, standard iPhone, narrow Android */
@media (max-width: 390px) {
  .vp-head { padding: 10px 12px; }
  .vp-title h3,
  .vp-title .vp-current-slide { font-size: 16px; }
  .vp-stage-wrap { min-height: 180px; padding: 14px; }
  .vp-overlay-btn { width: 44px; height: 44px; font-size: 16px; }
  .vp-text-panel { padding: 14px 12px; }
  .vp-text-title { font-size: 16px; }
  .vp-text-body { font-size: 13px; }
  .vs-stat .vs-stat-value { font-size: 38px; }
  .vs-title h3 { font-size: 20px; }
  /* Controls collapse to icons-only labels on the narrowest devices */
  .vp-controls { padding: 8px 10px; gap: 6px; }
  .vp-btn { padding: 9px 8px; min-width: 44px; font-size: 9.5px; letter-spacing: 0.04em; }
  .vp-btn.vp-play { min-width: 68px; }
  .vp-hint { display: none; }   /* keyboard hint is irrelevant on phone */
}

/* Android small (≤360px) */
@media (max-width: 360px) {
  .vp-stage-wrap { min-height: 160px; padding: 12px; }
  .vp-overlay-btn { width: 40px; height: 40px; font-size: 14px; }
  .vp-text-panel { padding: 12px; }
  .vs-stat .vs-stat-value { font-size: 32px; }
  .vs-title h3 { font-size: 18px; }
  .vp-controls { padding: 8px; }
  .vp-btn { padding: 8px 6px; min-width: 38px; font-size: 9px; }
  .vp-btn.vp-play { min-width: 58px; }
  .vp-toc-toggle { font-size: 9.5px; padding: 6px 10px; }
}

/* Landscape phones — short viewport, wider than tall */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  .vp-body.two-panel.text-panel { grid-template-columns: 1.4fr 1fr; }   /* keep two-panel in landscape */
  .vp-text-panel { border-left: 1px solid var(--rule); border-top: 0; max-height: 60vh; }
  .vp-stage-wrap { min-height: 160px; padding: 12px; }
  .vp-overlay-btn { width: 40px; height: 40px; font-size: 14px; }
  .vp-controls { gap: 6px; padding: 8px 12px; }
}

/* Image-inspector bottom sheet — honor iOS home-indicator safe area */
.img-inspector-panel { padding-bottom: max(12px, var(--safe-bottom, 0px)); }

/* Floating narration control — page-level quick play/pause/close for the
   long-form narration. Fixed bottom-right; sits below modals (9500) and, in
   edit mode, lifts above the editor toolbar (9000 at bottom:16px) so the edit
   button stays visible. */
.vw-fab-audio {
  position: fixed;
  right: calc(16px + var(--safe-right, 0px));
  bottom: calc(16px + var(--safe-bottom, 0px));
  z-index: 8000;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--paper, #F7F4ED);
  border: 1px solid var(--rule-strong, #B8AE99);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(11, 12, 15, 0.22);
  animation: vw-fab-in 160ms ease-out;
}

.vw-fab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;          /* never let flex shrink the circle into an oval */
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent, #1A3A6E);
  padding: 0;
  line-height: 0;
}
.vw-fab-btn svg { display: block; }
.vw-fab-toggle { background: var(--accent, #1A3A6E); color: var(--paper, #F7F4ED); }
.vw-fab-toggle svg { fill: currentColor; }
.vw-fab-toggle:hover { background: var(--accent-soft, #2E5A9E); }
.vw-fab-close { color: var(--ink-50, #5E5F66); }
.vw-fab-close:hover { color: var(--ink, #0B0C0F); background: var(--paper-alt, #EFEAD9); }

@keyframes vw-fab-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .vw-fab-audio { animation: none; }
  .civic-detail .toc-fab { transition: none; }
}

/* While the narration control occupies the bottom-right corner, lift the
   mobile section-navigation (TOC) button above it so the two never overlap.
   Higher specificity (body + two classes) wins over the breakpoint overrides. */
body.vw-narration-fab .civic-detail .toc-fab {
  bottom: calc(80px + var(--safe-bottom, 0px));
}
