/* =========================================
   BASE — Variables, reset, typo
   ========================================= */

:root {
  /* Palette noir & blanc */
  --bg: #ffffff;
  --bg-2: #0a0a0a;
  --ink: #0a0a0a;
  --ink-soft: #6b6b6b;
  --white: #ffffff;
  --accent: #0a0a0a;
  --line: rgba(10, 10, 10, 0.12);

  /* Palette projet Instable (conservée pour les assets) */
  --instable-bg: #f5f5f5;
  --instable-burgundy: #883647;
  --instable-orange: #c66625;

  /* Typo — Stolzl en premier, fallback Inter Tight */
  --font-display: 'Stolzl', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-serif: 'Stolzl', 'Noto Sans SC', Georgia, serif;

  /* Easing cinématiques */
  --ease-slow: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 0.65, 0);

  /* Layout */
  --gutter: clamp(1.25rem, 3vw, 3rem);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Pas d'overflow sur html : sur iPhone, un overflow-x sur html ET body
     casse l'inertie du defilement (un geste rapide se bloquait au lieu de
     filer puis freiner). Le debordement des images des projets est coupe
     a sa source (.project-grid, css/project.css). */
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.4;
  overflow-x: hidden;
}

/* Landing : le hero plein écran est le seul contenu, aucun défilement.
   Verrouillé explicitement pour qu'un arrondi de 100svh ne laisse pas
   apparaître une barre de défilement de quelques pixels. */
body[data-page="home"] {
  height: 100svh;
  overflow: hidden;
}

/* Override fonds selon page */
body[data-page="works"],
body[data-page^="project-"] {
  background: #ffffff;
}

body[data-page="works"] .loader,
body[data-page^="project-"] .loader {
  background: #ffffff;
}

/* About — fond blanc, comme le reste du site */
body[data-page="about"] .loader {
  background: var(--bg);
}

/* Contact — fond blanc */
body[data-page="contact"] .loader {
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea { font-family: inherit; }

/* Accessibilité — pour le H1 caché du hero */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* =========================================
   GRAIN GLOBAL — texture 35mm
   ========================================= */
/* Allege pour l'ordinateur : avant, le calque faisait 4 fois l'ecran et
   bougeait en continu, ce qui obligeait le navigateur a recomposer toute
   la page a chaque image (gros ralentissement sur grand ecran). Il fait
   maintenant la taille de l'ecran et bouge beaucoup moins souvent (un
   saut toutes les ~4 s au lieu de ~0,7 s) : meme texture a l'oeil. */
.grain {
  position: fixed;
  inset: -20px;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 24s steps(6) infinite;
}

@keyframes grain {
  /* Decalages en px, inferieurs au debord de 20 px : jamais de bord visible */
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-13px, 7px); }
  40% { transform: translate(9px, -14px); }
  60% { transform: translate(-6px, 15px); }
  80% { transform: translate(15px, -4px); }
}

/* =========================================
   LOADER — partagé toutes pages
   ========================================= */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.loader__lottie {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.loader.is-done {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0s, visibility 0s;
}

.loader__inner {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.loader__count {
  font-size: clamp(5rem, 18vw, 14rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.loader__label {
  font-size: .75rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.loader__bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--line);
}

.loader__bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
}

/* =========================================
   TYPO UTILITIES — pour les reveals GSAP
   ========================================= */
.split-line {
  display: block;
  overflow: hidden;
}

.split-line__inner {
  display: block;
}

/* Préférences d'accessibilité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
