/* ==========================================================================
   MGXProduction — base.css
   Reset, variables communes, en-tête, pied de page, boutons, utilitaires,
   système de reveal, barre de progression, lightbox et placeholders.
   Chaque page charge base.css + sa feuille propre (home, pmrs, afterlight,
   vitalia) qui redéfinit les variables de thème.
   ========================================================================== */

@view-transition { navigation: auto; }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
/* Les décors et les reveal latéraux ne doivent jamais créer de défilement horizontal */
main, .site-footer { overflow-x: clip; }
img, svg, video, canvas, picture { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 { line-height: 1.15; text-wrap: balance; overflow-wrap: break-word; }
p { text-wrap: pretty; overflow-wrap: break-word; }
[hidden] { display: none !important; }

/* ---------- Variables (accueil par défaut ; chaque page les redéfinit) ----------
   :where() garde une spécificité nulle pour que les feuilles de page gagnent. */
:where(:root) {
  --font-head: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --border: #232836;
  --text: #e9edf5;
  --text-2: #9aa3b5;
  --accent: #2f5bff;          /* boutons pleins (texte blanc) */
  --accent-hover: #2449e6;
  --accent-text: #ffffff;
  --accent-light: #4d7cff;    /* liens, lueurs */
  --accent-2: #22d3ee;        /* dégradés */
  --focus: #8fb0ff;
  --header-bg: rgba(11, 13, 18, .78);
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, .7);
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, .45);
  --progress: linear-gradient(90deg, var(--accent), var(--accent-2));

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 20px;
  --header-h: 64px;
  --hud-h: 0px;
  --container: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Lightbox (habillée par chaque page) */
  --lb-backdrop: rgba(5, 7, 12, .9);
  --lb-text: #e9edf5;
  --lb-btn-bg: rgba(255, 255, 255, .08);
  --lb-btn-bg-hover: rgba(255, 255, 255, .16);
  --lb-btn-border: rgba(255, 255, 255, .16);
  --lb-frame-border: rgba(255, 255, 255, .12);
  --lb-radius: 16px;

  color-scheme: dark;
}
:where(:root[data-theme="light"]) {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #e1e5ee;
  --text: #0e121a;
  --text-2: #556070;
  --accent-light: #2f5bff;
  --accent-2: #0891b2;
  --focus: #2f5bff;
  --header-bg: rgba(246, 247, 251, .82);
  --shadow: 0 18px 40px -22px rgba(16, 24, 40, .28);
  --shadow-sm: 0 2px 8px -3px rgba(16, 24, 40, .18);
  color-scheme: light;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* Aucun style de focus pour la souris, un contour bien visible pour le clavier */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Utilitaires ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .2s var(--ease);
}
.skip-link:focus { transform: none; outline: 3px solid var(--focus); outline-offset: 3px; }

.section {
  position: relative;
  padding-block: clamp(72px, 10vw, 128px);
  scroll-margin-top: 16px;
}
[id] { scroll-margin-top: calc(var(--hud-h) + 16px); }

.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- En-tête ---------- */
.site-header {
  position: fixed;
  top: var(--hud-h);
  left: 0; right: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: transform .35s var(--ease), background-color .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.site-header.is-scrolled {
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.site-header.is-hidden { transform: translateY(calc(-100% - var(--hud-h) - 2px)); }
.site-header:has(:focus-visible),
.site-header.menu-open { transform: none; }

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-right: auto;
  font-family: var(--font-head);
  font-size: 1.125rem;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--text);
  border-radius: 10px;
}
.brand__logo { width: 34px; height: 34px; flex: none; }
.brand__name { font-weight: 400; white-space: nowrap; }
.brand__name strong { font-weight: 700; }

/* Navigation principale (accueil) */
.site-nav__list { display: flex; gap: 4px; }
.site-nav__list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
  font-size: .9375rem;
  text-decoration: none;
  transition: color .2s, background-color .2s;
}
.site-nav__list a:hover { color: var(--text); background: var(--surface-2); }

.header-tools { display: flex; align-items: center; gap: 8px; }

/* Sélecteur de langue FR | EN */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.lang-switch button {
  position: relative;
  isolation: isolate;
  min-width: 44px;
  min-height: 44px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-2);
  transition: color .2s;
}
.lang-switch button::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border-radius: inherit;
  background: transparent;
  transition: background-color .2s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { color: var(--accent-text); }
.lang-switch button[aria-pressed="true"]::before { background: var(--accent); }

/* Bouton thème (soleil / lune) */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background-color .2s, border-color .2s, color .2s, transform .2s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Bouton menu mobile */
.menu-toggle { display: none; }
.menu-toggle__bars { position: relative; width: 18px; height: 12px; }
.menu-toggle__bars span {
  position: absolute; left: 0; right: 0;
  height: 2px; border-radius: 2px;
  background: currentColor;
  transition: transform .25s var(--ease), opacity .2s;
}
.menu-toggle__bars span:nth-child(1) { top: 0; }
.menu-toggle__bars span:nth-child(2) { top: 5px; }
.menu-toggle__bars span:nth-child(3) { top: 10px; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 859px) {
  .menu-toggle { display: inline-grid; }
  .site-nav {
    position: absolute;
    top: 100%; left: 0; right: 0;
  }
  .site-nav__list {
    flex-direction: column;
    gap: 2px;
    margin: 0 var(--gutter);
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .2s ease, transform .25s var(--ease), visibility 0s linear .25s;
  }
  .site-header.menu-open .site-nav__list {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity .2s ease, transform .25s var(--ease), visibility 0s;
  }
  .site-nav__list a { width: 100%; padding: 0 16px; color: var(--text); }
}
/* Petits écrans : nom sur deux lignes (« MGX » / « Production ») pour garder
   les commandes visibles avec des cibles tactiles de 44 px */
@media (max-width: 440px) {
  .site-header__inner { gap: 8px; }
  .header-tools { gap: 6px; }
  .site-header .brand__name {
    display: grid;
    font-size: .8125rem;
    line-height: 1.05;
    letter-spacing: .01em;
  }
  .site-header .brand__name strong { font-size: 1.1875rem; letter-spacing: .02em; }
  .site-header .brand { gap: 8px; }
  .brand__logo { width: 32px; height: 32px; }
  .site-header .back-link { gap: 6px; padding: 0 6px 0 2px; }
  .site-header .back-link__arrow { width: 16px; height: 16px; }
}

/* Bouton retour des pages de projets : « ← MGXProduction » */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-right: auto;
  padding: 0 12px 0 8px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.back-link__arrow { width: 18px; height: 18px; flex: none; transition: transform .2s var(--ease); }
.back-link:hover .back-link__arrow { transform: translateX(-3px); }
.back-link__logo { width: 26px; height: 26px; flex: none; }
.back-link .brand__name { font-size: .9375rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .2s var(--ease), background-color .2s, color .2s, border-color .2s, box-shadow .2s;
}
.btn .icon { width: 1.15em; height: 1.15em; }
.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 10px 26px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0); }
.btn--ghost {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text-2) 45%, var(--border)); transform: translateY(-1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ---------- Placeholder neutre (« Bientôt ») ---------- */
.ph {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-style: italic;
}
.ph::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

/* ---------- Barre de progression du scroll ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  height: 3px;
  pointer-events: none;
}
.scroll-progress__bar {
  display: block;
  height: 100%;
  background: var(--progress);
  transform-origin: 0 50%;
  transform: scaleX(0);
  will-change: transform;
}

/* ---------- Reveal au scroll (vers le bas ET vers le haut) ----------
   Les états cachés n'existent que sous html.js : sans JS tout reste visible.
   .rv-above = l'élément est au-dessus de l'écran → il entrera par le haut. */
html.js [data-reveal] {
  --rv-sign: 1;
  --rv-dy: 28px;
  --rv-x: 0px;
  --rv-s: 1;
  opacity: 0;
  transform: translate3d(var(--rv-x), calc(var(--rv-sign) * var(--rv-dy)), 0) scale(var(--rv-s));
  transition:
    opacity .7s var(--ease-out) var(--rv-delay, 0ms),
    transform .8s var(--ease-out) var(--rv-delay, 0ms);
}
html.js [data-reveal].rv-above { --rv-sign: -1; }
html.js [data-reveal="fade"] { --rv-dy: 10px; }
html.js [data-reveal="zoom"] { --rv-dy: 16px; --rv-s: .94; }
html.js [data-reveal="left"] { --rv-x: -40px; --rv-dy: 14px; }
html.js [data-reveal="right"] { --rv-x: 40px; --rv-dy: 14px; }
html.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Pied de page ---------- */
.site-footer {
  position: relative;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: 56px 28px;
  font-size: .9375rem;
}
.footer-grid {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
}
.footer-brand { display: grid; gap: 12px; justify-items: start; }
.footer-brand p { color: var(--text-2); max-width: 36ch; }
.footer-title {
  margin-bottom: 12px;
  font-family: var(--font-head);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.footer-links { display: grid; gap: 2px; }
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  transition: color .2s;
}
.footer-links a:hover { color: var(--accent-light); text-decoration: underline; text-underline-offset: 4px; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: .875rem;
}
.footer-bottom a { color: var(--text-2); }
.footer-bottom a:hover { color: var(--text); }
.to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  text-decoration: none;
}

/* ---------- Lightbox (composant commun, habillé par chaque page) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 12px clamp(8px, 3vw, 32px) 16px;
  color: var(--lb-text);
  opacity: 0;
  transition: opacity .25s ease;
}
.lightbox.is-open { opacity: 1; }
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--lb-backdrop);
}
.lightbox__top {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lightbox__counter {
  min-width: 64px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: .06em;
}
.lightbox__btn {
  display: inline-grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 999px;
  border: 1px solid var(--lb-btn-border);
  background: var(--lb-btn-bg);
  color: var(--lb-text);
  transition: background-color .2s, transform .2s;
}
.lightbox__btn:hover { background: var(--lb-btn-bg-hover); }
.lightbox__btn svg { width: 22px; height: 22px; }
.lightbox__stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2vw, 24px);
}
.lightbox__figure {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: 12px;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}
.lightbox__frame {
  max-height: 100%;
  min-height: 0;
  display: grid;
  border-radius: var(--lb-radius);
  border: 1px solid var(--lb-frame-border);
  overflow: hidden;
  background: #000;
  transform: scale(.96);
  transition: transform .3s var(--ease-out), opacity .2s ease;
}
.lightbox.is-open .lightbox__frame { transform: none; }
.lightbox__frame.is-switching { opacity: 0; }
.lightbox__img {
  max-width: min(92vw, 1100px);
  max-height: calc(100dvh - 190px);
  width: auto;
  height: auto;
  object-fit: contain;
}
.lightbox__caption {
  max-width: 60ch;
  display: grid;
  gap: 2px;
  text-align: center;
  font-size: .9375rem;
  line-height: 1.45;
}
.lightbox__cap-title { font-weight: 700; }
@media (max-width: 599px) {
  .lightbox__stage { grid-template-columns: minmax(0, 1fr); }
  .lightbox__prev, .lightbox__next {
    position: absolute;
    bottom: -2px;
    z-index: 2;
  }
  .lightbox__prev { left: 0; }
  .lightbox__next { right: 0; }
  .lightbox__figure { padding-bottom: 56px; }
  .lightbox__caption { padding-inline: 56px; }
  .lightbox__img { max-height: calc(100dvh - 210px); }
}
html.is-locked { overflow: hidden; }

/* ---------- Transition douce lors d'un changement de thème ---------- */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
  transition-property: background-color, color, border-color, fill, stroke, box-shadow, outline-color !important;
  transition-duration: .25s !important;
  transition-timing-function: ease !important;
  transition-delay: 0s !important;
}

/* ---------- Affichage différé en anglais (évite le flash du texte FR) ----------
   Ajouté par le script inline du <head> ; retiré par i18n.js.
   Filet de sécurité : la page s'affiche quand même après 1,2 s. */
html.i18n-pending body { opacity: 0; animation: mgx-show 0s linear 1.2s forwards; }
@keyframes mgx-show { to { opacity: 1; } }

/* ---------- Mouvement réduit : tout est visible tout de suite ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  html.js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  [data-parallax] { transform: none !important; }
}
