:root { --cuir: #8f1d2d; --barre: calc(64px + env(safe-area-inset-bottom)); --col: min(100vw, 480px); }
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { background: #070505; overflow-x: clip; touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; }
body { width: var(--col); margin: 0 auto; background: #070505; color: #fff; overflow-x: clip;
  font: 500 16px/1.4 Archivo, system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.titre { font-weight: 900; font-size: 38px; line-height: 1; letter-spacing: -.035em; font-style: italic; }

/* ---------- L'accueil ---------- */
.scene { position: sticky; top: 0; height: 100svh; overflow: hidden; }
#clip { height: 130svh; } /* 30 pour avancer la caméra, puis le catalogue monte */
#accueil { position: absolute; inset: 0; touch-action: pan-y; }
#accueil::after { content: ""; position: absolute; inset: auto 0 0; height: 110px; background: linear-gradient(#07050500, #070505); pointer-events: none; }
/* Le cadre garde la proportion 9:16 des plans et couvre l'écran : tout se place en % de l'image. */
.cadre { position: absolute; top: 0; left: 50%; height: max(100svh, calc(var(--col) * 1.7778)); aspect-ratio: 1008 / 1792; margin-left: calc(max(100svh, var(--col) * 1.7778) * -.28125);
  --x: 0; --y: 0; --p: 0;
  /* La caméra avance : toute la scène d'un bloc, jamais un plan seul, sinon la chaîne se décroche (refusé le 25/11). */
  transform-origin: 50% 46svh; transform: scale(calc(1 + var(--p) * .75)); }
.plateau, .pendule { will-change: transform; }
.plan { position: absolute; inset: 0; width: 100%; height: 100%; }
.plateau { transform: scale(1.06) translate(calc(var(--x) * -8px), calc(var(--y) * -5px)); }
/* La chaîne tombe du plafond : lettres au milieu de l'écran, haut de l'image toujours au-dessus du bord. */
.pendule { --l: calc(var(--col) * .95); position: absolute; left: 50%; width: var(--l); margin-left: calc(var(--l) / -2);
  top: min(-6px, calc(45svh - var(--l) * 1.155)); transform-origin: 50% -12%;
  transform: perspective(900px) translate(calc(var(--x) * 5px), calc(var(--y) * 5px)) rotateZ(var(--a, 0deg)) rotateY(calc(var(--x) * 12deg)); }
.pendule img { display: block; width: 100%; }
.pendule canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
canvas { pointer-events: none; }
.zone { position: absolute; display: block; }
.z-logo { inset: 4% 0 22%; }

/* Le lancement. 1 : dans le noir, de tout près, les pierres se sertissent de gauche à droite sur le métal nu.
   2 : la caméra recule, les étoiles s'allument de haut en bas, la barre monte. Toucher l'écran passe au 2. */
.allume { background: #070505; }
.nu { display: none !important; }
.charge .nu, .sertit .nu { display: block !important; position: absolute; inset: 0; filter: brightness(.2) contrast(1.15); }
.charge .serti, .sertit .serti { position: relative; -webkit-mask-image: linear-gradient(98deg, #000 calc(var(--front, 0) * 1%), #0000 calc(var(--front, 0) * 1% + 7%)); mask-image: linear-gradient(98deg, #000 calc(var(--front, 0) * 1%), #0000 calc(var(--front, 0) * 1% + 7%)); }
.charge .pendule, .charge #barre, .sertit #barre { visibility: hidden; }
.charge .pendule { opacity: 0; }
.sertit .pendule { animation: paraitre .35s; }
.charge .cadre, .sertit .cadre { transform: scale(1.75) translateX(calc((50 - min(100, var(--front, 0))) * .42%)); } /* la caméra suit la pierre qu'on pose */
.ouvre .cadre { animation: recule 1.5s cubic-bezier(.22, 1, .36, 1); }
.ouvre #barre { animation: leve .6s .7s cubic-bezier(.16, 1, .3, 1) backwards; }
@keyframes paraitre { from { opacity: 0; } }
@keyframes recule { from { transform: scale(1.75) translateX(calc((50 - min(100, var(--front, 0))) * .42%)); } }
@keyframes leve { from { transform: translateY(100%); } }
.ouvre .allume { animation: etoiles 1.5s ease-in-out forwards; -webkit-mask: linear-gradient(#0000 33%, #000 66%) 0 100% / 100% 300%; mask: linear-gradient(#0000 33%, #000 66%) 0 100% / 100% 300%; }
@keyframes etoiles { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
.feuille p { font-size: 21px; font-weight: 600; margin: 8px 0 16px; color: #e9dfdd; }
.bouton { display: block; width: 100%; min-height: 54px; border-radius: 27px; background: var(--cuir); font-weight: 800; font-size: 17px; }
.bouton:active { background: #701522; }

/* ---------- La pièce ouverte ---------- */
.feuille { position: fixed; z-index: 30; top: 0; bottom: 0; left: 50%; width: var(--col); margin-left: calc(var(--col) / -2); background: #070505; overflow: hidden auto; overscroll-behavior: contain; }
.feuille[hidden] { display: none; }
.feuille { animation: ouvre .4s cubic-bezier(.16, 1, .3, 1); }
@keyframes ouvre { from { opacity: 0; scale: 1.12; } }
.feuille-photo { position: relative; height: min(44svh, calc(var(--col) * 1.1)); overflow: hidden; }
.haute { --c: .92; } .haute .feuille-bas { margin-top: -22px; } .haute .feuille-photo { height: min(56svh, calc(var(--col) * 1.25)); }
.feuille-photo::after { content: ""; position: absolute; inset: 55% 0 0; background: linear-gradient(#07050500, #070505 92%); }
.feuille-photo img, .feuille-photo canvas { position: absolute; left: 0; top: calc(50% - var(--col) * var(--c, .95)); width: 100%; height: auto; aspect-ratio: 1008 / 1792; }
.feuille-bas { position: relative; padding: 4px 24px calc(28px + env(safe-area-inset-bottom)); margin-top: -52px; }
.feuille .bouton { position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); }
.fermer { position: absolute; z-index: 2; top: calc(14px + env(safe-area-inset-top)); right: 16px; width: 46px; height: 46px; border-radius: 50%; background: #070505cc; font-size: 28px; line-height: 1; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 700; margin-bottom: 9px; padding: 0; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puces label { position: relative; }
.puces input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
.puces span { display: block; min-width: 50px; padding: 11px 12px; text-align: center; border-radius: 12px; background: #241719; font-weight: 700; }
.puces input:checked + span { background: #fff; color: #070505; }
.puces input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- La barre ---------- */
#barre { position: fixed; z-index: 20; bottom: 0; left: 50%; width: var(--col); margin-left: calc(var(--col) / -2); height: var(--barre); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(3, 1fr); background: #070505; }
#barre button { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: #a89d9d; }
#barre svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
#barre [aria-current] { color: #fff; }
#barre b { position: absolute; top: 7px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--cuir); color: #fff; font-size: 11px; line-height: 18px; }
#mot { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--barre) + 14px); width: calc(var(--col) - 48px); margin-left: calc(var(--col) / -2 + 24px); padding: 14px 18px; border-radius: 16px; background: #fff; color: #070505; font-weight: 700; text-align: center; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
#mot.la { opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; } }
