/* How a family line is found — CSS/SVG animation. Transforms and opacity only. */

.journey-section .journey-intro {
  max-width: 38rem;
  margin: 0.85rem 0 0;
  font-size: 1.12rem;
}

.journey {
  margin-top: 2.2rem;
}

.journey-stage {
  position: relative;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper-2) 70%, #fffdf8), #fffdf8 38%);
  border: 1px solid var(--gold-line);
  overflow: hidden;
  aspect-ratio: 5 / 4;
  min-height: 22rem;
  isolation: isolate;
}

.journey-badge {
  position: absolute;
  z-index: 4;
  top: 0.7rem;
  left: 0.8rem;
  margin: 0;
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  padding: 0.28rem 0.55rem;
  pointer-events: none;
}

.scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  padding: 2.4rem 1.1rem 1.2rem;
}

.scene.is-on {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

.scene svg {
  width: min(100%, 34rem);
  max-height: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.journey-status {
  margin: 0.85rem 0 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink-soft);
  min-height: 1.8em;
}

.journey-steps {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
}

.journey-steps button {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: color-mix(in srgb, var(--paper-2) 60%, var(--paper));
  border: 1px solid var(--gold-line);
  color: var(--ink-soft);
  padding: 0.7rem 0.7rem 0.8rem;
  font-family: var(--display);
  font-size: 0.92rem;
  line-height: 1.3;
}

.journey-steps button .num {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oxblood);
  margin-bottom: 0.28rem;
}

.journey-steps button.is-on,
.journey-steps button[aria-current="true"] {
  background: var(--green);
  color: var(--paper);
  border-color: var(--green);
}

.journey-steps button.is-on .num,
.journey-steps button[aria-current="true"] .num {
  color: #c9b896;
}

.journey-replay {
  margin-top: 0.8rem;
}

/* ---- Scene 1: intake ---- */
.intake-card {
  width: min(100%, 22.5rem);
  background: #fffdf8;
  border: 1px solid var(--gold-line);
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: 0 18px 40px rgba(26, 23, 20, 0.06);
  transform: translateY(10px);
  opacity: 0;
}

.scene-intake.is-on .intake-card {
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.intake-card h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.45rem;
  margin: 0 0 0.9rem;
}

.intake-field {
  border-top: 1px solid var(--rule);
  padding: 0.55rem 0 0.4rem;
}

.intake-field:last-child { border-bottom: 1px solid var(--rule); }

.intake-field .lbl {
  display: block;
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.15rem;
}

.intake-field .val {
  display: inline-block;
  font-size: 1.05rem;
  color: var(--ink);
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  border-right: 1px solid transparent;
}

.scene-intake.is-on .f1 .val {
  animation: write 900ms 400ms steps(22, end) forwards, caret 800ms 400ms 2;
}
.scene-intake.is-on .f2 .val {
  animation: write 900ms 1400ms steps(22, end) forwards, caret 800ms 1400ms 2;
}
.scene-intake.is-on .f3 .val {
  animation: write 1100ms 2400ms steps(28, end) forwards, caret 800ms 2400ms 2;
}

@keyframes write {
  from { max-width: 0; border-right-color: var(--oxblood); }
  to { max-width: 20rem; border-right-color: transparent; }
}
@keyframes caret {
  50% { border-right-color: transparent; }
}
@keyframes rise {
  to { transform: translateY(0); opacity: 1; }
}

/* ---- Scene 2: tree ---- */
.tree-label, .node-name, .node-role {
  font-family: "Cormorant Garamond", Palatino, serif;
}
.tree-label { font-size: 11px; letter-spacing: 0.12em; fill: var(--gold); text-transform: uppercase; }
.node-name { font-size: 15px; fill: var(--ink); }
.node-role { font-size: 10px; fill: var(--muted); }
.node-box { fill: #fffdf8; stroke: var(--gold-line); stroke-width: 1; }
.node-box.start { stroke: var(--green); stroke-width: 1.4; fill: color-mix(in srgb, var(--green) 8%, #fffdf8); }
.tree-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
}

.scene-tree.is-on .n0 { animation: fade-up 500ms 80ms both; }
.scene-tree.is-on .l1 { animation: draw 700ms 450ms both; }
.scene-tree.is-on .n1 { animation: fade-up 500ms 1000ms both; }
.scene-tree.is-on .l2 { animation: draw 700ms 1400ms both; }
.scene-tree.is-on .n2 { animation: fade-up 500ms 1950ms both; }
.scene-tree.is-on .l3 { animation: draw 700ms 2350ms both; }
.scene-tree.is-on .n3 { animation: fade-up 500ms 2900ms both; }
.scene-tree.is-on .l4 { animation: draw 700ms 3300ms both; }
.scene-tree.is-on .n4 { animation: fade-up 500ms 3850ms both; }

@keyframes draw {
  from { stroke-dashoffset: 80; }
  to { stroke-dashoffset: 0; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-tree .n0,
.scene-tree .n1,
.scene-tree .n2,
.scene-tree .n3,
.scene-tree .n4 {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

/* ---- Scene 3: records ---- */
.records {
  width: min(100%, 36rem);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  align-items: stretch;
}

.record {
  background: #fffdf8;
  border: 1px solid var(--gold-line);
  padding: 0.8rem 0.65rem 0.75rem;
  min-height: 11.5rem;
  opacity: 0;
  transform: translateY(14px);
  position: relative;
}

.scene-records.is-on .record:nth-child(1) { animation: card-in 600ms 80ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.scene-records.is-on .record:nth-child(2) { animation: card-in 600ms 280ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.scene-records.is-on .record:nth-child(3) { animation: card-in 600ms 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.scene-records.is-on .record:nth-child(4) { animation: card-in 600ms 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }

.record h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0.45rem 0 0.25rem;
}
.record p {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  margin: 0;
}
.record .mark {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--paper-3);
  margin-left: auto;
}
.scene-records.is-on .record .mark {
  animation: lamp 400ms 1400ms forwards;
}
.scene-records.is-on .record:nth-child(2) .mark { animation-delay: 1800ms; }
.scene-records.is-on .record:nth-child(3) .mark { animation-delay: 2200ms; }
.scene-records.is-on .record:nth-child(4) .mark { animation-delay: 2600ms; }

@keyframes card-in {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes lamp {
  to { background: var(--oxblood); box-shadow: 0 0 0 3px color-mix(in srgb, var(--oxblood) 20%, transparent); }
}

.record-art { width: 100%; height: 4.2rem; display: block; }

/* ---- Scene 4: report ---- */
.report-frame {
  width: min(100%, 24rem);
  background: #fffdf8;
  border: 1px solid var(--gold-line);
  box-shadow: 0 20px 44px rgba(26, 23, 20, 0.08);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
}
.scene-report.is-on .report-frame {
  animation: report-in 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes report-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.report-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  background: var(--green);
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.report-bar i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #c9b896;
  display: block;
}
.report-page {
  padding: 1rem 1.1rem 1.15rem;
}
.report-page .kicker { margin-bottom: 0.35rem; }
.report-page h3 {
  font-family: var(--display);
  font-weight: 500;
  font-style: italic;
  font-size: 1.7rem;
  margin: 0 0 0.25rem;
}
.report-page .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
.lines { display: grid; gap: 0.38rem; }
.lines b {
  display: block;
  height: 0.42rem;
  background: var(--paper-3);
  transform-origin: left center;
  transform: scaleX(0);
}
.scene-report.is-on .lines b {
  animation: line-in 500ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.scene-report.is-on .lines b:nth-child(1) { animation-delay: 500ms; width: 92%; }
.scene-report.is-on .lines b:nth-child(2) { animation-delay: 700ms; width: 78%; }
.scene-report.is-on .lines b:nth-child(3) { animation-delay: 900ms; width: 86%; }
.scene-report.is-on .lines b:nth-child(4) { animation-delay: 1100ms; width: 64%; }
.scene-report.is-on .chart {
  animation: fade-up 600ms 1400ms both;
}
@keyframes line-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.chart {
  margin-top: 0.9rem;
  border: 1px solid var(--gold-line);
  padding: 0.4rem;
  opacity: 0;
}
.chart svg { width: 100%; height: 4.4rem; }

/* ---- Scene 5: scroll unroll ---- */
.scroll-wrap {
  width: min(100%, 32rem);
  position: relative;
}
.scroll-sheet {
  background:
    repeating-linear-gradient(
      90deg,
      color-mix(in srgb, var(--paper-2) 80%, #efe4cc) 0 1px,
      #f3ead4 1px 8px
    );
  border: 1px solid var(--gold-line);
  padding: 1rem 1.5rem 1rem 1.1rem;
  transform-origin: left center;
  transform: scaleX(0.08);
  opacity: 0.4;
  overflow: hidden;
}
.scene-scroll.is-on .scroll-sheet {
  animation: unroll 1600ms 200ms cubic-bezier(0.22, 1, 0.32, 1) forwards;
}
@keyframes unroll {
  to { transform: scaleX(1); opacity: 1; }
}
.scroll-rod {
  position: absolute;
  top: -0.35rem;
  bottom: -0.35rem;
  width: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a4036, #1b2e27 40%, #3c5648);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.15);
  z-index: 2;
}
.scroll-rod.left { left: -0.2rem; }
.scroll-rod.right {
  right: -0.2rem;
  opacity: 0;
  transform: translateX(-18rem);
}
.scene-scroll.is-on .scroll-rod.right {
  animation: rod-out 1600ms 200ms cubic-bezier(0.22, 1, 0.32, 1) forwards;
}
@keyframes rod-out {
  to { opacity: 1; transform: translateX(0); }
}
.scroll-sheet svg { width: 100%; height: auto; display: block; }
.scroll-caption {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: var(--gold);
}
.unroll-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.2;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
}
.scene-scroll.is-on .unroll-line {
  animation: draw-long 1400ms 900ms forwards;
}
@keyframes draw-long {
  to { stroke-dashoffset: 0; }
}
.scroll-node { opacity: 0; }
.scene-scroll.is-on .scroll-node { animation: fade-up 400ms both; }
.scene-scroll.is-on .sn0 { animation-delay: 1100ms; }
.scene-scroll.is-on .sn1 { animation-delay: 1400ms; }
.scene-scroll.is-on .sn2 { animation-delay: 1700ms; }
.scene-scroll.is-on .sn3 { animation-delay: 2000ms; }
.scene-scroll.is-on .sn4 { animation-delay: 2300ms; }

/* Sticky scroll-driven layout on larger screens */
@media (min-width: 861px) {
  .journey-pin {
    height: 420vh;
    margin-top: 0.5rem;
  }
  .journey:not(.is-static) .journey-sticky {
    position: sticky;
    top: 5rem;
    padding-bottom: 1.2rem;
    background: var(--paper);
  }
  .journey-stage { aspect-ratio: 16 / 10; min-height: 28rem; }
}

@media (max-width: 860px) {
  .journey-steps {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.35rem;
  }
  .journey-steps li:last-child { grid-column: auto; }
  .journey-steps button {
    font-size: 0.72rem;
    padding: 0.45rem 0.3rem 0.5rem;
    text-align: center;
  }
  .journey-steps button .num { margin-bottom: 0.1rem; }
  .records { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
  .record { min-height: 0; padding: 0.55rem 0.45rem 0.55rem; }
  .record h3 { font-size: 0.88rem; }
  .record p { font-size: 0.72rem; }
  .record-art { height: 3.1rem; }
  .journey-stage {
    aspect-ratio: 1 / 1;
    min-height: 17.5rem;
    max-height: calc(100svh - 16.5rem);
  }
  .scene { padding: 1.9rem 0.7rem 0.7rem; }
  .journey-status { font-size: 1.05rem; margin-top: 0.65rem; }
}

/* Reduced motion: static frames, no pin, no keyframe motion */
@media (prefers-reduced-motion: reduce) {
  .journey-pin { height: auto !important; }
  .journey-sticky { position: static !important; }
  .journey-stage {
    aspect-ratio: auto;
    min-height: 0;
    height: auto;
    display: grid;
    gap: 1.1rem;
    padding: 1rem 0.8rem 1.1rem;
    overflow: visible;
  }
  .journey-badge { position: static; margin: 0 0 0.4rem 0.2rem; }
  .scene {
    position: relative;
    inset: auto;
    opacity: 1 !important;
    pointer-events: auto;
    padding: 0.2rem 0.4rem 0.6rem;
    border-top: 1px solid var(--rule);
  }
  .scene h4.static-label {
    display: block;
    font-family: var(--display);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0.6rem 0 0.5rem;
  }
  .intake-card,
  .report-frame,
  .record,
  .scroll-sheet,
  .scroll-rod.right,
  .scene-tree .n0,
  .scene-tree .n1,
  .scene-tree .n2,
  .scene-tree .n3,
  .scene-tree .n4,
  .chart,
  .lines b,
  .unroll-line,
  .scroll-node {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    max-width: none;
    stroke-dashoffset: 0 !important;
  }
  .intake-field .val { max-width: none; border-right: 0; }
  .journey-steps, .journey-replay, .journey-status { display: none; }
}

.scene h4.static-label { display: none; }
.journey.is-static .scene h4.static-label { display: block; }

@media (prefers-reduced-motion: reduce) {
  .scene h4.static-label { display: block; }
}
