/* ========================================
   BASE — Reset et styles globaux (police et variables : tokens.css, chargé avant)
   ======================================== */

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-main);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Couche modale ouverte (kley.js, Kley.couche : tiroir de la navbar, modale de recherche,
   visionneuse, feuille du calendrier) : la page ne défile plus dessous */
html.couche-ouverte,
html.couche-ouverte body {
    overflow: hidden;
}

/* Le pied de page reste bas sur les pages courtes ; cible du lien d'évitement, sans contour */
body > main {
    min-height: 60vh;
}

body > main:focus {
    outline: none;
}

/* Ancres (#annulation…) : la cible ne passe pas sous la navbar sticky */
[id] {
    scroll-margin-top: calc(var(--nav-height) + 16px);
}

h1, h2 {
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

h3, h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol {
    list-style: none;
}

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

button {
    -webkit-tap-highlight-color: transparent;
}

/* Focus clavier visible partout ; un clic souris ne dessine pas de contour */
:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

::selection {
    background: var(--color-primary-light);
    color: var(--color-text);
}

/* Utilitaires */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--page-gutter);
}

/* Lisible par les lecteurs d'écran uniquement */
.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;
}

/* Lien d'évitement : hors écran jusqu'au premier Tab */
.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: var(--z-modale);
    padding: 12px 20px;
    border-radius: var(--radius-pill);
    background: var(--color-dark);
    color: var(--color-on-dark);
    font-weight: 700;
    font-size: var(--font-size-sm);
    transform: translateY(-200%);
    transition: transform 0.2s var(--ease);
}

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

/* Mouvement réduit : animations et transitions quasi instantanées */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

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