/* Florilège, le site : papier craft, aquarelle vivante, écriture à la main.
 *
 * Principe : les styles de base décrivent l'état final, immobile (c'est ce que voient les
 * navigateurs sans JavaScript et ceux qui ont demandé moins d'animations). Les animations
 * s'ajoutent par-dessus avec la classe `.motion` posée sur <html> par le script du <head>.
 */

/* MARK: - Polices (SIL OFL, hébergées ici) */

@font-face {
  font-family: "Kalam";
  src: url("/assets/fonts/kalam-light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Kalam";
  src: url("/assets/fonts/kalam-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Kalam";
  src: url("/assets/fonts/kalam-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/assets/fonts/caveat.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* MARK: - Couleurs et mesures */

:root {
  color-scheme: light;
  --ink: #3b2a18;
  --ink-2: #6e5236;
  --teal: #2e7a71;
  --teal-deep: #246259;
  --teal-wash: rgba(104, 178, 164, 0.55);
  --rose: #9b5a68;
  --rose-deep: #844b58;
  --rose-wash: rgba(190, 128, 142, 0.4);
  --ochre: #d9a640;
  --paper: #f4ebda;
  --paper-2: #efe4cc;
  --shadow: rgba(59, 42, 24, 0.38);
  --hand: "Kalam", "Bradley Hand", "Marker Felt", "Comic Sans MS", cursive;
  --script: "Caveat", "Bradley Hand", "Noteworthy", cursive;
  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --ease-soft: cubic-bezier(0.22, 0.7, 0.2, 1);
}

/* MARK: - Base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper) url("/assets/img/paper-tile.webp") repeat;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: transparent;
  font-family: var(--script);
  font-size: clamp(22px, 0.45vw + 20px, 25px);
  line-height: 1.3;
  font-weight: 500;
  overflow-x: clip;
}

/* Les traits de lavis sous les titres dépassent un peu de leur boîte. On coupe au bord de la page
   sur <main> : sur <body>, le réglage passe à la fenêtre, qui sur mobile mesure quand même la largeur
   débordante. */
main {
  display: block;
  position: relative; /* le repère de l'aquarelle (`.lavis`) */
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  font-family: var(--hand);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0 0 0.6em;
  text-wrap: pretty;
}

a {
  color: var(--teal-deep);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  text-decoration-color: rgba(46, 122, 113, 0.45);
}

a:hover {
  text-decoration-color: currentColor;
}

/* Focus clavier : un trait d'encre bien visible sur le papier. */
:focus-visible {
  outline: 3px solid var(--teal-deep);
  outline-offset: 4px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 8px 14px;
  background: var(--paper);
  font-family: var(--hand);
  font-weight: 700;
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}

.skip:focus {
  top: 12px;
}

.wrap {
  width: min(var(--wrap), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* MARK: - Bande de papier déchiré (strip.webp), étirée sans déformer ses bords */

.paper {
  border-style: solid;
  border-color: transparent;
  border-width: 18px 22px;
  border-image: url("/assets/img/strip.webp") 52 66 fill / 18px 22px / 0 stretch;
}

/* MARK: - En-tête : langue */

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter);
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topbar .home {
  display: block;
  width: 132px;
  line-height: 0;
}

.corner {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Le haut-parleur de l'app : un carré de papier plié, un haut-parleur tracé à la plume. Coupé, les
   ondes s'effacent et un trait vieux rose le barre. */
.sound {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: url("/assets/img/key.webp") center / 100% 100% no-repeat;
  rotate: 3deg;
  cursor: pointer;
  transition: rotate 0.4s var(--ease-soft), scale 0.2s ease;
}

.sound:hover {
  rotate: -1deg;
}

.sound:active {
  scale: 0.92;
}

.sound svg {
  width: 23px;
  height: 17px;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound .spk,
.sound .waves {
  stroke: var(--ink);
  stroke-width: 4.2;
}

.sound .waves {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.35s ease-in-out;
}

.sound .slash {
  stroke: var(--rose);
  stroke-width: 4.8;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s ease-in-out;
}

.sound[aria-pressed="true"] .waves {
  stroke-dashoffset: 0;
}

.sound[aria-pressed="true"] .slash {
  stroke-dashoffset: 1;
}

/* Pendant que la musique joue, les ondes respirent doucement. */
.motion .sound.playing .waves {
  animation: waves 2.6s ease-in-out infinite;
}

@keyframes waves {
  50% {
    opacity: 0.45;
  }
}

.lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 18px 8px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
  background: url("/assets/img/key.webp") center / 100% 100% no-repeat;
  rotate: 1.5deg;
  transition: rotate 0.4s var(--ease-soft), translate 0.4s var(--ease-soft);
}

.lang:hover {
  rotate: -1deg;
  translate: 0 -1px;
}

/* MARK: - Aquarelle vivante (le moteur de l'app, porté en WebGL 2 par le script)

   Chaque écran de la page se peint goutte à goutte, comme le menu de l'app : une goutte tombe,
   s'étale avec l'eau, sèche avec un liseré, des auréoles et du grain, et reste; les taches
   s'empilent tant qu'on regarde l'écran. Le script les peint dans `.lavis`, sous tout le contenu
   (un canevas par écran), posé en « multiplier » sur le papier de la page.

   Sans script, sans WebGL 2, et quand on a demandé moins d'animations : quelques taches déjà
   sèches par section (`.washes`, images rendues par le même moteur). Avec le mouvement, elles ne
   sont ni affichées ni téléchargées, sauf si le script y renonce (`.lavis-fixe`). */

.lavis {
  display: none;
}

.motion .lavis {
  display: block;
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: clip;
  pointer-events: none;
  mix-blend-mode: multiply;
  /* Au bas de <main>, juste avant le pied de page : les taches s'effacent doucement au lieu
     d'être coupées net au bord. */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 220px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 220px), transparent);
}

.lavis canvas {
  position: absolute;
  left: 0;
  display: block;
  width: 100%;
  /* Là où les marges de 2 écrans se chevauchent, leurs taches se multiplient aussi entre elles. */
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 0.9s ease;
}

.lavis canvas.in {
  opacity: 1;
}

.lavis canvas[hidden] {
  display: none;
}

.washes {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.wash {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  max-width: none;
  height: auto;
  aspect-ratio: 1;
  translate: -50% -50%;
  rotate: var(--r, 0deg);
  mix-blend-mode: multiply;
}

.motion:not(.lavis-fixe) .wash {
  display: none;
}

.motion.lavis-fixe .wash {
  animation: appear 2.4s ease both;
}

/* MARK: - Titres de section, posés sur un trait de lavis */

.title {
  position: relative;
  display: inline-block;
  isolation: isolate;
  font-size: clamp(32px, 3.2vw + 14px, 52px);
  padding: 0 0.25em;
}

.title::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -0.4em;
  right: -0.5em;
  top: 34%;
  bottom: -8%;
  background: var(--streak, url("/assets/img/streak-teal.webp")) center / 100% 100% no-repeat;
  opacity: 0.8;
  rotate: -1.2deg;
}

.title.rose {
  --streak: url("/assets/img/streak-rose.webp");
}

.title.ochre {
  --streak: url("/assets/img/streak-ochre.webp");
}

.motion .title::before {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.4s var(--ease-soft) 0.15s;
}

.motion .in .title::before,
.motion .title.in::before {
  clip-path: inset(0 0 0 0);
}

.lede {
  max-width: 34em;
  margin: 18px auto 0;
  font-size: 1.08em;
  color: var(--ink);
}

section {
  position: relative;
}

.section-head {
  position: relative;
  z-index: 2;
  text-align: center;
}

/* MARK: - Fleur d'origami (HANDOFF, « Assemblage de la fleur ») */

.flower {
  --w: 240px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.2);
  filter: drop-shadow(1px 2px 1.6px var(--shadow));
}

.flower img {
  position: absolute;
  display: block;
  max-width: none;
  -webkit-user-drag: none;
  user-select: none;
}

.fl-sway {
  position: absolute;
  inset: 0;
  transform-origin: 50% 96%;
}

.fl-stem {
  width: calc(var(--w) * 0.345);
  height: calc(var(--w) * 0.72);
  left: calc(var(--w) * 0.3275);
  top: calc(var(--w) * 0.42);
  transform-origin: 50% 100%;
}

.fl-petal {
  width: calc(var(--w) * 0.218);
  height: calc(var(--w) * 0.36);
  left: calc(var(--w) * 0.391);
  top: calc(var(--w) * 0.0852);
  transform-origin: 50% 93%;
  rotate: calc(var(--i) * 51.4286deg);
}

.fl-heart {
  width: calc(var(--w) * 0.173);
  height: calc(var(--w) * 0.2);
  left: calc(var(--w) * 0.4135);
  top: calc(var(--w) * 0.32);
}

/* Pétale tombé, couché au pied de la tige, réduit à 60 %. */
.fl-fallen {
  width: calc(var(--w) * 0.131);
  height: calc(var(--w) * 0.216);
  left: calc(var(--fx, 0.66) * var(--w) - var(--w) * 0.0654);
  top: calc(var(--fy, 1.06) * var(--w) - var(--w) * 0.108);
  rotate: var(--fr, 102deg);
}

.fl-petal.gone {
  visibility: hidden;
}

/* Le sol d'origami de la fleur du défilement (`_tools/ground.py`) : un tapis de gazon plié, de
   l'herbe et 2 roches, de 0,96 W au bas de la fleur, un peu plus large qu'elle (l'allée a 1,136 W).
   La 2e image, devant le pied de la tige, le plante dans l'herbe. Les pétales tombés s'y posent. */
.fl-ground {
  width: calc(var(--w) * 1.12);
  height: calc(var(--w) * 0.24);
  left: calc(var(--w) * -0.06);
  top: calc(var(--w) * 0.96);
}

.motion .flower.assemble .fl-ground {
  animation: ground-in 0.9s var(--ease-soft) var(--t0, 0.4s) both;
}

@keyframes ground-in {
  from {
    opacity: 0;
    translate: 0 8%;
  }
}

/* Le vent : la fleur se balance doucement, chaque pétale frémit à son rythme. */
.motion .fl-sway {
  animation: sway 7.5s ease-in-out infinite alternate;
}

.motion .fl-petal {
  animation: flutter calc(4.6s + var(--i) * 0.45s) ease-in-out calc(var(--i) * -0.8s) infinite;
}

@keyframes sway {
  from {
    rotate: -1.3deg;
  }
  to {
    rotate: 1.5deg;
  }
}

/* Part de la position de repos et y revient : aucun saut quand le frémissement commence. */
@keyframes flutter {
  0%,
  100% {
    transform: none;
  }
  35% {
    transform: rotate(1.8deg);
  }
  70% {
    transform: rotate(-1.5deg);
  }
}

/* La fleur se plie sous nos yeux : la tige pousse, les pétales se déplient un à un, le cœur se pose. */
.motion .flower.assemble .fl-stem {
  animation: grow 1.1s var(--ease-soft) var(--t0, 0.4s) both;
}

.motion .flower.assemble .fl-petal {
  animation:
    unfold 1.25s cubic-bezier(0.2, 0.9, 0.3, 1.12) calc(var(--t0, 0.4s) + 0.55s + var(--i) * 0.12s) both,
    flutter calc(4.6s + var(--i) * 0.45s) ease-in-out calc(var(--t0, 0.4s) + 2.8s) infinite;
}

.motion .flower.assemble .fl-heart {
  animation: pop 0.8s cubic-bezier(0.3, 1.6, 0.5, 1) calc(var(--t0, 0.4s) + 1.55s) both;
}

.motion .flower.assemble .fl-fallen {
  animation: fall-into-place 2.6s cubic-bezier(0.45, 0.05, 0.55, 0.95) calc(var(--t0, 0.4s) + 4.4s) both;
}

.motion .flower.assemble .fl-petal.gone {
  visibility: visible;
  animation:
    unfold 1.25s cubic-bezier(0.2, 0.9, 0.3, 1.12) calc(var(--t0, 0.4s) + 0.55s + var(--i) * 0.12s) both,
    let-go 0.01s linear calc(var(--t0, 0.4s) + 4.4s) forwards;
}

/* Sur scroll : rien ne bouge avant que la fleur soit visible. */
.motion .flower.assemble.wait:not(.in) * {
  animation-play-state: paused !important;
}

@keyframes grow {
  from {
    transform: scaleY(0);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes unfold {
  from {
    opacity: 0;
    transform: perspective(500px) rotateX(78deg) scale(0.3) rotate(-38deg);
  }
  45% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-60deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes let-go {
  to {
    visibility: hidden;
  }
}

/* Le 7e pétale (en haut à gauche) se détache, tombe en tournoyant et se pose au pied de la tige.
   Il part du centre du pétale attaché (0,379 W ; 0,3235 W), tourné de 308,6°, à sa taille réelle. */
@keyframes fall-into-place {
  0% {
    opacity: 0;
    translate: calc(var(--w) * (0.379 - var(--fx, 0.66))) calc(var(--w) * (0.3235 - var(--fy, 1.06)));
    rotate: -51.4deg;
    scale: 1.667;
  }
  0.6% {
    opacity: 1;
  }
  18% {
    translate: calc(var(--w) * (0.33 - var(--fx, 0.66))) calc(var(--w) * (0.45 - var(--fy, 1.06)));
    rotate: -20deg;
    scale: 1.5;
  }
  40% {
    translate: calc(var(--w) * (0.5 - var(--fx, 0.66))) calc(var(--w) * (0.64 - var(--fy, 1.06)));
    rotate: 40deg;
    scale: 1.3;
  }
  62% {
    translate: calc(var(--w) * (0.36 - var(--fx, 0.66))) calc(var(--w) * (0.82 - var(--fy, 1.06)));
    rotate: 10deg;
    scale: 1.15;
  }
  84% {
    translate: calc(var(--w) * (0.58 - var(--fx, 0.66))) calc(var(--w) * (0.98 - var(--fy, 1.06)));
    rotate: 80deg;
    scale: 1.03;
  }
  100% {
    opacity: 1;
    translate: 0 0;
    rotate: var(--fr, 102deg);
    scale: 1;
  }
}

/* MARK: - Pétales qui tombent du ciel (créés par le script) */

.petal-rain {
  position: absolute;
  inset: 0;
  overflow: clip;
  pointer-events: none;
  z-index: 3;
}

.drift {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pw, 22px);
  height: auto;
  opacity: 0.92;
  filter: drop-shadow(1px 2px 1.4px rgba(59, 42, 24, 0.3));
  will-change: transform;
}

/* MARK: - La page : le contenu, et l'allée où la fleur suit le défilement */

/* Sur téléphone, une allée étroite à droite, après le haut de page : la fleur s'y tient en bas de
   l'écran et ne passe jamais sur le texte. Sur grand écran, une colonne qui commence dès le haut de
   page : la fleur se tient au milieu de la hauteur, à côté de la feuille, puis du contenu. */
.story {
  --lane: clamp(64px, 16vw, 150px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--lane);
}

.story > section {
  grid-column: 1;
  min-width: 0;
  container: content / inline-size;
}

.story > .hero {
  grid-column: 1 / -1;
  grid-row: 1;
}

.story > .how {
  grid-row: 2;
}

.story > .demo {
  grid-row: 3;
}

.story > .themes {
  grid-row: 4;
}

.story > .screens {
  grid-row: 5;
}

.story > .cta {
  grid-column: 1 / -1;
  grid-row: 6;
}

/* Sur téléphone, le contenu va jusqu'à l'allée : la marge de droite, c'est elle. */
.story > :is(.how, .demo, .themes, .screens) > .wrap {
  width: min(var(--wrap), 100% - var(--gutter));
  margin-left: max(var(--gutter), (100% - var(--wrap)) / 2);
  margin-right: auto;
}

.lane {
  grid-column: 2;
  grid-row: 2 / 6;
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

.lane-flower {
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: grid;
  justify-items: center;
}

.lane .flower {
  --w: calc(var(--lane) * 0.88);
}

@media (min-width: 980px) {
  .story {
    --lane: clamp(220px, 23vw, 340px);
  }

  .story > :is(.how, .demo, .themes, .screens) > .wrap {
    width: min(var(--wrap), 100% - 2 * var(--gutter));
    margin-inline: auto;
  }

  .lane {
    grid-row: 1 / 6;
    justify-content: flex-start;
  }

  /* La fleur (0,62 × 1,2 de l'allée de haut) au milieu de la hauteur de l'écran. */
  .lane-flower {
    top: calc(50vh - var(--lane) * 0.372);
    top: calc(50svh - var(--lane) * 0.372);
    bottom: auto;
  }

  .lane .flower {
    --w: calc(var(--lane) * 0.62);
  }
}

/* MARK: - Haut de page : une feuille carrée, pliée en 4, qui se déplie */

.hero {
  position: relative;
  padding: clamp(72px, 10vh, 100px) 0 clamp(26px, 5vh, 56px);
}

/* La feuille : environ la moitié de la largeur sur grand écran, presque toute la largeur sur
   téléphone, jamais plus haute que la fenêtre. */
.sheet-stage {
  --S: max(280px, min(88vw, 100vh - 230px, 560px));
  position: relative;
  width: var(--S);
  height: var(--S);
  margin: 0 auto;
}

@supports (height: 100svh) {
  .sheet-stage {
    --S: max(280px, min(88vw, 100svh - 230px, 560px));
  }
}

@media (min-width: 980px) {
  .sheet-stage {
    --S: max(320px, min(50vw, 100vh - 290px, 740px));
  }

  @supports (height: 100svh) {
    .sheet-stage {
      --S: max(320px, min(50vw, 100svh - 290px, 740px));
    }
  }

  .hero-text .pitch {
    max-width: 34em;
  }
}

/* Le papier : la photo de la feuille pliée, ses bords jaunis en haut et en bas, et les 2 plis en
   relief (un côté dans l'ombre, l'autre dans la lumière). Les quarts qui se déplient prennent chacun
   leur part de ce même fond : le passage à la feuille entière ne se voit pas. Le logotype est placé
   en fractions de la feuille (--lx, --ly, --lw), pour la feuille entière comme pour ses quarts. */
.sheet {
  --lx: 0.1;
  --ly: 0.215;
  --lw: 0.8;
  --paper-front:
    linear-gradient(90deg, transparent 46.5%, rgba(59, 42, 24, 0.07) 49.6%, rgba(255, 252, 244, 0.3) 50.4%, transparent 53.5%),
    linear-gradient(transparent 46.5%, rgba(59, 42, 24, 0.06) 49.6%, rgba(255, 252, 244, 0.26) 50.4%, transparent 53.5%),
    linear-gradient(rgba(150, 105, 50, 0.18), transparent 3.5%, transparent 96.5%, rgba(150, 105, 50, 0.18)),
    url("/assets/img/paper-square.webp");
  --sheet-shadow:
    0 1px 2px rgba(59, 42, 24, 0.22),
    0 24px 44px -20px rgba(59, 42, 24, 0.55);
  position: absolute;
  inset: 0;
}

.sheet-flat {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  background: var(--paper-front);
  background-size: 100% 100%;
  box-shadow: var(--sheet-shadow);
  rotate: -0.8deg;
}

.sheet .logo {
  margin: 0;
  line-height: 0;
}

.logo-art,
.ink {
  position: absolute;
  display: block;
  aspect-ratio: 2195 / 945;
  isolation: isolate;
}

.logo-art {
  left: calc(var(--lx) * 100%);
  top: calc(var(--ly) * 100%);
  width: calc(var(--lw) * 100%);
}

.logo-art img,
.ink img {
  position: absolute;
  display: block;
  max-width: none;
}

.logo-body {
  inset: 0;
  width: 100%;
  height: 100%;
}

/* La feuille découpée du F : posée là où elle était (pixels de l'image source 2195 × 945). */
.logo-leaf {
  left: 4.966%;
  top: 4.127%;
  width: 13.212%;
  height: 18.519%;
  transform-origin: 83.79% 12.57%;
  mix-blend-mode: plus-lighter;
}

/* Le slogan, écrit à la main sous le logotype. */
.sheet .tagline {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 61%;
  margin: 0;
  text-align: center;
  font-size: max(19px, 5.3cqw);
}

/* Les 4 quarts (décor) : cachés tant qu'on ne les anime pas. */
.arrive {
  display: none;
}

/* Avec le mouvement : à l'arrivée, la feuille est pliée en 4, posée de travers au centre. Les poses
   du CSS sont celles du départ (le script les reprend à l'identique, en matrices). Chaque quart a son
   origine au coin de la feuille : sa pose s'écrit en coordonnées de la feuille. */
.motion .arrive {
  display: block;
  position: absolute;
  inset: 0;
  perspective: calc(var(--S) * 2.6);
  perspective-origin: 50% 50%;
  animation: sheet-arrive 1s var(--ease-soft) 0.1s both;
}

.motion .sheet-flat {
  opacity: 0;
}

.motion .sheet.open .sheet-flat {
  opacity: 1;
}

.motion .sheet.open .arrive {
  display: none;
}

/* Si le script ne vient pas, la feuille paraît dépliée d'elle-même. */
.motion .sheet:not(.js) .sheet-flat {
  animation: appear 0.8s ease 4.5s forwards;
}

.motion .sheet:not(.js) .arrive {
  animation:
    sheet-arrive 1s var(--ease-soft) 0.1s both,
    vanish 0.8s ease 4.5s forwards;
}

@keyframes sheet-arrive {
  from {
    opacity: 0;
    transform: translateY(-18px) scale(1.05);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes vanish {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.folds {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 0 0;
  transform: translate(calc(var(--S) / 2), calc(var(--S) / 2)) rotate(-7deg) translate(calc(var(--S) / -4), calc(var(--S) * -0.75));
}

.q {
  position: absolute;
  width: 50%;
  height: 50%;
  transform-style: preserve-3d;
}

.q.tl {
  left: 0;
  top: 0;
  transform-origin: 0 0;
  transform: translateZ(1px) translateY(calc(var(--S) / 2)) rotateX(-180deg) translateY(calc(var(--S) / -2));
}

.q.tr {
  --ox: 0.5;
  left: 50%;
  top: 0;
  transform-origin: calc(var(--S) / -2) 0;
  transform:
    translate3d(calc(var(--S) / 2), 0, 3px) rotateY(-180deg) translateX(calc(var(--S) / -2))
    translateZ(1px) translateY(calc(var(--S) / 2)) rotateX(-180deg) translateY(calc(var(--S) / -2));
}

.q.bl {
  --oy: 0.5;
  left: 0;
  top: 50%;
}

.q.br,
.q.brf {
  --ox: 0.5;
  --oy: 0.5;
  left: 50%;
  top: 50%;
}

/* Le bas droit posé ne paraît qu'à la 2e étape (le script l'allume). */
.q.br .face {
  opacity: 0;
}

.q.brf {
  transform-origin: calc(var(--S) / -2) calc(var(--S) / -2);
  transform: translate3d(calc(var(--S) / 2), 0, 3px) rotateY(-180deg) translateX(calc(var(--S) / -2));
}

/* L'ombre de la feuille sur la table : elle suit l'empreinte du papier (un quart, la moitié, tout). */
.sheet-shadow {
  position: absolute;
  inset: 0;
  box-shadow: var(--sheet-shadow);
  transform-origin: 0 100%;
  transform: translateZ(-1px) scale(0.5);
}

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--paper-front);
  background-size: 200% 200%;
  box-shadow: 0 0 1px rgba(59, 42, 24, 0.4);
}

.q.tl .front {
  background-position: 0 0;
}

.q.tr .front {
  background-position: 100% 0;
}

.q.bl .front {
  background-position: 0 100%;
}

.q.br .front {
  background-position: 100% 100%;
}

/* Le verso : le même papier, ses plis du côté des charnières. */
.back {
  transform: rotateY(180deg);
}

.q.tl .back {
  transform: rotateX(180deg);
  background-position: 0 100%;
}

.q.brf .back {
  background-position: 0 100%;
}

.q.tr .back {
  background-position: 0 0;
}

.ink {
  left: calc((var(--lx) - var(--ox, 0)) * 200%);
  top: calc((var(--ly) - var(--oy, 0)) * 200%);
  width: calc(var(--lw) * 200%);
}

/* La lumière vient d'en haut à gauche : le script règle l'ombre et le reflet de chaque face selon son
   inclinaison, et l'ombre que le rabat levé jette sur le papier dessous. */
.face i {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.face .shade {
  background: rgb(59, 42, 24);
}

.face .shine {
  background: rgb(255, 251, 242);
}

.face .cast-h {
  background: linear-gradient(rgba(59, 42, 24, 0.5), rgba(59, 42, 24, 0.16) 45%, transparent);
  transform-origin: 50% 0;
}

.face .cast-v {
  background: linear-gradient(270deg, rgba(59, 42, 24, 0.42), transparent 65%);
}

/* La feuille ouverte : la feuille du F au vent (16,8 s, comme dans l'app), le slogan qui s'écrit. */
.motion .sheet.open .logo-leaf {
  animation: leaf-life 16.8s ease-in-out 1.2s infinite;
}

@keyframes appear {
  to {
    opacity: 1;
  }
}

@keyframes leaf-life {
  0% {
    rotate: 0deg;
    translate: 0 0;
    scale: 1;
    opacity: 1;
  }
  12% {
    rotate: -5deg;
  }
  25% {
    rotate: 2.5deg;
  }
  38% {
    rotate: -4deg;
  }
  52% {
    rotate: 3deg;
  }
  65.4% {
    rotate: -6deg;
    translate: 0 0;
    opacity: 1;
  }
  68% {
    rotate: -24deg;
    translate: -6% 30%;
  }
  72% {
    rotate: -70deg;
    translate: 14% 110%;
  }
  77% {
    rotate: -40deg;
    translate: -8% 220%;
  }
  82% {
    rotate: -110deg;
    translate: 12% 330%;
    opacity: 0.7;
  }
  86.9% {
    rotate: -90deg;
    translate: 0 420%;
    opacity: 0;
    scale: 1;
  }
  89% {
    rotate: 0deg;
    translate: 0 0;
    opacity: 0;
    scale: 0;
  }
  100% {
    rotate: 0deg;
    translate: 0 0;
    opacity: 1;
    scale: 1;
  }
}

.tagline {
  font-family: var(--hand);
  font-weight: 700;
  line-height: 1.2;
}

.tagline span {
  display: block;
}

.tagline .t1 {
  color: var(--teal);
}

.tagline .t2 {
  color: var(--rose);
}

/* Le slogan s'écrit de gauche à droite (masque), comme une lettre trouvée dans l'app. */
.motion .tagline span {
  clip-path: inset(-10% 100% -20% 0);
}

.motion .sheet.open .tagline span,
.motion .sheet:not(.js) .tagline span {
  animation: write 1.1s cubic-bezier(0.5, 0.1, 0.3, 1) forwards;
}

.motion .sheet.open .tagline .t1 {
  animation-delay: 0.35s;
}

.motion .sheet.open .tagline .t2 {
  animation-delay: 1s;
}

.motion .sheet:not(.js) .tagline .t1 {
  animation-delay: 5s;
}

.motion .sheet:not(.js) .tagline .t2 {
  animation-delay: 5.6s;
}

@keyframes write {
  to {
    clip-path: inset(-10% -4% -20% 0);
  }
}

.hero-text {
  margin-top: clamp(20px, 3.4vh, 34px);
  text-align: center;
}

.pitch {
  max-width: 25em;
  margin: 0 auto clamp(12px, 2vh, 20px);
  font-size: clamp(23px, 0.8vw + 17px, 28px);
  line-height: 1.28;
}

.store {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 22px;
}

/* Posée à même le papier, sous l'aquarelle qui s'empile : l'encre pleine, pour rester lisible. */
.store-note {
  margin: 0;
  font-size: 21px;
  color: var(--ink);
}

/* Badge d'Apple : tel quel, jamais animé, entouré d'au moins un quart de sa hauteur d'espace libre. */
.badge {
  display: inline-block;
  padding: 14px;
  margin: -14px;
  line-height: 0;
  border-radius: 14px;
}

.badge img {
  display: block;
  height: 54px;
  width: auto;
}

/* MARK: - Comment on joue : les 4 règles sur une feuille pliée en quatre */

.how {
  padding: clamp(56px, 9vw, 120px) 0 clamp(40px, 6vw, 80px);
}

/* Grand écran : une feuille, 2 plis en croix, une règle par quart. Le papier est la photo de la feuille
   carrée (ses plis tombent entre les quarts); chaque quart penche un peu vers la lumière ou s'en
   détourne, comme un papier qu'on vient de déplier. */
.rules {
  position: relative;
  z-index: 2;
  list-style: none;
  max-width: 980px;
  margin: clamp(30px, 5vw, 56px) auto 0;
  padding: clamp(6px, 1.4cqi, 16px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  background:
    linear-gradient(rgba(150, 105, 50, 0.16), transparent 4%, transparent 96%, rgba(150, 105, 50, 0.16)),
    url("/assets/img/paper-square.webp") center / 100% 100%;
  box-shadow:
    0 1px 2px rgba(59, 42, 24, 0.2),
    0 22px 42px -20px rgba(59, 42, 24, 0.5);
  rotate: 0.4deg;
}

.beat {
  position: relative;
  isolation: isolate;
  padding: clamp(20px, 3cqi, 34px) clamp(16px, 2.6cqi, 30px) clamp(20px, 3cqi, 32px) clamp(84px, 9cqi, 100px);
}

/* Le relief des quarts. */
.beat::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(var(--tilt-light, 135deg), rgba(255, 252, 244, 0.22), rgba(59, 42, 24, 0.05));
}

.beat:nth-child(2)::after {
  --tilt-light: 225deg;
}

.beat:nth-child(3)::after {
  --tilt-light: 45deg;
}

.beat:nth-child(4)::after {
  --tilt-light: 315deg;
}

.beat h3 {
  font-size: clamp(25px, 1vw + 18px, 31px);
  margin: 4px 0 6px;
}

.beat p {
  margin: 0;
  font-size: clamp(21px, 0.4vw + 19px, 24px);
}

/* Le numéro, sur une touche du clavier en papier plié. */
.beat .num {
  position: absolute;
  left: clamp(14px, 2cqi, 26px);
  top: clamp(18px, 2.8cqi, 30px);
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 30px;
  color: var(--ink);
  background: url("/assets/img/key.webp") center / 100% 100% no-repeat;
  rotate: var(--key-tilt, -3deg);
}

.beat .num::before {
  content: "";
  position: absolute;
  inset: 8%;
  z-index: -1;
  background: var(--wash, url("/assets/img/stain-teal-1.webp")) center / 150% no-repeat;
  opacity: 0.9;
}

.beat:nth-child(2) .num {
  --wash: url("/assets/img/stain-rose-1.webp");
  --key-tilt: 2deg;
}

.beat:nth-child(3) .num {
  --wash: url("/assets/img/stain-ochre.webp");
  --key-tilt: -1deg;
}

.beat:nth-child(4) .num {
  --wash: url("/assets/img/stain-mix.webp");
  --key-tilt: 3deg;
}

.beat .num span {
  position: relative;
}

/* Les règles s'écrivent sur la feuille quand on arrive à elles. */
.motion .beat {
  opacity: 0;
  translate: 0 14px;
  transition:
    opacity 0.9s ease,
    translate 1.2s var(--ease-soft);
  transition-delay: calc(var(--n, 0) * 0.16s);
}

.motion .beat.in {
  opacity: 1;
  translate: 0 0;
}

/* Colonne étroite : la feuille pliée en accordéon, une règle par pan, un pli entre chaque. */
@container content (max-width: 640px) {
  .rules {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
    background:
      linear-gradient(90deg, rgba(150, 105, 50, 0.14), transparent 4%, transparent 96%, rgba(150, 105, 50, 0.14)),
      linear-gradient(rgba(150, 105, 50, 0.14), transparent 2%, transparent 98%, rgba(150, 105, 50, 0.14)),
      #f7efdf url("/assets/img/paper-tile.webp");
    rotate: 0.3deg;
  }

  .beat {
    padding: 18px 14px 18px 74px;
  }

  .beat + .beat::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -1px;
    height: 3px;
    background: linear-gradient(rgba(59, 42, 24, 0.12), rgba(255, 252, 244, 0.7));
  }

  .beat::after {
    background: linear-gradient(var(--tilt-light, 180deg), rgba(255, 252, 244, 0.25), rgba(59, 42, 24, 0.05));
  }

  .beat:nth-child(even)::after {
    --tilt-light: 0deg;
  }

  .beat .num {
    left: 10px;
    top: 18px;
    width: 50px;
    height: 50px;
    font-size: 26px;
  }
}

.em-teal {
  color: var(--teal-deep);
  font-weight: 700;
}

.em-rose {
  color: var(--rose-deep);
  font-weight: 700;
}

/* MARK: - Démo : une manche jouée sous nos yeux */

.demo {
  padding: clamp(40px, 7vw, 100px) 0 clamp(50px, 8vw, 110px);
}

.board {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
  margin: clamp(26px, 4vw, 44px) auto 0;
  padding: clamp(18px, 3vw, 30px) clamp(10px, 3vw, 34px) clamp(18px, 3vw, 30px);
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("/assets/img/paper-sheet.webp") center / cover no-repeat;
  border-radius: 6px;
  box-shadow:
    0 1px 2px rgba(59, 42, 24, 0.18),
    0 18px 40px -18px rgba(59, 42, 24, 0.45);
  rotate: -0.4deg;
}

.banner {
  position: relative;
  isolation: isolate;
  width: fit-content;
  margin: 0 auto 4px;
  padding: 4px 34px 6px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(22px, 1.4vw + 15px, 30px);
  text-align: center;
  transition: opacity 0.5s ease;
}

.banner::before {
  content: "";
  position: absolute;
  inset: 8% -6% 0;
  z-index: -1;
  background: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  opacity: 0.8;
  transition: opacity 0.6s ease;
}

.banner::after {
  content: "";
  position: absolute;
  inset: 8% -6% 0;
  z-index: -1;
  background: url("/assets/img/streak-rose.webp") center / 100% 100% no-repeat;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.board[data-turn="rose"] .banner::before {
  opacity: 0;
}

.board[data-turn="rose"] .banner::after {
  opacity: 0.8;
}

.board[data-turn="none"] .banner::before {
  opacity: 0.55;
}

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  margin-top: 4px;
}

.side {
  display: grid;
  justify-items: center;
  transition: opacity 0.7s ease, filter 0.7s ease;
}

.side .flower {
  --w: clamp(104px, 13vw, 150px);
}

.side .name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(22px, 1vw + 16px, 28px);
  margin-top: -6px;
}

.side .count {
  font-size: 19px;
  color: var(--ink-2);
  margin: 0;
}

.side.rose .name {
  color: var(--rose);
}

.side.teal .name {
  color: var(--teal);
}

/* Le côté qui n'a pas le trait pâlit. */
.board[data-turn="teal"] .side.rose,
.board[data-turn="rose"] .side.teal {
  opacity: 0.5;
  filter: saturate(0.6);
}

.words {
  display: grid;
  gap: 10px;
  margin: 14px 0 6px;
}

.word {
  position: relative;
  padding: 2px 14px 8px;
  transition: opacity 0.6s ease;
}

.word .label {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
}

.word.rose .label {
  color: var(--rose-deep);
}

.word.teal .label {
  color: var(--teal-deep);
}

.cells {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 1.2cqi, 12px);
  margin: 0;
  padding: 2px 0 4px;
}

.cell {
  position: relative;
  display: grid;
  place-items: end center;
  width: clamp(25px, 6cqi, 44px);
  height: clamp(34px, 7cqi, 50px);
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(25px, 4.4cqi, 36px);
  line-height: 1;
  color: var(--ink);
}

/* Le trait sous la case, à la main. */
.cell::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -2px;
  height: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 7' preserveAspectRatio='none'%3E%3Cpath d='M1 4.2C8 2.4 14 5.6 21 3.8S33 2.6 39 4' fill='none' stroke='%236e5236' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  opacity: 0.8;
}

.cell .l {
  display: block;
  clip-path: inset(-20% -20% -20% 0);
}

.cell .l.teal {
  color: var(--teal);
}

.cell .l.rose {
  color: var(--rose);
}

.cell .l.missing {
  color: #b9a88f;
}

.motion .cell .l.new {
  animation: write-letter 0.55s cubic-bezier(0.5, 0.1, 0.3, 1) both;
}

@keyframes write-letter {
  from {
    clip-path: inset(-20% 100% -20% 0);
  }
  to {
    clip-path: inset(-20% -20% -20% 0);
  }
}

/* La place de la définition est gardée pendant la manche : le plateau garde sa hauteur du début à
   la fin, rien ne bouge sous lui (ni quand elle paraît, ni quand le plateau se remet à zéro). */
.definition {
  margin: 4px 4px 2px;
  font-size: 20px;
  line-height: 1.22;
  text-align: center;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.8s ease 0.3s;
}

.board.over .definition {
  opacity: 1;
}

/* Rejouée : les définitions s'effacent avec le reste, au lieu de traîner sur la manche neuve. */
.board.rewind .definition {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Manche rejouée sous nos yeux : ce qui est écrit sur la feuille s'efface un instant, la feuille
   reste. */
.board :is(.banner, .sides, .cells, .caption, .keyboard) {
  transition: opacity 0.4s ease;
}

.board.rewind :is(.banner, .sides, .cells, .caption, .keyboard) {
  opacity: 0;
}

.caption {
  min-height: 2.6em;
  margin: 4px auto 10px;
  max-width: 30em;
  text-align: center;
  font-size: clamp(20px, 0.5vw + 17px, 23px);
  font-weight: 600;
  transition: opacity 0.35s ease;
}

.caption b {
  font-family: var(--hand);
}

.caption .teal {
  color: var(--teal-deep);
}

.caption .rose {
  color: var(--rose-deep);
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 8px);
  width: min(460px, 100%);
  margin: 0 auto;
}

.key {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(19px, 2.4vw, 25px);
  color: var(--ink);
  background: url("/assets/img/key.webp") center / 100% 100% no-repeat;
  rotate: var(--kt, 0deg);
  transition: opacity 0.5s ease, scale 0.25s ease;
}

.key::before {
  content: "";
  position: absolute;
  inset: 4%;
  z-index: -1;
  background: center / 160% no-repeat;
  opacity: 0;
}

.key.hit-teal::before {
  background-image: url("/assets/img/stain-teal-1.webp");
  opacity: 0.95;
}

.key.hit-rose::before {
  background-image: url("/assets/img/stain-rose-1.webp");
  opacity: 0.95;
}

.motion .key.hit-teal::before,
.motion .key.hit-rose::before {
  animation: key-wash 1.1s var(--ease-soft) both;
}

@keyframes key-wash {
  from {
    opacity: 0;
    scale: 0.3;
  }
  to {
    opacity: 0.95;
    scale: 1;
  }
}

.key.miss {
  color: rgba(59, 42, 24, 0.5);
}

/* Lettre ratée : barrée à la main, de la couleur de qui l'a jouée. */
.key.miss::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 46%;
  height: 10%;
  background: var(--bar) center / 100% 100% no-repeat;
  rotate: -28deg;
}

.key.miss.by-teal {
  --bar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 6' preserveAspectRatio='none'%3E%3Cpath d='M2 3.6C12 2 26 4.2 38 2.6' fill='none' stroke='%232e7a71' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
}

.key.miss.by-rose {
  --bar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 6' preserveAspectRatio='none'%3E%3Cpath d='M2 3.6C12 2 26 4.2 38 2.6' fill='none' stroke='%239b5a68' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
}

.key.press {
  scale: 0.9;
}

.demo-actions {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

/* Bouton en bande de papier, lavis bleu-vert comme le bouton principal de l'app. */
.btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 30px 8px;
  border: 0;
  font: 700 clamp(20px, 0.6vw + 17px, 24px) / 1.1 var(--hand);
  color: var(--ink);
  background: url("/assets/img/strip.webp") center / 100% 100% no-repeat;
  cursor: pointer;
  rotate: -0.8deg;
  transition: rotate 0.35s var(--ease-soft), translate 0.35s var(--ease-soft);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 16% 4% 10%;
  z-index: -1;
  background: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  opacity: 0.6;
}

.btn:hover {
  rotate: 0.6deg;
  translate: 0 -1px;
}

/* MARK: - Captures, dans un téléphone tout simple */

.screens {
  padding: clamp(50px, 8vw, 110px) 0 clamp(40px, 6vw, 80px);
}

.fan {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: clamp(34px, 5vw, 60px) auto 0;
  padding-bottom: 10px;
}

.phone {
  --pw: clamp(96px, 23cqi, 250px);
  position: relative;
  flex: none;
  width: var(--pw);
  margin: 0;
  padding: calc(var(--pw) * 0.034);
  border-radius: calc(var(--pw) * 0.165);
  background: linear-gradient(150deg, #4a3826, #241a10 55%, #3a2b1d);
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 220, 0.12),
    0 2px 3px rgba(59, 42, 24, 0.25),
    0 26px 50px -18px rgba(59, 42, 24, 0.55);
}

.phone img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 1391;
  border-radius: calc(var(--pw) * 0.135);
  background: var(--paper-2);
}

.phone figcaption {
  position: absolute;
  left: 50%;
  bottom: calc(-1 * clamp(34px, 3vw, 44px));
  translate: -50% 0;
  white-space: nowrap;
  font-size: clamp(19px, 0.6vw + 15px, 23px);
  font-weight: 700;
  color: var(--ink); /* à même le papier, sous l'aquarelle */
}

.phone.p1 {
  rotate: -7deg;
  translate: 18% 8%;
  z-index: 1;
}

.phone.p2 {
  --pw: clamp(112px, 27cqi, 290px);
  z-index: 2;
}

.phone.p3 {
  rotate: 7deg;
  translate: -18% 8%;
  z-index: 1;
}

.motion .phone {
  opacity: 0;
  transition:
    opacity 0.9s ease,
    transform 1.4s var(--ease-soft);
  transform: translateY(60px) rotate(var(--rot0, 0deg));
}

.motion .phone.p1 {
  --rot0: -6deg;
  transition-delay: 0.15s;
}

.motion .phone.p3 {
  --rot0: 6deg;
  transition-delay: 0.3s;
}

.motion .in .phone {
  opacity: 1;
  transform: none;
}

.features {
  position: relative;
  z-index: 2;
  list-style: none;
  margin: clamp(70px, 8vw, 100px) auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 26px);
}

.feature {
  padding: 8px 12px 12px;
  rotate: var(--tilt, 0.6deg);
  text-align: center;
}

.feature:nth-child(2n) {
  --tilt: -0.7deg;
}

.feature h3 {
  font-size: clamp(22px, 0.7vw + 17px, 27px);
  margin: 2px 0 4px;
}

.feature p {
  margin: 0;
  font-size: clamp(20px, 0.3vw + 18px, 22px);
  line-height: 1.22;
}

.motion .feature {
  opacity: 0;
  translate: 0 26px;
  transition: opacity 0.8s ease, translate 1.1s var(--ease-soft);
  transition-delay: calc(var(--n, 0) * 0.12s);
}

.motion .feature.in {
  opacity: 1;
  translate: 0 0;
}

/* MARK: - Les thèmes : tous, comme à l'écran « Thème » de l'app (mêmes noms, mêmes teintes, même
   pose de travers), lancés comme des bouts de papier sur une table */

.themes {
  padding: clamp(40px, 7vw, 100px) 0 clamp(20px, 4vw, 60px);
}

/* Un trait de lavis vert sauge (la teinte du 1er thème), teint par masque dans la forme du trait
   bleu-vert. */
.title.sage::before {
  background: rgb(150 176 124);
  -webkit-mask: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  mask: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  opacity: 1;
}

/* Les mots du pendu de la petite école, écrits comme au tableau. */
.plain-word {
  font-family: var(--hand);
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}

.theme-table {
  position: relative;
  z-index: 2;
  max-width: 780px;
  margin: clamp(30px, 4vw, 50px) auto 0;
}

/* Un bout de papier : la bande déchirée (strip.webp, comme `.paper`, en plus fin), posée de
   travers selon son nom (`SlipPose`), avec une ombre légère qui suit ses bords déchirés. */
:is(.slip, .random-slip) {
  position: relative;
  isolation: isolate;
  border-style: solid;
  border-color: transparent;
  translate: var(--dx, 0px) var(--dy, 0px);
  rotate: var(--a, 0deg);
  filter: drop-shadow(0.8px 1.3px 1.3px rgba(59, 42, 24, 0.2));
}

/* « Au hasard », en tête : choisi, comme à l'ouverture de l'app. Un lavis bleu-vert sur tout le
   papier, un trait sous le titre, le titre encerclé à la plume, et un dé posé dans le coin. */
.random-slip {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 2px 20px 4px;
  border-width: 12px 16px;
  border-image: url("/assets/img/strip.webp") 52 66 fill / 12px 16px / 0 stretch;
  text-align: center;
}

.random-slip::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -4px -6px;
  background: radial-gradient(ellipse 70% 80% at 46% 55%, rgba(104, 178, 164, 0.34), rgba(104, 178, 164, 0.14) 62%, rgba(104, 178, 164, 0) 92%);
  mix-blend-mode: multiply;
}

/* Pas de contexte d'empilement ici : le trait se mélange au papier du bout de papier. */
.random-word {
  position: relative;
  display: inline-block;
  padding: 0 14px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(27px, 0.7vw + 22px, 32px);
  line-height: 1.2;
}

.random-word::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -6px;
  right: -8px;
  top: 34%;
  bottom: 2%;
  background: var(--hue);
  -webkit-mask: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat, url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  mask: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat, url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  mix-blend-mode: multiply;
}

/* Le cercle à la plume (`HandCircle` de l'app), un peu plus grand que le titre. */
.pen {
  position: absolute;
  left: -10px;
  top: -7px;
  width: calc(100% + 20px);
  height: calc(100% + 12px);
  overflow: visible;
  pointer-events: none;
}

.pen path {
  fill: none;
  stroke: var(--teal-deep);
  stroke-opacity: 0.88;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.random-line {
  display: block;
  margin-top: -2px;
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(21px, 0.4vw + 19px, 24px);
  line-height: 1.1;
  color: var(--ink-2);
}

.die {
  position: absolute;
  top: -26px;
  right: -14px;
  width: 38px;
  height: 38px;
  rotate: 16deg;
}

.slips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px 10px;
  margin: 22px 0 0;
  padding: 0;
}

.slip {
  padding: 2px 8px 3px;
  border-width: 6px 9px;
  border-image: url("/assets/img/strip.webp") 52 66 fill / 6px 9px / 0 stretch;
  font-family: var(--hand);
  font-weight: 400;
  font-size: clamp(18px, 0.35vw + 16.5px, 21px);
  line-height: 1.1;
  text-align: center;
  color: var(--ink);
}

/* Le trait d'aquarelle pâle de sa teinte, sous le nom (1 des 3 formes, parfois retournée). Le
   masque est posé 2 fois : le trait prend plus de pigment sans perdre son grain. */
.slip::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -2px;
  right: 0;
  top: 24%;
  bottom: 4%;
  background: var(--hue);
  -webkit-mask: var(--stroke) center / 100% 100% no-repeat, var(--stroke) center / 100% 100% no-repeat;
  mask: var(--stroke) center / 100% 100% no-repeat, var(--stroke) center / 100% 100% no-repeat;
  scale: var(--flip, 1) 1;
  opacity: 0.8;
  mix-blend-mode: multiply;
}

.drawn {
  margin: clamp(24px, 3vw, 34px) auto 0;
  max-width: 30em;
  text-align: center;
  color: var(--ink-2);
}

.drawn > span:first-child {
  display: block;
}

.drawn b {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.76em;
  letter-spacing: 0.05em;
  color: var(--ink);
  white-space: nowrap;
}

.drawn .sep {
  margin-inline: 0.12em;
}

.themes-note {
  max-width: 30em;
  margin: 8px auto 0;
  text-align: center;
  font-size: 0.92em;
  color: var(--ink);
}

/* Lancés sur la table quand on arrive : chaque papier tombe de un peu plus haut, en tournant un
   peu plus, et se pose (`TossIn` de l'app, plus lent). Remplissage « backwards » seulement : une
   fois posé, le papier reprend ses propres valeurs (et le survol peut le soulever). */
.motion .theme-table:not(.in) :is(.slip, .random-slip) {
  opacity: 0;
}

.motion .theme-table.in :is(.slip, .random-slip) {
  animation: toss 0.8s cubic-bezier(0.3, 1.3, 0.55, 1) calc(0.15s + var(--n, 0) * 0.07s) backwards;
}

@keyframes toss {
  from {
    opacity: 0;
    translate: calc(var(--dx, 0px) + var(--fx, 0px)) calc(var(--dy, 0px) + var(--fy, 30px));
    rotate: calc(var(--a, 0deg) + var(--spin, 0deg));
    scale: 1.08;
  }
  35% {
    opacity: 1;
  }
}

/* Le cercle se trace à la plume une fois les papiers posés. */
.motion .theme-table .pen path {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}

.motion .theme-table.in .pen path {
  animation: pen-circle 0.7s ease-out 1.5s forwards;
}

@keyframes pen-circle {
  to {
    stroke-dashoffset: 0;
  }
}

/* Sous le doigt (souris seulement) : le papier se soulève et se redresse un peu, comme dans l'app.
   Sans animations, seule l'ombre change. */
@media (hover: hover) and (pointer: fine) {
  .slip {
    transition:
      filter 0.3s ease,
      scale 0.35s cubic-bezier(0.3, 1.5, 0.5, 1),
      rotate 0.35s cubic-bezier(0.3, 1.5, 0.5, 1),
      translate 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
  }

  .slip:hover {
    filter: drop-shadow(0.8px 6px 6px rgba(59, 42, 24, 0.28));
  }

  .motion .slip:hover {
    scale: 1.06;
    rotate: calc(var(--a, 0deg) * 0.45);
    translate: var(--dx, 0px) calc(var(--dy, 0px) - 3px);
  }
}

/* MARK: - Dernier appel */

.cta {
  padding: clamp(60px, 10vw, 140px) 0 clamp(60px, 9vw, 120px);
  text-align: center;
  overflow: clip;
}

.cta > .wrap {
  position: relative;
  z-index: 2;
}

.cta .flower {
  --w: clamp(170px, 18vw, 230px);
  margin: 0 auto 10px;
}

.cta-flower {
  position: relative;
  width: fit-content;
  margin: 0 auto;
}

.cta h2 {
  font-size: clamp(38px, 4vw + 16px, 64px);
}

.cta p {
  max-width: 26em;
  margin: 14px auto 26px;
  font-size: clamp(23px, 0.8vw + 18px, 28px);
}

.cta .store {
  justify-content: center;
}

/* MARK: - Pied de page */

.site-footer {
  position: relative;
  z-index: 2;
  padding: 26px 0 40px;
  text-align: center;
  color: var(--ink-2);
}

.site-footer .paper {
  padding: 8px clamp(10px, 3vw, 30px) 14px;
}

.foot-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 20px;
}

.foot-nav a {
  display: inline-block;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}

.foot-nav a:hover {
  text-decoration: underline;
  text-decoration-color: var(--teal);
}

.site-footer p {
  margin: 4px 0;
  font-size: 20px;
  line-height: 1.25;
}

.site-footer .mail {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 20px;
}

.site-footer .credits {
  color: var(--ink);
}

.site-footer .tm {
  margin-top: 12px;
  font-family: var(--hand);
  font-weight: 300;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-2);
}

.to-top {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 18px;
}

/* MARK: - Pages de texte (confidentialité, conditions, soutien) */

.doc-page {
  position: relative;
}

.doc-page .topbar {
  position: relative;
}

.doc-head {
  position: relative;
  isolation: isolate;
  padding: clamp(20px, 4vw, 40px) 0 10px;
  text-align: center;
}

.doc-head h1 {
  display: inline-block;
  position: relative;
  isolation: isolate;
  font-size: clamp(34px, 3vw + 18px, 54px);
  padding: 0 0.2em;
}

.doc-head h1::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -0.35em;
  right: -0.4em;
  top: 38%;
  bottom: -6%;
  background: url("/assets/img/streak-teal.webp") center / 100% 100% no-repeat;
  opacity: 0.75;
  rotate: -1deg;
}

.updated {
  margin-top: 8px;
  font-size: 21px;
  color: var(--ink-2);
}

.doc {
  position: relative;
  z-index: 2;
  width: min(760px, 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding-bottom: 30px;
  font-family: var(--hand);
  font-weight: 400;
  font-size: 17.5px;
  line-height: 1.62;
}

.doc h2 {
  margin: 2.1em 0 0.5em;
  font-size: clamp(24px, 0.8vw + 19px, 30px);
  scroll-margin-top: 20px;
}

.doc h3 {
  margin: 1.4em 0 0.3em;
  font-size: 20px;
}

.doc p,
.doc li {
  text-wrap: pretty;
}

.doc ul,
.doc ol {
  padding-left: 1.3em;
  margin: 0 0 1em;
}

.doc li {
  margin: 0.25em 0;
}

.doc li::marker {
  color: var(--teal);
}

.doc strong {
  font-weight: 700;
}

.doc .card {
  margin: 22px 0 10px;
  padding: 14px 26px 18px;
}

.doc .card h2 {
  margin: 4px 0 6px;
  font-size: 24px;
}

.doc .card ul {
  margin-bottom: 0;
}

.toc {
  margin: 26px 0 6px;
}

.toc h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.toc ol {
  columns: 2 16em;
  column-gap: 2em;
  margin: 0;
}

.toc li {
  break-inside: avoid;
}

.toc a {
  color: var(--ink);
}

.doc .path {
  font-weight: 700;
  color: var(--teal-deep);
}

.doc .mail-big {
  display: inline-block;
  font-size: 24px;
  font-weight: 700;
}

.contact-card {
  margin: 20px 0;
  padding: 16px 26px 20px;
  text-align: center;
}

.contact-card p {
  margin: 0 0 4px;
}

/* MARK: - Colonne large : le plateau de la démo en 2 colonnes, pour tenir dans la fenêtre */

@container content (min-width: 820px) {
  .board {
    width: min(1000px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    grid-template-areas:
      "banner banner"
      "sides words"
      "sides caption"
      "sides keys";
    column-gap: clamp(20px, 3cqi, 44px);
    align-items: start;
    padding: 24px 40px 34px;
  }

  .board .banner {
    grid-area: banner;
    margin-bottom: 10px;
  }

  .board .sides {
    grid-area: sides;
    align-self: center;
    margin-top: -10px;
  }

  .board .side .flower {
    --w: clamp(150px, 16cqi, 210px);
  }

  .board .words {
    grid-area: words;
    margin-top: 0;
  }

  .board .caption {
    grid-area: caption;
    margin: 6px auto 12px;
  }

  .board .keyboard {
    grid-area: keys;
    width: min(430px, 100%);
  }
}

/* MARK: - Colonnes étroites, petits écrans */

@container content (max-width: 820px) {
  .features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container content (max-width: 480px) {
  .features {
    grid-template-columns: minmax(0, 1fr);
    max-width: 400px;
  }

  .fan {
    margin-left: -8px;
    margin-right: -8px;
  }

  .phone.p1 {
    translate: 26% 8%;
  }

  .phone.p3 {
    translate: -26% 8%;
  }

  .phone figcaption {
    font-size: 17px;
  }

  .board {
    padding-inline: 8px;
  }

  .word {
    padding-inline: 8px;
  }
}

@media (max-width: 860px) {
  .store {
    flex-direction: column;
    gap: 16px;
  }

  .badge img {
    height: 50px;
  }
}

@media (max-width: 520px) {
  .topbar .home {
    width: 108px;
  }

  .doc {
    font-size: 17px;
  }
}

/* Moins d'animations : une version peinte, immobile. Le script ne pose pas `.motion`; ceci
   attrape aussi ce qui bougerait encore (navigation douce, transitions de survol). */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  html {
    background: #fff;
  }

  .petal-rain,
  .topbar,
  .lane,
  .arrive {
    display: none;
  }

  .sheet-flat {
    opacity: 1 !important;
  }
}
