/* ========================================
   COMMLOCK — Retro-Futuristic Sci-Fi Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Audiowide&family=Michroma&family=Barlow+Condensed:wght@300;400;500;600;700&family=Share+Tech+Mono&display=swap');

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

:root {
  --bg-dark: #08080a;
  --bg-light: #e8e4dc;
  --bg-accent: #1a1610;
  --text-on-dark: #d8d4cc;
  --text-on-light: #1a1a1a;
  --accent: #d4a574;
  --accent-dim: #8a6a48;
  --muted: #7a7268;
  --font-display: 'Michroma', sans-serif;
  --font-hero: 'Audiowide', sans-serif;
  --font-body: 'Barlow Condensed', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

html {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  font-family: var(--font-body);
  overflow-x: hidden;
}

body {
  background: var(--bg-dark);
}

/* ---- LOADER ---- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-brand {
  font-family: var(--font-hero);
  font-size: 2.4rem;
  letter-spacing: 0.3em;
  color: var(--accent);
}

#loader-bar-wrap {
  width: 200px;
  height: 2px;
  background: rgba(200, 149, 108, 0.15);
  border-radius: 1px;
  overflow: hidden;
}

#loader-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

#loader-percent {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--muted);
}

/* ---- MASQUE HAUT DE PAGE ---- */
/* Bande noire fixe au-dessus du texte (z 90) mais sous le header (z 100) :
   masque la montée du texte derrière le menu/logo. Absent à l'ouverture,
   révélé au scroll par js/app.js. Bas dégradé pour éviter la rupture. */
#top-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 90px;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    #08080a 0%,
    #08080a calc(100% - 35px),
    rgba(8, 8, 10, 0) 100%
  );
}

/* ---- HEADER ---- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.5rem 3vw;
}

.nav-logo,
.lang-switch {
  mix-blend-mode: difference;
}

.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: #fff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 2.5rem;
}

.nav-links a {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.nav-links a:hover {
  opacity: 1;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
}

.lang-btn {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.55);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.3s, border-color 0.3s;
}

.lang-btn:hover {
  opacity: 1;
}

.lang-btn.active {
  opacity: 1;
  background: #fff;
  border-color: #fff;
  color: #000;
}

/* ---- CONTRÔLE SON ---- */

.sound-ctl {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  color: #fff;
}

.sound-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff2f2f;
  box-shadow: 0 0 6px #ff2f2f;
  transition: background 0.25s, box-shadow 0.25s;
}

.sound-ctl.on .sound-dot {
  background: #22e06a;
  box-shadow: 0 0 6px #22e06a;
}

.sound-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

.sound-caret {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1;
}

.sound-mix {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

.sound-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  background: rgba(8, 10, 14, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  min-width: 190px;
}

.sound-panel[hidden] {
  display: none;
}

.sound-fader {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cfd6e0;
}

.sound-fader input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---- HERO ---- */

.hero-standalone {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #000 url('../Comlock-Alpha.jpg') center bottom / 100% auto no-repeat;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.hero-standalone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  animation: scanline-scroll 4s linear infinite;
  z-index: 0;
}

.hero-text {
  display: flex;
  justify-content: center;
  margin-top: 12vh;
  position: relative;
  z-index: 1;
}

.crt-wrapper {
  position: relative;
  display: inline-block;
  animation: crt-power-on 1.2s ease-out forwards;
}

.hero-title-img {
  width: clamp(280px, 50vw, 700px);
  height: auto;
  display: block;
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  animation: scanline-scroll 4s linear infinite;
}

@keyframes crt-power-on {
  0% {
    clip-path: inset(49% 0 49% 0);
    opacity: 0;
    filter: brightness(3);
  }
  30% {
    clip-path: inset(49% 0 49% 0);
    opacity: 1;
    filter: brightness(3);
  }
  50% {
    clip-path: inset(0 0 0 0);
    filter: brightness(2.5);
  }
  70% {
    filter: brightness(1.2);
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes scanline-scroll {
  0% { background-position: 0 0; }
  100% { background-position: 0 40px; }
}

/* Premier ecran de scroll (phase 2) : entree du texte, extinction du hero,
   puis temps de pause avant l'ouverture. Allonger cette hauteur = rester
   plus longtemps sur le texte avant que le Commlock ne s'ouvre. */
.hero-spacer {
  height: 150vh;
}

/* ---- PHASE 2 : TEXTE D'INTRO (porte par .hero-spacer) ---- */

/* Hauteur de scroll de l'ouverture circulaire (phase 3) */
.transition-spacer {
  height: 100vh;
}

/* Retient les blocs de texte hors ecran pendant la transition.
   Reglage du temps mort avant la remontee du premier bloc :
   100vh = le bloc n'entre qu'a la fin de l'ouverture (temps mort marque),
   50vh  = il entre pendant le dernier tiers et devient lisible juste apres,
   0     = il monte des le debut de l'ouverture (reglage actuel). */
.post-transition-spacer {
  height: 0;
}

/* Texte centre plein ecran, au-dessus du hero. Opacite et transform sont
   pilotees en JS (applyIntroAnim) : ne pas les figer ici. */
#intro-text {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8vw;
  opacity: 0;
  pointer-events: none;
}

#intro-text .intro-line {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.2vw, 2.8rem);
  line-height: 1.35;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--text-on-dark);
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.8);
  max-width: 22ch;
}

.hero-standalone .section-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 2rem;
}

.hero-heading {
  font-family: var(--font-hero);
  font-size: clamp(5rem, 14vw, 14rem);
  line-height: 0.9;
  letter-spacing: 0.08em;
  color: var(--text-on-dark);
  margin-bottom: 2rem;
}

.hero-heading span {
  display: inline-block;
}

.hero-tagline {
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1.8;
  color: var(--muted);
  max-width: 520px;
  letter-spacing: 0.04em;
}

.scroll-indicator {
  position: absolute;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--accent-dim);
  animation: pulse-down 2s ease-in-out infinite;
}

.scroll-indicator span {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

@keyframes pulse-down {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(8px); opacity: 1; }
}

/* ---- CANVAS ---- */

.canvas-wrap {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  clip-path: circle(0% at 50% 50%);
  background: var(--bg-dark);
}


#circle-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95), rgba(200,220,255,0.6), transparent 70%);
}

canvas#canvas {
  transform-origin: center center;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- DARK OVERLAY ---- */

#dark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-dark);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

/* ---- MARQUEE ---- */

.marquee-wrap {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100vw;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
}

.marquee-text {
  font-family: var(--font-hero);
  font-size: 12vw;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(200, 149, 108, 0.15);
  white-space: nowrap;
  will-change: transform;
}

/* ---- SCROLL CONTAINER ---- */

#scroll-container {
  position: relative;
  width: 100%;
  z-index: 5;
}

/* ---- SCROLL SECTIONS ---- */

.scroll-section {
  display: flex;
  align-items: center;
  min-height: 60vh;
  padding-top: 10vh;
  padding-bottom: 10vh;
  opacity: 0;
  transform: translateY(60px);
  transition: transform 0.8s ease;
}

.scroll-section.visible {
  transform: translateY(0);
}

.align-left {
  padding-left: 5vw;
  padding-right: 55vw;
  justify-content: flex-start;
}

.align-right {
  padding-left: 55vw;
  padding-right: 5vw;
  justify-content: flex-end;
}

/* Vidéo 280x240 sous le texte, centrée dans le bloc,
   fond noir fondu dans la page */
.section-video {
  position: relative;
  width: 280px;
  height: 240px;
  margin: 4rem auto 0;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.section-video video,
.section-video .section-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Couche de base : image (blocs avec image) */
.section-video .section-image {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Image de repos animée : même nom que l'image, en .mp4 (posée par blocks.js).
   Elle se fond par-dessus l'image une fois la première frame décodée ;
   sans fichier, la couche est retirée et l'image reste. */
.section-video .section-still {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.section-video .section-still.ready {
  opacity: 1;
}

/* Vidéo 1 : couche de base sans image (autoplay), sinon révélée au survol */
.section-video .video-1 {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.section-video.has-image .video-1 {
  opacity: 0;
}

.section-video.has-image:hover .video-1,
.section-video.has-image.audio-playing .video-1 {
  opacity: 1;
}

/* Après une vidéo complète : retour à l'image fixe même si la souris est
   restée sur le cadre (le survol reprend dès qu'elle en ressort) */
.section-video.has-image.rest .video-1 {
  opacity: 0;
}

/* Tactile : phase d'attente avant la voix, la vidéo "wait" N&B est visible */
.section-video.audio-arming .video-1 {
  opacity: 1;
}

/* Vidéo complète (image + voix) : layer au-dessus de tout, version FR */
.section-video .video-full {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.section-video.full-playing .video-full {
  opacity: 1;
}

/* Vidéo 2 en layer par-dessus, révélée au clic (avec le son) */
.section-video .video-hover {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.section-video.audio-playing .video-hover {
  opacity: 1;
}

.align-left .section-inner,
.align-right .section-inner {
  max-width: 35vw;
  background: rgba(8, 8, 10, 0.55);
  padding: 2.5rem 2.5rem;
  border-left: 2px solid rgba(212, 165, 116, 0.2);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(8px);
}

.section-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.section-heading {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 3rem);
  line-height: 1.1;
  color: #ffffff;
  margin-bottom: 1.5rem;
}

.section-heading.hero-glow {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  letter-spacing: -0.02em;
  position: relative;
}

.section-heading.hero-glow em {
  font-style: normal;
  color: #39FF4A;
  text-shadow: 0 0 40px rgba(57,255,74,0.4);
  position: relative;
  display: inline-block;
}

.section-heading.hero-glow em::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.18) 2px,
    rgba(0,0,0,0.18) 4px
  );
  pointer-events: none;
  animation: scanline-scroll 4s linear infinite;
}

.section-body {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.85;
  color: #c8c4bc;
  max-width: 840px;
  letter-spacing: 0.02em;
}

.section-note {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(212, 165, 116, 0.25);
}

/* ---- STATS ---- */

.section-stats {
  justify-content: center;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3rem;
  max-width: 900px;
  width: 90vw;
  background: #2a2a2e;
  padding: 2.5rem 3rem;
  border-radius: 4px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
}

.stat-number {
  font-family: var(--font-hero);
  font-size: clamp(1.8rem, 3.5vw, 3.2rem);
  color: var(--accent);
  line-height: 1;
}

.stat-suffix {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-dim);
}

.stat-label {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #b0aaa0;
  margin-top: 0.5rem;
}

/* ---- CTA ---- */

.cta-button {
  display: inline-block;
  margin-top: 2rem;
  padding: 1rem 2.5rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bg-dark);
  background: var(--text-on-dark);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
}

.cta-button:hover {
  background: #82ade5;
  transform: translateY(-2px);
}

/* ---- ÉCRANS < 1600px : blocs centrés, vidéo sous le texte ---- */

@media (max-width: 1600px) {
  .align-left,
  .align-right {
    padding-left: 6vw;
    padding-right: 6vw;
    justify-content: center;
  }

  .align-left .section-inner,
  .align-right .section-inner {
    max-width: min(90vw, 1080px);
    padding: 2rem 1.5rem;
    background: rgba(8, 8, 10, 0.55);
  }
}

/* ---- MOBILE ---- */

@media (max-width: 768px) {
  #scroll-container {
    height: 600vh;
  }

  .section-heading {
    font-size: 2rem;
  }

  /* Image hero en version portrait, cadrée plein écran */
  .hero-standalone {
    background: #000 url('../Comlock-Alpha-portrait.jpg') center center / cover no-repeat;
  }

  /* Titre descendu d'une demi-hauteur (~44px pour un titre de 280px de large) */
  .hero-text {
    margin-top: calc(12vh + 44px);
  }

  /* Espacement entre blocs réduit */
  .scroll-section {
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Bloc texte opaque et lisible, avec fondu doux vers le fond en bas :
     padding sous la vidéo + dégradé alpha (mask) sur les derniers pixels. */
  .align-left .section-inner,
  .align-right .section-inner {
    background: rgba(8, 8, 10, 1);
    padding-bottom: 12rem;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 6rem), transparent);
  }

  /* Texte plus compact */
  .section-body {
    font-size: 1rem;
    line-height: 1.2;
  }

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

  .nav-links {
    display: none;
  }

  .hero-heading {
    font-size: 4rem;
  }

  .marquee-text {
    font-size: 20vw;
  }
}

/* ---- INDICATEUR DE SCROLL ---- */
/* Icone souris (images/scroll2.png), posee en bas de page :
   image deja blanche, aucun traitement de couleur. Visible par defaut ;
   app.js ne fait que la faire disparaitre quand l'ouverture circulaire sur la
   video commence (le loader, en z-index 9999, la couvre au chargement). */
#scroll-hint {
  position: fixed;
  left: 50%;
  bottom: 80px;
  z-index: 60;
  width: 80px;
  height: auto;
  margin-left: -40px;
  opacity: 0.75;
  pointer-events: none;
  animation: scroll-hint-bounce 1.8s ease-in-out infinite;
}

@keyframes scroll-hint-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  #scroll-hint { animation: none; }
}

@media (max-width: 640px) {
  #scroll-hint { bottom: 56px; }
}
