/* Story-specific accents. The live JS root opts in; prerendered and no-JS
   content stays in its final, readable state. */
#dc-prerender [data-story-svg] { display: none; }
/* Measured connections belong to the live layout; keep snapshot text visible
   without showing desktop coordinates before responsive hydration. */
#dc-prerender .convergence-connections { visibility: hidden; }
#dc-prerender .closing-aura canvas, #dc-prerender .closing-aura-toggle { display: none; }
#dc-prerender .closing-aura .closing-aura-fallback { opacity: 1; }

#dc-root.story-ready {
  --story-ease: cubic-bezier(.22,.8,.24,1);
  --story-fast: 500ms;
  --story-base: 550ms;
}

/* Records choreography uses finite row/source/wire WAAPI effects. */
#dc-root.story-ready [data-story="records"] .records-list > li {
  animation: none;
}
#dc-root.story-ready [data-story="records"]:is(.is-playing, .is-paused) .records-list > li { will-change: background-color; }
#dc-root.story-ready [data-story="records"]:is(.is-playing, .is-paused) .record-source .onboarding-icon-tile { will-change: box-shadow; }
#dc-root.story-ready [data-story="records"]:is(.is-playing, .is-paused) .record-signal { will-change: opacity, stroke-dashoffset; }
#dc-root.story-ready [data-story] {
  opacity: 1;
  transform: none;
}
/* Timeline and gauge elements use story choreography instead of row-in animation. */
#dc-root.story-ready [data-story="timeline"] .history-event { animation: none; }
#dc-root.story-ready [data-story="analyze"] .gauge-arc-marker {
  transform-box: fill-box;
  transform-origin: center;
}
#dc-root.story-ready #timeline [data-home-motion]:not(.history-panel) {
  opacity: 1;
  transform: none;
}
#dc-root.story-ready #timeline .history-event { animation: none; }
/* Finite hero and workflow beats. The closing canvas owns its own frames. */
#dc-root.story-ready [data-story="workflow"] [data-flow-path] {
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}
#dc-root.story-ready [data-story="hero-record"]:is(.is-playing, .is-paused) .hero-record-wires .record-wire { will-change: stroke; }
#dc-root.story-ready [data-story="hero-record"]:is(.is-playing, .is-paused) [data-hero-record-row] { will-change: background-color; }
#dc-root.story-ready [data-story="workflow"]:is(.is-playing, .is-paused) [data-flow-path] { will-change: stroke-dashoffset; }
#dc-root.story-ready [data-story="workflow"] .step-card {
  transition: border-color var(--story-fast) var(--story-ease), box-shadow var(--story-fast) var(--story-ease);
}
#dc-root.story-ready [data-story="workflow"] .step-card.is-flow-active {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgb(184 220 48 / 16%);
}
/* The capture scan is a finite transform and opacity sweep. */
#dc-root.story-ready [data-story="capture"] .step-example {
  position: relative;
  overflow: hidden;
}
#dc-root.story-ready [data-story="capture"] .step-example::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-100%);
  background: linear-gradient(to bottom, transparent, rgb(184 220 48 / 22%) calc(100% - 2px), var(--accent) calc(100% - 2px));
}
#dc-root.story-ready [data-story="capture"]:is(.is-playing, .is-paused, .is-flow-active) .step-example::after {
  animation: story-capture-scan 700ms linear 1 both;
}
#dc-root.story-ready [data-story="capture"].is-paused .step-example::after { animation-play-state: paused; }
#dc-root.story-ready [data-story="workflow"].is-paused [data-story="capture"] .step-example::after { animation-play-state: paused; }
@keyframes story-capture-scan {
  0% { opacity: 0; transform: translateY(-100%); }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translateY(0); }
}

#dc-root.story-ready [data-story="analyze"] .gauge-status {
  transition: opacity var(--story-base) var(--story-ease), transform var(--story-base) var(--story-ease);
}
#dc-root.story-ready [data-story="analyze"]:is(.is-playing, .is-paused) .gauge-status:not(.is-revealed) {
  opacity: 0;
  transform: translateY(8px);
}

/* Timeline connections stay inside a dedicated left gutter. */
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] {
  position: relative;
  overflow: visible;
}
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-spine,
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-connection,
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-forecast {
  transform-box: fill-box;
  transform-origin: center;
  vector-effect: non-scaling-stroke;
}
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-spine {
  stroke: var(--line-strong);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  transform: none;
}
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-connection {
  stroke: var(--story-link-color, var(--accent-press));
  fill: none;
  stroke-width: 1.5;
  opacity: 1;
  stroke-linecap: round;
  transition: opacity var(--story-fast) var(--story-ease), stroke-width var(--story-fast) var(--story-ease);
}
#dc-root.story-ready [data-story="timeline"] .story-connection.is-stage-active {
  stroke-width: 2;
  opacity: 1;
}
#dc-root:is(.story-ready, .story-complete) [data-story="timeline"] .story-forecast {
  stroke: #d9710e;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 6 6;
}
#dc-root.story-ready [data-story="timeline"] .history-event p {
  text-decoration-color: transparent;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color var(--story-fast) var(--story-ease), text-decoration-color var(--story-fast) var(--story-ease);
}
#dc-root.story-ready [data-story="timeline"] .history-event p.is-called-out {
  color: var(--ink);
  text-decoration-color: var(--accent-press);
}
#dc-root.story-ready #timeline:not(.history-handoff) .history-stages > div {
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: var(--r-sm);
  transition: background-color var(--story-fast) var(--story-ease), box-shadow var(--story-fast) var(--story-ease);
}
#dc-root.story-ready #timeline:not(.history-handoff) .history-stages > div.is-active {
  background: var(--accent-subtle);
  box-shadow: inset 3px 0 var(--accent);
}
#dc-root.story-ready .history-report.is-emphasized { box-shadow: var(--shadow-soft); }
#dc-root.story-ready [data-story="timeline"] .history-event.is-revealed::before {
  box-shadow: 0 0 0 5px var(--accent-subtle);
}

/* Reading remains user-controlled; native swipe and keyboard scrolling stay on. */
#dc-root.story-ready [data-story="library"] {
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  -webkit-overflow-scrolling: touch;
}
#dc-root.story-ready [data-story="library"] .library-card {
  scroll-snap-align: start;
  transform: scale(1);
  opacity: 1;
  transition: none;
}
/* Explicit final state for low-motion/data modes, still fully readable. */
#dc-root.story-complete [data-story="records"] .records-list > li,
#dc-root.story-complete [data-story="timeline"] .history-event,
#dc-root.story-complete [data-story="timeline"] .story-spine,
#dc-root.story-complete [data-story="timeline"] .story-forecast {
  opacity: 1;
}
#dc-root.story-complete [data-story="timeline"] .story-spine { transform: none; }
#dc-root.story-complete [data-story="capture"] .step-example::after {
  animation: none;
  opacity: 0;
}

/* Optional pinned scene is enabled only by JS after checking viewport and content fit. */
#timeline.timeline-scroll-enabled { display: block; min-height: 0; height: 240svh; padding-block: 0; }
#timeline.timeline-scroll-enabled > .timeline-stage { position: sticky; top: 76px; margin-block: 0; padding-block: 24px; }
#dc-root.story-ready [data-story="timeline"] .history-event,
#dc-root.story-ready [data-story="timeline"] .history-event p,
#dc-root.story-ready #timeline:not(.history-handoff) .history-stages > div,
#dc-root.story-ready [data-story="timeline"] .history-report { opacity: 1; }
/* Quiet handoff: a single visual stage, with the report earned by completing
   the connections. The native disclosure is the non-JS/mobile fallback. */
#timeline.history-handoff .history-copy { position: relative; }
#timeline.history-handoff .history-heading { margin-bottom: 32px; }
#timeline.history-handoff .history-stages { display: grid; min-height: 64px; gap: 0; }
#timeline.history-handoff .history-stages > div { grid-area: 1 / 1; margin: 0; padding: 0; opacity: 0; visibility: hidden; transition: opacity 100ms ease, visibility 0s linear 100ms; }
#timeline.history-handoff .history-stages > div.is-active { opacity: 1; visibility: visible; transition: opacity 250ms ease 100ms, visibility 0s; }
#timeline.history-handoff .history-stages h3 { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#timeline.history-handoff .history-stages p { margin: 0; font-size: 18px; line-height: 1.55; max-width: 38ch; }
#timeline.history-handoff .history-context { margin: 24px 0 0; opacity: 0; transition: opacity 450ms ease; }
#timeline.history-handoff.history-show-result .history-context { opacity: 1; }
#timeline.history-handoff .history-visual { display: grid; align-items: center; padding-top: 32px; }
#timeline.history-handoff .history-panel, #timeline.history-handoff .history-outcome { grid-area: 1 / 1; transition: opacity 180ms ease, transform 500ms cubic-bezier(.22,.8,.24,1), visibility 0s linear 180ms; }
#timeline.history-handoff .history-panel { transition-delay: 180ms, 180ms, 0s; }
#timeline.history-handoff .history-outcome { display: block; margin: 0; opacity: 0; visibility: hidden; transform: translateY(24px) scale(.97); pointer-events: none; }
#timeline.history-handoff .history-outcome > summary { display: none; }
#timeline.history-handoff .history-year-trace { display: flex; }
#timeline.history-handoff .history-report { padding: 28px; border-radius: 24px; box-shadow: var(--shadow-soft); }
#timeline.history-handoff .history-report .summary-list li { padding-block: 16px; }
#timeline.history-handoff .history-report .summary-list li::before { top: 25px; }
#timeline.history-handoff.history-show-result .history-panel { opacity: 0; visibility: hidden; transform: translateY(-20px); pointer-events: none; transition-delay: 0s, 0s, 180ms; }
#timeline.history-handoff.history-show-result .history-outcome { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 180ms, 180ms, 0s; }
@media (max-width: 999px) {
  #dc-root.story-ready #timeline .history-stages > div.is-active { background: none; box-shadow: none; }
  #dc-root.story-ready #timeline .history-event.is-revealed::before { box-shadow: none; }
  #dc-root.story-ready #timeline .history-event p.is-called-out { color: var(--ink-2); text-decoration: none; }
}
@media (prefers-reduced-motion: reduce) {
  #dc-root.story-ready *, #dc-root.story-ready *::before, #dc-root.story-ready *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
