/* ==========================================================================
   YOUSSEF LABS — DESIGN SYSTEM  (1/3)
   Jetons, reset, typographie, primitives de mise en page, accessibilité.

   Aucune valeur brute (couleur, rayon, durée) ne doit apparaître ailleurs
   que dans ce fichier : tout passe par les custom properties ci-dessous.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. JETONS DE DESIGN
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* — Couleurs de marque — */
  --color-bg: #0d0d0d;
  --color-surface: #141414;
  --color-surface-2: #191919;
  --color-border: #222222;
  --color-border-strong: #303030;
  --color-text: #ffffff;
  --color-text-muted: #888888;
  --color-accent: #1473e6;
  --color-on-accent: #000000;
  --color-input: rgba(0, 0, 0, 0.28);
  --color-input-focus: rgba(0, 0, 0, 0.42);
  --color-soft: rgba(255, 255, 255, 0.03);
  --color-soft-hover: rgba(255, 255, 255, 0.05);
  --color-placeholder: #5c5c5c;
  --color-footer-bg: rgba(13, 13, 13, 0.6);
  --color-glow-neutral: rgba(255, 255, 255, 0.05);

  /* — Déclinaisons d'accent (jamais de rgba() improvisé dans les composants) — */
  --accent-06: rgba(20, 115, 230, 0.06);
  --accent-12: rgba(20, 115, 230, 0.12);
  --accent-24: rgba(20, 115, 230, 0.24);
  --accent-45: rgba(20, 115, 230, 0.45);

  /* — Verre dépoli — */
  --glass-bg: rgba(20, 20, 20, 0.62);
  --glass-bg-strong: rgba(13, 13, 13, 0.86);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-blur: 18px;
  --glass-highlight: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.055) 0%,
    rgba(255, 255, 255, 0) 42%
  );

  /* — Couleurs sémantiques de statut (distinctes de l'accent) — */
  --status-online: #34d17d;
  --status-progress: #ff9f1c;
  --status-soon: #7a7a7a;

  /* — Typographie — */
  --font-sans: "Inter", "Inter var", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: clamp(1.0625rem, 0.35vw + 1rem, 1.1875rem);
  --text-xl: clamp(1.25rem, 0.7vw + 1.1rem, 1.5rem);
  --text-2xl: clamp(1.625rem, 1.4vw + 1.3rem, 2.25rem);
  --text-3xl: clamp(2rem, 2.4vw + 1.45rem, 3.125rem);
  --text-hero: clamp(2.6rem, 6vw + 0.85rem, 5.75rem);

  --leading-tight: 1.04;
  --leading-snug: 1.22;
  --leading-normal: 1.6;
  --leading-relaxed: 1.8;

  --tracking-tight: -0.035em;
  --tracking-snug: -0.02em;
  --tracking-label: 0.16em;

  /* — Espacements (base 4 px) — */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Respiration verticale des sections, fluide et généreuse. */
  --section-gap: clamp(4.5rem, 9vw, 9rem);

  /* — Rayons — */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* — Ombres très douces — */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 14px 34px -20px rgba(0, 0, 0, 0.95);
  --shadow-lg: 0 34px 84px -44px rgba(0, 0, 0, 1);
  --shadow-accent: 0 24px 64px -32px rgba(20, 115, 230, 0.35);

  /* — Mouvement — */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 140ms;
  --duration: 260ms;
  --duration-slow: 640ms;

  /* — Mise en page — */
  --container: 1180px;
  --container-narrow: 760px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --header-height: 72px;

  /* — Profondeur — */
  --z-background: 0;
  --z-base: 1;
  --z-sticky: 50;
  --z-header: 100;
  --z-fab: 200;
  --z-modal: 1000;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-2: #eef2f7;
  --color-border: #dce2ea;
  --color-border-strong: #b8c2cf;
  --color-text: #101114;
  --color-text-muted: #596273;
  --color-on-accent: #ffffff;
  --color-input: rgba(255, 255, 255, 0.82);
  --color-input-focus: #ffffff;
  --color-soft: rgba(16, 17, 20, 0.035);
  --color-soft-hover: rgba(16, 17, 20, 0.06);
  --color-placeholder: #7a8492;
  --color-footer-bg: rgba(245, 247, 251, 0.72);
  --color-glow-neutral: rgba(20, 115, 230, 0.045);
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-bg-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(16, 17, 20, 0.08);
  --glass-highlight: linear-gradient(160deg, rgba(255, 255, 255, 0.8) 0%, transparent 42%);
  --shadow-sm: 0 1px 2px rgba(30, 45, 65, 0.08);
  --shadow-md: 0 14px 34px -20px rgba(30, 45, 65, 0.28);
  --shadow-lg: 0 34px 84px -44px rgba(30, 45, 65, 0.35);
}

/* --------------------------------------------------------------------------
   2. RESET MODERNE
   -------------------------------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Compense le header fixe lors des ancres. */
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
}

body {
  min-height: 100svh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Le fond animé est en position fixe : on isole le contexte d'empilement. */
  isolation: isolate;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

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

ul,
ol {
  list-style: none;
  padding: 0;
}

p,
li,
h1,
h2,
h3,
h4 {
  overflow-wrap: break-word;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHIE
   -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
}
h2 {
  font-size: var(--text-2xl);
}
h3 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-snug);
}
h4 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-snug);
}

p {
  text-wrap: pretty;
}

strong,
b {
  font-weight: 600;
  color: var(--color-text);
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Libellé en capitales : eyebrows, en-têtes de colonnes, statuts. */
.label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Paragraphe d'introduction. */
.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-muted);
  max-width: 62ch;
}

.muted {
  color: var(--color-text-muted);
}

.accent {
  color: var(--color-accent);
}

/* Corps de texte long : jamais plus de ~65 caractères par ligne. */
.prose {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 65ch;
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
}

.prose strong {
  color: var(--color-text);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   4. PRIMITIVES DE MISE EN PAGE
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  position: relative;
  padding-block: var(--section-gap);
}

/* Variante compacte, pour deux sections très liées. */
.section--tight {
  padding-block: clamp(3rem, 6vw, 5.5rem);
}

/* En-tête de section : eyebrow + titre + accroche. */
.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 62ch;
  margin-bottom: var(--space-12);
}

.section-head--center {
  align-items: center;
  text-align: center;
  margin-inline: auto;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent);
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.section-head--center .eyebrow::before {
  display: none;
}

/* Piles et grilles génériques (l'espacement vient du layout, pas des marges). */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.grid {
  display: grid;
  gap: var(--space-5);
}

/* Séparateur horizontal en dégradé (plus doux qu'un trait plein). */
.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--color-border-strong) 22%,
    var(--color-border-strong) 78%,
    transparent
  );
}

/* --------------------------------------------------------------------------
   5. FOND ANIMÉ DISCRET
   Trois halos très diffus + grille technique estompée. Aucun coût de layout :
   uniquement des transformations et des opacités composées par le GPU.
   -------------------------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-background);
  pointer-events: none;
  overflow: hidden;
}

.backdrop__glow {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.backdrop__glow--1 {
  top: -14vmax;
  left: -8vmax;
  background: radial-gradient(circle, var(--accent-12) 0%, transparent 68%);
  animation: drift-a 34s var(--ease-in-out) infinite alternate;
}

.backdrop__glow--2 {
  top: 18vmax;
  right: -16vmax;
  background: radial-gradient(circle, var(--color-glow-neutral) 0%, transparent 70%);
  animation: drift-b 44s var(--ease-in-out) infinite alternate;
}

.backdrop__glow--3 {
  bottom: -22vmax;
  left: 28%;
  background: radial-gradient(circle, var(--accent-06) 0%, transparent 72%);
  animation: drift-c 52s var(--ease-in-out) infinite alternate;
}

/* Grille fine, masquée en fondu vers le bas. */
.backdrop__grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--color-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-border) 1px, transparent 1px);
  background-size: 68px 68px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 0%, transparent 78%);
}

/* Vignettage : ancre le regard au centre de la page. */
.backdrop__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% 40%, transparent 45%, var(--color-bg) 100%);
}

@keyframes drift-a {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(9vmax, 6vmax, 0) scale(1.14);
  }
}

@keyframes drift-b {
  from {
    transform: translate3d(0, 0, 0) scale(1.08);
  }
  to {
    transform: translate3d(-11vmax, 8vmax, 0) scale(1);
  }
}

@keyframes drift-c {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(7vmax, -9vmax, 0) scale(1.2);
  }
}

/* --------------------------------------------------------------------------
   6. RÉVÉLATIONS AU DÉFILEMENT
   L'état masqué n'est appliqué que si JavaScript est actif : sans JS, tout
   le contenu reste lisible (progressive enhancement).
   -------------------------------------------------------------------------- */

.js .reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition: opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* Variantes directionnelles pour les sections alternées. */
.js .reveal--left {
  transform: translate3d(-26px, 0, 0);
}
.js .reveal--right {
  transform: translate3d(26px, 0, 0);
}
.js .reveal--scale {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   7. ACCESSIBILITÉ
   -------------------------------------------------------------------------- */

/* Lien d'évitement : visible dès qu'il reçoit le focus clavier. */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: calc(var(--z-modal) + 1);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--duration) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* Anneau de focus unique et lisible partout. */
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Contenu réservé aux lecteurs d'écran. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

/* Barre de défilement discrète, cohérente avec le thème. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border: 3px solid var(--color-bg);
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
  background: #3d3d3d;
}

/* Icônes Lucide : trait uniforme, taille pilotée par le contexte. */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 1em;
  height: 1em;
}
.icon--lg {
  width: 1.75em;
  height: 1.75em;
}

/* --------------------------------------------------------------------------
   8. PRÉFÉRENCE « MOUVEMENT RÉDUIT »
   Le site reste entièrement fonctionnel, sans aucune animation.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }

  .backdrop__glow {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   9. IMPRESSION
   -------------------------------------------------------------------------- */

@media print {
  .backdrop,
  .site-header,
  .site-footer {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}
