/* Mise en page : vue à la première personne depuis le siège du pilote.
   Espace + étoiles → image du cockpit (pare-brise transparent) → écrans animés → affichage sur le pare-brise → poussières. */
:root {
  --void: #05070d;
  --ash: #aeb3bf;
  --bone: #f6f1e7;
  --lava: #ff6a00;
  --magma: #ffb347;
  --f-display: 'Saira Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --f-hud: 'Saira Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --scene-ratio: 16 / 9;
  --scene-img: url(../assets/pov-wide.webp);
  --vanish-y: .3; /* centre du pare-brise, point de fuite des étoiles */
  --logo-w: min(26cqh, 32vw);
  --digit: min(7vw, 11cqh);
  --edge: max(20px, 2.2vw);
  --px: 0;
  --py: 0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--bone);
  font: 600 15px/1.4 var(--f-hud);
  -webkit-font-smoothing: antialiased;
}
p, h1 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.stage { position: fixed; inset: 0; overflow: hidden; isolation: isolate; }

/* ---------- Décor ---------- */
.space {
  position: absolute; inset: -6%; width: 112%; height: 112%; max-width: none;
  object-fit: cover;
  transform: translate3d(calc(var(--px) * -26px), calc(var(--py) * -16px), 0);
}
/* Lueur chaude au point de fuite : elle réchauffe le ciel et donne une direction au voyage. */
.heat {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen;
  background:
    radial-gradient(9% 7% at 50% calc(var(--vanish-y) * 100%), rgba(255, 226, 170, .55), transparent 100%),
    radial-gradient(46% 30% at 50% calc(var(--vanish-y) * 100%), rgba(255, 128, 40, .42), rgba(255, 80, 20, .12) 55%, transparent 100%);
}
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Boîte au format de l'image, qui couvre l'écran : son contenu reste calé sur le cockpit (unités cqw / cqh). */
.cockpit {
  position: absolute; left: 50%; top: 50%;
  width: max(100vw, 100svh * var(--scene-ratio)); aspect-ratio: var(--scene-ratio);
  container-type: size;
  transform: translate3d(calc(-50% + var(--px) * -9px), calc(-50% + var(--py) * -6px), 0) scale(1.035);
}
.cockpit__img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; /* les clics traversent jusqu'aux écrans */ filter: brightness(.84) contrast(1.06) saturate(1.08); }
/* Reflets : la lueur du dehors éclaire le tableau de bord, et des bandes de lumière glissent sur l'habitacle. */
.reflet {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge;
  -webkit-mask: var(--scene-img) center / 100% 100% no-repeat; mask: var(--scene-img) center / 100% 100% no-repeat;
  overflow: hidden;
  background:
    radial-gradient(75% 46% at 50% calc(var(--vanish-y) * 100% + 24%), rgba(255, 118, 30, .13), rgba(255, 90, 20, .04) 60%, transparent 100%);
}
.grade {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(125% 100% at 50% 40%, transparent 55%, rgba(14, 6, 2, .62) 100%);
}
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Bande de lumière qui glisse sur l'habitacle (déplacée par transform, sans repeindre le fond). */
.reflet::after {
  content: ''; position: absolute; inset: 0 -60%; transform: translateX(-60%);
  background: linear-gradient(100deg, transparent 44%, rgba(255, 150, 60, .13) 50%, transparent 56%);
}

/* ---------- Écrans : plaqués par script sur leur emplacement dans l'image (voir js/screens.js) ---------- */
.screen { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.screen-backing { position: absolute; background: #0c0e13; } /* fond opaque derrière chaque découpe */
/* Moniteur de droite, dans le même esprit que la carte « Arrivée » :
   une carte Instagram à gauche, l'aftermovie entier dans un cadre 9:16 à droite. Tout l'écran est cliquable. */
.media {
  display: block; overflow: hidden;
  background: linear-gradient(135deg, #12151c, #07080c);
  color: #f6f3ee; text-decoration: none;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1;
}
/* Les unités cq d'un conteneur visent son parent : la mise en page se fait donc dans cet élément intérieur. */
.media__inner {
  position: absolute; inset: var(--bleed-y, 0px) var(--bleed-x, 0px); /* zone utile = la découpe, sans le débord */
  display: flex; align-items: stretch;
  container-type: size; /* les marges de ses enfants s'expriment en cqw / cqh de cette zone */
}
.media__info {
  flex: 1; min-width: 0; margin: 6cqh 0 6cqh 2.6cqw; display: flex; flex-direction: column; gap: 3.5cqh; padding: 6cqh 3cqw;
  border-radius: 9cqh; background: rgba(255, 255, 255, .075);
}
.media__label { font-size: 8.5cqh; font-weight: 500; color: rgba(235, 238, 245, .55); }
.media__title { font-size: 13cqh; font-weight: 700; white-space: nowrap; }
/* Le lien Instagram passe en premier : sur grand écran, la main du pilote masque le bas gauche du moniteur. */
.media__insta { order: -1; display: flex; align-items: center; gap: 2.4cqw; min-width: 0; margin-bottom: 2cqh; }
.media__badge {
  flex: none; width: 21cqh; height: 21cqh; display: grid; place-items: center; border-radius: 30%;
  background: var(--lava); color: #fff; transition: scale .3s var(--ease-out);
}
.media__badge svg { width: 64%; height: 64%; }
.media__handle { font-size: 8.5cqh; font-weight: 600; color: var(--magma); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media__frame { flex: none; margin: 6cqh 2.6cqw 6cqh 3cqw; aspect-ratio: 9 / 16; border-radius: 7cqh; overflow: hidden; background: #000; }
.media__video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media:hover .media__badge, .media:focus-visible .media__badge { scale: 1.15; }
.media:focus-visible { outline: 2px solid var(--bone); outline-offset: -2px; }
/* Écran presque carré (téléphone) : la carte se réduit à l'icône Instagram. */
@container (max-aspect-ratio: 3/2) {
  .media__info { justify-content: center; align-items: center; padding: 4cqh 2cqw; }
  .media__label, .media__title, .media__handle { display: none; }
  .media__badge { width: 34cqh; height: 34cqh; }
}

/* ---------- Affichage sur le pare-brise ---------- */
.glass {
  position: absolute; left: 50%; top: 0; height: 100%; width: min(100cqw, 100vw);
  transform: translate3d(calc(-50% + var(--px) * 5px), calc(var(--py) * 3px), 0);
  pointer-events: none; text-align: center;
}
.glass > * { position: absolute; left: 0; right: 0; }
.logo { top: 11.4cqh; margin-inline: auto; width: var(--logo-w); aspect-ratio: 2345 / 1285; }
.logo img {
  display: block; width: 100%; height: 100%;
  filter: drop-shadow(0 0 22px rgba(255, 140, 50, .35)) drop-shadow(0 6px 18px rgba(0, 0, 0, .6));
}
.count { top: 27.4cqh; display: flex; justify-content: center; gap: clamp(18px, 3.4vw, 62px); }
.unit { display: flex; flex-direction: column; align-items: center; gap: .7cqh; }
.num {
  display: flex; font: 200 var(--digit)/.9 var(--f-display); font-variant-numeric: tabular-nums;
  filter: drop-shadow(0 0 .2em rgba(255, 140, 50, .55)) drop-shadow(0 2px 10px rgba(0, 0, 0, .55));
}
/* Chiffres fins, blanc cassé qui se réchauffe vers le bas. */
.dig {
  display: inline-block; width: .56em; text-align: center;
  color: transparent;
  background: linear-gradient(180deg, var(--bone) 20%, #ffc48a 100%);
  -webkit-background-clip: text; background-clip: text;
}
.lab { color: var(--ash); font-size: clamp(10px, 1.5cqh, 13px); letter-spacing: .34em; text-transform: uppercase; text-indent: .34em; text-shadow: 0 1px 10px #000, 0 0 3px #000; }
.date { top: 43cqh; text-transform: uppercase; }
.date { display: flex; flex-direction: column; align-items: center; gap: .3em; }
.date span { display: none; color: var(--ash); font-size: clamp(10px, 1.45cqh, 13px); letter-spacing: .3em; text-indent: .3em; }
.date strong { font-weight: 700; font-size: clamp(14px, 2.3cqh, 22px); letter-spacing: .2em; text-indent: .2em; text-shadow: 0 2px 14px rgba(0, 0, 0, .8); }
.liftoff {
  top: 25cqh; display: none; flex-direction: column; align-items: center; gap: 1.5cqh;
  font: 200 min(11vw, 13cqh)/.9 var(--f-display); text-transform: uppercase; letter-spacing: .04em;
  color: var(--bone); text-shadow: 0 0 .25em rgba(255, 170, 100, .3);
  padding-inline: var(--edge);
}
.liftoff span { font: 700 clamp(13px, 2.2cqh, 20px)/1.3 var(--f-hud); letter-spacing: .12em; }
.live .count { display: none; }
.live .liftoff { display: flex; }

/* ---------- Habillage ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud__corner { position: absolute; width: 18px; height: 18px; border: 0 solid rgba(246, 241, 231, .4); }
.hud__corner--tl { left: calc(var(--edge) * .5); top: calc(var(--edge) * .5); border-width: 1px 0 0 1px; }
.hud__corner--tr { right: calc(var(--edge) * .5); top: calc(var(--edge) * .5); border-width: 1px 1px 0 0; }
.hud__corner--bl { left: calc(var(--edge) * .5); bottom: calc(var(--edge) * .5); border-width: 0 0 1px 1px; }

.insta {
  position: absolute; right: var(--edge); bottom: max(var(--edge), calc(env(safe-area-inset-bottom, 0px) + 12px));
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%;
  color: var(--bone); border: 1px solid rgba(246, 241, 231, .45); background: rgba(5, 7, 13, .45);
  transition: background-color .25s, border-color .25s, scale .3s var(--ease-out);
}
.insta svg { width: 22px; height: 22px; }
.insta:hover, .insta:focus-visible { background: var(--lava); border-color: var(--lava); scale: 1.08; }
.insta:focus-visible { outline: 2px solid var(--bone); outline-offset: 4px; }

/* ---------- Écran de mise en route ---------- */
.boot { display: none; }
.js .boot {
  position: fixed; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--void); transition: opacity .9s ease, visibility 0s .9s;
}
.boot__label { font-size: 11px; letter-spacing: .5em; text-indent: .5em; text-transform: uppercase; color: var(--ash); }
.boot__bar { width: 160px; height: 2px; background: rgba(246, 241, 231, .15); overflow: hidden; }
.boot__bar span { display: block; width: 40%; height: 100%; background: var(--magma); animation: boot 1.1s ease-in-out infinite; }
@keyframes boot { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
.js.on .boot { opacity: 0; visibility: hidden; }

/* ---------- Téléphone en portrait : image verticale, positions mesurées sur celle-ci ---------- */
@media (max-aspect-ratio: 5/8) {
  :root { --scene-ratio: 9 / 16; --scene-img: url(../assets/pov-tall.webp); --vanish-y: .235; --logo-w: min(56vw, 20cqh); --digit: min(13vw, 7.6cqh); }
  /* Décalage vers la droite pour garder l'écran du bras dans le cadre ; le pare-brise est recentré d'autant. */
  .cockpit { left: calc(50% + 2svh); background: linear-gradient(#0a0a0c, #0a0a0c) top / 100% 4% no-repeat; }
  .glass { left: calc(50% - 2svh); }
  .logo { top: 7.4cqh; }
  .date { top: 21.8cqh; }
  .date span { display: block; } /* sur téléphone l'écran du bras est trop petit pour porter le lieu */
  .count { top: 29.6cqh; gap: 4.4vw; }
  .lab { letter-spacing: .22em; text-indent: .22em; }
}

/* ---------- Animations ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .space, .js .fx, .js .cockpit__img, .js .screen, .js .heat, .js .reflet { opacity: 0; }
  .js .logo, .js .count, .js .date, .js .hud, .js .insta { opacity: 0; }

  .js.on .space { animation: fade 3.5s ease forwards, space-drift 160s ease-in-out infinite alternate; }
  .js.on .fx { animation: fade 3.5s ease forwards; }
  .js.on .heat { animation: fade 4s ease 1s forwards, heat 7s ease-in-out 5s infinite; }
  .js.on .reflet { animation: fade 3s ease 1.6s forwards, heat 7s ease-in-out 5s infinite; }
  .reflet::after { animation: reflet 8s linear 3s infinite; }
  .js.on .cockpit__img { animation: fade 2.6s ease .3s forwards; }
  /* Le regard du pilote flotte très légèrement. */
  .js.on .cockpit { animation: sway 11s ease-in-out infinite; }
  .js.on .screen { animation: power-on 1.6s steps(8, end) 2.4s forwards, screen-glow 6s ease-in-out 4.4s infinite; }
  .js.on .screen--aux { animation-delay: 2.8s, 4.8s; }
  .js.on .screen--wrist { animation-delay: 3.3s, 5.2s; }
  .js.on .logo { animation: settle 2.4s var(--ease-out) 1s forwards; }
  .js.on .count { animation: fade 2s ease 1.6s forwards; }
  .js.on .unit { animation: up 1.8s var(--ease-out) calc(1.6s + var(--n) * .14s) backwards; }
  .js.on .date { animation: fade 2s ease 2.3s forwards; }
  .js.on .hud, .js.on .insta { animation: fade 2s ease 2.8s forwards; }
  .dig.tick { animation: drop .7s var(--ease-out); }

  @keyframes fade { to { opacity: 1; } }
  @keyframes heat { 50% { opacity: .72; } }
  @keyframes reflet { to { transform: translateX(60%); } }
  @keyframes up { from { translate: 0 22px; } }
  @keyframes settle { from { opacity: 0; scale: 1.06; filter: blur(6px); } to { opacity: 1; } }
  @keyframes sway { 50% { translate: .12cqw -.35cqh; rotate: .12deg; } }
  @keyframes power-on { 0% { opacity: 0; } 30% { opacity: .5; } 45% { opacity: .1; } 100% { opacity: 1; } }
  @keyframes screen-glow { 50% { opacity: .86; } }
  @keyframes space-drift { to { scale: 1.14; rotate: 1.2deg; } }
  @keyframes drop { from { opacity: 0; transform: translateY(-.1em); } }
}
