/*
================================================
base.css : reset, elements nus, focus, mouvement reduit
================================================
*/

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }

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

  body {
    min-height: 100dvh;
    line-height: var(--leading-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  img, svg, video, canvas { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button, summary, label[for], select { cursor: pointer; }
  p, h1, h2, h3, h4, h5, h6, li, dd { overflow-wrap: break-word; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  table { border-collapse: collapse; }
  fieldset { border: 0; padding: 0; min-width: 0; }

  /* !important dans la couche la plus basse = gagne sur toutes les autres :
     l'attribut hidden remplace tout style inline de masquage. */
  [hidden] { display: none !important; }
}

@layer base {
  html {
    font-family: var(--font-sans);
    font-size: 100%;
    background: var(--bg);
    color: var(--text);
    scroll-padding-block-start: var(--space-4);
  }

  body {
    font-size: var(--text-base);
    font-optical-sizing: auto;
    font-feature-settings: "calt", "ss01";
    background: var(--bg);
  }

  h1, h2, h3, h4 {
    font-weight: 650;
    line-height: var(--leading-tight);
    letter-spacing: -0.015em;
    text-wrap: balance;
  }
  h1 { font-size: var(--text-2xl); letter-spacing: -0.025em; }
  h2 { font-size: var(--text-xl); }
  h3 { font-size: var(--text-lg); }
  h4 { font-size: var(--text-base); }
  p { text-wrap: pretty; }

  a {
    color: var(--accent-text);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.2em;
    transition: color var(--transition-fast);
  }
  a:hover { color: var(--accent-hover); }

  strong, b { font-weight: 650; }

  code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
  }

  hr {
    border: 0;
    border-block-start: 1px solid var(--line);
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  ::selection {
    background: var(--accent-soft);
    color: var(--text);
  }

  progress { vertical-align: middle; }

  /* Mouvement reduit : plus d'animation ni de transition perceptible */
  @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;
    }
  }

  /* Mode contraste renforce : les bordures ne dependent plus de la couleur */
  @media (forced-colors: active) {
    .bk-card, .bk-panel, .bk-input, .bk-btn { border: 1px solid CanvasText; }
  }
}

/* Transitions entre pages (navigation multi-pages), jamais en mouvement reduit.
   Hors @layer : at-rule de premier niveau. Ignore par les navigateurs qui ne le gerent pas. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.18s; }
}

@layer utilities {
  .bk-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .bk-mono { font-family: var(--font-mono); font-size: 0.92em; }
  .bk-muted { color: var(--text-2); }
  .bk-nowrap { white-space: nowrap; }
  .bk-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
