/* In the cart, in one click: the product page plays (user request of 16 November 2026:
   the picture of the Online moment "animée", after the film of incident.io's homepage).
   One source for the homepage picture and for the `h-online` Stageshow scene
   (product-ui/src/home.tsx), which films the poster this play ends on.

   What plays, once each time the picture is looked at. It opens on the whole product
   page, the widget in it with its two offers still to come: a quiet skeleton at their
   own geometry, in the widget's own tint. The offers for this product arrive, one row
   after the other, their words coming into focus. Once they have been read the first is
   chosen: its switch slides on, the one full violet that enters the picture. Then the
   page's own button is pressed: its word gives way to a tick, which is held, and the
   word comes back. The last frame is the filmed poster, and the picture holds it.

   Two halves. The offers arrive as soon as the first of them is in the window; the two
   presses wait until the button is in it too (--onp-gate-at is where the play is held,
   with every offer there and nothing moving: online-play.js). So the picture is never
   left on its placeholders while its words are read beside it.

   Taken from the reference: the manner (content that comes into focus where a
   placeholder stood, a control that answers a press nobody is seen to make, a mark that
   confirms and gives the words back). Nothing of incident.io's own. No pointer is drawn,
   as on the reference, and nothing stands in for one.

   How it is built. Every piece that plays carries a class of this sheet (--n is its row,
   0 or 1):
     .onp__bone    a placeholder bar: --icon, --title, --sub, --switch
     .onp__icon    the offer's icon, .onp__title its name, .onp__sub its price
     .onp__switch  its switch; .onp__flip the one that is turned on (its child is the knob)
     .onp__button  the page's button, .onp__word its word, .onp__done its tick
   In the scene they are the interface's own elements. On the page they are cuts of the
   filmed poster and a few plain shapes (see "The page" below). The root, .onp, is marked
   data-play: "ready" holds the first frame, "on" plays, "held" holds the play where it
   is (the page uses it between the two halves), anything else is the poster.
   data-size is "wide" or "compact"; the two play alike.

   Lengths are the picture's design pixels (--p: one of them), so the scene and the page,
   at any width, move alike. */

.onp {
  /* The clock, from the moment the play starts. The opening is held for --onp-rows-at;
     the second row follows the first by --onp-row-beat, and both are there by 1.2s.
     --onp-gate-at is a moment when nothing moves, where the page may hold the play.
     The cover is chosen at --onp-flip-at, once the offers have had a second and a half
     to be read: they are what the picture is about. The button is pressed at
     --onp-add-at; its tick, the payoff, is held for --onp-held. */
  --onp-rows-at: .5s;
  --onp-row-beat: .14s;
  --onp-gate-at: 1.7s;
  --onp-flip-at: 2.6s;
  --onp-add-at: 3.45s;
  --onp-held: 2s;
  --onp-tick-at: calc(var(--onp-add-at) + .22s);
  --onp-back-at: calc(var(--onp-tick-at) + .32s + var(--onp-held));
  --onp-end: calc(var(--onp-back-at) + .7s);
  /* The kit's curve for an arrival from nowhere */
  --onp-arrive: cubic-bezier(.22, 1, .36, 1);
  /* The placeholders are the widget's, not the page's: Evy's accent, faint, where the page's own filler is grey */
  --onp-bone: rgb(99 53 232 / .09);
}
/* When a row's offer arrives (--n is set on the row, or on each of its pieces) */
.onp__row, .onp--page > * { --onp-at: calc(var(--onp-rows-at) + var(--n, 0) * var(--onp-row-beat)); }

/* The placeholders and the tick are in the picture only while it plays */
.onp__bone, .onp__done { opacity: 0; visibility: hidden; }
.onp__done { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; pointer-events: none; }

/* What is animated is a registered number, and each piece's opacity, size, place and focus
   are computed from it, as claim-play.css and agent-cast.css do, and for the same reason:
   animated in the usual way a piece is drawn on a sheet of its own for as long as it
   moves, a pixel off the picture, and steps when the play ends. Do not go back to
   animating opacity, translate, scale or filter directly on a piece that stays.
     --onp-in     how much of a piece is in the picture
     --onp-on     how far the switch is on (the knob and the track each run their own)
     --onp-push   how far the button is pressed
     --onp-draw   how much of the tick is drawn */
@property --onp-in { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --onp-on { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --onp-push { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --onp-draw { syntax: '<number>'; inherits: false; initial-value: 0; }
/* Until its moment a piece is not in the picture at all (hidden only at the very start
   of the keyframes: it is seen from the first step of its arrival) */
@keyframes onp-in { from { --onp-in: 0; visibility: hidden; } }
/* A placeholder gives way */
@keyframes onp-out { from { --onp-in: 1; visibility: visible; } to { --onp-in: 0; visibility: hidden; } }
/* The word of the button leaves, and later comes back: two animations, the second over the first */
@keyframes onp-leave { from { --onp-in: 1; } to { --onp-in: 0; } }
@keyframes onp-back { from { --onp-in: 0; } to { --onp-in: 1; } }
@keyframes onp-on { from { --onp-on: 0; } }
/* A press: down, held a moment, let go */
@keyframes onp-push { 0%, 100% { --onp-push: 0; } 34%, 58% { --onp-push: 1; } }
@keyframes onp-draw { from { --onp-draw: 0; visibility: visible; } to { --onp-draw: 1; visibility: visible; } }
@keyframes onp-wipe { from { --onp-in: 1; visibility: visible; } to { --onp-in: 0; visibility: hidden; } }
/* Nothing: the end of the first is the end of the play, the end of the second the moment between
   its two halves (online-play.js listens for both) */
@keyframes onp-clock { to { visibility: visible; } }
@keyframes onp-gate { to { visibility: visible; } }

@media (prefers-reduced-motion: no-preference) {
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) { animation: onp-clock var(--onp-end) linear both, onp-gate var(--onp-gate-at) linear both; }

  /* The offers arrive. A bar fades as its words come into focus, in place: nothing moves */
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__bone { opacity: var(--onp-in); animation: onp-out .3s ease var(--onp-at) both; }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__icon {
    opacity: var(--onp-in); scale: calc(.8 + .2 * var(--onp-in)); transform-origin: 50% 50%;
    animation: onp-in .4s var(--onp-arrive) calc(var(--onp-at) + .04s) both;
  }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) :is(.onp__title, .onp__sub) {
    opacity: var(--onp-in); filter: blur(calc((1 - var(--onp-in)) * 3 * var(--p)));
    animation: onp-in .42s ease-out calc(var(--onp-at) + .08s) both;
  }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__sub { animation-delay: calc(var(--onp-at) + .14s); }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__switch { opacity: var(--onp-in); animation: onp-in .3s ease calc(var(--onp-at) + .1s) both; }

  /* The cover is chosen: the switch goes on as the kit's own does (its track in a fifth of
     a second, its knob in a quarter, on the kit's curve), and nothing else answers. A fill
     on the row was tried and taken out: with no pointer in the picture it read as a hover
     nobody made. The kit's transitions are set aside while the numbers drive the switch:
     left on, they would run after every frame of the numbers. */
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__flip {
    background-color: color-mix(in srgb, var(--onp-off), var(--onp-accent) calc(var(--onp-on) * 100%)); transition: none;
    animation: onp-in .3s ease calc(var(--onp-at) + .1s) both, onp-on .2s ease var(--onp-flip-at) both;
  }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__flip > * {
    translate: calc((var(--onp-on) - 1) * 12 * var(--p)) 0; transition: none;
    animation: onp-on .25s var(--onp-arrive) var(--onp-flip-at) both;
  }

  /* The button is pressed: a small give, as the kit's. Its word goes out of focus, the tick
     is drawn where it was and held; then the tick leaves whole and the word comes back.
     The tick starts while the last of the word is still there, and the word comes back
     under the last of the tick: the button is never a bare bar. */
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__button { scale: calc(1 - .03 * var(--onp-push)); transform-origin: 50% 50%; animation: onp-push .44s ease var(--onp-add-at) both; }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__word {
    opacity: var(--onp-in); filter: blur(calc((1 - var(--onp-in)) * 3 * var(--p)));
    animation: onp-leave .2s ease calc(var(--onp-add-at) + .14s) forwards, onp-back .42s ease-out calc(var(--onp-back-at) + .04s) forwards;
  }
  .onp:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__done {
    opacity: calc(min(1, var(--onp-draw) * 12) * var(--onp-in)); stroke-dashoffset: calc(1 - var(--onp-draw));
    animation: onp-draw .32s cubic-bezier(.65, 0, .35, 1) var(--onp-tick-at) forwards, onp-wipe .2s ease var(--onp-back-at) forwards;
  }

  /* On the page the button is a cut of the picture, and the painted button stays under it: while it
     gives, and only then, the page's white is laid over the painted one */
  .onp--page:is([data-play='ready'], [data-play='on'], [data-play='held']) .onp__under { opacity: calc(var(--onp-push) * 1000); animation: onp-push .44s ease var(--onp-add-at) both; }

  /* The first frame, held until the picture is looked at, and the play held between its two halves.
     The rules above set `animation` whole, which would start each piece again: this one has to win over them. */
  .onp:is([data-play='ready'], [data-play='held']), .onp:is([data-play='ready'], [data-play='held']) * { animation-play-state: paused !important; }
}

/* ---- The page ----
   The homepage shows the filmed poster (product-ui/renders/h-online-<language>-<size>.webp).
   online-play.js lays this layer over it: a sheet of the card's white over what each row
   holds, and over the sheets the poster again, cut into the pieces named above, with the
   placeholder bars, the switch that is turned on and the tick as plain shapes. Each cut
   shows its own part of the poster, in register, so at rest the layer and the poster are
   one picture; the cuts are what the play moves. No word is written on the page.

   Boxes are in the picture's design pixels (600 x 440 wide, 358 x 358 compact), the same
   in every language: the page is laid out alike in all seven. A row is 63 high; --rx,
   --rw and --ry are the first row's left edge, its width and its top, and every box is
   counted from them, so the two sizes share one set of rules. A cut only ever ends in the
   white between two pieces. product-ui/scripts/online-cuts.mjs proves all of it against
   the poster and against the scene, in seven languages: run it after any change to the
   page's screen or to a box. */
[data-online-play] { position: relative; }
/* The two colours of the switch: the kit's grey for off, and for on the accent as the posters'
   compression gives it (#6435e9 in all fourteen, one level off the scene's #6335e8) */
.onp--page { position: absolute; inset: 0; container: onp / size; pointer-events: none; --stage: 600; --rx: 284; --rw: 252; --ry: 200; --p: calc(100cqw / var(--stage)); --onp-off: rgb(0 0 0 / .15); --onp-accent: #6435e9; }
.onp--page[data-size='compact'] { --stage: 358; --rx: 32; --rw: 294; --ry: 178; }
/* Shown once the poster it is cut from has arrived, and never where it cannot be placed */
.onp--page:not([data-play]) { display: none; }
/* On paper the picture is the poster: a page printed while the layer holds its first frame would show the offers still to come */
@media print { .onp--page { display: none; } }
/* A piece: its box (--x, --y, --w, --h) in design pixels, from the corner of what holds it (--ox, --oy) */
.onp--page :is(.onp__room, .onp__first, .onp__sheet, .onp__under, .onp__cut, .onp__bone, .onp__switch, .onp__face, .onp__done) {
  --u: calc(100cqw / var(--stage)); --top: calc(var(--ry) + var(--n, 0) * 63);
  position: absolute; left: calc((var(--x) - var(--ox, 0)) * var(--u)); top: calc((var(--y) - var(--oy, 0)) * var(--u)); width: calc(var(--w) * var(--u)); height: calc(var(--h) * var(--u));
}
.onp--page :is(.onp__sheet, .onp__under) { background: #fff; }
.onp--page .onp__under { opacity: 0; }
/* A cut is a window onto the poster. The poster inside it is the picture's own size and stands
   exactly where the picture stands, so the browser sets it on the same pixels as the picture
   under it; only the window's edges, which fall in white, are placed by the cut's own box. */
.onp--page .onp__cut { overflow: hidden; }
.onp--page .onp__cut > b { position: absolute; left: calc(var(--x) * var(--u) * -1); top: calc(var(--y) * var(--u) * -1); width: 100cqw; height: 100cqh; background: var(--onp-poster) 0 0 / 100% 100% no-repeat; }

/* What must be in the window (online-play.js): for the play to start, the widget down to the foot of its
   first offer; for the two presses, the widget and the button under it */
.onp--page .onp__first { --x: var(--rx); --y: calc(var(--ry) - 40); --w: var(--rw); --h: 103; }
.onp--page .onp__room { --x: var(--rx); --y: calc(var(--ry) - 40); --w: var(--rw); --h: 210; }
/* A row: the sheet over what it holds, inside the card's corners; the bars; the cuts */
.onp--page .onp__sheet { --x: calc(var(--rx) + 10); --y: calc(var(--top) + 9); --w: calc(var(--rw) - 20); --h: 46; }
.onp--page .onp__bone { background: var(--onp-bone); }
.onp--page :is(.onp__icon, .onp__bone--icon) { --x: calc(var(--rx) + 12); --y: calc(var(--top) + 24); --w: 16; --h: 16; }
.onp--page .onp__bone--icon { border-radius: calc(4 * var(--u)); }
.onp--page .onp__title { --x: calc(var(--rx) + 40); --y: calc(var(--top) + 13); --w: calc(var(--rw) - 94); --h: 19; }
.onp--page .onp__sub { --x: calc(var(--rx) + 40); --y: calc(var(--top) + 34); --w: calc(var(--rw) - 94); --h: 17; }
.onp--page .onp__bone--title { --x: calc(var(--rx) + 40); --y: calc(var(--top) + 18); --w: var(--bone); --h: 8; border-radius: calc(4 * var(--u)); }
.onp--page .onp__bone--sub { --x: calc(var(--rx) + 40); --y: calc(var(--top) + 39); --w: var(--bone); --h: 7; border-radius: calc(3.5 * var(--u)); }
.onp--page :is(.onp__switch, .onp__bone--switch) { --x: calc(var(--rx) + var(--rw) - 42); --y: calc(var(--top) + 23); --w: 30; --h: 18; }
.onp--page .onp__bone--switch { border-radius: calc(9 * var(--u)); }
/* The switch that is turned on is drawn here as the kit draws its own (product-ui/kit/controls/Toggle.css):
   a knob cannot be cut from a picture and slid over another colour. It stays once the play is over. */
.onp--page .onp__flip { border-radius: calc(9 * var(--u)); background-color: var(--onp-accent); }
.onp--page .onp__flip > i { position: absolute; left: calc(2 * var(--u)); top: calc(2 * var(--u)); width: calc(14 * var(--u)); height: calc(14 * var(--u)); border-radius: 50%; background: #fff; box-shadow: 0 calc(.5 * var(--u)) calc(1.5 * var(--u)) rgb(0 0 0 / .14), 0 0 0 calc(.5 * var(--u)) rgb(0 0 0 / .04); transform: translateX(calc(12 * var(--u))); }
/* The button: the page's white under it, for the moment it gives; its own cut; over the painted word,
   the button's violet as the poster has it, then the word's cut and the tick */
.onp--page .onp__under { --x: calc(var(--rx) - 1); --y: calc(var(--ry) + 137); --w: calc(var(--rw) + 2); --h: 34; }
.onp--page .onp__button { --x: var(--rx); --y: calc(var(--ry) + 138); --w: var(--rw); --h: 32; }
.onp--page .onp__button > :is(.onp__face, .onp__word) { --ox: var(--rx); --oy: calc(var(--ry) + 138); --x: calc(var(--rx) + 16); --y: calc(var(--ry) + 144); --w: calc(var(--rw) - 32); --h: 20; }
.onp--page .onp__face { background: var(--onp-accent); }
.onp--page .onp__done { --ox: var(--rx); --oy: calc(var(--ry) + 138); --x: calc(var(--rx) + var(--rw) / 2 - 11); --y: calc(var(--ry) + 143); --w: 22; --h: 22; }
