/*
 * Zoey Made — Bubble Draws It, and the route the paper airplane follows.
 *
 *   inc/discovery/draws.php                the stage: the route layer, the paper, Bubble, the graphite
 *   assets/js/discovery-draws.js           the claim, the route geometry, the phases, the exit
 *   this file                              the runway, and what the five phases look like
 *   components/discovery-object.css        what the finished object looks like, unchanged
 *   components/discovery-trigger.css       the control and the target, unchanged
 *
 * ## The v2 rule
 *
 *     Bubble draws the dotted route → the sketch becomes a real paper airplane →
 *     the airplane follows that exact route → the landed airplane is the ordinary discovery.
 *
 * The thing that changed between v1 and v2 is *who owns the trajectory*. v1 had a hand-authored
 * `transform` keyframe list in this file and no visible route, which is why the reviewer read it
 * as an element being translated rather than as paper catching air: there was nothing on the page
 * claiming the plane was going anywhere in particular, and a twelve-keyframe arc is a shape the
 * eye has no reason to trust. v2 has one geometric authority — a single SVG path — and both the
 * dotted trail the visitor watches being drawn and the flight itself are read off it
 * (Paper Airplane v2 Design Authority §7).
 *
 * So the motion is split differently now, and deliberately:
 *
 *   this file   the runway. How far along the band the plane goes, how high it is allowed to
 *               climb, how big the loop is, and which of the two authored shapes applies. Every
 *               number the geometry is built from is a custom property here.
 *   the module  the path those numbers describe, sampled once per run into transform keyframes.
 *
 * The module never invents a distance. It measures the four properties below and builds the route
 * from them, which is what keeps a responsive design decision in the stylesheet where it can be
 * seen next to the media query it belongs to.
 *
 * ## The five phases
 *
 *   (none)      the control the server sent: a finished paper airplane, at its landing place
 *   idle        the runtime has it. Back at the drawing spot: a dart, open at the nose
 *   routing     the paper and Bubble arrive, the dotted route draws out across the band, and
 *               the sketch closes behind it
 *   resolving   colour, a shadow and a pop. The moment the line stops being a line
 *   lifting     it comes off the page and hangs there for a beat
 *   moving      the flight. Owned by the module, because it is the route
 *
 * ## Timing
 *
 *     routing    660ms      §5's 0.45–0.70s path draw
 *     resolving  200ms  ┐   §5's 0.20–0.35s resolve / lift
 *     lifting    130ms  ┘
 *     moving    1240ms      §5's 0.40–0.60s launch/loop/climb + 0.55–0.85s glide/landing
 *     ---------------
 *     total     2230ms      §5's ~2.0–2.6s
 *
 * Four of those five live here. `moving` is in the module beside the sampling that produces it;
 * there is no way to keyframe a sampled path in CSS, and splitting one number away from the code
 * that consumes it would be worse than stating plainly where it went.
 *
 * ## What is deliberately absent
 *
 * A repeat, an idle animation, a hover flourish of its own, a parallax layer, a scroll dependency,
 * a spinner, a bounce, a perspective camera, a flash, a physics engine, a canvas and a frame loop.
 * §11 names most of them; the rest follow from the same rule — this happens once, because somebody
 * asked, and then the page is calm again.
 */

/* --- The runway ------------------------------------------------------------------------ */

/*
 * The four numbers the route is built from, and the only place any of them is decided.
 *
 * `--zoey-plane-run` is the usable width of the band the plane hides in, reconstructed from the
 * two facts that decide it — the theme's wide size and its root padding — less the width of the
 * control itself. It is stated rather than measured because a container query would mean putting
 * `container-type` on DISCOVERY-005's own element, which is a layout change to accepted work for
 * a decoration's convenience.
 *
 * Every one of them is asserted rather than trusted: the harness samples the flying control's
 * rectangle through the whole route at 320, 390, 768, 844x390, 1024 and 1440, at 200% text, at
 * 400% zoom and under WCAG text spacing, and fails if it ever crosses the band's trailing edge,
 * the closing section's heading or the creator section above.
 */
.zoey-discovery[data-zoey-drawing] {
  --zoey-plane-run: calc(
    min(var(--wp--style--global--wide-size, 1240px), 100vw - 2 * clamp(20px, 4vw, 40px)) - 2.75rem
  );

  /*
   * Where it lands.
   *
   * §6 asks the plane to use substantially more of the runway than v1 and puts the target at
   * roughly 35–45% of it, and then says in the next breath that a landing farther along is
   * *preferred* if it makes the interaction read as "Bubble sent it somewhere". Those two
   * sentences pull in opposite directions here, because the v1 the reviewer measured against
   * travelled about 16% of the band and the reference frame's own composition lands the plane
   * near 70% of it.
   *
   * 62% is the number that serves the reason behind both, and the deciding argument is not
   * composition — it is that §6 also asks for a shallow launch and a shallow descent, and an
   * angle is a ratio. The ceiling is fixed by the whitespace the page actually has; the only
   * other term is how much runway the climb and the descent get to happen over. At 45% the
   * launch pitches about 20 degrees and the hook drops at 18; at 62% they are 14 and 13, inside
   * and beside §6's own bands. A shorter landing does not make the flight gentler, it makes it
   * steeper.
   *
   * It also lands where the reference frame draws it, and §6 says in as many words that farther
   * along is preferred if it reads as "Bubble sent it somewhere".
   *
   * §4a of the implementation report answers §6's five conditions for moving a landing spot one
   * at a time. This is one constant: a reviewer who wants the literal 35–45% changes 0.62 to
   * 0.45 and changes nothing else — and should expect the attitudes to steepen with it.
   */
  --zoey-plane-land: calc(var(--zoey-plane-run) * 0.62);

  /*
   * How high. The clear air above the plane is this band's 24px of opening padding plus the 72px
   * the creator section leaves below itself; the route's crest is 92% of this, so the cap keeps
   * the plane's box a comfortable margin inside that at every text size. A plane that flies
   * higher than this is a plane over somebody's paragraph (§2, §6).
   *
   * It is also half of what decides how steep the flight looks — the landing distance is the
   * other half. §6 asks for a launch of +8 to +14 degrees and a descent of 3 to 8, and an angle
   * is a ratio: a taller arc would use the whitespace more boldly and arrive at nearly twice the
   * pitch, which is the flight §6 was asking not to get. Fifty-six pixels against a 740px run is
   * what puts the climb at about 14 degrees.
   */
  --zoey-plane-rise: min(3.5rem, 13vw);

  /*
   * The loop's radius. Compact and readable is §3.2's phrase, and 35px across against a 24px plane
   * is what that measures: unmistakably a loop, nowhere near a stunt. The module clamps it to a
   * third of the ceiling, because a clockwise loop hangs below the point it is entered from and
   * has to fit underneath it.
   */
  --zoey-plane-loop: min(1.1rem, 4vw);

  /*
   * Which of the two authored shapes applies. §3.3 is explicit that mobile is the same
   * personality rather than the desktop curve scaled down, so the module carries two segment
   * budgets and this is how it is told which one it is building. A plain keyword, because a
   * custom property holding an identifier is the one kind `getComputedStyle` hands back intact.
   */
  --zoey-plane-shape: open;

  /*
   * Which way is forward. The route is authored in the inline direction and SVG has never heard
   * of one, so the sign is carried here and applied once, to every x the module produces.
   */
  --zoey-draws-way: 1;

  position: relative;
}

[dir='rtl'] .zoey-discovery[data-zoey-drawing] {
  --zoey-draws-way: -1;
}

/*
 * The narrow runway (§3.3).
 *
 * Not the open shape scaled down. A smaller loop and a lower ceiling are set here, the landing
 * takes a larger *fraction* of a much shorter band so the flight still crosses it convincingly,
 * and the module's compact segment budget spends proportionally less on the glide and more on
 * the loop — because at 236px of usable runway a glide that is a third of the route is eighty
 * pixels of nothing, and the loop is the part worth keeping.
 */
@media (max-width: 599px) {
  .zoey-discovery[data-zoey-drawing] {
    --zoey-plane-land: calc(var(--zoey-plane-run) * 0.85);
    --zoey-plane-rise: min(3.25rem, 12vw);
    --zoey-plane-loop: min(1.05rem, 4.5vw);
    --zoey-plane-shape: compact;
  }

  /*
   * And the sheet of paper shrinks with it.
   *
   * The stage is a fixed number of rem wide, which is a third of the whole runway on a 320px
   * phone — and the first thing past the paper's trailing edge is the loop, so at full size
   * Bubble stands on top of it. Everything here is the same scene at four-fifths the size: the
   * sheet is narrower, Bubble is smaller and closer in, and the loop has somewhere to be.
   */
  .zoey-bubble-draws__paper {
    inset-block-start: -0.4rem;
    inline-size: 4.75rem;
    block-size: 3.5rem;
  }

  /*
   * **These two rules are inert, and WB-004 measured that rather than assuming it.** They sit
   * earlier in this file than the base rules they mean to override and carry the same specificity,
   * so the later declaration wins and the narrow scene has never applied — on a 320px phone the
   * paper computes to the desktop size on this branch *and on the base commit*, which is how the
   * measurement attributes it. WB-004 neither fixes nor worsens it.
   *
   * It is left exactly as written rather than renumbered for the amended scene, because repairing
   * the order would change the phone scene for the first time since it was authored, and that is a
   * visible change to an accepted surface which belongs in its own story with its own review. The
   * `img` qualification the base rule needed is deliberately **not** applied here either: matching
   * it would silently switch the narrow scene on as a side effect of a specificity fix.
   */
  .zoey-bubble-draws__bubble {
    inset-block-end: -0.3rem;
    inset-inline-start: 3.25rem;
    block-size: 2.5rem;
  }
}

/*
 * The landing place, for everybody.
 *
 * Both control slots, so the `<summary>` a visitor without JavaScript keeps and the `<button>`
 * everyone else gets agree about where this secret is. A visitor under reduced motion, a visitor
 * with no JavaScript, a visitor who found it on another device and a visitor who watched the
 * whole flight all find the paper airplane in the same place — which is the point of putting the
 * offset here rather than leaving it behind as the end state of an animation. It is also the
 * value the module reads back as the route's endpoint, so the trail, the flight and the resting
 * plane cannot disagree about where the runway ends.
 *
 * A `transform`, so the layout box never moves: no reflow, no CLS, and nothing else in the band
 * to push around (§10). Pointer hit-testing and the focus ring both follow it. The stacking
 * position is here too, because the route is an absolutely positioned sibling and the plane has
 * to fly over its own pencil line rather than under it.
 */
.zoey-discovery[data-zoey-drawing] > .zoey-discovery__fallback,
.zoey-discovery[data-zoey-drawing] > .zoey-discovery__trigger {
  position: relative;
  z-index: 1;
  transform: translateX(calc(var(--zoey-plane-land) * var(--zoey-draws-way)));
}

/*
 * …except while the drawing has it, when the control is back at the spot DISCOVERY-005 hid the
 * secret in. `moving` is in this list too: the flight starts at the drawing spot and the module's
 * own animation is what carries the control away from it, so the landing offset must not be
 * underneath waiting to be inherited if that animation is ever cancelled mid-run.
 */
.zoey-discovery[data-zoey-phase='idle'] > .zoey-discovery__trigger,
.zoey-discovery[data-zoey-phase='routing'] > .zoey-discovery__trigger,
.zoey-discovery[data-zoey-phase='resolving'] > .zoey-discovery__trigger,
.zoey-discovery[data-zoey-phase='lifting'] > .zoey-discovery__trigger,
.zoey-discovery[data-zoey-phase='moving'] > .zoey-discovery__trigger {
  transform: none;
}

/*
 * A `<button>` is allowed to clip its overflow in some engines, and the loop paints well outside
 * 44px. Scoped to a control that actually has a drawing, so no accepted secret's box changes
 * because this file loaded.
 */
.zoey-discovery[data-zoey-drawing] .zoey-discovery-trigger {
  overflow: visible;
}

/* --- The route ------------------------------------------------------------------------- */

/*
 * The dotted trail, in its own layer over the band.
 *
 * Nothing in it is ever in the flow and it is never a hit target: it is `position: absolute` on a
 * scope that is `position: relative`, `pointer-events: none`, and `aria-hidden` in the markup.
 * That is §10's zero-CLS requirement made structural rather than measured — none of this has ever
 * been part of the page's layout, so none of it can move the page — and §10's "intermediate
 * drawing phases are not narrated" made impossible rather than promised.
 *
 * The module gives the SVG its box and its `d`. Nothing here knows the shape of the route, which
 * is the point: the shape is one path, and one path is what both the trail and the flight read.
 *
 * A zero-sized box at the stage's own top-left corner, and everything inside it placed from there
 * in pixels. Physical `top` and `left` rather than logical insets, because the module positions the
 * SVG with numbers it measured from the control's layout box and the two have to agree about which
 * corner they are counting from; the inline direction is carried by the geometry instead, where it
 * belongs, and where one sign covers the whole route.
 */
.zoey-plane-route {
  position: absolute;
  top: 0;
  left: 0;
  inline-size: 0;
  block-size: 0;
  pointer-events: none;
}

/*
 * The module gives this its box in pixels, and it is a great deal wider than the 44px control it
 * hangs off — so the site-wide `max-width: 100%` in base.css, which exists to stop media
 * outgrowing its container, has to be lifted for the one element whose whole job is to.
 */
.zoey-plane-route__svg {
  position: absolute;
  overflow: visible;
  max-inline-size: none;
  max-block-size: none;
}

/*
 * The four numbers, in a form a script can read.
 *
 * `getComputedStyle` hands back a custom property as the tokens it was written with — `calc(...)`
 * and all — so a module that wants the *pixels* has to ask something that has been through
 * layout. This has: its inline size is the landing distance, its block size is the ceiling, and
 * its inline start padding is the loop's radius. Three resolved lengths off one element, and the
 * stylesheet stays the only place any of them is decided.
 *
 * It is inside the stage, so it is display:none for as long as the stage is — which is every moment
 * except the ones where a drawing is actually being held.
 */
.zoey-plane-route__gauge {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  box-sizing: content-box;
  inline-size: var(--zoey-plane-land);
  block-size: var(--zoey-plane-rise);
  padding-inline-start: var(--zoey-plane-loop);
  visibility: hidden;
  pointer-events: none;
}

/*
 * §3.1's pencil: a thick, rounded, dotted graphite trail, 3.5px through the middle with 8px dashes
 * and 12px gaps and round caps — which on a 3.5px stroke reads as a row of soft lozenges rather
 * than as a technical dashed line. Ink Soft is the family's own linework and the closest thing the
 * production palette has to the #6B7280 §3.1 names; it clears 4.8:1 on Surface Soft, well past the
 * 3:1 WCAG asks of a non-text indicator, and it is the same graphite the sketch beside it is drawn
 * in — which is what makes the trail read as the same pencil.
 *
 * `stroke-dasharray` is spent on the dots, so it cannot also be spent revealing them. The reveal
 * is a mask (below), which is the one treatment that can uncover a dotted line *along its own
 * length* — including the loop, where the route doubles back and any left-to-right wipe would
 * uncover the wrong end first.
 */
.zoey-plane-route__trail {
  fill: none;
  stroke: var(--wp--preset--color--ink-soft);
  stroke-width: 3.5;
  stroke-dasharray: 8 12;
  stroke-linecap: round;
}

/*
 * The mask's stroke, and the only thing in this file that is animated by length. `pathLength="100"`
 * in the markup is what makes one dash length correct whatever the route measures, so the offset
 * counts down from 100 to 0 and nothing has to be measured twice.
 *
 * Wide enough to uncover the trail's round caps, and butt-capped so the leading edge of the reveal
 * is the point of the pencil rather than a lozenge arriving early.
 */
.zoey-plane-route__reveal {
  fill: none;
  stroke: #fff;
  stroke-width: 14;
  stroke-linecap: butt;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* --- The stage ------------------------------------------------------------------------- */

/*
 * The paper, the character and the graphite, in one absolutely positioned layer over the spot the
 * drawing happens — which is the discovery's own origin, and therefore where the control is
 * standing while it is being drawn.
 */
.zoey-bubble-draws {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 2.75rem;
  pointer-events: none;
}

.zoey-bubble-draws[hidden] {
  display: none;
}

/* --- The drawing surface --------------------------------------------------------------- */

/*
 * A small sheet of maker paper, off-white on the band's Surface Soft, with one faint rule low on
 * it so it reads as something torn out of a notebook rather than as a white box. Not a chalkboard:
 * a dark surface would open a second visual world beside the bright Secret Maker Layer this epic
 * is built in.
 *
 * It is anchored to the drawing spot's leading edge and extends into the runway, so the sketch sits
 * at the leading edge of the band and Bubble has somewhere to stand at the other end of the sheet.
 * Its 0.62rem overhang above and below the 2.75rem target is inside the band's own padding at
 * every text size.
 */
.zoey-bubble-draws__paper {
  position: absolute;
  inset-block-start: -0.62rem;
  inset-inline-start: -0.35rem;
  inline-size: 7rem;
  block-size: 4.6rem;
  border: 1px solid var(--wp--preset--color--border-soft);
  border-radius: var(--wp--custom--radius--small);
  background-color: var(--wp--preset--color--surface);
  background-image: linear-gradient(
    to bottom,
    transparent calc(74% - 1px),
    var(--wp--preset--color--border-soft) calc(74% - 1px),
    var(--wp--preset--color--border-soft) 74%,
    transparent 74%
  );
  box-shadow: 0 1px 2px rgb(51 47 61 / 10%);
  opacity: 0;
  transform: rotate(-1.5deg);
}

/* --- Bubble ---------------------------------------------------------------------------- */

/*
 * The approved **Draw** pose, mirrored, at the right-hand edge of the paper with her pencil **on**
 * the sketch, and the route drawing outward from exactly there (§8). She does not enter from
 * anywhere and does not travel: §8 is firm that Bubble is the cause of the action rather than the
 * star of the scene, and a character who walks on is a character the sequence has to wait for. She
 * fades in over 160ms and is present.
 *
 * She arrives with the route rather than living on the page, which is the other half of §4's
 * "nothing autoplays on page load": before a visitor asks, the band holds one small unfinished
 * doodle and nothing else.
 *
 * `block-size` with `inline-size: auto` keeps her aspect ratio off this file — the intrinsic ratio
 * comes from the `width` and `height` the server put on the element, which is also what reserves
 * her box before the bytes arrive.
 */
/*
 * **The drawing pose is square, and the slot was not — WB-004.**
 *
 * This rule was written for `bubble-message.webp`, and `inline-size: auto` let that file's own
 * ratio decide the width. The approved **Draw** master is 1:1, and the first adoption measured
 * 44 x 49.6 rather than 49.6 square: `components/character.css` carries `max-inline-size: 100%` —
 * the guard that stops a cameo pushing a narrow column sideways — and the stage region here is
 * 44px wide, so it clamped the width while `block-size` held the height and squashed her by 11%.
 *
 * So the size is stated on both axes and the guard is lifted **for this one placement**, where
 * overflowing the region is the intent rather than an accident: she stands at the trailing edge of
 * the paper and is meant to extend past it.
 */
img.zoey-bubble-draws__bubble {
  position: absolute;
  inset-block-end: 1.2606rem;
  inset-inline-start: 1.4606rem;
  inline-size: 3.1rem;
  max-inline-size: none;
  block-size: 3.1rem;
  opacity: 0;
}

/* --- The graphite ---------------------------------------------------------------------- */

/*
 * The sketch sits exactly where the finished object is standing while it is being drawn, at the
 * same size and in the same 24-unit box, because it is the same geometry (inc/discovery/draws.php).
 * That is what makes the resolve legible: the line the visitor watched being drawn is the edge of
 * the object that flies away, rather than a stand-in that dissolves into one.
 */
.zoey-bubble-draws__sketch {
  position: relative;
  inline-size: 2.6rem;
  block-size: 2.6rem;
  overflow: visible;
  transform: rotate(-2deg);
  transition: transform 180ms ease;
}

.zoey-bubble-draws__stroke {
  fill: none;
  stroke: var(--wp--preset--color--ink-soft);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.zoey-bubble-draws__stroke:first-child {
  stroke-dashoffset: var(--zoey-draws-cue, 100);
}

/* --- idle: the doodle ------------------------------------------------------------------- */

/*
 * §4's Phase A: the cue is an unfinished graphite paper-airplane sketch. The object has to visibly
 * not exist yet, or there is no transformation for anybody to notice — a dart left open at the nose
 * is something in progress, and a finished paper airplane that plays an animation is a finished
 * paper airplane that plays an animation.
 *
 * The finished object is made transparent rather than removed, so the control keeps exactly the box,
 * the target and the layout it has in every other state. And only the *enhanced* control's artwork
 * is touched: the `<details>` fallback keeps its complete plane whatever happens to the runtime
 * beside it.
 */
.zoey-discovery[data-zoey-phase='idle'] .zoey-discovery__trigger .zoey-discovery-object__art,
.zoey-discovery[data-zoey-phase='routing'] .zoey-discovery__trigger .zoey-discovery-object__art {
  opacity: 0;
}

/*
 * The doodle answers to a cursor the way the rest of the family does — a small lift and nothing
 * else. Without this the hover response would land on the transparent object above and read as a
 * control that has stopped noticing anyone (DISCOVERY-002, *Hover*). `:has()` because the stage and
 * the control are siblings; a browser without it simply gets no hover flourish on the doodle, which
 * costs nothing that matters.
 */
.zoey-discovery[data-zoey-phase='idle']:has(.zoey-discovery-trigger:hover) .zoey-bubble-draws__sketch {
  transform: rotate(-2deg) scale(1.12);
}

/* --- routing: Bubble draws the way --------------------------------------------------------- */

/*
 * 660ms, and §4's Phase B: the route must visibly *progress from start to finish* rather than fade
 * in as a complete line, and it must establish where the airplane is going before the airplane
 * launches. The paper and Bubble arrive in the first 160, the pencil runs out across the band for
 * 620, and the sketch closes behind it.
 *
 * The eased curve is a hand rather than a machine: it leaves quickly, holds a steady pace through
 * the loop and the long middle, and eases off as it reaches the far end.
 */
.zoey-discovery[data-zoey-phase='routing'] .zoey-bubble-draws__paper,
.zoey-discovery[data-zoey-phase='resolving'] .zoey-bubble-draws__paper,
.zoey-discovery[data-zoey-phase='lifting'] .zoey-bubble-draws__paper {
  animation: zoey-draws-surface 160ms ease-out forwards;
}

.zoey-discovery[data-zoey-phase='routing'] .zoey-bubble-draws__bubble,
.zoey-discovery[data-zoey-phase='resolving'] .zoey-bubble-draws__bubble,
.zoey-discovery[data-zoey-phase='lifting'] .zoey-bubble-draws__bubble {
  animation: zoey-draws-surface 160ms ease-out 40ms forwards;
}

.zoey-discovery[data-zoey-phase='routing'] .zoey-plane-route__reveal {
  animation: zoey-draws-route 620ms cubic-bezier(0.25, 0.6, 0.3, 1) 40ms forwards;
}

/*
 * And it stays drawn. The reveal's offset is a declared 100 and `zoey-draws-route`'s fill belongs
 * to the phase that set it, so without this the whole trail would vanish in the frame the sketch
 * starts resolving — at exactly the moment its job is to say where the plane is about to go.
 */
.zoey-discovery[data-zoey-phase='resolving'] .zoey-plane-route__reveal,
.zoey-discovery[data-zoey-phase='lifting'] .zoey-plane-route__reveal,
.zoey-discovery[data-zoey-phase='moving'] .zoey-plane-route__reveal {
  stroke-dashoffset: 0;
}

/*
 * The sketch closes under the pencil's own run: the silhouette's open nose at 300ms and the centre
 * fold behind it, both finished by 630 — a little before the route is, so the airplane is whole and
 * waiting when the pencil reaches the far end. §4's Phase C asks the fold to be the line that
 * resolves, and this is it arriving last.
 *
 * The stagger is `animation-delay` off the stroke's own index, so a future drawing with five strokes
 * lays them down in order without this file learning how many there are. The first stroke gets a
 * shorter one because the cue is most of it already; left at full length it would crawl the last few
 * units of the outline, which reads as hesitation rather than as drawing.
 */
.zoey-discovery[data-zoey-phase='routing'] .zoey-bubble-draws__stroke {
  animation: zoey-draws-stroke 200ms cubic-bezier(0.45, 0, 0.3, 1) forwards;
  animation-delay: calc(300ms + var(--zoey-draws-stroke, 0) * 130ms);
}

.zoey-discovery[data-zoey-phase='routing'] .zoey-bubble-draws__stroke:first-child {
  animation-duration: 170ms;
}

@keyframes zoey-draws-surface {
  to {
    opacity: 1;
  }
}

@keyframes zoey-draws-route {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes zoey-draws-stroke {
  to {
    stroke-dashoffset: 0;
  }
}

/* --- resolving: the moment ----------------------------------------------------------------- */

/*
 * §4's Phase C in 200ms, and the reason the flight is allowed to be as short as it is: this is the
 * signature, not the travel. The graphite goes, paper-white fill arrives, the drop shadow the
 * object already owns comes up underneath it, and the pink maker mark is dotted onto the wing last.
 * Drawing → real object, rather than "style changed".
 */
.zoey-discovery[data-zoey-phase='resolving'] .zoey-bubble-draws__sketch {
  animation: zoey-draws-erase 140ms ease-in forwards;
}

.zoey-discovery[data-zoey-phase='resolving'] .zoey-discovery__trigger .zoey-discovery-object__art {
  animation: zoey-draws-resolve 200ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

/*
 * A small pop, on the same box and with the same curve the family already pops with when a secret
 * is pressed (components/discovery-object.css). "Too little to notice" is a real risk here and worth
 * naming: the sketch and the object are the same two strokes in the same colour, and what separates
 * them — a paper-white fill on a near-white band, a 1px shadow — is honest handmade art direction
 * and almost nothing to look at. The pop is what makes the instant legible. Gentler than the
 * family's, because this one is not a celebration.
 */
.zoey-discovery[data-zoey-phase='resolving'] .zoey-discovery__trigger .zoey-discovery-object {
  animation: zoey-draws-pop 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/*
 * And the last thing that happens is the one spot of colour in the drawing: the maker mark somebody
 * dots onto the wing before throwing it. `backwards` holds it at nothing through its delay, so it
 * arrives after the fill rather than growing alongside it.
 */
.zoey-discovery[data-zoey-phase='resolving'] .zoey-discovery-object__accent {
  transform-box: fill-box;
  transform-origin: center;
  animation: zoey-draws-mark 170ms cubic-bezier(0.34, 1.56, 0.64, 1) 80ms backwards;
}

@keyframes zoey-draws-erase {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes zoey-draws-resolve {
  from {
    opacity: 0;
  }

  60% {
    opacity: 1;
  }

  to {
    opacity: 1;
  }
}

@keyframes zoey-draws-pop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.16);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes zoey-draws-mark {
  from {
    transform: scale(0);
  }

  to {
    transform: scale(1);
  }
}

/* --- lifting: off the page ------------------------------------------------------------------ */

/*
 * 130ms. §4's Phase C ends with "the plane gets a small lift from the drawing surface before
 * acceleration", and this is that beat: seven pixels up, a small tilt into the nose, and a held
 * moment. Without it the graphite becomes an object and that object is already travelling, which
 * is the signature arriving and leaving in the same frame.
 *
 * It is on the object rather than on the control, so it composes with the flight that follows
 * instead of having to be unwound first: the control is still standing at the drawing spot, and
 * what has moved is the plane inside it. The module's own first keyframe starts from exactly this
 * transform and releases it over the launch.
 */
.zoey-discovery[data-zoey-phase='lifting'] .zoey-discovery__trigger .zoey-discovery-object {
  animation: zoey-draws-lift 130ms cubic-bezier(0.2, 0.9, 0.35, 1) forwards;
}

.zoey-discovery[data-zoey-phase='lifting'] .zoey-discovery__trigger .zoey-discovery-object__art,
.zoey-discovery[data-zoey-phase='moving'] .zoey-discovery__trigger .zoey-discovery-object__art {
  opacity: 1;
}

/*
 * And the graphite stays gone. `zoey-draws-erase` belonged to the phase that has just ended, so
 * without this the sketch would return to its resting opacity and reappear on the paper at the
 * exact moment the plane takes off from it.
 */
.zoey-discovery[data-zoey-phase='lifting'] .zoey-bubble-draws__sketch,
.zoey-discovery[data-zoey-phase='moving'] .zoey-bubble-draws__sketch {
  opacity: 0;
}

@keyframes zoey-draws-lift {
  from {
    transform: translateY(0) rotate(0deg);
  }

  70% {
    transform: translateY(-8px) rotate(calc(-6deg * var(--zoey-draws-way)));
  }

  to {
    transform: translateY(-7px) rotate(calc(-5deg * var(--zoey-draws-way)));
  }
}

/* --- moving: the flight ---------------------------------------------------------------------- */

/*
 * The trajectory is not here. It is sixty-five transform keyframes sampled off the route in
 * assets/js/discovery-draws.js, because the route is the authority and a keyframe list written by
 * hand beside it would be a second opinion about the same curve — which is precisely the thing
 * that made v1 read as a translated element.
 *
 * What is here is everything else the flight does to the rest of the stage.
 *
 * The paper and Bubble leave as it goes. Her part is over the moment the drawing is real, and a
 * character standing under a plane for the length of its flight is a cutscene.
 */
.zoey-discovery[data-zoey-phase='moving'] .zoey-bubble-draws__paper,
.zoey-discovery[data-zoey-phase='moving'] .zoey-bubble-draws__bubble {
  animation: zoey-draws-clear 240ms ease-in forwards;
}

/*
 * And the route softens away under the landing (§9): it has done its job, it is presentation only,
 * and it does not stay on the page as decoration. 900ms into a 1240ms flight, so the last thing a
 * visitor sees is the plane settling onto a band that is already calm again.
 */
.zoey-discovery[data-zoey-phase='moving'] .zoey-plane-route {
  animation: zoey-draws-fade 340ms ease-in 900ms forwards;
}

/*
 * `from` is stated rather than inherited, because the opacity the paper and Bubble are sitting at
 * is an animation's fill and not a declared value — dropping `zoey-draws-surface` returns them to
 * the 0 they are declared at, and a fade from 0 to 0 is a disappearance.
 */
@keyframes zoey-draws-clear {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes zoey-draws-fade {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* --- Forced colors ---------------------------------------------------------------------------- */

/*
 * The flourish may simplify; the discovery may not.
 *
 * The paper is a pastel rectangle with a hairline and a shadow, and forced colors has no use for any
 * of those — it becomes a Canvas panel with a CanvasText border, which is a sheet of paper in a
 * system palette. The graphite and the trail both go to CanvasText, which is what every other stroke
 * in the family does (components/discovery-object.css). The object they resolve into is already
 * handled there and needs nothing from this file.
 */
@media (forced-colors: active) {
  .zoey-bubble-draws__paper {
    border-color: CanvasText;
    background-color: Canvas;
    background-image: none;
    box-shadow: none;
  }

  .zoey-bubble-draws__stroke,
  .zoey-plane-route__trail {
    stroke: CanvasText;
  }
}

/* --- Reduced motion ----------------------------------------------------------------------------- */

/*
 * There is nothing to switch off here, and that is the design.
 *
 * assets/js/discovery-draws.js never claims a discovery when `prefers-reduced-motion: reduce`
 * matches, and gives one back the moment the preference changes mid-session — so under reduced
 * motion no phase attribute is ever set, not one of the phase selectors above can match, the route
 * is never built and the stage is never unhidden. What a visitor has is the finished paper airplane
 * at its landing place, with its 44 x 44 target, its name, its card and its found state: §10's
 * requirement exactly, the route is not drawn, the plane does not fly, and the complete settled
 * state is what is presented.
 *
 * The reference frame's implementation note 5 reads "show the plane in its final position with the
 * full path". §10 of the locked authority says not to draw the route at all, and §9 says the route
 * is never permanent page decoration; a static dotted trail left on the homepage for every
 * reduced-motion visitor would be both. The prose authority wins, and the implementation report
 * records the conflict.
 *
 * The landing offset above is deliberately *not* inside a phase selector, and that is what makes it
 * true: where the secret lives is a fact about the secret rather than the end state of an animation,
 * so it is the same fact for a visitor who watched the flight, a visitor who cannot have motion, and
 * a visitor with no JavaScript at all.
 *
 * This block exists to say so. A reader who searches this file for the preference and finds nothing
 * has no way to tell a decision from an omission.
 */
