/* =========================================================================
   v1.42 · CHAPTER 05 — THE LIVING BOTANICAL ATLAS (approved test, now in the full site)
   VOICE   quiet, scholarly, warm — a private botanical atlas.
   IDEA    one plate, one object: the engraving and the living plant are the
           SAME image (the engraving is drawn from the living one), so leaves,
           pods and branch never move — they only gain colour and texture.
   PICTURE a large cacao branch entering from the top-right edge; it settles
           in as the chapter opens, then comes to life leaf-first, fruit-last.
   COLOUR  ivory ground, cacao-brown ink, forest-green type; nature's own
           greens, golds and burgundy arrive with the scroll.
   LAYOUT  desktop: sticky stage (~3 screens of track); type in the free left
           field, never over the plant. Phone / reduced motion: plain flow.
   ========================================================================= */

.atlas { position: relative; background: var(--ivory);
  --plant-w: min(115svh, 64vw);
  --text-l: max(var(--gutter), (100vw - 1600px) / 2);
  --gap: clamp(1.75rem, 3vw, 3.25rem);
  --col: calc(100vw - var(--plant-w) - var(--text-l) - var(--gap));
  --shift: calc(var(--plant-w) * 0.2); }

/* ---------- the plate (three registered layers of one image) ---------- */
.atlas__plant { position: relative; aspect-ratio: 1082 / 941;
  /* the plate never ends on a hard edge: its foot melts into the paper */
  -webkit-mask-image: linear-gradient(180deg, #000 80%, transparent 99%); mask-image: linear-gradient(180deg, #000 80%, transparent 99%); }
.atlas__l { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.atlas__plant { background: var(--ivory); }
/* the engraving is printed on white and multiplied onto the page's own ivory: no seam, ever */
.atlas__a { position: relative; mix-blend-mode: multiply; }
/* life spreads from where the branch enters the page… */
.atlas__leaves { -webkit-mask-image: radial-gradient(circle farthest-corner at 93% 1%, #000 calc(var(--rl, 0%) - 30%), transparent var(--rl, 0%));
                 mask-image: radial-gradient(circle farthest-corner at 93% 1%, #000 calc(var(--rl, 0%) - 30%), transparent var(--rl, 0%)); }
/* …and the fruiting branch ripens downward from the stalks */
.atlas__fruit { -webkit-mask-image: linear-gradient(196deg, #000 calc(var(--rf, 0%) - 32%), transparent var(--rf, 0%));
                mask-image: linear-gradient(196deg, #000 calc(var(--rf, 0%) - 32%), transparent var(--rf, 0%)); }

/* ---------- type ---------- */
.atlas h2 { font-family: var(--font-display); font-weight: 340; color: var(--forest); letter-spacing: -0.035em; line-height: 0.95; font-variation-settings: "opsz" 144; }
.atlas__lead { color: var(--muted); font-size: clamp(1.06rem, 1.25vw, 1.3rem); line-height: 1.6; max-width: 27em; }
.atlas__dir { display: grid; grid-template-columns: clamp(2.6rem, 3.4vw, 3.6rem) minmax(0, 1fr); align-items: baseline; }
.atlas__n { grid-row: 1 / span 2; font-family: var(--font-display); font-style: italic; font-weight: 320; font-size: clamp(1.35rem, 1.7vw, 1.8rem); line-height: 1; color: var(--terra); }
.atlas__dir h3 { font-family: var(--font-display); font-weight: 360; color: var(--forest); font-size: clamp(1.4rem, 1.85vw, 2.05rem); line-height: 1.12; letter-spacing: -0.015em; text-wrap: balance; }
.atlas__body p { color: var(--muted); font-size: clamp(0.98rem, 1.04vw, 1.075rem); line-height: 1.62; max-width: 30em; padding-top: 0.7rem; }

/* =========================================================================
   DESKTOP SCROLL STORY (html.atlas-scroll — set by atlas.js on wide screens
   without reduced motion)
   ========================================================================= */
html.atlas-scroll .atlas__track { height: 320svh; }
html.atlas-scroll .atlas__stage { position: sticky; top: 0; height: 100svh; overflow: hidden; }
html.atlas-scroll .atlas__plant { position: absolute; top: 0; right: 0; width: var(--plant-w);
  transform: translate3d(calc(var(--shift) * var(--px, 1)), 0, 0); will-change: transform; }
html.atlas-scroll .atlas__text { position: absolute; inset: 0; }

/* intro: large, set in the free field the plate leaves before it settles */
html.atlas-scroll .atlas__intro { position: absolute; left: var(--text-l); top: 50%; width: calc(var(--col) + var(--shift));
  transform: translate3d(0, calc(-50% + var(--iy, 0) * -6svh), 0); opacity: var(--io, 1); }
html.atlas-scroll .atlas__intro h2 { font-size: min(7.2rem, 11.6svh, calc((var(--col) + var(--shift)) / 6.95)); }
html.atlas-scroll .atlas__lead { margin-top: clamp(1.5rem, 3.2svh, 2.6rem); max-width: min(27em, 92%); }

/* the four directions: one at a time, the earlier ones folding into an index */
html.atlas-scroll .atlas__dirs { position: absolute; left: var(--text-l); top: clamp(6rem, 23svh, 15rem); width: var(--col); max-width: 34rem; list-style: none; }
html.atlas-scroll .atlas__dir { padding-block: clamp(0.65rem, 1.5svh, 1.1rem); opacity: 0; transform: translate3d(0, 14px, 0);
  transition: opacity 0.7s var(--ease), transform 0.9s var(--ease-out); }
html.atlas-scroll .atlas__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.75s var(--ease-out); }
html.atlas-scroll .atlas__body > p { overflow: hidden; min-height: 0; opacity: 0; transition: opacity 0.5s var(--ease); }
html.atlas-scroll .atlas__dir.is-past,
html.atlas-scroll .atlas__dir.is-now { opacity: 1; transform: none; }
html.atlas-scroll .atlas__dir.is-past .atlas__n { color: var(--muted); }
html.atlas-scroll .atlas__dir.is-now .atlas__body { grid-template-rows: 1fr; }
html.atlas-scroll .atlas__dir.is-now .atlas__body > p { opacity: 1; transition-delay: 0.15s; }
html.atlas-scroll .atlas__dir.is-now h3 { font-size: clamp(1.7rem, 2.5vw, 2.7rem); }
html.atlas-scroll .atlas__dir h3 { transition: font-size 0.6s var(--ease-out); }
html.atlas-scroll .atlas__dir.is-now .atlas__n { font-size: clamp(1.6rem, 2.2vw, 2.4rem); }


/* =========================================================================
   FLOW (phones, tall portrait screens, reduced motion): no pinning.
   The plate comes to life as it passes through the screen; the directions
   follow as a quiet list.
   ========================================================================= */
html:not(.atlas-scroll) .atlas { padding: clamp(6rem, 12vw, 9rem) 0 clamp(4rem, 8vw, 6rem); }
html:not(.atlas-scroll) .atlas__text { display: contents; }
html:not(.atlas-scroll) .atlas__stage { display: flex; flex-direction: column; }
html:not(.atlas-scroll) .atlas__intro { order: 1; padding-inline: var(--gutter); }
html:not(.atlas-scroll) .atlas__intro h2 { font-size: clamp(2.6rem, 11.5vw, 4.6rem); }
html:not(.atlas-scroll) .atlas__lead { margin-top: 1.3rem; }
html:not(.atlas-scroll) .atlas__plant { order: 2; width: 112vw; margin: 1.5rem 0 0 -4vw; }
html:not(.atlas-scroll) .atlas__dirs { order: 3; list-style: none; padding-inline: var(--gutter); margin-top: 1.5rem; display: grid; row-gap: 2rem; max-width: 40rem; }
html:not(.atlas-scroll) .atlas__dir { opacity: 0; transform: translate3d(0, 16px, 0); transition: opacity 0.8s var(--ease), transform 1s var(--ease-out); }
html:not(.atlas-scroll) .atlas__dir.is-seen { opacity: 1; transform: none; }
html:not(.atlas-scroll) .atlas__dir h3 { font-size: 1.5rem; }
@media (min-width: 700px) {
  html:not(.atlas-scroll) .atlas__plant { width: min(100vw, 1100px); margin: 2rem 0 0 auto; }
}
/* reduced motion: the living plate, all text visible, nothing moves */
html.atlas-still .atlas__leaves, html.atlas-still .atlas__fruit { -webkit-mask-image: none; mask-image: none; }
html.atlas-still .atlas__dir { opacity: 1; transform: none; transition: none; }

/* =========================================================================
   SITE INTEGRATION (exp/ch05-atlas-site) — the atlas inside the full page.
   Only what the page needs; the chapter itself is the approved test above.
   ========================================================================= */
.atlas h2, .atlas h3, .atlas p, .atlas ol, .atlas figure { margin: 0; padding: 0; }
.atlas h2 { max-width: none; text-wrap: wrap; }   /* site h2 balances lines; the atlas sets its own three lines */
/* the heading is the anchor of the 04 → 05 hand-off: it appears on the forest exactly where it stays — the
   Second Sentence's place, i.e. the left edge of every other chapter's text (.wrap), the same top, size and three
   lines. Its size gives way only where the free field beside the plate is narrower (wide screens), measured in the
   font actually loaded (--hk, atlas.js). The four directions keep the approved test's own field (--text-l, --col):
   they never share the screen with the heading, and on wide screens that field is the roomier one. */
.atlas { --anchor-l: max(var(--gutter), (100% - var(--max)) / 2);
  --anchor-lv: max(var(--gutter), (100vw - var(--max)) / 2);
  --fit: calc((100vw - var(--plant-w) - var(--anchor-lv) - var(--gap) + var(--shift)) / var(--hk, 6.95)); }
html.atlas-scroll .atlas__intro { left: var(--anchor-l); width: calc(100% - var(--plant-w) - var(--anchor-l) - var(--gap) + var(--shift));
  top: clamp(6.5rem, 9.5vw, 9.5rem); transform: translate3d(0, calc(var(--iy, 0) * -6svh), 0); }
html.atlas-scroll .atlas__intro h2 { font-size: min(clamp(3rem, 6.1vw, 6.9rem), var(--fit)); white-space: nowrap; }   /* exactly the three lines, in any font */
html:not(.atlas-scroll) .atlas { padding-top: clamp(6.5rem, 9.5vw, 9.5rem); overflow-x: clip; }
html:not(.atlas-scroll) .atlas__intro { padding-inline: var(--anchor-l); }
html:not(.atlas-scroll) .atlas__intro h2 { font-size: clamp(3rem, 6.1vw, 6.9rem); }
@media (max-width: 860px) {
  html:not(.atlas-scroll) .atlas { padding-top: 6.5rem; }
  html:not(.atlas-scroll) .atlas__intro h2 { font-size: clamp(2.5rem, 11.5vw, 3.6rem); }
}
/* the 04 → 05 hand-off holds the whole chapter still while the forest gives way (see .ss-hold in site.css) */
html.ch05-ss .ss-hold > .atlas { position: sticky; top: 0; }

/* =========================================================================
   TYPOGRAPHY & SPACING REFINEMENT (exp/ch05-atlas-type) — the four directions
   only: larger type for the scale of the plate, more air between the items.
   Animation, timing, active-item logic, plate, colours and texts unchanged.
   ========================================================================= */
.atlas__dir { grid-template-columns: clamp(2.85rem, 3.95vw, 4.15rem) minmax(0, 1fr); }
.atlas__n { font-size: clamp(1.45rem, 2vw, 2.1rem); }                          /* ≈ +15 % */
.atlas__dir h3 { font-size: clamp(1.5rem, 2.17vw, 2.35rem); }                  /* ≈ +15–18 % */
.atlas__body p { font-size: clamp(1.05rem, min(1.17vw, 2.1svh), 1.2rem); line-height: 1.68; padding-top: 0.8rem; }   /* ≈ +12 %, a little more leading */
/* the list starts a little higher and breathes more between the items; on short screens both give way first */
html.atlas-scroll .atlas__dirs { top: clamp(5.75rem, 19svh, 13rem); }
html.atlas-scroll .atlas__dir { padding-block: clamp(0.7rem, 1.95svh, 1.4rem); }
html.atlas-scroll .atlas__dir.is-now h3 { font-size: clamp(1.85rem, min(3.05vw, 5.3svh), 3.3rem); }   /* ≈ +20 %: a step further from the rest */
html.atlas-scroll .atlas__dir.is-now .atlas__n { font-size: clamp(1.75rem, min(2.6vw, 4.5svh), 2.8rem); }
@media (max-height: 800px) {   /* short laptop screens: the list starts higher and keeps a tighter rhythm, so the active item never reaches the edge */
  html.atlas-scroll .atlas__dirs { top: clamp(5.5rem, 17svh, 13rem); }
  html.atlas-scroll .atlas__dir { padding-block: clamp(0.65rem, 1.6svh, 1.4rem); }
}
html:not(.atlas-scroll) .atlas__dirs { row-gap: 2.5rem; }
html:not(.atlas-scroll) .atlas__dir h3 { font-size: 1.75rem; }

/* =========================================================================
   SMOOTH STEPS (exp/ch05-atlas-smooth): the list changes size in one step and
   glides there on the compositor (atlas.js · glideDirs) — no font-size or
   height animation that would re-wrap a title or push the items below.
   ========================================================================= */
html.atlas-scroll .atlas__dir h3 { transition: translate 0.9s var(--ease-cine), scale 0.9s var(--ease-cine), opacity 0.55s var(--ease) 0.3s; transform-origin: 0 0; }
html.atlas-scroll .atlas__n { transition: translate 0.9s var(--ease-cine), scale 0.9s var(--ease-cine), color 0.6s var(--ease); transform-origin: 0 0; }
html.atlas-scroll .atlas__body { transition: translate 0.9s var(--ease-cine); }
html.atlas-scroll .atlas__dir.is-now .atlas__body > p { transition: opacity 0.6s var(--ease) 0.45s; }
.atlas__leaving { color: var(--muted); font-size: clamp(1.05rem, min(1.17vw, 2.1svh), 1.2rem); line-height: 1.68; padding-top: 0.8rem;
  max-width: 30em; pointer-events: none; transition: opacity 0.28s var(--ease); }

/* =========================================================================
   v1.44 · CHAPTER 05 — MOTION REFINEMENT
   One timing family for every step change: things that move on screen glide
   0.62 s on one strong ease-out (an immediate answer, a soft landing); the text
   that leaves and the text that arrives cross over (the new one starts 0.14 s
   in, while the old one is still fading) — no empty moment between them.
   Layout, sizes, colours and type are exactly v1.43's.
   ========================================================================= */
.atlas { --ease-step: cubic-bezier(0.22, 1, 0.36, 1); --t-step: 0.62s; }
html.atlas-scroll .atlas__dir { transition: opacity 0.5s var(--ease), transform 0.62s var(--ease-step); }
html.atlas-scroll .atlas__dir h3 { transition: translate var(--t-step) var(--ease-step), scale var(--t-step) var(--ease-step), opacity 0.36s var(--ease) 0.12s; }
html.atlas-scroll .atlas__n { transition: translate var(--t-step) var(--ease-step), scale var(--t-step) var(--ease-step), color 0.45s var(--ease); }
html.atlas-scroll .atlas__body { transition: translate var(--t-step) var(--ease-step); }
html.atlas-scroll .atlas__dir.is-now .atlas__body > p { transition: opacity 0.42s var(--ease) 0.14s; }
.atlas__leaving { transition: opacity 0.26s var(--ease); }


/* reduced motion: the site's Motion setting already stops movement; what changes state still crosses over gently */
@media (prefers-reduced-motion: reduce) {
  html:not(.motion-ok) .atlas__dir { transition-property: opacity !important; transition-duration: 0.25s !important; }
}
