/* ==========================================================================
   TOINUS — FACTS
   Design system : scénographie visuelle, typographie, rythme, politique de l'image
   Palette / typo / motion issues du brief (v1.0)
   ========================================================================== */

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("../assets/fonts/oswald-300.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/oswald-400.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/oswald-500.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/oswald-600.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/oswald-700.woff2") format("woff2");
}

:root {
  --noir-signal: #0b0b0d;
  --gris-interface: #1b1f24;
  --gris-acier: #38424a;
  --blanc-donnees: #e6e6e6;
  --rouge-alerte: #ff202d;
  --cyan-reseau: #00f0ff;

  --accent: var(--rouge-alerte);

  --font: "Oswald", "Arial Narrow", sans-serif;

  /* Échelle typographique (taille/line-height), en clamp() pour rester
     proportionnelle au brief (128/132 desktop) tout en restant lisible. */
  --fs-title: clamp(2.75rem, 5vw + 2rem, 8rem);
  --lh-title: 1.03;
  --fs-subtitle: clamp(1.5rem, 2.2vw + 1rem, 4.5rem);
  --lh-subtitle: 1.05;
  --fs-section: clamp(1.25rem, 1.4vw + 0.9rem, 2.25rem);
  --lh-section: 1.1;
  --fs-body: 1.125rem;
  --lh-body: 1.35;
  --fs-meta: 0.75rem;
  --lh-meta: 1.35;

  --ease-glitch: cubic-bezier(0.2, 0.9, 0.1, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--noir-signal);
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--blanc-donnees);
  text-transform: uppercase;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(1rem, 2vw, 2.5rem);
}

/* ---- Overlays : grille + scanlines (interface scénique, couches transparentes) ---- */

#grid-overlay,
#scanline-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

#grid-overlay {
  background-image: linear-gradient(var(--gris-interface) 1px, transparent 1px),
    linear-gradient(90deg, var(--gris-interface) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.18;
}

#scanline-overlay {
  background: repeating-linear-gradient(
    0deg,
    rgba(230, 230, 230, 0.06),
    rgba(230, 230, 230, 0.06) 1px,
    transparent 2px,
    transparent 4px
  );
  animation: scan-drift 9s linear infinite;
  mix-blend-mode: overlay;
}

@keyframes scan-drift {
  from {
    background-position-y: 0;
  }
  to {
    background-position-y: 100px;
  }
}

/* ---- HUD (méta / timecode / catégorie) ---- */

.hud {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--gris-acier);
}

.hud-tag {
  font-size: var(--fs-meta);
  line-height: var(--lh-meta);
  letter-spacing: 0.14em;
  color: var(--accent);
  transition: color 0.4s var(--ease-glitch);
}

.hud-tag--right {
  color: var(--gris-acier);
  font-variant-numeric: tabular-nums;
}

.hud--bottom {
  align-items: center;
  gap: 1.5rem;
}

.hud-meta {
  font-size: var(--fs-meta);
  line-height: var(--lh-meta);
  letter-spacing: 0.06em;
  color: var(--gris-acier);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Écran de fact ---- */

.fact-screen {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding-left: clamp(0.5rem, 2vw, 1.5rem);
  border-left: 4px solid var(--accent);
  transition: border-color 0.4s var(--ease-glitch);
}

.fact-stat {
  font-size: var(--fs-title);
  line-height: var(--lh-title);
  font-weight: 600;
  color: var(--blanc-donnees);
  margin: 0;
}

.fact-stat-suffix {
  font-size: var(--fs-subtitle);
  line-height: var(--lh-subtitle);
  font-weight: 400;
  color: var(--accent);
  margin: 0;
  transition: color 0.4s var(--ease-glitch);
}

.fact-text {
  font-size: var(--fs-section);
  line-height: var(--lh-section);
  font-weight: 300;
  color: var(--blanc-donnees);
  max-width: 60ch;
  margin: 0.5em 0 0;
}

/* ---- Ticks de rythme (rythme visuel du brief, 0s -> durée du fact) ---- */

.progress-ticks {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--gris-interface);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

/* ---- Waveform / pulses (cadence liée à la "basse") ---- */

.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  flex: 0 0 auto;
}

.waveform span {
  display: block;
  width: 2px;
  height: 4px;
  background: var(--gris-acier);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    height: 4px;
    background: var(--gris-acier);
  }
  50% {
    height: 16px;
    background: var(--accent);
  }
}

/* ---- Glitch transition contrôlé ---- */

.fact-screen.is-glitching {
  animation: glitch-jitter 260ms steps(6, end);
}

.fact-screen.is-glitching .fact-stat,
.fact-screen.is-glitching .fact-stat-suffix,
.fact-screen.is-glitching .fact-text {
  animation: glitch-split 260ms steps(6, end);
}

@keyframes glitch-jitter {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
  20% {
    transform: translate3d(-6px, 1px, 0);
  }
  40% {
    transform: translate3d(5px, -1px, 0);
    opacity: 0.7;
  }
  60% {
    transform: translate3d(-3px, 0, 0);
    opacity: 0.4;
  }
  80% {
    transform: translate3d(2px, 1px, 0);
    opacity: 0.85;
  }
  100% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
}

@keyframes glitch-split {
  0%,
  100% {
    text-shadow: none;
  }
  30% {
    text-shadow: 2px 0 var(--cyan-reseau), -2px 0 var(--rouge-alerte);
  }
  60% {
    text-shadow: -3px 0 var(--cyan-reseau), 3px 0 var(--rouge-alerte);
  }
}

.reduced-motion #scanline-overlay,
.reduced-motion .waveform span {
  animation: none;
}

@media (max-width: 640px) {
  .fact-text {
    max-width: 100%;
  }
  .hud-meta {
    display: none;
  }
}
