/* ==========================================================================
   HORUS — Base : reset moderne + typographie + a11y
   ========================================================================== */

/* ── @font-face : self-hosted Fraunces + Inter ───────────────────────
   Variable fonts (un seul fichier couvre tous les poids/italiques).
   Lancer `php tools/fetch-fonts.php` après clone pour récupérer les .woff2.
   ==================================================================== */
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-Italic-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/Inter-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── Reset moderne ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; hanging-punctuation: first last; scroll-behavior: smooth; }
/* scroll-behavior smooth désactivé si l'utilisateur préfère réduire le motion */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  /* Filet de sécurité contre tout débordement horizontal résiduel —
     un long mot CJK, une image décoratrice off-canvas, un calc()
     latent ne pourra plus introduire de scroll horizontal sur mobile. */
  overflow-x: clip;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* Fix global du quirk natif <fieldset> : min-width: min-content par défaut
   empêche les enfants flex/grid de respecter leur largeur (items compressés
   en colonne verticale au lieu de remplir le grid-template-columns).
   Cf fix appliqué dans la session du 2026-04-25 sur le picker images admin. */
fieldset { display: block; min-width: 0; max-width: 100%; }

/* ── Hiérarchie typographique ─────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: var(--fw-semi); line-height: var(--lh-tight); letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5, h6 { font-family: var(--font-sans); font-weight: var(--fw-semi); line-height: var(--lh-snug); }

p { line-height: var(--lh-base); }
small { font-size: var(--fs-sm); color: var(--color-muted); }
strong { font-weight: var(--fw-semi); }

/* ── Liens ─────────────────────────────────────────────────────────── */
a {
  color: var(--color-fg);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  transition: color var(--dur-fast) var(--ease-out), text-decoration-thickness var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--color-accent); text-decoration-thickness: 2px; }

/* ── Focus visible ────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── Utilitaires a11y ─────────────────────────────────────────────── */
.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;
}

.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--color-ink); color: var(--color-paper);
  padding: var(--s-3) var(--s-4); z-index: 9999;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ── Layout helpers ──────────────────────────────────────────────── */
.container       { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: var(--container-narrow); }

.stack > * + *   { margin-top: var(--s-4); }
.stack-sm > * + *{ margin-top: var(--s-2); }
.stack-lg > * + *{ margin-top: var(--s-6); }
.stack-xl > * + *{ margin-top: var(--s-8); }

/* ── Utilitaires design (Phase A — texture & profondeur) ───────────
   .text-gradient-display : à POSER EXPLICITEMENT sur un titre qui compte
     particulièrement (règle : max 2-3 par page, jamais sur h3/h4/cards).
   .shadow-cinematic      : ombres layered 3 niveaux (contact + key + ambient).
   .surface-soft          : fond papyrus → sable, pour sections "respiration".
   .surface-paper         : micro-texture papier SVG noise, opacité 5%.
   ──────────────────────────────────────────────────────────────── */
.text-gradient-display {
  background-image: var(--gradient-text-display);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  /* Fallback si background-clip: text indisponible — couleur dégradée non rendue, mais texte reste lisible. */
}
/* Modifier pour titres posés sur fond sombre (hero avec overlay cool, sections section--ink) */
.text-gradient-display--on-dark { background-image: var(--gradient-text-display-on-dark); }
/* Forced colors (Windows High Contrast) — on désactive le gradient pour garder contraste système. */
@media (forced-colors: active) {
  .text-gradient-display {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
}

.shadow-cinematic { box-shadow: var(--shadow-cinematic); }

/* Accents éditoriaux Lapis + Oxide (Phase D) — pour souligner un mot
   dans un lede, un chapô, un édito. Règle d'or : ne jamais combiner les deux
   dans le même composant (cf. docs/design-system.md). */
.accent-lapis { color: var(--color-lapis); }
.accent-oxide { color: var(--color-oxide); }
/* En dark, lapis sur fond encre est en limite de contraste AA (3.2:1).
   On l'éclaircit via color-mix vers le papyrus pour garantir la lisibilité. */
@media (prefers-color-scheme: dark) {
  .accent-lapis { color: color-mix(in oklab, var(--color-lapis) 55%, var(--color-paper)); }
}

/* Focus ring secondaire (lapis) — à poser explicitement sur les éléments
   à caractère info (ex: liens éditoriaux secondaires). Le focus primaire
   reste bronze (cf. base.css :focus-visible). */
.focus-ring-secondary:focus-visible {
  outline-color: var(--focus-ring-secondary);
}

.surface-soft { background: var(--gradient-surface-soft); }

.surface-paper { position: relative; isolation: isolate; }
.surface-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--texture-paper);
  background-size: 160px 160px;
  opacity: .05;
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: -1;
}
@media (prefers-color-scheme: dark) {
  .surface-paper::before { opacity: .08; mix-blend-mode: screen; }
}

/* ── Sélection & divers ──────────────────────────────────────────── */
::selection { background: var(--color-accent); color: var(--color-accent-fg); }

hr { border: 0; height: 1px; background: var(--color-border); margin-block: var(--s-5); }

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
