/* Documentation Trame — feuille de style unique, servie depuis le site lui-meme.
   Couleurs alignees sur les tokens produit (tailwind.config.js) :
   accent indigo #5B5FEF, touche chaude #F5833F, navy #07294D, gris Front. */

:root {
  --accent: #5b5fef;
  --accent-hover: #4a4ed6;
  --accent-soft: #eef0fe;
  --warm: #f5833f;
  --navy: #07294d;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #4b5563;
  --tertiary: #475569;
  --surface: #ffffff;
  --surface-alt: #f7f7f8;
  --hair: #ececef;
  --hair-strong: #e2e2e6;
  --radius: 8px;
  --sidebar-w: 17rem;
  --header-h: 3.5rem;
  --content-max: 46rem;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-soft);
  background: var(--surface);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.875rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  color: var(--navy);
  white-space: nowrap;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; color: var(--navy); }
.brand-mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 140%);
  display: inline-block;
  flex: 0 0 auto;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0.4375rem 0.3125rem;
  border-top: 2px solid #fff;
  border-bottom: 2px solid #fff;
}
.brand-name { font-size: 0.9375rem; letter-spacing: -0.01em; }
.brand-sub { color: var(--tertiary); font-weight: 500; }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  border: 1px solid var(--hair-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.nav-toggle svg { width: 1.125rem; height: 1.125rem; }

.search-wrap { position: relative; margin-left: auto; flex: 1 1 auto; max-width: 22rem; min-width: 0; }
.search-input {
  width: 100%;
  height: 2.25rem;
  padding: 0 2rem 0 2.125rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--hair-strong);
  border-radius: var(--radius);
}
.search-input::placeholder { color: var(--tertiary); }
.search-input:focus { background: #fff; border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon {
  position: absolute;
  left: 0.6875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--tertiary);
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--tertiary);
  border: 1px solid var(--hair-strong);
  border-radius: 4px;
  padding: 0 0.25rem;
  background: #fff;
  pointer-events: none;
}
.search-input:focus ~ .search-kbd { display: none; }

.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: min(30rem, calc(100vw - 1.75rem));
  max-height: min(28rem, calc(100vh - 6rem));
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: 12px;
  box-shadow: 0 4px 24px -4px rgb(15 23 42 / 0.16), 0 2px 6px -2px rgb(15 23 42 / 0.08);
  padding: 0.375rem;
  display: none;
}
.search-results[data-open='true'] { display: block; }
.search-hit {
  display: block;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  color: inherit;
}
.search-hit:hover, .search-hit[data-active='true'] { background: var(--accent-soft); text-decoration: none; }
.search-hit-crumb { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tertiary); line-height: 1.4; }
.search-hit-title { display: block; font-size: 0.875rem; font-weight: 600; color: var(--navy); line-height: 1.35; }
.search-hit-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 0.125rem;
}
.search-hit-snippet mark { background: #fdece1; color: var(--ink); border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 0.875rem 0.75rem; font-size: 0.875rem; color: var(--muted); }

/* ----------------------------------------------------------------- layout */

.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: var(--header-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.25rem 0.75rem 3rem;
  border-right: 1px solid var(--hair);
  background: var(--surface-alt);
}
.sidebar-section {
  margin: 1.25rem 0 0.375rem;
  padding: 0 0.625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tertiary);
}
.sidebar-section:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block;
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--ink-soft);
  line-height: 1.4;
}
.sidebar a:hover { background: #f0f0f2; color: var(--ink); text-decoration: none; }
.sidebar a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.sidebar-download { display: inline-flex; align-items: center; gap: 0.3125rem; }
.sidebar-tag {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--tertiary);
  border: 1px solid var(--hair-strong);
  border-radius: 4px;
  padding: 0 0.1875rem;
  background: #fff;
}

.scrim { display: none; }

.main { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; gap: 2rem; padding: 0 1.5rem; }
.content { flex: 1 1 auto; min-width: 0; max-width: var(--content-max); padding: 2rem 0 5rem; }

.toc {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  flex: 0 0 13rem;
  width: 13rem;
  max-height: calc(100vh - var(--header-h) - 4rem);
  overflow-y: auto;
  padding: 2rem 0 2rem;
  display: none;
}
.toc-title { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tertiary); margin-bottom: 0.5rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 0.1875rem 0 0.1875rem 0.625rem; border-left: 2px solid var(--hair); font-size: 0.8125rem; color: var(--muted); line-height: 1.4; }
.toc a:hover { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }
.toc a[data-active='true'] { color: var(--accent); border-left-color: var(--accent); }
.toc .toc-l3 { padding-left: 1.25rem; }

/* -------------------------------------------------------------- typography */

.breadcrumb { font-size: 0.75rem; color: var(--tertiary); margin-bottom: 0.5rem; letter-spacing: 0.01em; }

.content h1, .content h2, .content h3, .content h4 {
  color: var(--navy);
  line-height: 1.25;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--header-h) + 1rem);
  position: relative;
}
.content h1 { font-size: 1.875rem; margin: 0 0 1rem; }
.content h2 { font-size: 1.3125rem; margin: 2.5rem 0 0.75rem; padding-top: 1.25rem; border-top: 1px solid var(--hair); }
.content h3 { font-size: 1.0625rem; margin: 1.75rem 0 0.5rem; }
.content h4 { font-size: 0.9375rem; margin: 1.25rem 0 0.5rem; }

.heading-link {
  margin-left: 0.375rem;
  font-weight: 400;
  color: var(--hair-strong);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.content h1:hover .heading-link,
.content h2:hover .heading-link,
.content h3:hover .heading-link,
.content h4:hover .heading-link { opacity: 1; }
.heading-link:hover { color: var(--accent); text-decoration: none; }
.alias-anchor { position: absolute; top: 0; scroll-margin-top: calc(var(--header-h) + 1rem); }

.content p { margin: 0.875rem 0; }
.content ul, .content ol { margin: 0.875rem 0; padding-left: 1.375rem; }
.content li { margin: 0.3125rem 0; }
.content li::marker { color: var(--tertiary); }
.content hr { border: 0; border-top: 1px solid var(--hair); margin: 2rem 0; }
.content strong { color: var(--ink); font-weight: 650; }

.content blockquote {
  margin: 1.25rem 0;
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  color: var(--ink-soft);
}
.content blockquote > :first-child { margin-top: 0; }
.content blockquote > :last-child { margin-bottom: 0; }
/* `:not(pre) >` : ne jamais repeindre le code d'un bloc cloture imbrique dans une
   citation — sinon fond clair + texte clair, illisible (vu au 768 px). */
.content blockquote :not(pre) > code { background: rgba(255, 255, 255, 0.75); }

.content figure { margin: 1.5rem 0; }
.content img { max-width: 100%; height: auto; display: block; border: 1px solid var(--hair); border-radius: 10px; }

/* --------------------------------------------------------------- code */

.content code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--surface-alt);
  border: 1px solid var(--hair);
  border-radius: 5px;
  padding: 0.0625rem 0.3125rem;
  color: var(--navy);
  /* Les chemins d'API (`POST /v1/conversations/{id}/comment`) depassent la colonne
     de texte sous 800 px : on autorise le retour a la ligne plutot que de pousser
     la page. `break-word` garde le jeton entier tant qu'il tient sur une ligne —
     la coupure agressive (`anywhere`) n'est activee qu'en dessous de 640 px. */
  white-space: normal;
  overflow-wrap: break-word;
}
.content h1 code, .content h2 code, .content h3 code, .content h4 code { font-size: 0.9em; }

.code-block { position: relative; margin: 1.25rem 0; }
.code-block pre {
  margin: 0;
  padding: 0.9375rem 1rem;
  overflow-x: auto;
  background: #0f172a;
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
.code-block code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre;
  background: none;
  border: 0;
  padding: 0;
  color: #e2e8f0;
  tab-size: 2;
}
.code-lang {
  position: absolute;
  top: 0.5rem;
  right: 0.625rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  pointer-events: none;
}

/* -------------------------------------------------------------- tableaux */

.table-wrap {
  margin: 1.25rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hair);
  border-radius: 10px;
}
.content table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.content th, .content td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--hair);
}
.content thead th { background: var(--surface-alt); color: var(--navy); font-weight: 650; white-space: nowrap; }
.content .ta-left { text-align: left; }
.content .ta-center { text-align: center; }
.content .ta-right { text-align: right; }
.content tbody tr:last-child td { border-bottom: 0; }
/* Dans un tableau le conteneur scrolle deja : on garde les jetons insecables. */
.content td code, .content th code { white-space: nowrap; overflow-wrap: normal; }

/* ----------------------------------------------------------- sommaire home */

.summary-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin: 1.25rem 0 0; }
.summary-card { border: 1px solid var(--hair); border-radius: 12px; padding: 1rem 1.125rem; background: var(--surface-alt); }
.summary-card h3 { margin: 0 0 0.5rem; font-size: 0.8125rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--tertiary); }
.summary-card ul { list-style: none; margin: 0; padding: 0; }
.summary-card li { margin: 0.25rem 0; }
.summary-card a { font-size: 0.875rem; }

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

.pager { display: flex; gap: 0.75rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--hair); }
.pager a {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--hair-strong);
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  color: var(--navy);
}
.pager a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.pager .pager-dir { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tertiary); }
.pager .pager-title { font-size: 0.875rem; font-weight: 600; }
.pager .next { text-align: right; }
.pager-gap { flex: 1 1 0; }

.page-foot { margin-top: 1.5rem; font-size: 0.75rem; color: var(--tertiary); }

/* ------------------------------------------------------------------- 404 */

.notfound { padding: 4rem 0; text-align: center; }
.notfound h1 { font-size: 2.25rem; margin-bottom: 0.5rem; }
.notfound p { color: var(--muted); max-width: 30rem; margin-inline: auto; }
.notfound .cta {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
}
.notfound .cta:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }

/* ------------------------------------------------------------ responsive */

@media (min-width: 1180px) {
  .toc { display: block; }
}

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    z-index: 35;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 8px 24px -8px rgb(15 23 42 / 0.25);
    width: min(var(--sidebar-w), 85vw);
    flex-basis: auto;
  }
  body[data-nav='open'] .sidebar { transform: translateX(0); }
  body[data-nav='open'] .scrim {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 34;
    background: rgb(15 23 42 / 0.32);
  }
  .main { padding: 0 1.125rem; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .brand-sub { display: none; }
  .main { padding: 0 1rem; }
  .content { padding: 1.5rem 0 4rem; }
  .content h1 { font-size: 1.5rem; }
  .content h2 { font-size: 1.1875rem; }
  .search-kbd { display: none; }
  .content code { overflow-wrap: anywhere; }
  .pager { flex-direction: column; }
  .pager .next { text-align: left; }
}

@media (max-width: 400px) {
  .topbar { gap: 0.5rem; padding: 0 0.625rem; }
  .brand-name { font-size: 0.875rem; }
  .search-input { font-size: 0.8125rem; padding-left: 1.875rem; }
  .main { padding: 0 0.75rem; }
  .content code { font-size: 0.75em; }
  .code-block code { font-size: 0.75rem; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .heading-link, .scrim { display: none !important; }
  .main { padding: 0; }
}
