/* ===================================================================
   MEISTERSTÜCK — MONTBLANC — scrollytelling en 3 actes
   Acte 1 : vidéo du stylo seule (fond épuré clair)
   Acte 2 : plan figé + bulles par pièce
   Acte 3 : sections texte claires sur photo N&B assombrie
   =================================================================== */

:root {
  --bg-light: #f7f4ee;
  --bg-dark: #0c0b09;
  --bg-cave: #0b0c0e; /* noir froid bleuté — letterbox des scènes vidéo */
  --bg-accent: #171310;

  --text-on-light: #16130f;
  --text-on-light-muted: #5c564c;
  --text-on-dark: #f2ece0;
  --text-on-dark-muted: #b3aa9c;

  --gold: #a9824a;
  --gold-bright: #c9a668;
  --hairline-light: rgba(22, 19, 15, 0.14);
  --hairline-dark: rgba(242, 236, 224, 0.16);

  --font-display: 'Fraunces', serif;
  --font-body: 'General Sans', 'Helvetica Neue', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  background: var(--bg-light);
  color: var(--text-on-light);
  font-family: var(--font-body);
  overflow-x: hidden;
  cursor: default;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------
   Loader
   --------------------------------------------------------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
#loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}
.loader-star {
  font-size: 1.6rem;
  color: var(--gold-bright);
}
.loader-brand {
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.5em;
  color: var(--text-on-dark);
  padding-left: 0.5em; /* optical balance for letter-spacing */
}
#loader-bar {
  width: 220px;
  height: 1px;
  background: var(--hairline-dark);
  overflow: hidden;
}
#loader-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--gold-bright);
  transition: width 0.2s ease-out;
}
#loader-percent {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--text-on-dark-muted);
}
#loader-percent::after { content: "%"; }

/* ---------------------------------------------------------------
   Header — masqué à l'Acte 1 (piloté par JS via autoAlpha)
   --------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  padding: 1.6rem 3vw;
  mix-blend-mode: difference;
}
.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #f2ece0;
}
.logo-star { font-size: 1.1rem; }
.logo-text {
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  font-weight: 500;
}
.nav-links {
  display: flex;
  gap: 2.6rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f2ece0;
  position: relative;
  padding-bottom: 2px;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 0%;
  height: 1px;
  background: currentColor;
  transition: width 0.35s ease;
}
.nav-links a:hover::after { width: 100%; }
.nav-cta { opacity: 0.9; }

@media (max-width: 768px) {
  .nav-links { gap: 1.2rem; }
  .nav-links li:not(:last-child) { display: none; }
}

/* ---------------------------------------------------------------
   Acte 3 : photo du Mont Blanc (révélée par JS, léger parallaxe)
   --------------------------------------------------------------- */
.photo-bg {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: url("../assets/mont-blanc.jpg") center / cover no-repeat;
  will-change: transform, opacity;
}

/* Acte 0 : vidéo d'ouverture (montagne → grotte), sous la scène stylo */
.intro-stage {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: var(--bg-cave);
  will-change: opacity;
}
.intro-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Texte d'ouverture sur la montagne (Acte 0) */
.intro-caption {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.6rem;
  padding: 0 6vw;
  pointer-events: none;
  will-change: transform, opacity;
}
.intro-label {
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-on-dark);
  padding-left: 0.42em; /* optical balance for letter-spacing */
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.55);
}
.intro-star { color: var(--gold-bright); }
.intro-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 1.1;
  color: var(--text-on-dark);
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55);
}
.intro-sub {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------
   Acte 1 : scène vidéo
   --------------------------------------------------------------- */
.video-stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg-cave);
  will-change: transform, opacity;
}
.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* le JS bascule sur .canvas-wrap si le scrubbing vidéo rame */
.video-stage.is-hidden-mode { display: none; }

/* Indicateur de scroll : au-dessus de la photo (Acte 0), texte clair */
.scroll-indicator {
  position: fixed;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  z-index: 12;
  pointer-events: none;
}
.scroll-indicator span {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-on-dark);
  opacity: 0.85;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}
.scroll-arrow {
  width: 1px;
  height: 42px;
  background: linear-gradient(to bottom, var(--gold), transparent);
  position: relative;
  overflow: hidden;
}
.scroll-arrow::after {
  content: "";
  position: absolute;
  top: -100%;
  left: 0; right: 0;
  height: 100%;
  background: var(--gold-bright);
  animation: scroll-drip 2.2s ease-in-out infinite;
}
@keyframes scroll-drip {
  0% { top: -100%; }
  60% { top: 100%; }
  100% { top: 100%; }
}

/* ---------------------------------------------------------------
   Fallback canvas (121 frames) — activé par JS si nécessaire
   --------------------------------------------------------------- */
.canvas-wrap {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  background: var(--bg-cave);
}
.canvas-wrap.is-active { display: block; }
#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------------------------------------------------------
   Grille de révélation (transition Acte 2 → 3) — cellules générées
   par JS ; chacune porte un fragment de la montagne (cover viewport)
   et s'ouvre en vague. Transform/opacity uniquement.
   --------------------------------------------------------------- */
#reveal-grid {
  position: fixed;
  inset: 0;
  z-index: 15; /* au-dessus des scènes stylo (10), sous le voile (20) */
  visibility: hidden;
  pointer-events: none;
  will-change: transform;
}
#reveal-grid .reveal-cell {
  position: absolute;
  background-repeat: no-repeat;
  opacity: 0;
}
/* will-change posé uniquement pendant la traversée de la zone */
#reveal-grid.is-animating .reveal-cell {
  will-change: transform, opacity;
}

/* ---------------------------------------------------------------
   Dark overlay — permanent pendant l'Acte 3 (piloté par JS)
   --------------------------------------------------------------- */
#dark-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg-dark);
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------
   Acte 2 : bulles ancrées sur les pièces
   Le point (left/top) est posé par JS en pixels écran ;
   ligne et carte se déploient autour selon data-side.
   --------------------------------------------------------------- */
#bubbles {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  will-change: transform;
}
.bubble {
  position: absolute;
  opacity: 0;
  visibility: hidden;
}
.bubble-dot {
  position: absolute;
  left: -5px; top: -5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(201, 166, 104, 0.25);
  animation: dot-pulse 2.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(201, 166, 104, 0.25); }
  50%      { box-shadow: 0 0 0 9px rgba(201, 166, 104, 0.08); }
}
.bubble-line {
  position: absolute;
  left: 0;
  width: 1px;
  height: 64px;
  background: linear-gradient(to bottom, var(--gold), rgba(169, 130, 74, 0.15));
}
.bubble[data-side="top"] .bubble-line { top: -69px; transform: scaleY(-1); }
.bubble[data-side="bottom"] .bubble-line { top: 5px; }
/* étage 2 : ligne plus longue, carte plus haute — évite le chevauchement
   des cartes voisines quand les pièces sont alignées au sol */
.bubble[data-level="2"] .bubble-line { height: 150px; }
.bubble[data-level="2"][data-side="top"] .bubble-line { top: -155px; }
.bubble[data-level="2"][data-side="top"] .bubble-card { bottom: 160px; }
.bubble-card {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  width: 250px;
  padding: 1rem 1.2rem;
  background: rgba(247, 244, 238, 0.93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--hairline-light);
  box-shadow: 0 18px 44px rgba(12, 11, 9, 0.14);
}
.bubble[data-side="top"] .bubble-card { bottom: 74px; }
.bubble[data-side="bottom"] .bubble-card { top: 74px; }
.bubble-title {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.bubble-card p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-on-light);
}

/* ---------------------------------------------------------------
   Scroll container & sections (Acte 3 — texte clair sur fond sombre)
   --------------------------------------------------------------- */
#scroll-container {
  position: relative;
  height: 1300vh;
  z-index: 40;
}

.scroll-section {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
}
.scroll-section.is-active { pointer-events: auto; }

.section-inner { max-width: 40vw; }

.align-left { padding-left: 8vw; padding-right: 52vw; justify-content: flex-start; }
.align-right { padding-left: 52vw; padding-right: 8vw; justify-content: flex-end; }
.align-left .section-inner, .align-right .section-inner { max-width: 40vw; }

.section-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin-bottom: 1.4rem;
}
.section-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 4.4vw, 4.6rem);
  line-height: 1.05;
  color: var(--text-on-dark);
  margin-bottom: 1.6rem;
}
.section-body {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-on-dark-muted);
  max-width: 34ch;
}
.section-note {
  margin-top: 1.2rem;
  font-size: 0.85rem;
  font-style: italic;
  font-family: var(--font-display);
  color: var(--gold-bright);
}

/* Titre d'ouverture de l'Acte 3 */
.section-title {
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
}
.section-title .section-inner { max-width: 900px; }
.section-title .section-heading {
  font-size: clamp(3.6rem, 9vw, 9.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin-bottom: 1.4rem;
}
.section-title .section-body {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  margin: 0 auto;
  max-width: none;
}

/* Stats */
.section-stats {
  justify-content: center;
  padding: 0 6vw;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4vw;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-number {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 5vw, 5rem);
  font-weight: 400;
  color: var(--text-on-dark);
  line-height: 1;
}
.stat-suffix {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--gold-bright);
  margin-top: 0.3rem;
}
.stat-label {
  margin-top: 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-on-dark-muted);
  max-width: 22ch;
}

/* CTA */
.section-cta {
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
}
.section-cta .section-inner { max-width: 640px; }
.section-cta .section-heading { font-size: clamp(2.6rem, 5vw, 5.5rem); }
.section-cta .section-body { margin: 0 auto; }
.cta-button {
  display: inline-block;
  margin-top: 2.6rem;
  padding: 1.1rem 2.8rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid var(--text-on-dark);
  color: var(--text-on-dark);
  position: relative;
  overflow: hidden;
  transition: color 0.5s ease;
}
.cta-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text-on-dark);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: -1;
}
.cta-button:hover { color: var(--bg-dark); }
.cta-button:hover::before { transform: scaleX(1); }

/* ---------------------------------------------------------------
   Mobile
   --------------------------------------------------------------- */
@media (max-width: 768px) {
  #scroll-container { height: 900vh; }

  /* vidéos en contain : les 4 pièces (et la grotte) restent visibles
     (cover les recadrerait hors champ en portrait). La scène stylo est
     remontée pour ne pas passer sous le rail de bulles de l'Acte 2. */
  .video-stage video,
  .intro-stage video { object-fit: contain; }
  .video-stage video { object-position: center 30%; }

  /* bulles : rail empilé en bas, sans lignes de rappel */
  #bubbles {
    inset: auto 0 4vh 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0 5vw;
  }
  .bubble { position: static; }
  .bubble-dot, .bubble-line { display: none; }
  .bubble-card {
    position: static;
    transform: none;
    width: 100%;
    padding: 0.9rem 1rem;
  }

  .align-left, .align-right {
    padding-left: 7vw;
    padding-right: 7vw;
    justify-content: center;
    text-align: center;
  }
  .align-left .section-inner, .align-right .section-inner {
    max-width: 100%;
  }
  .section-body { margin: 0 auto; max-width: 40ch; }

  .section-heading { font-size: clamp(2rem, 8vw, 2.8rem); }
  .section-title .section-heading { font-size: clamp(3rem, 14vw, 4.6rem); }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem 2rem;
  }

  .site-header { padding: 1.2rem 5vw; }
}

/* ---------------------------------------------------------------
   prefers-reduced-motion : pas de pulsation ; le JS remplace le
   scrubbing par le poster et réduit les animations à des fondus
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .bubble-dot { animation: none; }
  .scroll-arrow::after { animation: none; }
}
