/* After purchase: the messages arrive (user request of 16 November 2026: "Il faut animer
   l'apparition des messages dans l'image « Un second moment, plus calme, pour dire oui. »").
   One source for the homepage picture and for the `h-after` Stageshow scene
   (product-ui/src/home.tsx), which films the poster this play ends on.

   What plays, once each time a reader comes down to the picture. The retailer's message
   arrives, from its tail's corner, as its place comes into the window. After a beat the
   customer's yes arrives from its own corner, quicker and solid: it is the viewer's own.
   Then the card for what the yes bought rises into the column. The last frame is the
   filmed poster, and the picture holds it. Nothing else moves, and nothing moves after.

   One clock, 2.3s, started once: the yes and the card do not wait for the reader to
   scroll further. (A first version did: the yes waited for the whole conversation to be
   in the window, and a reader who stopped at the block's title was left with one bubble
   over an empty picture. Found by the fresh-eye review of 16 November 2026.) So the part
   of the picture that is in the window is never left unfinished for more than two seconds.

   The manner is the kit's own (product-ui/kit/messages.css): a bubble rises 6px and
   grows out of its tail's corner on the kit's curve for an arrival; a card arrives
   whole, with no growth. No typing dots: the retailer's message is one that is
   received, and the yes is the viewer's own, who has taken the device's place.

   How it is built. The three pieces carry a class of this sheet:
     .afp__ask   the retailer's message
     .afp__yes   the customer's yes
     .afp__card  what the yes bought
   In the scene they are the interface's own elements (the kit's bubbles and card). On
   the page each is a picture of that one object, alone with its shadow, set over a
   picture of the ground (see "The page" below). The root, .afp, is marked data-play:
   "ready" holds the first frame (the ground alone), "on" plays, and anything else is
   the poster. data-size is "wide" or "compact".

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

.afp {
  /* The clock, from the moment the play starts: the message; a beat of half a second
     once it has landed; the yes; a quarter of a second; the card. */
  --afp-ask-at: 0s;
  --afp-ask-for: .5s;
  --afp-yes-at: calc(var(--afp-ask-at) + var(--afp-ask-for) + .5s);
  --afp-yes-for: .35s;
  --afp-card-at: calc(var(--afp-yes-at) + var(--afp-yes-for) + .25s);
  --afp-card-for: .6s;
  --afp-end: calc(var(--afp-card-at) + var(--afp-card-for) + .1s);
  /* The kit's curve for an arrival from nowhere */
  --afp-arrive: cubic-bezier(.22, 1, .36, 1);
  --afp-u: 1px;
}

/* How a piece arrives. What is animated is one registered number, --afp-in, from 0 to 1,
   and the piece's opacity, place and size are computed from it, as claim-play.css and
   agent-cast.css do, for the reason given there: animated in the usual way, a piece is
   drawn on a sheet of its own for as long as it moves and steps a pixel as it lands.
   Do not go back to animating opacity, translate or scale directly. */
@property --afp-in { syntax: '<number>'; inherits: false; initial-value: 1; }
/* Until its moment a piece is not in the picture at all (visibility is hidden only at the
   very start of the keyframes: it is seen from the first step of its arrival) */
@keyframes afp-in { from { --afp-in: 0; visibility: hidden; } }
/* Nothing: its end is the end of the play (after-play.js listens for it) */
@keyframes afp-clock { to { visibility: visible; } }

/* A bubble grows out of the corner its tail is on, as the kit's does */
.afp__ask { transform-origin: 0 100%; }
.afp__yes { transform-origin: 100% 100%; }

@media (prefers-reduced-motion: no-preference) {
  .afp:is([data-play='ready'], [data-play='on']) { animation: afp-clock var(--afp-end) linear both; }
  /* The message, received: it fades up, rising 6px as the kit's bubble does, and grows a tenth */
  .afp:is([data-play='ready'], [data-play='on']) .afp__ask {
    opacity: var(--afp-in); translate: 0 calc((1 - var(--afp-in)) * 6 * var(--afp-u)); scale: calc(.9 + .1 * var(--afp-in));
    animation: afp-in var(--afp-ask-for) var(--afp-arrive) var(--afp-ask-at) both;
  }
  /* The yes, sent: the viewer's own does not come up from below. It grows out of its corner, quicker and
     further, and is solid almost at once (its fade lasts the first five eighths of the growth, some 60ms) */
  .afp:is([data-play='ready'], [data-play='on']) .afp__yes {
    opacity: min(1, var(--afp-in) * 1.6); scale: calc(.84 + .16 * var(--afp-in));
    animation: afp-in var(--afp-yes-for) var(--afp-arrive) var(--afp-yes-at) both;
  }
  /* The card rises into the column, whole: a card does not grow, and a solid thing is no ghost, so it is
     opaque by the first third of its rise (some 45ms). Not from its first frame: nothing is popped in whole. */
  .afp:is([data-play='ready'], [data-play='on']) .afp__card {
    opacity: min(1, var(--afp-in) * 3); translate: 0 calc((1 - var(--afp-in)) * 12 * var(--afp-u));
    animation: afp-in var(--afp-card-for) var(--afp-arrive) var(--afp-card-at) both;
  }
  /* The first frame, held until a reader comes down to the picture. The rules above set `animation`
     whole, which would start each piece again: this one has to win over them. */
  .afp[data-play='ready'], .afp[data-play='ready'] * { animation-play-state: paused !important; }
}

/* ---- The page ----
   The homepage shows the filmed poster (product-ui/renders/h-after-<language>-<size>.webp).
   after-play.js lays this layer over it: the ground alone
   (renders/h-after-ground-<size>.webp, the scene filmed with nothing on it), and on it the
   three objects, each a picture of that object alone on nothing, with its own shadow whole
   (renders/h-after-ask|yes|card-<language>-<size>.webp, made by product-ui/export-h-after.py).
   Each is the picture's own size and stands exactly where the picture stands, so at rest the
   four together are the filmed poster. They cannot be cut from the poster, as the claims
   play's pieces are: there the shadow of one object lies under the next (the message's under
   the yes on a phone, the yes's under the card), and a piece that arrives before its
   neighbour needs the whole of its shadow.
   Nothing is drawn by hand and no word is written here: the page does not load the
   picture's face. product-ui/scripts/h-after-pieces.mjs proves the layer against the poster and
   against the scene, in seven languages: run it after any change to the scene, to this
   sheet or to the posters. */
.afp--page { position: absolute; inset: 0; container: afp / size; pointer-events: none; }
/* Shown once its four pictures have arrived, and never where it cannot be placed */
.afp--page:not([data-play]) { display: none; }
.afp--page > i { position: absolute; inset: 0; background: 0 0 / 100% 100% no-repeat; }
.afp--page .afp__ground { background-image: var(--afp-ground); }
.afp--page .afp__ask { background-image: var(--afp-ask); }
.afp--page .afp__yes { background-image: var(--afp-yes); }
.afp--page .afp__card { background-image: var(--afp-card); }
/* A design pixel, and the corner each bubble grows from: where its tail meets the column
   (design pixels of the 600 x 440 picture, the same in every language: all seven are
   brought to the same number of lines) */
.afp--page { --afp-u: calc(100cqw / 600); }
.afp--page .afp__ask { transform-origin: calc(56 / 600 * 100%) calc(136.53 / 440 * 100%); }
.afp--page .afp__yes { transform-origin: calc(544 / 600 * 100%) calc(183.88 / 440 * 100%); }
/* .afp__door is the message's own place: the play starts when a reader coming down the page has a
   quarter of it in the window (after-play.js). Above it the picture is its own gutter, with nothing
   to show, so no more than a sliver of the message's place is ever in the window without its message. */
.afp--page .afp__door { inset: auto; left: 0; width: 100%; top: calc(var(--y) / var(--stage-h) * 100%); height: calc(var(--h) / var(--stage-h) * 100%); background: none; }
.afp--page { --stage-h: 440; }
.afp--page .afp__door { --y: 56; --h: 81; }

/* Compact, 358 x 358: the same three objects, the message on four lines */
.afp--page[data-size='compact'] { --afp-u: calc(100cqw / 358); --stage-h: 358; }
.afp--page[data-size='compact'] .afp__ask { transform-origin: calc(28 / 358 * 100%) calc(130.63 / 358 * 100%); }
.afp--page[data-size='compact'] .afp__yes { transform-origin: calc(330 / 358 * 100%) calc(177.97 / 358 * 100%); }
.afp--page[data-size='compact'] .afp__door { --y: 28; --h: 103; }
