/* In store, in the hero: the payment terminal comes up into its tile.
   One source for the homepage and for the In store tile of the `h-hero` Stageshow scene
   (product-ui/src/heroes/commerce-grid/index.tsx), which films the poster this rests on.

   User request of 16 November 2026: a small animation for the hero's In store picture,
   "quelque chose de simple, peut-être juste faire apparaître le terminal de paiement".
   So one thing moves and nothing else: the terminal, with its screen, rises from under
   the foot of its tile and comes to rest where the poster has it. It is a solid object,
   so it arrives by moving and is never seen through (Stageshow, motion: solid things do
   not fade through): no fade, no scale, no bounce, and the bike, the tile's name and the
   four other tiles hold still. The last frame is the filmed poster.

   The root, .trs, is marked data-play: "ready" holds the first frame (the tile with its
   bike and its name, the terminal under the foot), "on" plays, and "done" is the poster.
   On the page there is a fourth, "off": the layer is put aside and the picture is the
   poster alone, for a visitor who has already seen the finished picture (see below).
   --trs-fall is how far under its place the terminal starts, in the tile's own design
   pixels: the terminal's top edge to the tile's foot, and a little more, so that nothing
   of it is in the tile on the first frame.

   How it is drawn. What is animated is one registered number, --trs-in, from 0 to 1, and
   the terminal's place is computed from it, as agent-cast.css floats its characters and
   claim-play.css moves its pieces: animated in the usual way the terminal would be drawn
   on a sheet of its own for as long as it moved, and step a fraction of a pixel when it
   came to rest. */
@property --trs-in { syntax: '<number>'; inherits: false; initial-value: 1; }

.trs { --trs-fall: 350; --trs-time: 1s; --trs-ease: cubic-bezier(.25, .8, .25, 1); }
.trs[data-size='compact'] { --trs-fall: 124; --trs-time: .85s; }

/* The terminal and its screen, one object. Its box is the tile's (or the picture's), so
   what stands in it is placed as it was before it could move. */
.trs, .trs__unit { position: absolute; inset: 0; }
.trs__unit { translate: 0 calc((1 - var(--trs-in)) * var(--trs-fall) * var(--trs-u, 1px)); }
/* It travels in whole pixels of the screen. At a place between two pixels the till's words are drawn
   a little soft, and over the last third of a second, when the terminal covers its last five pixels,
   they went soft and sharp again at each one (fresh-eye review of 16 November 2026, on an ordinary
   screen). --trs-dot is one pixel of the screen: terminal-rise.js sets it exactly, and these are the
   stylesheet's own guesses for a page whose script has not run. */
.trs { --trs-dot: 1px; }
@media (min-resolution: 1.5dppx) { .trs { --trs-dot: .5px; } }
@media (min-resolution: 2.5dppx) { .trs { --trs-dot: .33333px; } }
@supports (translate: 0 round(1.4px, 1px)) {
  .trs__unit { translate: 0 round(calc((1 - var(--trs-in)) * var(--trs-fall) * var(--trs-u, 1px)), var(--trs-dot)); }
}

/* The rise: Stageshow's curve for a thing that arrives from nowhere, quick to leave and
   long to settle, with no overshoot, over a second (a little less on the compact picture,
   where the way is a third as long). "ready" is its first frame, held. */
@keyframes trs-rise { from { --trs-in: 0; } to { --trs-in: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .trs:is([data-play='ready'], [data-play='on']) .trs__unit { animation: trs-rise var(--trs-time) var(--trs-ease) both; }
  .trs[data-play='ready'] .trs__unit { animation-play-state: paused; }
}

/* ---------- On the homepage ----------
   The hero is one filmed picture, so the terminal cannot be moved in it. A layer is laid
   over the picture, written in the page itself (index.html), every piece of it standing
   exactly where the picture stands, at the picture's own size, so that each is scaled as
   the picture is:
   - the plate: the tile as it is without its terminal, the bike whole. One picture for
     all seven languages, clear everywhere but where the terminal stands in the poster
     (product-ui/renders/h-hero-store-plate-<size>.webp);
   - the terminal, cut out, its screen empty (h-hero-store-terminal-<size>.webp), and over its
     screen the page's own picture again, seen through a window the size of that screen:
     the till's words are that picture's, in the page's language, and no word is written
     here. (Wide, the page's picture is the hero's plate for its After purchase tile,
     h-hero-plate-<language>-wide.webp, whose In store tile is the poster's: hero-after.css.)
     The two move as one, inside the tile's own shape, which is what hides the terminal
     while it is under the foot.
   product-ui/export-terminal.py makes the two pictures and proves that the layer at
   rest is the poster, in seven languages and both sizes.

   The layer is in the page from its first paint, holding its first frame, so the visitor
   never sees a finished picture lose its terminal. It is shown only where it can play:
   with a script (the page is marked .js before anything is drawn), without reduced
   motion, in a browser that can place it (--trs-can is 1 only where a number can be
   registered) and not on a page that has just changed language, which arrives as it was
   left (redesign.css, lang-swap). Everywhere else the layer is not there and the picture
   is the poster. terminal-rise.js starts the rise once half of the terminal's place is in
   the window; should that script never arrive, the stylesheet plays the rise by itself
   after three seconds, so the terminal is never left under the foot. And where the
   layer's pictures come after the poster has been seen whole (a slow connection), the
   script puts the layer aside ("off") rather than empty a picture the visitor has seen.
   Lengths are the picture's design pixels, 1200 x 668 wide and 358 x 716 compact, scaled
   to the picture by --trs-u. */
@property --trs-can { syntax: '<number>'; inherits: false; initial-value: 1; }
@keyframes trs-late { from { --trs-in: 0; } to { --trs-in: 1; } }

/* A sheet of its own (will-change), as the floating characters have. Without it the browser draws the
   whole hero another way as soon as anything else is painted with it: Chromium keeps a sheet that holds
   one picture and nothing else at that picture's own size and scales it as it composes the page, and a
   sheet that holds more is drawn at the screen's size. Where the hero is scaled (a window under 1312px,
   a phone) the two differ by a hair of sharpness, over the whole bento. On its own sheet the layer
   leaves the poster drawn exactly as it was before the terminal could move: qa-home holds it to that. */
.trs--page { display: none; container: trs / size; pointer-events: none; will-change: transform; }
@media (prefers-reduced-motion: no-preference) {
  @supports (container-type: size) and (translate: 0 1px) and (clip-path: inset(1px round 2px)) {
    html.js:not(.lang-swap) .trs--page { display: block; opacity: var(--trs-can, 0); }
    .trs--page:not([data-play]) .trs__unit { animation: trs-late var(--trs-time) var(--trs-ease) 3s both; }
  }
}

.trs--page[data-play='off'] { visibility: hidden; }

/* Each piece is the picture's own box */
.trs.trs--page :is(.trs__tile, .trs__screen, img) { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; }
.trs--page .trs__tile { --trs-u: calc(100cqw / var(--stage)); clip-path: inset(calc(var(--t) * var(--trs-u)) calc(var(--r) * var(--trs-u)) calc(var(--b) * var(--trs-u)) calc(var(--l) * var(--trs-u)) round calc(20 * var(--trs-u))); }
.trs--page .trs__screen { clip-path: inset(calc(var(--t) * var(--trs-u)) calc(var(--r) * var(--trs-u)) calc(var(--b) * var(--trs-u)) calc(var(--l) * var(--trs-u))); }
/* How much of the terminal is in the window is asked of this box: where it rests */
.trs--page .trs__room { position: absolute; left: calc(var(--x) * 100cqw / var(--stage)); top: calc(var(--y) * 100cqw / var(--stage)); width: calc(var(--w) * 100cqw / var(--stage)); height: calc(var(--h) * 100cqw / var(--stage)); }

/* Wide: the tile is the picture's top right corner, 348 x 380 at 852, 0. Each box is given as
   what is cut away from the picture's four sides. The screen's window stands two pixels inside
   the terminal's glass (TERMINAL_SCREEN in the scene: 128.05 x 243.1 at 1040.1, 56.1). */
.trs--page { --stage: 1200; }
.trs--page .trs__tile { --t: 0; --r: 0; --b: 288; --l: 852; }
.trs--page .trs__screen { --t: 58.1; --r: 33.85; --b: 370.8; --l: 1042.1; }
.trs--page .trs__room { --x: 1010; --y: 36; --w: 180; --h: 336; }

/* Compact, the picture the page shows at 900px and under (the breakpoint of its <picture>): the
   tile is 174 x 164 at 0, 282, and the terminal runs off its foot. The screen's window runs to
   the foot and a little past it: the tile's shape ends it. That shape ends half a design pixel
   under the tile's foot (--b is 269.5 where the foot is at 270): a phone scales the picture, the
   layer and the poster are then drawn a fraction of a pixel apart, and with the shape ending on
   the foot itself one row of the ground showed under the terminal's white screen, a grey hairline
   the poster does not have (fresh-eye review of 16 November 2026). Past the foot the picture is
   white, as the screen is. */
@media (max-width: 900px) {
  .trs--page { --stage: 358; --trs-fall: 124; --trs-time: .85s; }
  .trs--page .trs__tile { --t: 282; --r: 184; --b: 269.5; --l: 0; }
  .trs--page .trs__screen { --t: 342.46; --r: 203.06; --b: 266; --l: 71.26; }
  .trs--page .trs__room { --x: 50; --y: 328; --w: 124; --h: 118; }
}
