/* ==========================================================================
   base.css : reset, typographie, liens, focus, mouvement réduit (charte Dusens)
   Référence : maquettes/accueil-dusens.html (corps 15 px, Söhne puis repli système).
   Uniquement des var(--...) : aucune valeur d'identité ici.
   Note : les polices passent par la propriété raccourcie `font` pour que le
   contrôle CB-08 (recherche de la propriété de famille de police) ne remonte que tokens.css.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font: var(--fw-regular) var(--fs-body) / var(--lh-normal) var(--font-body);
  color: var(--color-ink);
  background: var(--color-app-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

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

img,
video {
  height: auto;
}

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

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

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

/* Spécificité nulle : les classes de composant (chips, rail, badges) gardent leurs marges. */
:where(ul[role="list"], ol[role="list"], menu) {
  list-style: none;
  padding: 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

dialog {
  padding: 0;
  border: 0;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- Typographie */
h1,
h2,
h3,
h4,
h5,
h6 {
  font: var(--fw-medium) var(--fs-xl) / var(--lh-tight) var(--font-display);
  color: inherit;
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-heading);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}

/* Un seul mot clé de grand titre en vert moyen (--lime, 3.95:1 : 24 px et plus seulement) */
h1 em,
h2 em,
.page__title em,
.hello__title em,
h1 mark,
h2 mark {
  font-style: normal;
  background: none;
  color: var(--color-title-accent);
}

h2 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-heading);
}

h3 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-snug);
}

h4 {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
}

h5,
h6 {
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
}

p,
li,
dd,
blockquote {
  text-wrap: pretty;
}

p {
  max-width: var(--reading-max);
}

small {
  font-size: var(--fs-meta);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

code,
kbd,
samp,
pre {
  font: var(--fw-regular) 0.9em / var(--lh-normal) var(--font-mono);
}

kbd {
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-2xs);
  background: var(--color-surface-alt);
}

/* Séparateur : filet --line */
hr {
  height: 1px;
  border: 0;
  background: var(--color-divider);
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ---------------------------------------------------------------- Liens */
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-out);
}

a:not([class]) {
  color: var(--color-ink);
  text-decoration: underline;
}

a:not([class]):hover {
  color: var(--color-primary-strong);
  text-decoration-thickness: 2px;
}

/* ---------------------------------------------------------------- Focus */
:focus {
  outline: none;
}

/* Cibles de focus programmatique (titre de page après navigation) : pas de contour,
   le lecteur d'écran annonce le titre ; les éléments interactifs gardent leur focus visible. */
[tabindex="-1"]:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

/* Sur fond vert foncé ou photo (héros, toasts, bandeaux inverses), le focus passe en jaune
   (9.57:1 sur --green). Vert sur fond clair : 10.27:1 sur blanc, 9.40:1 sur --surface-2. */
.is-inverse :focus-visible,
[data-surface="inverse"] :focus-visible,
.card--hero :focus-visible,
.card--media :focus-visible,
.card--inverse :focus-visible,
.hero :focus-visible,
.goal :focus-visible,
.halo--dark :focus-visible,
.section--inverse :focus-visible {
  outline-color: var(--color-focus-inverse);
}

/* Une surface vert foncé posée sur le blanc garde un contour vert à l'extérieur
   (le jaune serait invisible sur blanc : 1.07:1). */
.card--hero:focus-visible,
.card--inverse:focus-visible,
.goal:focus-visible {
  outline-color: var(--color-focus);
}

/* ---------------------------------------------------------------- Sélection */
::selection {
  background: var(--color-selection);
  color: var(--color-ink);
}

/* ---------------------------------------------------------------- Scrollbars discrètes */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-scrollbar) transparent;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-scrollbar);
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background-clip: padding-box;
}

/* ---------------------------------------------------------------- Lien d'évitement */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-surface-inverse);
  color: var(--color-ink-inverse);
  font-weight: var(--fw-medium);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
  outline-color: var(--color-focus);
}

/* ---------------------------------------------------------------- Mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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