/* =========================================================
   Ateban — intro
   Noir #07070A · Crème #F3E9DA · Or soleil #E8A25A
   Chronologie (5 s) :
     0     → 1,2 s   lueur du soleil sur fond noir
     1,2   → 3   s   image en fondu + zoom 1,08 → 1,00 (6 s), brume, poussière
     3     → 4,2 s   logo : tracé + descente de 12 px (1,2 s, cubic-bezier(.16,1,.3,1)), opacité 0 → 1
     3,7 s           impact (le logo est posé à 98 % de sa course) :
                     éclat 40 → 160 px (1,2 s), scène 1,000 → 1,012 (1,8 s),
                     6 à 8 braises (1,5 à 2,5 s), fissure en 0,4 s puis 30 %
     3,8   → 4,6 s   trait + losange
     4,0   → 4,9 s   reflet qui remonte la lance, puis éclat doux sur la pointe
     4,5   → 5   s   bouton « Entrer » + indication de défilement
   Règle : le style de base = état final. Les animations partent
   de l'état initial (fill-mode both). Sans animation → scène finale.
   ========================================================= */

:root {
  --noir: #07070A;
  --creme: #F3E9DA;
  --or: #E8A25A;
  --sun-x: 52%;
  --sun-y: 60%;
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-soft: cubic-bezier(.33, 0, .2, 1);
  --halo: drop-shadow(0 0 3px rgba(232, 162, 90, .55)) drop-shadow(0 0 14px rgba(232, 162, 90, .28));
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--noir);
  color: var(--creme);
  overflow: hidden;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.intro {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ---------- Scène : garde la proportion de l'image et couvre l'écran ---------- */
.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, 178.4vh);
  height: max(100vh, 56.05vw);
  width: max(100vw, 178.4dvh);
  height: max(100dvh, 56.05vw);
  translate: -50% -50%;
  /* Poussée vers la caméra à l'impact ; origine = point de contact (placée par le JS) */
  scale: 1.012;
}
@media (orientation: portrait) {
  .stage {
    width: max(100vw, 56.25vh);
    height: max(100vh, 177.78vw);
    width: max(100vw, 56.25dvh);
    height: max(100dvh, 177.78vw);
  }
}
.stage--front { pointer-events: none; }

.zoom, .reveal, .haze, .dust {
  position: absolute;
  inset: 0;
}

.zoom {
  transform-origin: var(--sun-x) var(--sun-y);
  will-change: transform;
}

.reveal img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lueur du soleil */
.glow {
  position: absolute;
  left: var(--sun-x);
  top: var(--sun-y);
  width: 46%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 214, 160, .95) 0%,
    rgba(232, 162, 90, .75) 14%,
    rgba(232, 162, 90, .28) 38%,
    rgba(180, 90, 40, .08) 58%,
    rgba(7, 7, 10, 0) 72%);
  mix-blend-mode: screen;
  opacity: .12;
  scale: 1.1;
  z-index: 2;
  pointer-events: none;
}
@media (orientation: portrait) {
  .glow { width: 120%; }
}

/* Brume chaude */
.haze { z-index: 3; mix-blend-mode: screen; pointer-events: none; }
.haze span {
  position: absolute;
  border-radius: 50%;
}
.haze__a {
  left: 18%; top: 48%; width: 70%; height: 34%;
  background: radial-gradient(closest-side, rgba(232, 162, 90, .20), rgba(232, 162, 90, 0));
  animation: drift-a 16s ease-in-out infinite alternate;
}
.haze__b {
  left: -10%; top: 74%; width: 120%; height: 22%;
  background: radial-gradient(closest-side, rgba(240, 180, 120, .22), rgba(240, 180, 120, 0));
  animation: drift-b 22s ease-in-out infinite alternate;
}
.haze__c {
  left: 30%; top: 34%; width: 60%; height: 30%;
  background: radial-gradient(closest-side, rgba(232, 140, 80, .10), rgba(232, 140, 80, 0));
  animation: drift-a 26s ease-in-out infinite alternate-reverse;
}
@keyframes drift-a { from { transform: translateX(-4%); } to { transform: translateX(4%); } }
@keyframes drift-b { from { transform: translateX(3%) scaleY(1); } to { transform: translateX(-3%) scaleY(1.15); } }

/* Poussière lumineuse */
.dust { width: 100%; height: 100%; z-index: 4; pointer-events: none; }

/* Assombrissement des bords + ciel pour la lisibilité du logo */
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(7, 7, 10, .5) 0%, rgba(7, 7, 10, 0) 32%),
    linear-gradient(to top, rgba(7, 7, 10, .55) 0%, rgba(7, 7, 10, 0) 22%),
    radial-gradient(ellipse at var(--sun-x) var(--sun-y), rgba(7, 7, 10, 0) 45%, rgba(7, 7, 10, .5) 100%);
}

/* ---------- Logo + trait ---------- */
/* Position par défaut (sans JS) ; le JS place le logo sur la lance */
.brand {
  position: absolute;
  left: 50%;
  top: 10%;
  translate: -50% 0;
  width: clamp(200px, 28vw, 400px);
  color: var(--creme);
}
@media (orientation: portrait) {
  .brand { width: clamp(190px, 58vw, 300px); }
}

.logo {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: var(--halo);
}
.draw { stroke-dasharray: 1; stroke-dashoffset: 0; }

.crack { opacity: .3; }
.crack__line { stroke-dasharray: 1; stroke-dashoffset: 0; }

.rule {
  position: relative;
  width: 140%;
  height: 12px;
  margin: clamp(14px, 2.6vh, 28px) 0 0 -20%;
  filter: var(--halo);
}
.rule svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.rule__line {
  transform-box: fill-box;
  transform-origin: left center;
  opacity: .85;
}
.rule__diamond {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  translate: -50% -50%;
  rotate: 45deg;
  background: var(--noir);
  border: 1px solid var(--creme);
}

/* ---------- Lance au premier plan (calque découpé, aligné sur l'image) ---------- */
/* Boîte de la découpe dans l'original 2912 × 1632 : x 1326 → 1448, y 119 → 472 */
.spear {
  position: absolute;
  left: 45.5357%;
  top: 7.2917%;
  width: 4.2239%;
  height: 21.6912%;
}
@media (orientation: portrait) {
  /* Recadrage mobile : x 1044 → 1962 de l'original */
  .spear { left: 30.7190%; width: 13.3987%; }
}
.spear img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Reflet qui remonte la hampe (placé et orienté par le JS) */
.glint {
  position: absolute;
  width: 2px;
  transform-origin: 50% 0;
  overflow: hidden;
  mix-blend-mode: screen;
  border-radius: 1px;
}
.glint__band {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 24%;
  background: linear-gradient(to bottom,
    rgba(255, 226, 180, 0) 0%,
    rgba(255, 226, 180, .95) 45%,
    rgba(232, 162, 90, .6) 70%,
    rgba(232, 162, 90, 0) 100%);
  transform: translateY(-100%);
}

/* Éclat doux sur la pointe */
.tip-flash {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 244, 226, .85) 0%,
    rgba(255, 214, 160, .45) 16%,
    rgba(232, 162, 90, .16) 38%,
    rgba(232, 162, 90, 0) 68%);
  opacity: 0;
}
.tip-flash::before, .tip-flash::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
}
.tip-flash::before { width: 30px; height: 1px; background: linear-gradient(to right, rgba(255, 236, 205, 0), rgba(255, 236, 205, .55), rgba(255, 236, 205, 0)); }
.tip-flash::after  { width: 1px; height: 30px; background: linear-gradient(to bottom, rgba(255, 236, 205, 0), rgba(255, 236, 205, .55), rgba(255, 236, 205, 0)); }

/* Éclat de l'impact : halo doux de 40 px à 160 px de diamètre */
.impact {
  position: absolute;
  width: 160px;
  height: 160px;
  margin: -80px 0 0 -80px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 246, 232, .95) 0%,
    rgba(255, 228, 190, .7) 9%,
    rgba(232, 162, 90, .42) 24%,
    rgba(232, 162, 90, .14) 46%,
    rgba(232, 162, 90, 0) 70%);
  opacity: 0;
}

/* Braises (créées par le JS) */
.sparks { position: absolute; width: 0; height: 0; }
.spark {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: #FFE6C2;
  box-shadow: 0 0 3px 1px rgba(232, 162, 90, .85), 0 0 9px 2px rgba(232, 162, 90, .35);
  opacity: 0;
}

/* ---------- Bas d'écran ---------- */
.cta {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(18px, 4.5vh, 48px));
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.2vh, 22px);
  z-index: 10;
}


.scroll-hint__track {
  position: relative;
  display: block;
  width: 1px;
  height: 34px;
  background: rgba(243, 233, 218, .22);
  overflow: hidden;
}
.scroll-hint__dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 10px;
  background: var(--creme);
  animation: scroll-dot 2.2s var(--ease-soft) infinite;
}
@keyframes scroll-dot {
  0%   { transform: translateY(-10px); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translateY(34px); opacity: 0; }
}

.skip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  z-index: 20;
  font: inherit;
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: rgba(243, 233, 218, .7);
  background: none;
  border: 0;
  padding: 14px 10px;
  min-height: 44px;
  cursor: pointer;
  transition: color .3s;
  /* état final : caché (l'intro est terminée) */
  opacity: 0;
  visibility: hidden;
}
.skip:hover { color: var(--creme); }
html:not(.js) .skip { display: none; }

/* Téléphone à l'horizontale (hauteur ≤ 480 px) */
@media (orientation: landscape) and (max-height: 480px) {
  .brand { width: clamp(180px, 24vw, 260px); }
  .rule { margin-top: 10px; }
  .cta { bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); gap: 8px; }
  .scroll-hint__track { height: 22px; }
}

/* =========================================================
   Chronologie
   ========================================================= */
.glow           { animation: glow 3s var(--ease-soft) 0s both; }
.zoom           { animation: zoom 6s var(--ease-soft) 1.2s both; }
.reveal,
.spear          { animation: fade-in 1.8s var(--ease-soft) 1.2s both; }
.haze           { animation: fade-in 1.6s var(--ease-soft) 1.6s both; }
.dust           { animation: fade-in 1.4s var(--ease-soft) 1.8s both; }

.stage          { animation: push 1.8s cubic-bezier(.33, 0, .25, 1) 3.7s both; }

.brand__fall    { animation: fall-y 1.2s cubic-bezier(.16, 1, .3, 1) 3s both,
                             fall-o 1.2s cubic-bezier(.4, 0, .6, 1) 3s both; }
.draw           { animation: draw 1s var(--ease-out) calc(3s + var(--d, 0s)) both; }
.dot            { animation: fade-in .6s var(--ease-soft) 3.5s both; }
.impact         { animation: impact 1.2s linear 3.7s both; }
.crack          { animation: crack-glow 1.8s var(--ease-soft) 3.7s both; }
.crack__line    { animation: draw .4s var(--ease-soft) 3.7s both; }

.rule__line     { animation: rule-draw .8s var(--ease-soft) 3.8s both; }
.rule__diamond  { animation: fade-in .4s var(--ease-soft) 4.5s both; }

.glint__band    { animation: glint .9s cubic-bezier(.45, 0, .55, 1) 4s both; }
.tip-flash      { animation: tip-glow .9s var(--ease-soft) 4.82s both; }

.cta            { animation: rise-in .5s var(--ease-out) 4.5s both; }
.skip           { animation: skip-life 5.5s linear 0s both; }

@keyframes glow {
  0%   { opacity: 0;   scale: .55; }
  38%  { opacity: 1;   scale: 1; }
  100% { opacity: .12; scale: 1.1; }
}
@keyframes zoom      { from { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes push      { from { scale: 1; } to { scale: 1.012; } }
@keyframes fall-y    { from { transform: translateY(-12px); } to { transform: none; } }
@keyframes fall-o    { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw      { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
/* 0,15 s d'apparition (12,5 %), puis extension et effacement jusqu'à 1,2 s */
@keyframes impact {
  0%    { opacity: 0;  transform: scale(.25); animation-timing-function: cubic-bezier(.3, 0, .6, 1); }
  12.5% { opacity: .9; transform: scale(.42); animation-timing-function: cubic-bezier(.22, .61, .36, 1); }
  100%  { opacity: 0;  transform: scale(1); }
}
@keyframes tip-glow {
  0%   { opacity: 0;   transform: scale(.5); }
  35%  { opacity: .75; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.15); }
}
/* apparition en 0,4 s, tenue, puis repos à 30 % */
@keyframes crack-glow {
  0%   { opacity: 0; }
  22%  { opacity: .9; }
  45%  { opacity: .9; }
  100% { opacity: .3; }
}
@keyframes rule-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes glint {
  0%   { transform: translateY(420%); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(-100%); opacity: 0; }
}
@keyframes rise-in   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes skip-life {
  0%, 91% { opacity: 1; visibility: visible; }
  100%    { opacity: 0; visibility: hidden; }
}

/* Attente du chargement de l'image avant de lancer la chronologie */
.js .tl { animation-play-state: paused; }
.js.is-ready .tl { animation-play-state: running; }

/* « Passer » : scène finale directe, fondu court */
.is-skipped .tl { animation: none !important; }
.is-skipped .intro { animation: fade-in .5s var(--ease-soft) both; }
.is-skipped .spark { display: none; }

/* Mouvement réduit : aucune animation, scène finale (lance plantée, fissure visible) */
@media (prefers-reduced-motion: reduce) {
  .tl,
  .haze span,
  .scroll-hint__dot { animation: none !important; }
  .scroll-hint__dot { top: 12px; }
}
