/* =============================================================================
   Base — remise à zéro, typographie, primitives de mise en page
   ========================================================================== */

/* ── Remise à zéro ───────────────────────────────────────────────────────── */

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

* { margin: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--paper-tint);
    color: var(--ink-body);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* ── Typographie ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    font-weight: 600;
    text-wrap: balance;
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }

p { text-wrap: pretty; }

a { color: var(--brand-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand); }

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

/* Les durées et distances s'empilent en colonnes : sans chiffres tabulaires,
   les unités dansent d'une ligne à l'autre. */
table, .tabular { font-variant-numeric: tabular-nums; }

/* ── Accessibilité ───────────────────────────────────────────────────────── */

/* Un anneau de focus visible et unique pour tout le site. `:focus-visible`
   plutôt que `:focus` : la souris ne le déclenche pas, le clavier oui. */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Lien d'évitement : premier élément focalisable de la page, invisible tant
   qu'on ne l'atteint pas au clavier. */
.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    transform: translateY(-200%);
    transition: transform var(--duration) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* ── Mise en page ────────────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding: var(--space-6) var(--space-5) var(--space-8);
}
.container-wide { max-width: var(--container-wide); }

/* Empilement vertical régulier — remplace les `margin-bottom` semés à la main
   sur chaque bloc. */
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-5); }

/* Rangée qui passe à la ligne, avec un espacement commun. Remplace la
   vingtaine de `style="display: flex; gap: …"` dispersés dans les templates. */
.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}
.cluster-between { justify-content: space-between; }
.cluster-tight { gap: var(--space-2); }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.page-header p { color: var(--ink-muted); font-size: var(--text-sm); margin-top: var(--space-1); }

/* ── Utilitaires ─────────────────────────────────────────────────────────── */
/* Volontairement peu nombreux : un utilitaire par besoin réellement transverse,
   pas une bibliothèque parallèle au système de composants. */

.text-muted   { color: var(--ink-muted); }
.text-subtle  { color: var(--ink-subtle); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-center  { text-align: center; }
.flex-1       { flex: 1; min-width: 0; }
.flex-2       { flex: 2; min-width: 0; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.full-width   { width: 100%; }

@media (max-width: 640px) {
    .hide-mobile { display: none; }
    .container { padding: var(--space-4) var(--space-3) var(--space-6); }
}
