/* The hero's AI agents tile: a purchase made inside ChatGPT, on a phone, plays in a loop
   (user request of 16 November 2026: the tile "représente une interface mobile d'un
   smartphone" and "soit animée", from a film of a phone on which an assistant finds a
   present, asks for approval in a payment sheet and confirms the purchase; ours "beaucoup
   plus courte"). One source for the homepage tile and for the hero's Stageshow scene
   (product-ui/src/heroes/commerce-grid/index.tsx), which films the poster the loop rests on.

   What plays, in 7.2s, from the poster and back to it:
   - the shopper's request is sent again: it rises from the foot of the screen and the
     conversation the poster shows runs up under the header, as a thread does when a
     message is sent (the next round's data comes in as new: nothing is seen to rewind);
   - the assistant is at work: its dot breathes under the request, for under a second;
   - the order arrives: the product, the cover marked in the accent, and what it costs;
   - the payment sheet rises over the dimmed conversation: what is due, the cover's
     share in the accent, one button;
   - a finger touches the button: it gives, its word goes, an arc turns, and the arc
     becomes a tick;
   - the sheet leaves, and the order confirms on itself: what it costs gives way to
     "Order confirmed", and its mark lands.
   Then the picture holds: the last frame is the filmed poster.

   Taken from the reference: the manner (a message sent and the thread running up, the
   wait, a sheet that rises to ask for the payment, a button that becomes its own
   confirmation, a quiet line once it is done). Nothing of the film's own: no word,
   picture or mark.

   How it is built. Every piece that plays carries a class of this sheet:
     .hag__gone    where the conversation the poster shows leaves: a room that does not
                   move, with a soft top edge, and in it .hag__old, the copy that runs up
     .hag__ask     the shopper's request
     .hag__dot     the assistant at work
     .hag__card    the order: .hag__offer what it costs, .hag__paid the line that says
                   it is confirmed, .hag__check that line's mark
     .hag__scrim   the dimmed screen under the sheet
     .hag__sheet   the payment sheet
     .hag__pay     its button: .hag__touch is the finger, .hag__pay-over hides the word,
                   .hag__pay-spin is the arc, .hag__pay-done the tick
   In the scene they are the interface's own elements. On the page they are windows onto
   pictures filmed from the scene (see "The page" below). The root, .hag, is marked
   data-play: "on" plays one round, anything else is the poster. data-size is "wide" or
   "compact".

   Lengths are the phone's own points (--p: its screen is 402 across), so the scene,
   where the phone is drawn at about three quarters, and the page, at any width, move
   alike. */

.hag {
  /* The clock, from the moment a round starts. The request is sent at once. */
  --hag-at-dot: .32s;    /* the assistant is at work */
  --hag-at-card: 1.5s;   /* the order arrives */
  --hag-at-sheet: 2.85s; /* the payment sheet rises */
  --hag-at-touch: 4.05s; /* a finger comes to the button */
  --hag-at-press: 4.3s;  /* and presses it */
  --hag-at-paid: 5.25s;  /* the arc becomes a tick */
  --hag-at-close: 5.95s; /* the sheet leaves */
  --hag-at-done: 6.3s;   /* the order confirms on itself */
  --hag-end: 7.2s;
  /* How far the thread runs when the request is sent, in points: the height of the
     conversation's room, so what leaves is gone and what arrives comes from the foot */
  --hag-travel: 178;
  /* How far the sheet travels, in points: from where it stands to under the tile's foot */
  --hag-drop: 204;
  /* The kit's curves: travel (a departure, clear travel, a soft arrival), an arrival from nowhere,
     a small mark that lands, UIKit's quick throw */
  --hag-run: cubic-bezier(.45, 0, .1, 1);
  --hag-arrive: cubic-bezier(.22, 1, .36, 1);
  --hag-land: cubic-bezier(.3, 1.35, .5, 1);
  --hag-rise: cubic-bezier(.3, .75, .1, 1);
}

/* What is in the picture only while a round plays */
.hag:not([data-play='on']) :is(.hag__gone, .hag__dot, .hag__offer, .hag__scrim, .hag__sheet, .hag__touch, .hag__pay-over, .hag__pay-spin, .hag__pay-done) { visibility: hidden; }

/* How a piece arrives and leaves. What is animated is a registered number per piece
   (--hag-in from 0 to 1 as it arrives, --hag-out from 0 to 1 as it leaves), and the
   piece's place, size, opacity and focus are computed from them, 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 and steps a pixel when it comes to rest.
   Do not go back to animating opacity, translate, scale or filter directly on a piece
   that stays in the picture. The arc and the dot are the exceptions: they turn and
   breathe in the usual way, and are gone before anything rests. */
@property --hag-in { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --hag-out { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --hag-ride { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --hag-press { syntax: '<number>'; inherits: false; initial-value: 0; }
/* Until its moment a piece is not in the picture at all, and once it has left it is out of it
   (visibility is hidden only at the very start, or the very end, of these keyframes) */
@keyframes hag-in { from { --hag-in: 0; visibility: hidden; } }
@keyframes hag-out { to { --hag-out: 1; visibility: hidden; } }
/* The same numbers for what is in the picture from a round's first frame */
@keyframes hag-edge { from { --hag-in: 0; } }
@keyframes hag-ride { from { --hag-ride: 0; } }
@keyframes hag-press { 0%, 100% { --hag-press: 0; } 42% { --hag-press: 1; } }
@keyframes hag-turn { to { rotate: 1turn; } }
@keyframes hag-breathe { 0%, 100% { scale: .72; } 50% { scale: 1; } }
/* Nothing: its end is the end of the round (hero-agent.js listens for it) */
@keyframes hag-clock { to { visibility: visible; } }

@media (prefers-reduced-motion: no-preference) {
  .hag[data-play='on'] { animation: hag-clock var(--hag-end) linear both; }
  /* The request is sent: the thread runs up by the height of its room. What the poster shows leaves
     under the header, through a soft edge that is drawn in as it starts to move (at rest the
     request stands against that edge, and must not be dimmed by it) */
  .hag[data-play='on'] .hag__gone {
    -webkit-mask-image: linear-gradient(rgb(0 0 0 / calc(1 - var(--hag-in))), #000 calc(18 * var(--p)));
    mask-image: linear-gradient(rgb(0 0 0 / calc(1 - var(--hag-in))), #000 calc(18 * var(--p)));
    animation: hag-edge .12s linear both;
  }
  .hag[data-play='on'] .hag__old {
    translate: 0 calc(var(--hag-out) * var(--hag-travel) * var(--p) * -1);
    animation: hag-out .7s var(--hag-run) both;
  }
  /* The request comes up from the foot, and the assistant's dot with it */
  .hag[data-play='on'] .hag__ask {
    translate: 0 calc((1 - var(--hag-in)) * var(--hag-travel) * var(--p));
    animation: hag-in .7s var(--hag-run) both;
  }
  /* The dot rides up under the request, breathes, and draws back before the order comes: the one is out
     before the other is in, they are never drawn over each other */
  .hag[data-play='on'] .hag__dot {
    opacity: calc(var(--hag-in) * (1 - var(--hag-out)));
    translate: 0 calc((1 - var(--hag-ride)) * var(--hag-travel) * var(--p));
    animation: hag-breathe 1s ease-in-out infinite, hag-ride .7s var(--hag-run) both, hag-in .2s linear var(--hag-at-dot) both, hag-out .16s linear calc(var(--hag-at-card) - .18s) both;
  }
  /* The order rises into the conversation, with what it costs */
  .hag[data-play='on'] .hag__card {
    opacity: var(--hag-in); translate: 0 calc((1 - var(--hag-in)) * 12 * var(--p));
    animation: hag-in .6s var(--hag-arrive) var(--hag-at-card) both;
  }
  /* The sheet rises from the foot, as UIKit throws one up, and leaves the way it came */
  .hag[data-play='on'] .hag__scrim {
    opacity: calc(var(--hag-in) * (1 - var(--hag-out)));
    animation: hag-in .4s ease-out var(--hag-at-sheet) both, hag-out .32s ease-in var(--hag-at-close) both;
  }
  .hag[data-play='on'] .hag__sheet {
    translate: 0 calc((1 - var(--hag-in) + var(--hag-out)) * var(--hag-drop) * var(--p));
    animation: hag-in .56s var(--hag-rise) var(--hag-at-sheet) both, hag-out .4s cubic-bezier(.5, 0, .85, .45) var(--hag-at-close) both;
  }
  /* The press. A finger comes to the button, as the kit's touch does: there only while it touches,
     smaller and brighter while it presses. The button gives a little under it and comes back. Then,
     one after the other and never together: its word goes into its violet, an arc turns there, and
     the arc becomes the tick. */
  .hag[data-play='on'] .hag__touch {
    opacity: calc((.3 + .14 * var(--hag-press)) * var(--hag-in) * (1 - var(--hag-out))); scale: calc((.7 + .3 * var(--hag-in)) * (1 - .18 * var(--hag-press)));
    animation: hag-in .16s var(--hag-arrive) var(--hag-at-touch) both, hag-press .3s ease-out var(--hag-at-press) both, hag-out .3s ease calc(var(--hag-at-press) + .26s) both;
  }
  .hag[data-play='on'] .hag__pay {
    scale: calc(1 - .035 * var(--hag-press)); transform-origin: 50% 50%;
    animation: hag-press .34s ease-out var(--hag-at-press) both;
  }
  .hag[data-play='on'] .hag__pay-over { opacity: var(--hag-in); animation: hag-in .16s linear calc(var(--hag-at-press) + .12s) both; }
  .hag[data-play='on'] .hag__pay-spin {
    opacity: calc(var(--hag-in) * (1 - var(--hag-out))); transform-origin: 50% 50%;
    animation: hag-turn .8s linear infinite, hag-in .18s linear calc(var(--hag-at-press) + .3s) both, hag-out .12s linear calc(var(--hag-at-paid) - .12s) both;
  }
  .hag[data-play='on'] .hag__pay-done {
    opacity: var(--hag-in); scale: calc(.45 + .55 * var(--hag-in)); transform-origin: 50% 50%;
    animation: hag-in .36s var(--hag-land) var(--hag-at-paid) both;
  }
  /* The order confirms on itself once the sheet has gone: what it costs goes out of focus, the line that
     says it is confirmed comes into focus in its place, as the kit's Stream sets words, and its mark lands */
  .hag[data-play='on'] .hag__offer {
    opacity: calc(1 - var(--hag-out)); filter: blur(calc(var(--hag-out) * 3 * var(--p)));
    animation: hag-out .22s linear var(--hag-at-done) both;
  }
  .hag[data-play='on'] .hag__paid {
    opacity: var(--hag-in); filter: blur(calc((1 - var(--hag-in)) * 3 * var(--p)));
    animation: hag-in .42s ease-out calc(var(--hag-at-done) + .2s) both;
  }
  .hag[data-play='on'] .hag__check {
    opacity: var(--hag-in); scale: calc(.35 + .65 * var(--hag-in)); transform-origin: 50% 50%;
    animation: hag-in .44s var(--hag-land) calc(var(--hag-at-done) + .36s) both;
  }
}

/* The marks that carry no word are drawn alike in the scene and on the page: the same
   elements, styled here. Sizes are in points. */
/* ChatGPT's own wait: one ink dot that breathes */
.hag__dot { display: block; width: calc(14 * var(--p)); height: calc(14 * var(--p)); border-radius: 50%; background: #0d0d0d; }
/* What the press shows, over the button: the finger's touch, the button's own violet over the word, then the arc
   and the tick in its middle. The touch is the kit's (a soft disc, there only while it touches), in white since
   it lands on the violet; it stands off the word, to its right. */
/* (the violet stands a point and a half inside the button: it only has to cover the word, and the button keeps its own edge) */
.hag__pay-over { position: absolute; inset: calc(1.5 * var(--p)); border-radius: calc(22 * var(--p)); background: #6335e8; }
.hag__pay-spin, .hag__pay-done { position: absolute; left: 50%; top: 50%; color: #fff; }
.hag__pay-spin { width: calc(22 * var(--p)); height: calc(22 * var(--p)); margin: calc(-11 * var(--p)) 0 0 calc(-11 * var(--p)); }
.hag__pay-done { width: calc(24 * var(--p)); height: calc(24 * var(--p)); margin: calc(-12 * var(--p)) 0 0 calc(-12 * var(--p)); }
.hag__touch { position: absolute; left: 74%; top: 50%; width: calc(38 * var(--p)); height: calc(38 * var(--p)); margin: calc(-19 * var(--p)) 0 0 calc(-19 * var(--p)); border-radius: 50%; background: #fff; }

/* ---- The page ----
   The homepage shows the hero's filmed poster (product-ui/renders/h-hero-<language>-<size>.webp).
   hero-agent.js lays this layer over the AI agents tile of it: a sheet of the screen's
   white over the conversation's room, and over it the pieces named above.
   - What the poster holds (the request, the order, its confirmation and its mark) is the
     poster again, seen through windows, one per piece: the poster inside a window is
     the hero's own size and stands exactly where the hero stands, so at rest the layer
     and the poster are one picture, pixel for pixel, and the loop moves the windows.
   - What the poster does not hold is filmed from the same scene, each picture the
     tile's own size and clear but for its piece: renders/h-hero-agent-offer-… (what the
     order costs before it is paid), …-sheet-… (the payment sheet) and …-scrim-… (the
     dimmed screen, which has no word and is one picture for every language).
   Where each piece stands is read from renders/h-hero-agent.json, which
   product-ui/export-hero-agent.py writes with the pictures: nothing here is placed by
   hand, and no word is written on the page, which does not load the picture's face.

   The tile's box in the hero (--tx, --ty, --tw, --th of --hw by --hh, in design pixels),
   the phone's scale (--s) and every piece's box (--x, --y, --w, --h) are set by the
   script from that file. --u is one design pixel, --p one point of the phone's screen. */
.hag--page {
  position: absolute; left: calc(var(--tx) / var(--hw) * 100%); top: calc(var(--ty) / var(--hh) * 100%); width: calc(var(--tw) / var(--hw) * 100%); height: calc(var(--th) / var(--hh) * 100%);
  overflow: hidden; container: hag / size; pointer-events: none;
  --u: calc(100cqw / var(--tw)); --p: calc(100cqw / var(--tw) * var(--s));
}
/* Shown once its pictures have arrived, and never where it cannot be placed */
.hag--page:not([data-play]) { display: none; }
.hag--page i { display: block; }
/* A piece with a box, from the corner of what holds it (--ox, --oy) */
.hag--page .hag__at { 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)); }
/* The screen's white: over the conversation's room, and under the button. The button's window is two pixels
   larger than the button, so that its soft edge is whole inside it, and the white under it two pixels larger
   again, so that nothing of the painted button shows round the one that gives under the press */
.hag--page .hag__room, .hag--page .hag__hole { background: #fff; }
/* The order's own grey, over the line that changes: what it costs and the confirmation are set over it */
.hag--page .hag__blank { background: #f4f4f4; }
/* A window onto the poster. The poster inside it is the hero's own size and stands exactly where the hero
   stands, so the browser sets it on the same pixels as the hero under it; only the window's edges are placed
   by the window's own box. (claim-play.css does the same, and says what went wrong before it did.) */
.hag--page .hag__cut { overflow: hidden; }
.hag--page .hag__cut > b { position: absolute; left: calc((var(--tx) + var(--x)) * var(--u) * -1); top: calc((var(--ty) + var(--y)) * var(--u) * -1); width: calc(var(--hw) * var(--u)); height: calc(var(--hh) * var(--u)); background: var(--hag-poster) 0 0 / 100% 100% no-repeat; }
/* A window onto a picture of the tile's own size, which stands where the tile stands */
.hag--page :is(.hag__offer, .hag__pay) > b { left: calc(var(--x) * var(--u) * -1); top: calc(var(--y) * var(--u) * -1); width: 100cqw; height: 100cqh; }
.hag--page .hag__offer > b { background-image: var(--hag-offer-picture); }
.hag--page .hag__pay > b { background-image: var(--hag-sheet-picture); }
/* A picture shown whole: the dimmed screen, the sheet */
.hag--page .hag__whole { position: absolute; left: 0; top: 0; width: 100cqw; height: 100cqh; background: 0 0 / 100% 100% no-repeat; }
/* Where the conversation leaves: the room's own box, which cuts what runs out of it; the copy fills it */
.hag--page .hag__gone { overflow: hidden; }
.hag--page .hag__old { position: absolute; inset: 0; }
.hag--page .hag__scrim { background-image: var(--hag-scrim-picture); }
.hag--page .hag__sheet { background-image: var(--hag-sheet-picture); }
.hag--page :is(.hag__pay-spin, .hag__pay-done) > svg { display: block; width: 100%; height: 100%; }
