/* oak-grows: the tree and the three steps beside it.
   At rest (no script, reduced motion, a phone, a tablet) every --g is 1: the whole tree stands beside the
   steps, and the section is as tall as what it holds. Live (.is-live, from 1024px on a screen 640px or
   taller) the section is two screens and its .wrap sticks for one while the tree grows. */

[data-moment="oak-grows"] {
  --soil: color-mix(in oklab, var(--p-surface) 70%, #8a6a44 30%);
  --bark: color-mix(in oklab, var(--p-ink) 88%, #6b4a2a);
  --root: color-mix(in oklab, var(--p-ink) 62%, #8a6a44);
  --leaf-0: color-mix(in oklab, var(--p-accent) 78%, #10180c);
  --leaf-1: var(--p-accent);
  --leaf-2: color-mix(in oklab, var(--p-accent) 62%, #b7bf72);
}

/* the frame: the drawing on the surface ground, as tall as the screen allows */
[data-moment="oak-grows"] .oak { margin: 0; background: var(--p-bg); border-radius: var(--r-lg); overflow: hidden;
  display: grid; place-items: center; aspect-ratio: 680 / 790; width: 100%; }
[data-moment="oak-grows"] .oak__svg { display: block; width: 100%; height: 100%; }

/* every growing part: --g from 0 to 1 */
[data-moment="oak-grows"] [data-g] { --g: 1; }
[data-moment="oak-grows"] .ln { fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1 1; stroke-dashoffset: calc(1 - var(--g)); opacity: clamp(0, calc(var(--g) * 40), 1); }
[data-moment="oak-grows"] .leaf { transform-box: fill-box; transform-origin: center;
  transform: scale(var(--g)); opacity: clamp(0, calc(var(--g) * 2.5), 1); }

[data-moment="oak-grows"] .oak__soil { fill: var(--soil); }
[data-moment="oak-grows"] .oak__strata { fill: none; stroke: var(--p-ink); stroke-opacity: .08; stroke-width: 1.2; stroke-dasharray: 2 7; }
[data-moment="oak-grows"] .oak__stone { fill: var(--p-ink); fill-opacity: .1; }
[data-moment="oak-grows"] .oak__ground { stroke: var(--p-ink); stroke-width: 2; stroke-opacity: .55; }
[data-moment="oak-grows"] .oak__grass { fill: none; stroke: var(--p-accent); stroke-width: 1.6; stroke-linecap: round; stroke-opacity: .7; }

[data-moment="oak-grows"] .oak__roots .ln { stroke: var(--root); }
[data-moment="oak-grows"] .oak__limbs .ln { stroke: var(--bark); }
[data-moment="oak-grows"] .oak__bark .ln { stroke: var(--p-surface); stroke-opacity: .35; stroke-width: 1.4; }
[data-moment="oak-grows"] .oak__trunk { fill: var(--bark); transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(var(--g)); }
[data-moment="oak-grows"] .oak__seed { fill: var(--root); stroke: var(--root); stroke-width: 2; stroke-linecap: round; opacity: calc(1 - var(--g)); }

[data-moment="oak-grows"] .leaf.t0 { fill: var(--leaf-0); }
[data-moment="oak-grows"] .leaf.t1 { fill: var(--leaf-1); }
[data-moment="oak-grows"] .leaf.t2 { fill: var(--leaf-2); }
[data-moment="oak-grows"] .oak__canopy--front .leaf { opacity: calc(clamp(0, var(--g) * 2.5, 1) * .85); }
[data-moment="oak-grows"] .acorn { fill: #8a6a3c; }
[data-moment="oak-grows"] .acorn path { fill: var(--bark); }

/* the rail of the three steps */
[data-moment="oak-grows"] .oak__rail { stroke: var(--p-ink); stroke-opacity: .18; stroke-width: 2; stroke-dasharray: 3 6; }
[data-moment="oak-grows"] .oak__rail-on { stroke: var(--p-accent); stroke-width: 2; }
[data-moment="oak-grows"] .oak__mark circle { fill: var(--p-bg); stroke: var(--p-ink); stroke-opacity: .35; stroke-width: 1.5; transition: fill 300ms ease, stroke 300ms ease; }
[data-moment="oak-grows"] .oak__mark text { font: 500 14px/1 var(--font-text); fill: var(--p-ink); transition: fill 300ms ease; }
[data-moment="oak-grows"] .oak__mark.is-reached circle,
[data-moment="oak-grows"]:not(.is-live) .oak__mark circle { fill: var(--p-accent); stroke: var(--p-accent); stroke-opacity: 1; }
[data-moment="oak-grows"] .oak__mark.is-reached text,
[data-moment="oak-grows"]:not(.is-live) .oak__mark text { fill: var(--p-accent-ink); }

/* the steps */
[data-moment="oak-grows"] .oak-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-6); }
[data-moment="oak-grows"] .oak-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--s-4); row-gap: var(--s-2); }
[data-moment="oak-grows"] .oak-step .step-num { grid-row: 1 / span 2; }
[data-moment="oak-grows"] .oak-step h3 { font-family: var(--font-text); font-weight: 500; font-size: var(--t-lead); line-height: 1.3; letter-spacing: -0.01em; margin: 0; padding-top: 3px; }
[data-moment="oak-grows"] .oak-step p { margin: 0; max-width: 46ch; }
[data-moment="oak-grows"] .oak-step .step-num { transition: background-color 300ms ease, color 300ms ease; }

/* at rest: the section is as tall as what it holds */
main > [data-moment="oak-grows"][data-moment]:not(.is-live) { height: auto; min-height: calc(var(--h, 1) * 100svh); }
@media (max-width: 639px) { main > [data-moment="oak-grows"][data-moment]:not(.is-live) { min-height: calc(var(--hm, 1) * 100lvh); } }
@media (max-width: 1023px) {
  [data-moment="oak-grows"] .oak { margin-top: var(--s-7); max-width: 560px; }
}

/* live */
main > [data-moment="oak-grows"][data-moment].is-live { height: 200svh; padding: 0; }
main > [data-moment="oak-grows"].is-live > .wrap { position: sticky; top: 0; height: 100svh; box-sizing: border-box;
  padding-top: calc(var(--nav) + var(--s-7)); padding-bottom: var(--s-7); }
[data-moment="oak-grows"].is-live .oak-grid { height: 100%; align-items: start; }
[data-moment="oak-grows"].is-live .oak { height: calc(100svh - var(--nav) - 2 * var(--s-7)); width: auto; max-width: 100%; justify-self: end; }
[data-moment="oak-grows"].is-live .oak-step:not(.is-on) .step-num { color: var(--muted); }
[data-moment="oak-grows"].is-live .oak-step.is-on .step-num { background: var(--p-accent); color: var(--p-accent-ink); border-color: var(--p-accent); }

@media (prefers-reduced-motion: reduce) {
  main > [data-moment="oak-grows"][data-moment] { height: auto; }
  [data-moment="oak-grows"] * { transition: none !important; }
}
@media print {
  main > [data-moment="oak-grows"][data-moment].is-live { height: auto; }
  main > [data-moment="oak-grows"].is-live > .wrap { position: static; height: auto; }
}
