/* Playfair Rivals — the motion BETWEEN screens, and the thing you just bought.
   Everything here is painted in #fx, a layer OUTSIDE #app, because render()
   replaces #app's whole innerHTML and anything parented inside it dies
   mid-flight (docs/278).

   Motion is transform and opacity only and nothing runs per frame: every move
   is a compositor animation (root CLAUDE.md, docs/77). No element here is ever
   larger than the phone column, so no move allocates a giant raster.

   ⚠️ Under prefers-reduced-motion the global rule in app.css collapses every
   animation to .001ms rather than removing it, so a `both` animation SNAPS TO
   ITS LAST FRAME AND HOLDS. Nothing in this file may have an invisible base
   state that only an animation reveals, and every teardown is driven by JS. */

#fx {
  /* copies #app, NOT #boot: #app is min(100vw,412px) and #boot is min(100%,412px),
     and the two differ by a desktop scrollbar. The flight lands on real button
     coordinates, so the column has to be the same column.
     No transform on the layer itself — it is spent by the children. */
  position: fixed; top: 0; left: 0; right: 0; margin-inline: auto;
  width: min(100vw, 412px); height: 100%; height: 100dvh; max-height: 100dvh;
  overflow: hidden; pointer-events: none; z-index: 33;   /* over .toast 30, under #boot 40 */
}

/* ── the screen change ────────────────────────────────────────────────────── */
/* ⛔ TWO MOVES LIVE HERE AND fx.js's `MOVE` PICKS ONE. The curtain (docs/352,
   his pick out of the animation gallery) is the one that plays; the quake
   below it (docs/305) is kept whole, one word from coming back. Both are the
   same `.fx-plate`, told apart by a modifier. */

/* His instruction, 2026-09-14: *"when you click bottom button - the button gets
   selected and it starts expanding onto the whole screen, with the symbol
   following expansion. When it covers the whole screen, the symbol stumps
   (quickly), does little 'earth quake/shake' and screen on background is
   crushing and disappears piece by piece randomly."*

   The key you pressed becomes the screen, the screen is struck, and then it
   breaks — and the holes are how the next screen arrives. fx.js owns the five
   beats and every number in them; this file owns only what the surface is made
   of. Replaces the blade of docs/278 / 282 / 303 entirely.

   ⛔ THE CLASS NAME IS .fx-plate AND IT STAYS. pf2_phone_walk.mjs,
   pf2_figma_pairs.mjs, pf2_fx_check.mjs and the probes all wait on
   "#fx .fx-plate" to detach before they photograph. Renaming it would be a
   GREEN RUN WITH WRONG PICTURES, which is the dangerous kind (docs/278).

   ⛔⛔ AND A MODIFIER ON IT IS NEVER A BARE WORD. app.css:133 declares an
   unqualified `.back { position:absolute; right:0; top:-3px; width:44px;
   height:44px }` for the head's arrow — and the plate that shipped on `.back`
   was a 44x44 square in the top-left corner, for every back tap in the game,
   for two batches (docs/282 §3). `.quake` is checked against app.css for the
   same reason. A class name is a global.

   ⛔ GOING BACK DOES NOT DO THIS (his instruction, 2026-09-14). app.js's
   toBack() swaps the screen and nothing here runs. */

.fx-plate {
  position: absolute; inset: 0; pointer-events: auto;   /* it swallows taps */
  will-change: transform;
}

/* ── the curtain (docs/352) ───────────────────────────────────────────────── */
/* His pick, 2026-09-25, card `ent-curtain-split` in the animation gallery:
   *"Two wine curtains with sewn folds meet with a small overshoot, his crest
   seals the seam for a beat, and they draw apart lifting slightly like real
   cloth."* Every value below is the card's own (scripts/anim_gallery/demos/
   50_entrances.js), scaled from its 412px stage to the column: a drape is a
   little more than half of it (the card's 214 of 412), so the two overlap by
   the card's 18px at the seam and no hairline of the screen behind can show
   down the middle. The one number that is NOT the card's is the outer overhang
   (see .drape-l below).

   fx.js owns every beat and number of the motion; this file owns only what the
   cloth is made of. Nothing here animates — the drapes and the crest are moved
   by Web Animations of transform and opacity, and the folds, the hem and the
   shadow are static paint.

   ⛔ EVERY CHILD CLASS IS SCOPED UNDER .fx-plate.curtain AND NONE IS A WORD
   app.css OWNS (docs/282 §3: a bare `.back` made a 44x44 plate). `.cur` was the
   card's name and app.css already has one, so these are `.drape`, `.hem`,
   `.seal`. pf2_fx_check.mjs measures the drapes' boxes rather than trusting the
   names, because a class name is a global. */
.fx-plate.curtain .drape {
  /* 10px past the top and the floor, as the card has it — the open LIFTS the
     cloth 14px and the bottom edge must not arrive before the drape has gone */
  position: absolute; top: -10px; bottom: -10px; display: block;
  width: calc(50% + 15px);
  pointer-events: auto;                /* what is still behind a drape cannot be pressed */
  will-change: transform;
  box-shadow: 0 0 30px rgba(0, 0, 0, .6);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .3) 0 7px, rgba(255, 255, 255, .05) 7px 20px, rgba(0, 0, 0, .16) 20px 30px),
    linear-gradient(#7d0748, #5a0235 60%, #3b0122);
}
/* ⚠️ THE BASE STATE IS PARKED, OFF THE GLASS — the same place the first and the
   last keyframe put it (fx.js PARK: 36px past the edge, so the 30px shadow is
   off the glass too). A drape whose animation never started covers nothing,
   and the swap's backstop still runs: the worst case is an instant change,
   never a curtain left across the phone. */
/* ⚠️⚠️ 6px PAST THE OUTER EDGE, NOT THE CARD'S 2. The drapes meet 3px PAST the
   seam (the overshoot), which pulls each one's outer edge 3px inward — and the
   swap happens at exactly that instant. Hung at the card's -2px, the outermost
   pixel of each side showed the screen being rebuilt, on every change of place.
   pf2_fx_check.mjs measured it; nothing you could see at speed would have. The
   width grows by the same 4px, so the seam still overlaps by the card's 18. */
.fx-plate.curtain .drape-l { left: -6px; transform: translate3d(calc(-100% - 36px), 0, 0); }
.fx-plate.curtain .drape-r { right: -6px; transform: translate3d(calc(100% + 36px), 0, 0); }
.fx-plate.curtain .hem {
  position: absolute; top: 0; bottom: 0; width: 5px; display: block;
  background: linear-gradient(90deg, #8a7148, #e6c88f, #8a7148);
}
.fx-plate.curtain .drape-l .hem { right: 0; }
.fx-plate.curtain .drape-r .hem { left: 0; }

/* his crest on the seam: a gold disc, a wine ring and the serif P — typography
   and light, never a picture (root CLAUDE.md, the phone section) */
.fx-plate.curtain .seal {
  position: absolute; left: 50%; top: 50%; width: 72px; height: 72px;
  margin: -36px 0 0 -36px; border-radius: 50%;
  display: grid; place-items: center;
  pointer-events: none; opacity: 0;    /* fx.js brings it in; it never takes a tap */
  will-change: transform, opacity;
  background: radial-gradient(circle at 40% 35%, #f3dca6, #d0b27a 55%, #8a7148);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .6);
}
.fx-plate.curtain .seal .ring {
  position: absolute; inset: 7px; display: block; border-radius: 50%;
  border: 2px solid rgba(59, 1, 34, .55);
}
.fx-plate.curtain .seal .p {
  position: relative; font-family: var(--serif); font-weight: 400;
  font-size: 34px; line-height: 1; color: #3b0122;
}

/* ── the fade (docs/353) ──────────────────────────────────────────────────── */
/* His two cards, one move: "Fade through with depth (tab change)" and "The hub
   arriving whole". fx.js owns every beat; this file owns only the photograph of
   the screen being left.

   ⭐ THE PLATE TAKES NO TAP; THE PHOTOGRAPH DOES. The plate is the whole column,
   but the tab bar is left uncovered (fx.js cuts the photograph around it and
   around the lit slot), so a second tab can be pressed while the first screen is
   still loading. The photograph swallows a tap as ONE surface: every copied node
   is `inert` and takes no pointer at all, so no button of the old screen — or of
   the new one under it — can be pressed through it.

   ⚠️ Its own ground is the game's ink, because the photograph must be OPAQUE: the
   destination is already drawn under it, and on the hub #app itself is see-through
   (docs/351), so a copied screen with a transparent corner would show the next
   screen early. And everything copied is held STILL — a copied node's animations
   would start again from their first frame, which is a flicker nobody asked for;
   the photograph is what the screen looked like when he pressed, not a replay. */
.fx-plate.fade { pointer-events: none; will-change: auto; }
.fx-plate.fade .fx-ghost {
  position: absolute; inset: 0; display: block; overflow: hidden;
  pointer-events: auto; background: var(--bg, #211d1e);
  transform-origin: 50% 45%; will-change: transform, opacity;
}
.fx-plate.fade .fx-ghost * { pointer-events: none !important; }
.fx-plate.fade .fx-ghost,
.fx-plate.fade .fx-ghost *,
.fx-plate.fade .fx-ghost *::before,
.fx-plate.fade .fx-ghost *::after { animation-play-state: paused !important; transition: none !important; }

/* ── the dolly (docs/355): through the lit doorway, and back out ──────────────
   His card `ent2-dolly-in`, for the hub <-> Places only. fx.js owns every beat and
   number; this file owns what the camera is made of. Like the fade's photograph, the
   plate takes no tap and the ghost does, cut round the tab bar; the camera inside it
   is his painting at the hub's own box, the near layer under the living hub's mask,
   eight motes of dust, the doorway's light, and a flash.
   ⚠️ The painting grows to 7x and the near layer to 14x — they are CLIPPED by the
   ghost, never larger on the glass than the column, and they are one <img> each (a
   picture the compositor scales), never a canvas. */
.fx-plate.dolly { pointer-events: none; will-change: auto; }
.fx-plate.dolly .fx-ghost.dl { position: absolute; inset: 0; overflow: hidden; pointer-events: auto; }
.fx-plate.dolly .dl-cam { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
/* the dark it stands on, a piece of its own so it can arrive with the painting over a living layer */
.fx-plate.dolly .dl-ink { position: absolute; inset: 0; background: #0d0b0c; }
.fx-plate.dolly .dl-far, .fx-plate.dolly .dl-near { position: absolute; max-width: none; image-rendering: pixelated;
  -webkit-user-drag: none; user-select: none; }
.fx-plate.dolly .dl-near { -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.fx-plate.dolly .dl-mo { position: absolute; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%;
  background: #f3dca6; opacity: 0; }
.fx-plate.dolly .dl-door { position: absolute; border-radius: 50%; opacity: 0;
  background: radial-gradient(closest-side, rgba(255,236,196,1), rgba(255,190,110,.6) 40%, rgba(255,160,80,0)); }
.fx-plate.dolly .dl-flash { position: absolute; inset: 0; background: #fff3dc; opacity: 0; pointer-events: none; }
/* the photograph: Places whole (on the game's ink), or the hub's furniture alone (clear,
   so the camera shows through — and without the ground panel every .view carries) */
.fx-plate.dolly .dl-shot { position: absolute; inset: 0; display: block; overflow: hidden;
  background: var(--bg, #211d1e); transform-origin: 50% 45%; }
.fx-plate.dolly .dl-shot.ui { background: none; }
.fx-plate.dolly .dl-shot.ui .view::before { display: none; }
.fx-plate.dolly .dl-shot * { pointer-events: none !important; }
.fx-plate.dolly .dl-shot,
.fx-plate.dolly .dl-shot *,
.fx-plate.dolly .dl-shot *::before,
.fx-plate.dolly .dl-shot *::after { animation-play-state: paused !important; transition: none !important; }

/* ── the quake (docs/305) — kept behind fx.js's MOVE ──────────────────────── */

/* ── the ground: the surface that grows, and then comes apart ─────────────── */
/* ⚠️ 14px OVERSIZED ON EVERY SIDE. The quake moves the whole plate by up to 7px,
   and a ground that ended exactly at the phone's edge would show a strip of the
   old screen down one side on the frame it is furthest over. */
/* ⛔⛔ THE SURFACE IS DECLARED ONCE AND READ TWICE. The ground wears it whole and
   each shard wears a slice of it, so it cannot be written in two places — and it
   cannot be `inherit` either, which is the bug that shipped first: fx.js drops
   the GROUND's own fill the moment the pieces start to fall, and an inherited
   value is LIVE, so all forty pieces went transparent in the same frame and the
   next screen arrived in one flat cut. The crumble was correct, built, animating,
   and completely invisible.
   ⭐ A custom property is the fix: the ground's inline `background: none` cannot
   reach it, so the pieces keep the surface they were cut from.
   ⚠️ And the wine survives only as the CROWN — by 200px it is the game's own
   ground. A flat field of saturated wine is the cheapest thing this palette can
   put on a phone and it was the whole complaint the first time (docs/282). */
.fx-plate.quake {
  --quake-fill: linear-gradient(180deg,
    #3d0b28    0%,
    #2c1422   11%,
    #221820   24%,
    #1a1519   45%,
    #151315   72%,
    #111013  100%);
}
.fx-plate.quake > .ground {
  position: absolute; inset: -14px;
  transform-origin: 0 0;
  will-change: transform;
  background-image: var(--quake-fill);
  background-size: 100% 100%;
}

/* ── the forty pieces ─────────────────────────────────────────────────────── */
/* ⭐ THE PIECES ARE THE GROUND, NOT A COPY OF IT. Each one carries the same
   gradient at five-by-eight the size, offset to its own cell — the standard
   sprite slice — so at rest they tile into exactly the surface above and there
   is no frame in which a handoff could show. fx.js drops the ground's own fill
   in the same frame it tells the first piece to go, or every hole would open
   onto the plate again instead of onto the screen behind it. */
.fx-plate.quake .shard {
  position: absolute; display: block;
  /* ⚠️⚠️ A HAIRLINE SEAM IS A GRID DRAWN ACROSS HIS SCREEN. Percentage cells land
     on fractional pixels, so once the ground's own fill is dropped every join
     would be a one-pixel line of the NEXT screen — forty pieces outlined in it,
     for the frame before they start to move. Each piece is grown by a pixel and
     pulled back half of one, so neighbours always overlap. The slice it carries
     shifts by half a pixel in a 78px cell, which is under a percent of one
     cell and cannot be seen. */
  width: calc(20% + 1px);       /* 100 / COLS */
  height: calc(12.5% + 1px);    /* 100 / ROWS */
  margin: -.5px 0 0 -.5px;
  will-change: transform, opacity;
  background-image: var(--quake-fill);
  background-size: 500% 800%;   /* COLS x ROWS */
}

/* ── the lit edge ─────────────────────────────────────────────────────────── */
/* ⭐ IT IS WHAT MAKES THE GROWING PLATE READ AS A THING rather than as the
   screen dimming, and it is the one part of the old move that was never the
   complaint (docs/303). Its own element, so the crumble can take it away
   without touching the pieces. */
.fx-plate.quake .edge {
  position: absolute; inset: 14px; display: block; pointer-events: none;
  border: 2px solid rgba(208, 178, 122, .55);
  border-top-color: #f6e6bb;
  box-shadow: 0 -2px 22px -4px rgba(246, 230, 187, .30),
              inset 0 2px 26px -10px rgba(246, 230, 187, .40);
}

/* ── the symbol ───────────────────────────────────────────────────────────── */
/* The key's own picture, travelling to the middle of the phone. His set is
   white on transparent (docs/260), so it needs no tint — only the light it
   throws, which is what the stomp lands with. */
.fx-plate.quake .mark {
  position: absolute; display: block; object-fit: contain;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 20px rgba(208, 178, 122, .45))
          drop-shadow(0 8px 18px rgba(0, 0, 0, .65));
}

/* Two gates on purpose: change() never builds the plate under stillness, and
   this covers one already in flight when the setting is flipped mid-move.
   Every beat of this move is a Web Animation, which app.css's .001ms collapse
   cannot reach at all — fx.js's own matchMedia listener is what closes that. */
@media (prefers-reduced-motion: reduce) { .fx-plate { display: none; } }

/* ── what you just bought ─────────────────────────────────────────────────── */
/* The tile itself leaves the shelf, turns in the middle of the screen where it
   can be read, and is put away in the button behind which it now lives. The
   wrapper is the only thing that moves; the tile inside it is a real clone, so
   the rarity frame is app.css's and not a seventh copy of the table. */
.fx-fly { position: absolute; pointer-events: none; will-change: transform, opacity; }
.fx-fly > .tile { width: 100%; height: 100%; }
.fx-fly .halo {
  position: absolute; left: -60%; top: -60%; width: 220%; height: 220%;
  border-radius: 50%; opacity: .55; pointer-events: none;
}

/* the button catches it: one ring, the size of the slot it landed in */
.fx-catch {
  position: absolute; border-radius: 12px; pointer-events: none;
  border: 2px solid rgba(208,178,122,.8);
  animation: fxCatch 420ms cubic-bezier(.2,.7,.3,1) both;
}
@keyframes fxCatch {
  0% { transform: scale(.5); opacity: 0; }
  35% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* what it cost, leaving the purse it came out of */
.fx-spend {
  position: absolute; pointer-events: none; font-family: var(--mono); font-weight: 700;
  font-size: 12px; line-height: 14px; white-space: nowrap; color: rgba(228,224,216,.75);
  text-shadow: 0 1px 4px #000; animation: fxSpend 900ms ease-out both;
}
@keyframes fxSpend {
  0% { transform: translateY(0); opacity: 0; }
  18% { transform: translateY(5px); opacity: 1; }
  100% { transform: translateY(26px); opacity: 0; }
}
/* a gain comes the other way and lands on the number, the hub's own reading */
.fx-spend.up { color: var(--gold); animation-name: fxGain; }
@keyframes fxGain {
  0% { transform: translateY(24px); opacity: 0; }
  22% { transform: translateY(18px); opacity: 1; }
  76% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ── THE LEVEL YOU JUST REACHED ───────────────────────────────────────────── */
/* His instruction, 2026-09-16: *"Add animation/effect when you get higher
   level."* It is the only thing in the game that happens TO the player rather
   than to a thing they are holding, so it is the whole column for a moment and
   then it is gone.

   Typography, light and one abstract shape — the rule for anything that could be
   mistaken for content (root CLAUDE.md, the phone section). No figure, no badge,
   no picture: a wash, two rings opening outward, the word and the numeral.

   ⛔ Transform and opacity only, and no element is larger than the column, so
   nothing here allocates a raster or runs per frame (docs/77). fx.js owns the
   timing and the teardown; under prefers-reduced-motion it never starts and the
   plate is shown still, because a `both` animation would snap to its last frame
   and hold an empty screen. */
.fx-level { position: absolute; inset: 0; pointer-events: none; }
.fx-level .wash {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at 50% 42%, rgba(102,2,60,.58), rgba(13,11,12,.86) 68%);
}
.fx-level .ring {
  position: absolute; left: 50%; top: 42%; width: 190px; height: 190px; margin: -95px 0 0 -95px;
  border-radius: 50%; border: 1.5px solid var(--gold); opacity: 0;
}
/* ⚠️ Lifted by half its own height so the numeral sits in the MIDDLE of the
   rings rather than hanging under them — `top: 42%` put the block's top edge on
   the rings' centre, which reads as two things that missed each other. The
   offset is CSS `top`; fx.js animates `transform` on this node and the two
   compose. */
.fx-level .word {
  position: absolute; left: 0; right: 0; top: calc(42% - 47px); text-align: center; opacity: 0;
}
.fx-level .word small {
  display: block; font-family: var(--sans); font-weight: 600; font-size: 10px;
  letter-spacing: 4px; color: var(--gold); text-transform: uppercase;
}
.fx-level .word b {
  display: block; font-family: var(--serif); font-weight: 400; font-size: 76px;
  line-height: 82px; color: var(--ink); text-shadow: 0 2px 22px rgba(0,0,0,.7);
}
/* stillness: shown, not played — fx.js adds this instead of starting anything */
.fx-level.still .wash { opacity: 1; }
.fx-level.still .ring { opacity: .5; }
.fx-level.still .word { opacity: 1; }
