/* =================================================================
   INDEX-THEATER.CSS
   Dedicated styles for the index.html scrollytelling experience.
   Decision Card theater, threshold scene, progress rail,
   before/after panel, state chips, editorial rhythm.
   ================================================================= */

/* ========== PROGRESS RAIL ========== */
/* Fixed left-edge chapter indicator. Must contrast on ALL backgrounds
   (cream, teal/dark, black threshold, white). Uses its own opaque
   background capsule so it never relies on section colors. */

.progress-rail {
  position: fixed;
  left: 0.75rem;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
  z-index: 300; /* above sticky cards */
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  /* Opaque capsule behind the entire rail */
  background: rgba(250, 247, 242, 0.88);
  padding: 10px 6px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.rail-track {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  position: relative;
}

/* Vertical connecting line */
.rail-track::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 2px;
  background: #c9c1b4;
  transform: translateX(-50%);
  z-index: -1;
}

.rail-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c9c1b4;
  border: 2px solid white;
  display: block;
  transition: all var(--transition-normal);
  position: relative;
  margin: 10px 0;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.rail-dot.active {
  background: var(--color-primary);
  border-color: white;
  box-shadow: 0 0 0 3px rgba(26, 92, 87, 0.25);
  transform: scale(1.3);
}

.rail-dot.visited {
  background: var(--color-secondary-1);
  border-color: white;
}

.rail-label {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: var(--color-primary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
  background: white;
  padding: 3px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.rail-dot:hover .rail-label,
.rail-dot.active .rail-label {
  opacity: 1;
}


/* ========== VISUAL STATE CHIPS ========== */

.state-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.is-draft {
  background: #f0ece4;
  color: #8a7d68;
  border: 1px dashed #c9bfa8;
}

.is-live {
  background: #e6f4ec;
  color: #1a6b3c;
  border: 1px solid #a5d6b7;
}

.is-warning {
  background: #fff3e0;
  color: #c26a00;
  border: 1px solid #f0c080;
}

.is-threshold {
  background: #fbe8e8;
  color: #b71c1c;
  border: 1px solid #e0a0a0;
  animation: pulse-threshold 2s ease-in-out infinite;
}

.is-paused {
  background: #e8eaf6;
  color: #3949ab;
  border: 1px solid #9fa8da;
}

.is-verified {
  background: #e0f2f1;
  color: var(--color-primary);
  border: 1px solid var(--color-secondary-1);
}

@keyframes pulse-threshold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(183, 28, 28, 0); }
  50% { box-shadow: 0 0 0 6px rgba(183, 28, 28, 0.12); }
}


/* ========== CHAPTER MARKERS ========== */

.chapter {
  position: relative;
}

.before-after-section {
  background: var(--color-background);
}


/* ========== EDITORIAL HERO ========== */

.hero-editorial {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 2rem 4rem;
  /* Override .hero overflow:hidden so it doesn't clip adjacent sticky */
  overflow: visible;
}

.hero-editorial .hero-content {
  max-width: 680px;
  /* Explicit centering for Safari */
  margin: auto;
}

.hero-kicker {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin-bottom: 1.5rem;
}

.hero-editorial .hero-headline {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
  margin-bottom: 1.5rem;
}

.hero-editorial .hero-subline {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  opacity: 0.85;
}


/* ========== NARROW PROSE ========== */

.narrow-prose .insight-container {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 1.5rem;
}


/* ========== DECISION CARD THEATER ========== */

.card-theater {
  display: -webkit-flex;
  display: flex;
  min-height: 100vh;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  /* Safari: explicit overflow for sticky children */
  overflow: visible;
}

/* LEFT: Sticky card */
.theater-card-column {
  -webkit-flex: 0 0 42%;
  flex: 0 0 42%;
  position: relative;
  /* Safari: explicit width fallback for flex-basis */
  width: 42%;
  min-width: 0;
}

.theater-card {
  position: -webkit-sticky;
  position: sticky;
  top: 120px;
  background: white;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color 0.6s ease, box-shadow 0.6s ease, border-style 0.6s ease;
  max-width: 380px;
}

/* Ghost state — card starts incomplete and unstable */
.theater-card.is-ghost {
  border-color: #d8d0c4;
  border-style: dashed;
  opacity: 0.75;
  background: #fdfcfa;
}

.ghost-text {
  color: #c9c1b4 !important;
  font-style: italic;
  letter-spacing: 0.03em;
}

/* Card evolves visually as it fills */
.theater-card.is-emerging {
  border-color: var(--color-secondary-1);
  border-style: dashed;
  opacity: 0.88;
  background: white;
}

.theater-card.is-filling {
  border-color: var(--color-secondary-1);
  border-style: solid;
  opacity: 1;
}

.theater-card.is-warning-state {
  border-color: var(--color-accent);
  border-style: solid;
  box-shadow: var(--shadow-md), 0 0 0 3px rgba(212, 168, 83, 0.15);
}

.theater-card.is-threshold-active {
  border-color: #b71c1c;
  border-style: solid;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(183, 28, 28, 0.15);
}

.theater-card.is-complete {
  border-color: var(--color-primary);
  border-style: solid;
  opacity: 1;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(26, 92, 87, 0.12);
}

/* Progress spine alongside the card */
.card-progress-spine {
  position: absolute;
  left: -12px;
  top: 1.5rem;
  bottom: 1.5rem;
  width: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.card-progress-spine .spine-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, var(--color-secondary-1), var(--color-primary));
  border-radius: 2px;
  transition: height 0.6s ease;
}

/* Step quotes — short punchy lines */
.step-quote {
  font-family: var(--font-serif) !important;
  font-style: italic !important;
  color: var(--color-primary) !important;
  font-size: var(--font-size-sm) !important;
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--color-accent);
}

.theater-card-header {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.theater-card-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--color-primary);
  /* Safari gap fallback */
  margin-left: 0.75rem;
}

/* Card fields */
.theater-field {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: baseline;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-light);
  opacity: 0.3;
  transform: translateY(4px);
  transition: opacity 0.5s ease, transform 0.5s ease, background-color 0.4s ease;
}

.theater-field.revealed {
  opacity: 1;
  transform: translateY(0);
}

.theater-field.highlighted {
  opacity: 1;
  transform: translateY(0);
  background: rgba(26, 92, 87, 0.05);
  border-radius: var(--radius-sm);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
}

.theater-field .field-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
  min-width: 110px;
  transition: color 0.4s ease;
}

.theater-field.revealed .field-label {
  color: var(--color-primary);
}

.theater-field .field-value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  text-align: right;
  transition: color 0.4s ease;
}

.theater-field .field-value.field-proof {
  color: var(--color-primary);
  text-decoration: underline;
}

.theater-field .field-value.field-stop {
  color: var(--color-secondary-2);
  font-weight: 600;
}

.theater-field .field-value.field-irreversibility {
  color: #b71c1c;
  font-weight: 700;
}

/* Threshold bar */
.threshold-bar {
  margin-top: 1rem;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.threshold-bar.active {
  opacity: 1;
}

.threshold-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-accent), #b71c1c);
  transition: width 1s ease;
  border-radius: 2px;
}

.threshold-bar.filling::after {
  width: 100%;
}

.threshold-text {
  position: absolute;
  top: 10px;
  right: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b71c1c;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.threshold-bar.active .threshold-text {
  opacity: 1;
}


/* RIGHT: Scrolling narrative steps */
.theater-narrative-column {
  flex: 1;
  padding: 6rem 0 6rem 3rem;
}

.theater-step {
  min-height: 65vh;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 2rem 0;
  opacity: 0.25;
  transition: opacity 0.5s ease;
}

.theater-step.active {
  opacity: 1;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.theater-step-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin-bottom: 1rem;
  line-height: var(--line-height-tight);
}

.theater-step p {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  margin-bottom: 0.75rem;
  max-width: 520px;
}

.step-hint {
  font-style: italic;
  color: var(--color-muted) !important;
  font-size: var(--font-size-sm) !important;
  margin-top: 0.5rem;
}

.step-link {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent);
}


/* ========== BEFORE / AFTER PANEL ========== */

.before-after-panel {
  display: -webkit-flex;
  display: flex;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.ba-side {
  flex: 1;
  padding: 2rem;
}

.ba-before {
  background: #f0ebe3;
  transition: opacity 0.6s ease, filter 0.6s ease;
}

.ba-before.desaturated {
  opacity: 0.65;
  filter: grayscale(0.3);
}

.ba-after {
  background: white;
  transition: opacity 0.6s ease, box-shadow 0.6s ease;
}

.ba-after.sharpened {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.ba-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-lg);
  margin-bottom: 1.25rem;
  color: var(--color-primary);
}

.ba-before .ba-title {
  color: #6b5e4f;
}

/* Ensure left-panel text is readable */
.ba-before .ba-field {
  color: var(--color-text);
}

.ba-before .ba-field span:not(.field-label) {
  color: #8a6d52;
}

.ba-before .ba-field .field-label {
  color: #6b5e4f;
}

.ba-before .ba-outcome {
  color: #9a5a3a;
}

.ba-divider {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: 3rem;
  min-width: 3rem;
  background: var(--color-light);
}

.ba-vs {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.ba-field {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: baseline;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}

.ba-field .field-label {
  font-weight: 600;
  color: var(--color-muted);
  min-width: 80px;
}

.ba-field-bad span:not(.field-label) {
  color: var(--color-secondary-2);
}

.ba-field-good span:not(.field-label) {
  color: var(--color-primary);
}

.ba-outcome {
  margin-top: 1rem;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--color-secondary-2);
}

.ba-outcome-good {
  color: var(--color-primary);
}


/* ========== THRESHOLD SCENE ========== */

.threshold-scene {
  position: relative;
  background: #1a1a1a;
  min-height: 80vh;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  overflow: hidden;
  padding: 4rem 2rem;
}

.threshold-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}

.threshold-content {
  position: relative;
  z-index: 1;
  max-width: 640px;
  text-align: center;
}

.threshold-gate {
  margin-bottom: 2.5rem;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
}

.threshold-line-visual {
  width: 200px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #b71c1c, transparent);
  border-radius: 2px;
  opacity: 0;
  transform: scaleX(0);
  transition: opacity 0.8s ease, transform 1s ease;
}

.threshold-scene.in-view .threshold-line-visual {
  opacity: 1;
  transform: scaleX(1);
}

.threshold-heading {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: white;
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease 0.3s, transform 0.6s ease 0.3s;
}

.threshold-scene.in-view .threshold-heading {
  opacity: 1;
  transform: translateY(0);
}

.threshold-prose {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1rem;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.6s ease 0.5s, transform 0.6s ease 0.5s;
}

.threshold-scene.in-view .threshold-prose {
  opacity: 1;
  transform: translateY(0);
}

.threshold-prose:nth-child(4) {
  transition-delay: 0.7s;
}

.threshold-principle {
  margin-top: 2rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(183, 28, 28, 0.3);
  border-radius: var(--radius-md);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.6s ease 0.9s, transform 0.6s ease 0.9s;
}

.threshold-scene.in-view .threshold-principle {
  opacity: 1;
  transform: translateY(0);
}

.threshold-principle p {
  color: rgba(255, 255, 255, 0.92);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  margin-top: 0.75rem;
  font-style: italic;
}


/* ========== AUDIENCE BLOCKS ========== */

.audience-block {
  padding: 3rem 0;
}

.audience-header {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 1.5rem;
}

.audience-header > * + * {
  margin-left: 1rem;
}

.audience-header h3 {
  font-family: var(--font-serif);
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin: 0;
}


/* ========== PILOT PATHS ========== */

.pilot-paths {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 2rem 0;
}

.pilot-path {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.pilot-path h4 {
  color: white;
  font-family: var(--font-serif);
  margin: 0.75rem 0;
}

.pilot-path p {
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}


/* ========== INVARIANT THEATER (sticky scrollytelling) ========== */
/* Override narrative-dark text cascade for theater children.
   .narrative-dark p sets color:white which we need to control precisely. */

.invariants-theater-section {
  padding: 0 0 2rem;
  overflow: visible;
  /* Safari: ensure sticky works inside this section */
  -webkit-overflow-scrolling: touch;
}

/* !important needed to beat .narrative-dark p specificity */
.invariants-theater-section .invariant-theater {
  display: -webkit-flex !important;
  display: flex !important;
  -webkit-flex-direction: row !important;
  flex-direction: row !important;
  min-height: 100vh;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  overflow: visible;
}

/* Override narrative-dark p { color: white } inside the theater.
   We need differentiated text colors for failure vs transform stories. */
.invariants-theater-section.narrative-dark .inv-step-failure {
  color: rgba(255, 255, 255, 0.78);
}
.invariants-theater-section.narrative-dark .inv-step-transform {
  color: rgba(255, 255, 255, 0.88);
}
.invariants-theater-section.narrative-dark .inv-shield-name {
  color: rgba(255, 255, 255, 0.85);
}
.invariants-theater-section.narrative-dark .inv-shield-title {
  color: rgba(255, 255, 255, 0.5);
}
.invariants-theater-section.narrative-dark .inv-shield-status {
  color: rgba(255, 255, 255, 0.5);
}
.invariants-theater-section.narrative-dark .inv-step-title {
  color: white;
}

/* LEFT: Sticky invariant shield */
.inv-shield-column {
  -webkit-flex: 0 0 38% !important;
  flex: 0 0 38% !important;
  position: relative;
  min-width: 0;
  width: 38%;
}

.inv-shield {
  position: -webkit-sticky;
  position: sticky;
  top: 120px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 340px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.inv-shield-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.inv-shield-item {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  padding: 0.65rem 0;
  opacity: 0.35;
  transition: opacity 0.5s ease, transform 0.3s ease;
}

.inv-shield-item.active {
  opacity: 1;
  transform: translateX(4px);
}

.inv-shield-item.completed {
  opacity: 0.85;
}

.inv-shield-dot {
  width: 10px;
  height: 10px;
  min-width: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  transition: all 0.4s ease;
}

.inv-shield-item.active .inv-shield-dot {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: 0 0 8px rgba(212, 168, 83, 0.4);
}

.inv-shield-item.completed .inv-shield-dot {
  background: var(--color-secondary-1);
  border-color: var(--color-secondary-1);
}

.inv-shield-name {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  /* Safari gap fallback */
  margin-left: 0.75rem;
}

.inv-shield-status {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-sans);
  transition: color 0.4s ease;
}

.inv-shield.all-active .inv-shield-status {
  color: var(--color-accent);
}

/* RIGHT: Scrolling invariant narratives */
.inv-narrative-column {
  -webkit-flex: 1 1 0% !important;
  flex: 1 1 0% !important;
  min-width: 0;
  padding: 4rem 0 4rem 3rem;
}

.inv-step {
  min-height: 70vh;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 2rem 0;
  opacity: 0.2;
  transition: opacity 0.5s ease;
}

.inv-step.active {
  opacity: 1;
}

.inv-step-summary {
  min-height: 50vh;
}

.inv-step-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-xl);
  color: white;
  margin: 0.75rem 0 1rem;
  line-height: var(--line-height-tight);
}

.inv-step-failure {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 1.5rem;
  max-width: 520px;
  padding-left: 1rem;
  border-left: 3px solid var(--color-secondary-2);
}

.inv-step-transform {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 0.75rem;
  max-width: 520px;
  padding-left: 1rem;
  border-left: 3px solid var(--color-secondary-1);
}

.inv-step .state-chip {
  margin-bottom: 0.5rem;
}

/* Invariant step quote */
.inv-step-quote {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-accent) !important;
  font-size: var(--font-size-sm);
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--color-accent);
}


/* ---- INVARIANT FORMAT: Story Conflict ---- */

.inv-format-story {
  max-width: 520px;
}

.inv-conflict {
  max-width: 520px;
}

.inv-conflict-setup {
  color: rgba(255, 255, 255, 0.78) !important;
  line-height: var(--line-height-relaxed);
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--color-secondary-2);
}

.inv-conflict-turn {
  color: var(--color-accent) !important;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--font-size-lg);
  margin: 1.25rem 0;
  text-align: center;
}

.inv-conflict-resolve {
  color: rgba(255, 255, 255, 0.88) !important;
  line-height: var(--line-height-relaxed);
  padding-left: 1rem;
  border-left: 3px solid var(--color-secondary-1);
}


/* ---- INVARIANT FORMAT: Visual Comparison ---- */

.inv-format-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 520px;
  margin-bottom: 0.5rem;
}

.inv-compare-side {
  padding: 1rem;
  border-radius: var(--radius-md);
}

.inv-compare-without {
  background: rgba(201, 123, 99, 0.12);
  border: 1px solid rgba(201, 123, 99, 0.25);
}

.inv-compare-with {
  background: rgba(123, 163, 144, 0.12);
  border: 1px solid rgba(123, 163, 144, 0.25);
}

.inv-compare-side .state-chip {
  margin-bottom: 0.5rem;
}

.inv-compare-side p {
  font-size: var(--font-size-sm) !important;
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.85) !important;
}


/* ---- INVARIANT FORMAT: Threshold Diagram ---- */

.inv-format-threshold {
  max-width: 520px;
}

.inv-threshold-zones {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.inv-zone {
  padding: 1rem 1.25rem;
}

.inv-zone p {
  font-size: var(--font-size-sm) !important;
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.85) !important;
  margin: 0;
}

.inv-zone-safe {
  background: rgba(123, 163, 144, 0.15);
  border: 1px solid rgba(123, 163, 144, 0.25);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.inv-zone-danger {
  background: rgba(183, 28, 28, 0.12);
  border: 1px solid rgba(183, 28, 28, 0.2);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.inv-zone-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.inv-zone-safe .inv-zone-label {
  color: var(--color-secondary-1);
}

.inv-zone-danger .inv-zone-label {
  color: #e57373;
}

.inv-zone-line {
  background: rgba(183, 28, 28, 0.3);
  text-align: center;
  padding: 0.4rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ef9a9a;
}


/* ---- INVARIANT FORMAT: Rule Card ---- */

.inv-format-rulecard {
  max-width: 520px;
}

.inv-rulecard {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.inv-rule {
  padding: 0.65rem 1rem;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.inv-rule:last-child {
  border-bottom: none;
}

.inv-rule-label {
  display: inline-block;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  margin-right: 0.5rem;
  min-width: 60px;
}


/* ---- INVARIANT FORMAT: Ledger / Correction-State ---- */

.inv-format-ledger {
  max-width: 520px;
}

.inv-ledger {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.inv-ledger-entry {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.inv-ledger-entry > * + * {
  margin-top: 0.25rem;
}

.inv-ledger-entry:last-child {
  border-bottom: none;
}

.inv-ledger-who {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
}

.inv-ledger-what {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: rgba(255, 255, 255, 0.85);
}


/* ========== THRESHOLD THEATER (sticky scrollytelling) ========== */

.threshold-theater-section {
  background: var(--color-background);
  padding: 0 0 2rem;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
}

.threshold-theater-section .threshold-theater {
  display: -webkit-flex !important;
  display: flex !important;
  -webkit-flex-direction: row !important;
  flex-direction: row !important;
  min-height: 100vh;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  overflow: visible;
}

/* LEFT: Sticky threshold card */
.thresh-card-column {
  -webkit-flex: 0 0 42% !important;
  flex: 0 0 42% !important;
  position: relative;
  min-width: 0;
  width: 42%;
}

.thresh-card {
  position: -webkit-sticky;
  position: sticky;
  top: 120px;
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  max-width: 380px;
  transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

.thresh-card.approaching {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
}

.thresh-card.at-threshold {
  border-color: #b71c1c;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(183, 28, 28, 0.15);
}

.thresh-card.resolved {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(26, 92, 87, 0.1);
}

.thresh-card-body {
  margin-bottom: 1rem;
}

.thresh-field {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: baseline;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--color-light);
  font-size: var(--font-size-sm);
}

.thresh-field .field-label {
  font-weight: 600;
  color: var(--color-primary);
  min-width: 90px;
}

.thresh-field span:not(.field-label) {
  color: var(--color-text);
  text-align: right;
}

/* The threshold line — central dramatic element */
.thresh-line-container {
  position: relative;
  margin: 1.25rem 0;
  padding: 0.75rem 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.thresh-line-container.visible {
  opacity: 1;
}

.thresh-line {
  height: 3px;
  background: linear-gradient(90deg, transparent, #b71c1c, transparent);
  border-radius: 2px;
  transform: scaleX(0);
  transition: transform 1s ease;
}

.thresh-line-container.visible .thresh-line {
  transform: scaleX(1);
}

.thresh-line-label {
  display: block;
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #b71c1c;
  font-weight: 700;
  margin-top: 0.5rem;
}

/* Below-the-line fields */
.thresh-card-below {
  opacity: 0.3;
  transition: opacity 0.5s ease;
}

.thresh-card-below.visible {
  opacity: 1;
}

.thresh-field-below .field-label {
  color: #b71c1c;
}

.thresh-field-below span:not(.field-label) {
  color: #b71c1c;
  font-weight: 600;
}

/* Ripple effects */
.thresh-ripples {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.thresh-ripples.visible {
  opacity: 1;
  transform: translateY(0);
}

.thresh-ripple {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #fbe8e8;
  color: #b71c1c;
  border: 1px solid #e0a0a0;
  /* Safari gap fallback */
  margin: 0 0.5rem 0.5rem 0;
}

/* RIGHT: Scrolling threshold narrative */
.thresh-narrative-column {
  -webkit-flex: 1 1 0% !important;
  flex: 1 1 0% !important;
  min-width: 0;
  padding: 4rem 0 4rem 3rem;
}

.thresh-step {
  min-height: 65vh;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 2rem 0;
  opacity: 0.25;
  transition: opacity 0.5s ease;
}

.thresh-step.active {
  opacity: 1;
}

.thresh-step .theater-step-title {
  margin-bottom: 1rem;
}

.thresh-step p {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  margin-bottom: 0.75rem;
  max-width: 520px;
}


/* ========== CTA BUTTONS ========== */

.cta-buttons {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.cta-buttons > * + * {
  margin-left: 1rem;
}


/* ========== RESPONSIVE ========== */

@media (max-width: 900px) {
  /* Hide progress rail on smaller screens */
  .progress-rail {
    display: none;
  }

  /* Card theater stacks */
  .card-theater {
    -webkit-flex-direction: column;
    flex-direction: column;
    padding: 0 1rem;
  }

  .theater-card-column {
    -webkit-flex: none;
    flex: none;
    width: auto;
    position: relative;
  }

  .theater-card {
    position: relative;
    top: auto;
    max-width: 100%;
    margin-bottom: 2rem;
  }

  .theater-narrative-column {
    -webkit-flex: none;
    flex: none;
    padding: 0;
  }

  .theater-step {
    min-height: 40vh;
  }

  /* Invariant theater stacks */
  .invariants-theater-section .invariant-theater {
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    padding: 0 1rem;
  }

  .inv-shield-column {
    -webkit-flex: none !important;
    flex: none !important;
    width: auto;
  }

  .inv-shield {
    position: relative;
    top: auto;
    max-width: 100%;
    margin-bottom: 2rem;
  }

  .inv-narrative-column {
    -webkit-flex: none !important;
    flex: none !important;
    padding: 0;
  }

  .inv-step {
    min-height: auto;
    padding: 2rem 0;
  }

  /* Threshold theater stacks */
  .threshold-theater-section .threshold-theater {
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    padding: 0 1rem;
  }

  .thresh-card-column {
    -webkit-flex: none !important;
    flex: none !important;
    width: auto;
  }

  .thresh-card {
    position: relative;
    top: auto;
    max-width: 100%;
    margin-bottom: 2rem;
  }

  .thresh-narrative-column {
    -webkit-flex: none !important;
    flex: none !important;
    padding: 0;
  }

  .thresh-step {
    min-height: auto;
    padding: 2rem 0;
  }

  /* Before/after stacks */
  .before-after-panel {
    -webkit-flex-direction: column;
    flex-direction: column;
  }

  .ba-divider {
    width: 100%;
    min-width: unset;
    height: 2rem;
  }

  /* Pilot paths stack */
  .pilot-paths {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hero-editorial {
    min-height: 60vh;
    padding: 5rem 1.5rem 3rem;
  }

  .theater-step {
    min-height: auto;
    padding: 3rem 0;
  }

  .inv-step-failure,
  .inv-step-transform {
    padding-left: 0.75rem;
  }

  .inv-format-comparison {
    grid-template-columns: 1fr;
  }
}


/* =================================================================
   SAFARI BULLETPROOF OVERRIDES
   Explicit hex colors (not CSS vars) and ID selectors to guarantee
   dark-section backgrounds and text colors paint in Safari.
   Also fixes progress rail overlap, footer text, and padding.
   ================================================================= */

/* --- Force dark background on narrative-dark sections ---
   Safari sometimes fails to paint background: var(--color-primary)
   on sections. Using explicit hex + background-color (not shorthand)
   + ID selectors to guarantee rendering. */

#chapter-signal {
  background-color: #1a5c57 !important;
  color: rgba(255,255,255,0.92) !important;
}

#chapter-invariants {
  background-color: #1a5c57 !important;
  color: rgba(255,255,255,0.92) !important;
}

#chapter-pilots {
  background-color: #1a5c57 !important;
  color: rgba(255,255,255,0.92) !important;
}

/* Ensure text inside dark sections is white/legible */
#chapter-signal h2,
#chapter-signal h3,
#chapter-invariants h2,
#chapter-invariants h3,
#chapter-pilots h2,
#chapter-pilots h3 {
  color: #ffffff !important;
}

#chapter-signal p,
#chapter-invariants p,
#chapter-pilots p {
  color: rgba(255,255,255,0.88) !important;
}

#chapter-signal .prose-lead,
#chapter-signal .prose-lead p {
  color: rgba(255,255,255,0.92) !important;
}

#chapter-signal .pull-quote p {
  color: #ffffff !important;
}

#chapter-pilots .prose-lead,
#chapter-pilots .prose-lead p {
  color: rgba(255,255,255,0.92) !important;
}

#chapter-pilots .pilot-path h4 {
  color: #ffffff !important;
}

#chapter-pilots .pilot-path p {
  color: rgba(255,255,255,0.82) !important;
}

/* Invariant shield text inside dark section */
#chapter-invariants .inv-shield-title {
  color: rgba(255,255,255,0.5) !important;
}

#chapter-invariants .inv-shield-name {
  color: rgba(255,255,255,0.85) !important;
}

#chapter-invariants .inv-shield-status {
  color: rgba(255,255,255,0.5) !important;
}

#chapter-invariants .inv-step-title {
  color: #ffffff !important;
}

#chapter-invariants .inv-step-quote {
  color: #d4a853 !important;
}

#chapter-invariants .inv-conflict-setup {
  color: rgba(255,255,255,0.78) !important;
}

#chapter-invariants .inv-conflict-turn {
  color: #d4a853 !important;
}

#chapter-invariants .inv-conflict-resolve {
  color: rgba(255,255,255,0.88) !important;
}

#chapter-invariants .inv-compare-side p {
  color: rgba(255,255,255,0.85) !important;
}

#chapter-invariants .inv-zone p {
  color: rgba(255,255,255,0.85) !important;
}

#chapter-invariants .inv-rule {
  color: rgba(255,255,255,0.85) !important;
}

#chapter-invariants .inv-rule-label {
  color: #d4a853 !important;
}

#chapter-invariants .inv-ledger-who {
  color: #d4a853 !important;
}

#chapter-invariants .inv-ledger-what {
  color: rgba(255,255,255,0.85) !important;
}

/* Pull quotes inside dark sections */
#chapter-invariants .pull-quote p,
#chapter-pilots .pull-quote p {
  color: #ffffff !important;
}

#chapter-invariants .pull-quote,
#chapter-pilots .pull-quote {
  border-color: #d4a853 !important;
}

/* Step links inside dark sections */
#chapter-invariants .step-link,
#chapter-pilots .step-link {
  color: #d4a853 !important;
}


/* --- Progress rail: prevent overlap with body content ---
   The progress rail (fixed, left: 0.75rem) overlaps section text.
   Add left padding to sections so content clears the rail.
   Box-sizing ensures padding doesn't affect background paint width.
   Only on desktop — rail is hidden below 900px. */

@media (min-width: 901px) {
  .chapter {
    padding-left: 55px;
    box-sizing: border-box;
  }

  /* Full-bleed hero breaks out of the chapter padding */
  .hero-editorial {
    margin-left: -55px;
    padding-left: 55px;
  }
}


/* --- Footer text: force white text on footer links & headings --- */

.footer .footer-brand h4,
.footer .footer-column h5,
.footer h4,
.footer h5 {
  color: #d4a853 !important;
}

.footer .footer-brand p,
.footer .footer-note {
  color: rgba(255,255,255,0.85) !important;
}

.footer .footer-column a,
.footer .footer-nav a,
.footer a {
  color: rgba(255,255,255,0.9) !important;
}

.footer .footer-column li,
.footer .footer-nav li {
  color: rgba(255,255,255,0.9) !important;
}

.footer .footer-bottom {
  color: rgba(255,255,255,0.8) !important;
}

.footer .footer-bottom p {
  color: rgba(255,255,255,0.8) !important;
}
