:root {
  --brand: #1A237E;
  --brand-soft: #e8eaf6;
  --bg: #ffffff;
  --bg-alt: #f5f6fa;
  --surface: #ffffff;
  --text: #1b1c22;
  --text-soft: #565a6e;
  --border: #e0e2ec;
  --shadow: 0 1px 2px rgba(16, 18, 32, .06), 0 8px 24px rgba(16, 18, 32, .06);
  --radius: 10px;
  --success: #1b7f3b;
  --info: #1a237e;
  --warning: #a56100;
  --error: #b3261e;
  --forbidden: #5b1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #aab4ff;
    --brand-soft: #23263a;
    --bg: #111219;
    --bg-alt: #171923;
    --surface: #1a1c27;
    --text: #e7e8ef;
    --text-soft: #a5a8bd;
    --border: #2b2e3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --success: #6fd48b;
    --info: #aab4ff;
    --warning: #e8b04b;
    --error: #ff8f85;
    --forbidden: #ff9d9d;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

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

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: .6rem 1rem;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ---------------------------------------------------------------- en-tête */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  /* Repli opaque d'abord : sans color-mix, la barre reste lisible. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.brand__mark {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 8px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 1.15rem;
}
@media (prefers-color-scheme: dark) { .brand__mark { color: #14162a; } }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text small { color: var(--text-soft); font-size: .78rem; }

.menu-toggle {
  display: none;
  border: 1px solid var(--border); background: var(--surface); color: inherit;
  border-radius: 8px; padding: .45rem .8rem; font: inherit; cursor: pointer;
}

/* -------------------------------------------------------------- structure */

.shell {
  display: grid;
  grid-template-columns: minmax(15rem, 17rem) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 3rem);
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem;
}

.sidebar-wrapper { position: sticky; top: 4.6rem; align-self: start; max-height: calc(100vh - 6rem); overflow-y: auto; }

.sidebar { font-size: .93rem; }
.sidebar h2 {
  margin: 1.4rem 0 .4rem;
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar li a {
  display: block; padding: .3rem .6rem; border-radius: 6px;
  color: var(--text); text-decoration: none; border-left: 2px solid transparent;
}
.sidebar li a:hover { background: var(--bg-alt); }
.sidebar li a[aria-current="page"] {
  color: var(--brand); font-weight: 600;
  background: var(--brand-soft); border-left-color: var(--brand);
}

.filters {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .8rem; margin-bottom: 1rem;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
}
.filters__title { margin: 0 0 .4rem; font-size: .78rem; color: var(--text-soft); }
.filter { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.filter input { accent-color: var(--brand); }

.search { position: relative; margin-bottom: .5rem; }
.search input {
  width: 100%; padding: .5rem .7rem; font: inherit;
  color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.search input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.search__results {
  list-style: none; margin: .35rem 0 0; padding: .3rem;
  max-height: 22rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
}
.search__results li a { display: block; padding: .35rem .5rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.search__results li a:hover, .search__results li a:focus { background: var(--brand-soft); }
.search__results small { display: block; color: var(--text-soft); font-size: .78rem; }
.search__empty { padding: .5rem; color: var(--text-soft); }

/* ---------------------------------------------------------------- contenu */

.content { min-width: 0; }

.breadcrumb { margin: 0 0 .3rem; font-size: .85rem; color: var(--text-soft); }
.breadcrumb a { color: var(--text-soft); }

h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); line-height: 1.2; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
.lead { font-size: 1.08rem; color: var(--text-soft); margin: 0 0 1rem; }
.hint { font-size: .9rem; color: var(--text-soft); }

.audiences { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.audience {
  font-size: .75rem; padding: .15rem .55rem; border-radius: 999px;
  background: var(--bg-alt); border: 1px solid var(--border); color: var(--text-soft);
}

.maturity {
  margin: 0 0 1.2rem; padding: .6rem .85rem;
  font-size: .9rem; border-left: 3px solid var(--border);
  background: var(--bg-alt); border-radius: 0 var(--radius) var(--radius) 0;
}
.maturity--stable { border-left-color: var(--success); }
.maturity--beta { border-left-color: var(--warning); }
.maturity--experimental { border-left-color: var(--error); }

.toc { margin: 0 0 2rem; padding: .7rem .9rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); }
.toc summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.toc ul { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .92rem; }
.toc__item--h3 { padding-left: 1rem; }
.toc__item a { text-decoration: none; }
.toc__item a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ prose */

.prose h2 { margin: 2.6rem 0 .8rem; font-size: 1.45rem; line-height: 1.25; letter-spacing: -.01em; }
.prose h3 { margin: 2rem 0 .6rem; font-size: 1.13rem; }
.prose h4 { margin: 1.5rem 0 .5rem; font-size: 1rem; }
.prose h2 + h3 { margin-top: 1rem; }

.anchored .anchor {
  margin-left: .4rem; color: var(--border); text-decoration: none;
  font-weight: 400; opacity: 0; transition: opacity .15s;
}
.anchored:hover .anchor, .anchor:focus { opacity: 1; color: var(--brand); }

.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose li > ul, .prose li > ol { margin: .25rem 0; }

.prose blockquote {
  margin: 1.2rem 0; padding: .1rem 1rem;
  border-left: 3px solid var(--brand); background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-soft);
}

.prose code {
  padding: .1rem .35rem; font-size: .88em; border-radius: 4px;
  background: var(--bg-alt); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.prose pre {
  margin: 1.2rem 0; padding: .9rem 1rem; overflow-x: auto;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
}
.prose pre code { padding: 0; background: none; border: 0; }

/* Une table large défile dans son cadre plutôt que d'élargir la page. */
.prose table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .93rem; }
.prose th, .prose td { padding: .45rem .7rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { background: var(--bg-alt); }

.prose hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--border); }

.external { font-size: .75em; margin-left: .1em; }

/* --------------------------------------------------------------- captures */

.capture { margin: 1.4rem 0 1.8rem; }
.capture img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--surface);
}
.capture a { display: block; }
.capture figcaption { margin-top: .5rem; font-size: .88rem; color: var(--text-soft); }
.capture__placeholder {
  display: grid; place-items: center; gap: .4rem;
  aspect-ratio: 16 / 9; padding: 1rem; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-alt); color: var(--text-soft);
}
.capture__placeholder code { font-size: .85rem; }

/* ------------------------------------------------------------------ index */

.home > .lead { max-width: 48rem; }
.section { margin: 2.5rem 0; }
.section h2 { font-size: 1.3rem; margin: 0 0 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.card {
  display: flex; flex-direction: column; gap: .3rem;
  padding: 1rem 1.1rem; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); }
.card h3 { margin: 0; font-size: 1.02rem; color: var(--brand); }
.card p { margin: 0; font-size: .9rem; color: var(--text-soft); }
.card__maturity { margin-top: .4rem; font-size: .72rem; color: var(--text-soft); }

/* ------------------------------------------------------------------ pager */

.pager { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.pager__link {
  flex: 1 1 12rem; display: flex; flex-direction: column;
  padding: .7rem .9rem; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.pager__link:hover { border-color: var(--brand); }
.pager__link small { color: var(--text-soft); font-size: .78rem; }
.pager__link--next { text-align: right; }

.footer {
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-soft); font-size: .85rem;
}
.footer p { max-width: 55rem; margin: 0 auto; }
/* Mention d'origine du contenu : discrète, mais pas illisible — c'est une
   information que le lecteur doit pouvoir lire, pas des mentions légales enfouies. */
.footer__ai { margin-top: .8rem !important; padding-top: .8rem; border-top: 1px solid var(--border); }

[hidden] { display: none !important; }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 60rem) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: 1rem; }
  .menu-toggle { display: block; }
  .sidebar-wrapper { position: static; max-height: none; overflow: visible; }
  /* Sans JavaScript, l'attribut hidden n'est jamais posé : le sommaire reste
     visible en haut de page plutôt que d'être inaccessible. */
  .sidebar-wrapper[hidden] { display: none !important; }
}

@media print {
  .topbar, .sidebar-wrapper, .pager, .toc, .footer, .skip { display: none !important; }
  .shell { display: block; padding: 0; }
  .capture img { box-shadow: none; }
}
