/* Repair subscriptions: the screen plays when it appears (user request of 16 November 2026:
   "L'image « Abonnements réparation » doit être animée à l'apparition", the how left to the
   session, "en cohérence avec le reste du site"). One source for the homepage tile and for
   the `h-care` scene (product-ui/src/home.tsx), which films the poster this play ends on.
   Built as the claims picture's play is (claim-play.css), which is the site's precedent.

   What plays, once each time the picture is looked at. It opens on the phone with the plan
   whole: the card, its wrench, "Unlimited repairs" and the price. Then what the plan has
   done arrives under it: the grey row rises into the column, the three repaired products
   land in it one after another, and "3 repaired this year" comes into focus beside them.
   After a beat the one button rises into its place. The last frame is the filmed poster,
   and the picture holds it. Nothing else moves: the phone, its status bar and the plan
   hold still, and nothing moves once the play is over.

   How it is built. Every piece that plays carries a class of this sheet:
     .crp__row     the grey row
     .crp__thumb   one of its three products (--n: 0, 1, 2)
     .crp__label   its words, .crp__more its chevron
     .crp__button  the button
   (and, on the page only, .crp__set: see "The page")
   In the scene they are the interface's own elements. On the page they are cuts of the
   filmed poster (see "The page" below), so nothing is drawn twice and no word is written
   there. The root, .crp, is marked data-play: "ready" holds the first frame, "on" plays,
   anything else is the poster.

   The pace was set after the fresh-eye review of that day, which found the first version
   slow where nothing happened and quick where the idea was: the row stood empty for a
   third of a second, the count was a ripple (three discs 130ms apart), and half a second
   passed before the button. The opening hold is short because the tile's own arrival has
   already been the hold (care-play.js starts the play as the tile's fade ends).

   Lengths are the tile's design pixels (--u: the picture is 384 across), so the scene and
   the page, at any width, move alike. */

.crp {
  --u: 1px;
  /* The clock, from the moment the play starts. The opening is held for --crp-row-at; the
     products are counted in from --crp-count-at, one every --crp-count-beat; the words
     follow the third; the button waits a beat after them. */
  --crp-row-at: .15s;
  --crp-count-at: calc(var(--crp-row-at) + .2s);
  --crp-count-beat: .16s;
  --crp-label-at: calc(var(--crp-count-at) + 2 * var(--crp-count-beat) + .12s);
  --crp-button-at: calc(var(--crp-label-at) + .75s);
  --crp-end: calc(var(--crp-button-at) + .7s);
  /* The claims play's two curves: an arrival from nowhere, and a small mark that lands */
  --crp-arrive: cubic-bezier(.22, 1, .36, 1);
  --crp-land: cubic-bezier(.3, 1.35, .5, 1);
}

/* How a piece arrives: one registered number, --crp-in, from 0 to 1, and the piece's place,
   size, opacity and focus computed from it, so that each piece is drawn afresh where it
   stands and lands exactly on the picture's own pixels (claim-play.css says what animating
   opacity, translate, scale or a filter directly cost there: do not go back to it). */
@property --crp-in { syntax: '<number>'; inherits: false; initial-value: 1; }
/* Until its moment a piece is not in the picture at all; it is seen from the first step of its arrival */
@keyframes crp-in { from { --crp-in: 0; visibility: hidden; } }
/* Nothing: its end is the end of the play. It runs on the page's layer alone, where care-play.js
   listens for it; in the scene the phone itself is the root, and an animation on it, even one
   that changes nothing, had the Stageshow gate read the phone as moving. */
@keyframes crp-clock { to { visibility: visible; } }

@media (prefers-reduced-motion: no-preference) {
  .crp--page:is([data-play='ready'], [data-play='on']) { animation: crp-clock var(--crp-end) linear both; }
  /* The row, then the button: each rises into the column */
  .crp:is([data-play='ready'], [data-play='on']) :is(.crp__row, .crp__button) {
    opacity: var(--crp-in); translate: 0 calc((1 - var(--crp-in)) * 8 * var(--u));
    animation: crp-in .6s var(--crp-arrive) var(--crp-row-at) both;
  }
  /* The button is solid before it is halfway in: a dark capsule that fades in over its whole
     travel stood pale grey for a tenth of a second, beside the neighbouring tile's solid one,
     and read as a disabled button (fresh-eye review). Its opacity leads its travel. */
  .crp:is([data-play='ready'], [data-play='on']) .crp__button { opacity: min(1, calc(var(--crp-in) * 2)); animation-delay: var(--crp-button-at); }
  /* One, two, three: each product lands where it stands */
  .crp:is([data-play='ready'], [data-play='on']) .crp__thumb {
    opacity: var(--crp-in); scale: calc(.4 + .6 * var(--crp-in)); transform-origin: 50% 50%;
    animation: crp-in .36s var(--crp-land) calc(var(--crp-count-at) + var(--n, 0) * var(--crp-count-beat)) both;
  }
  /* Each lands whole. The products overlap, each over the one before it, and the poster holds
     no pixel of a product under its neighbour: a first version therefore gave each landing
     disc a round bite where the next would be, which the fresh-eye review sent back (a
     crescent alone on the row for a tenth of a second). The page now cuts the first two
     from two small pictures of the row with one product and with two (see "The page"). */
  /* The words come into focus beside them, as the claims play sets what was done; the chevron follows */
  .crp:is([data-play='ready'], [data-play='on']) :is(.crp__label, .crp__more) {
    opacity: var(--crp-in); filter: blur(calc((1 - var(--crp-in)) * 3 * var(--u)));
    animation: crp-in .42s ease-out var(--crp-label-at) both;
  }
  .crp:is([data-play='ready'], [data-play='on']) .crp__more { animation-delay: calc(var(--crp-label-at) + .1s); }
  /* The page only: as the third product comes to rest, the poster's own picture of the three is set over them (see "The page") */
  .crp:is([data-play='ready'], [data-play='on']) .crp__set { animation: crp-in 1ms linear calc(var(--crp-count-at) + 2 * var(--crp-count-beat) + .37s) both; }
  /* The first frame, held until the picture is looked at. The rules above set `animation` whole,
     which would start each piece again: this one has to win over them. */
  .crp[data-play='ready'], .crp[data-play='ready'] * { animation-play-state: paused !important; }
}

/* ---- The page ----
   The homepage tile shows the filmed poster (product-ui/renders/h-care-<language>-wide.webp).
   care-play.js lays this layer over it: a sheet of the screen's white over the part of the
   screen that plays, and over that sheet the poster again, cut into the pieces named above.
   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. The plan is not covered: it is
   in the picture from the first frame. Two cuts hold another picture than the poster, for
   as long as they land: the first two products' (see .crp__thumb below).

   Boxes are in the picture's design pixels (384 x 300), the same in every language: the
   screen is laid out alike in all seven. A cut only ever ends in the screen's white or in
   the row's grey between two pieces; a product's cut is its own disc and nothing round it.
   product-ui/scripts/care-cuts.mjs proves all of it against the poster and against the
   scene, in seven languages: run it after any change to the screen or to a box. */
.crp--page { position: absolute; inset: 0; container: crp / size; pointer-events: none; --u: calc(100cqw / 384); }
/* Shown once the poster it is cut from has arrived, and never where it cannot be placed */
.crp--page:not([data-play]) { display: none; }
/* A piece: its box (--x, --y, --w, --h) in design pixels, from the corner of what holds it (--ox, --oy) */
.crp--page :is(.crp__room, .crp__cover, .crp__cut, .crp__patch) {
  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, as the poster's compression gives it in all seven languages */
.crp--page .crp__cover { background: #fefdff; }
/* 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 (claim-play.css says why it is not the cut's own background at an offset).
   Here the poster in a window is an image, as the picture under it is, and not a background:
   wherever the tile is not drawn at its design size (on a phone 390 or 360 wide it is 350 or
   328 across) the browser set a background a fraction of a pixel off the image under it,
   and every horizontal edge of the layer stood off the poster's (measured: 10,974 pixels of
   the picture at 390, none as an image). */
.crp--page .crp__cut { overflow: hidden; }
.crp--page .crp__cut > img.crp__pic { position: absolute; display: block; left: calc(var(--x) * var(--u) * -1); top: calc(var(--y) * var(--u) * -1); width: 100cqw; height: 100cqh; max-width: none; aspect-ratio: auto; }
/* The row's cut holds the row whole. So that its products, its words and its chevron can
   arrive after it, the row's own grey (the poster's, in all seven languages) is laid over
   them there, and their own cuts are set over that. Three cuts stand side by side on that
   grey and cover it from edge to edge: the three products' place (.crp__set, which is set
   over the three landed discs), the words and the chevron. So, played out, no pixel of
   the layer is the grey laid here, or a landing disc: all of it is the poster again. */
.crp--page .crp__patch { background: #f5f4f9; }
/* A product's cut is its disc, to the edge of its white rim and no further: a first cut took
   three quarters of a pixel more, which is its neighbour's picture where the two overlap,
   and that sliver showed as a dark arc beside the disc for as long as it was landing.
   The third product lies over the two others, so the poster has it whole and its cut holds
   the poster. The first and the second are partly under their neighbour in the poster: their
   cuts hold the row as it stands with one product, and with two
   (product-ui/renders/h-care-count-1-wide.webp and h-care-count-2-wide.webp, the poster's
   size and white but for the products' place, made by product-ui/export-care.py; the
   products carry no word, so the two pictures serve every language). care-play.js gives
   each cut its picture.
   A round window on a round picture leaves its rim a little off: a few levels where it
   lies on the laid grey, more where one disc's white rim crosses the disc under it (the
   rim is drawn half a pixel thin there). So as the third product comes to rest the poster's
   own picture of the three (.crp__set) is set over them, unseen, and every pixel is the
   poster's from there on, in the page's own language. */
.crp--page .crp__thumb { border-radius: 50%; }

/* .crp__room is what has to be in the window before the play starts: the screen from the
   top of the plan to the foot of the button (care-play.js). The sheet and the two bands
   cut from it, the row's and the button's, share their edges, which fall in white. */
.crp--page .crp__room { --x: 78; --y: 58; --w: 228; --h: 224; }
.crp--page .crp__cover { --x: 76; --y: 191; --w: 232; --h: 93; }
.crp--page .crp__row { --x: 76; --y: 191; --w: 232; --h: 45; }
.crp--page .crp__patch { --ox: 76; --oy: 191; --x: 85; --y: 200; --w: 214; --h: 24.5; }
.crp--page .crp__set { --x: 85; --y: 200; --w: 56; --h: 24.5; }
.crp--page .crp__thumb { --x: calc(87 + var(--n) * 14); --y: 202.14; --w: 20; --h: 20; }
.crp--page .crp__label { --x: 141; --y: 200; --w: 143; --h: 24.5; }
.crp--page .crp__more { --x: 284; --y: 200; --w: 15; --h: 24.5; }
.crp--page .crp__button { --x: 76; --y: 236; --w: 232; --h: 48; }
