/* =======================================================
   Guide d'utilisation Manifst
   Même palette que docs/api et docs/integrations, plus un thème sombre
   (prefers-color-scheme). Pages générées par tools/build-guide.php.
   ======================================================= */

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

:root {
  --primary: #6366f1;
  --primary-soft: #eef2ff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --code-bg: #f1f5f9;
  --code-text: #7c3aed;
  --info-bg: #eff6ff;   --info-border: #bfdbfe; --info-text: #1d4ed8;
  --tip-bg: #f0fdf4;    --tip-border: #bbf7d0;  --tip-text: #15803d;
  --warn-bg: #fffbeb;   --warn-border: #fde68a; --warn-text: #92400e;
  --yes: #16a34a;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --top-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #818cf8;
    --primary-soft: rgba(129, 140, 248, .14);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #273449;
    --bg: #0b1220;
    --card: #111a2c;
    --code-bg: #1a2539;
    --code-text: #c4b5fd;
    --info-bg: rgba(59, 130, 246, .12); --info-border: rgba(96, 165, 250, .35); --info-text: #93c5fd;
    --tip-bg: rgba(34, 197, 94, .10);   --tip-border: rgba(74, 222, 128, .30);  --tip-text: #86efac;
    --warn-bg: rgba(245, 158, 11, .10); --warn-border: rgba(251, 191, 36, .32); --warn-text: #fcd34d;
    --yes: #4ade80;
    --shadow: none;
    color-scheme: dark;
  }
}

html { scroll-padding-top: calc(var(--top-h) + 16px); }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ---------- Barre du haut ---------- */
.g-top { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.g-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.g-brand:hover { text-decoration: none; }
.g-brand img { border-radius: 7px; }
.g-brand em { font-style: normal; color: var(--muted); font-weight: 600; }
.g-menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 38px; height: 38px; font-size: 20px; cursor: pointer; }
.g-top-actions { margin-left: auto; display: flex; gap: 8px; }
.g-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; transition: border-color .12s, background .12s; }
.g-btn:hover { text-decoration: none; }
.g-btn-ghost { color: var(--text); border-color: var(--border); }
.g-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
/* Bouton de langue : le même que la landing et la doc API (.btn-ghost.btn-sm). */
.g-btn-lang { min-width: 44px; justify-content: center; letter-spacing: .02em; }
.g-btn-primary { background: var(--primary); color: #fff; }
.g-btn-primary:hover { filter: brightness(1.08); }

/* ---------- Recherche ---------- */
.g-search { position: relative; flex: 1; max-width: 460px; margin-left: 24px; }
.g-search > .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.g-search input { width: 100%; height: 38px; padding: 0 40px 0 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; outline: none; }
.g-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.g-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 600 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; pointer-events: none; }
.g-search input:focus ~ kbd { display: none; }
.g-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 70vh; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(15, 23, 42, .18); padding: 6px; }
.g-search-results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.g-search-results a:hover, .g-search-results a.active { background: var(--primary-soft); text-decoration: none; }
.g-search-results .r-sec { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.g-search-results .r-title { display: block; font-weight: 600; font-size: 14px; }
.g-search-results .r-desc { display: block; font-size: 12.5px; color: var(--muted); }
.g-search-results mark { background: none; color: var(--primary); font-weight: 700; }
.g-search-results .r-empty { padding: 12px; font-size: 13px; color: var(--muted); }

/* ---------- Mise en page ---------- */
.g-layout { display: grid; grid-template-columns: 272px minmax(0, 1fr) 220px; max-width: 1360px; margin: 0 auto; }
.g-nav { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 24px 12px 40px 20px; border-right: 1px solid var(--border); }
.g-nav-home { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.g-nav-section { display: flex; align-items: center; gap: 7px; padding: 16px 10px 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.g-nav-link { display: block; padding: 6px 10px 6px 28px; border-radius: 7px; font-size: 13.5px; color: var(--muted); }
.g-nav-link:hover, .g-nav-home:hover { color: var(--text); background: var(--card); text-decoration: none; }
.g-nav-link.active, .g-nav-home.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }

.g-main { padding: 40px 56px 64px; min-width: 0; }
.g-toc { position: sticky; top: var(--top-h); align-self: start; padding: 40px 20px 20px 0; max-height: calc(100vh - var(--top-h)); overflow-y: auto; }
.g-toc p { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.g-toc a { display: block; padding: 4px 0 4px 12px; border-left: 2px solid var(--border); font-size: 13px; color: var(--muted); line-height: 1.45; }
.g-toc a:hover { color: var(--text); text-decoration: none; }
.g-toc a.active { color: var(--primary); border-left-color: var(--primary); }

/* ---------- Article ---------- */
.g-crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.g-crumbs .bi { font-size: 10px; }
.g-article { max-width: 760px; }
.g-article h1, .g-hero h1 { font-size: 30px; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; margin-bottom: 10px; }
.g-lead { font-size: 16.5px; color: var(--muted); margin-bottom: 24px; max-width: 720px; }
.g-article h2 { font-size: 21px; font-weight: 700; margin: 40px 0 12px; padding-top: 8px; position: relative; }
.g-article h3 { font-size: 16px; font-weight: 700; margin: 28px 0 8px; position: relative; }
.g-article .anchor { position: absolute; left: -22px; color: var(--muted); opacity: 0; font-weight: 400; }
.g-article h2:hover .anchor, .g-article h3:hover .anchor { opacity: 1; text-decoration: none; }
.g-article p, .g-article li { font-size: 15px; line-height: 1.75; }
.g-article p { margin-bottom: 14px; }
.g-article ul, .g-article ol { margin: 0 0 16px 22px; }
.g-article li { margin-bottom: 6px; }
.g-article li > ul, .g-article li > ol { margin-top: 6px; margin-bottom: 4px; }
.g-article strong { font-weight: 650; }
.g-article code { font-family: ui-monospace, 'Cascadia Code', 'Fira Mono', monospace; font-size: .86em; background: var(--code-bg); color: var(--code-text); padding: 2px 6px; border-radius: 5px; }
.g-article pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 16px; }
.g-article pre code { background: none; padding: 0; color: var(--text); }
.g-article figure { margin: 8px 0 22px; }
.g-article figure img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); cursor: zoom-in; display: block; }
.g-article figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Étapes : une liste numérotée est toujours une procédure */
.g-article ol { list-style: none; margin-left: 0; counter-reset: step; }
.g-article ol > li { counter-increment: step; position: relative; padding-left: 38px; margin-bottom: 12px; }
.g-article ol > li::before { content: counter(step); position: absolute; left: 0; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }

/* Encadrés */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; border: 1px solid; margin: 0 0 18px; }
.callout > .bi { font-size: 16px; margin-top: 3px; flex-shrink: 0; }
.callout > div > :last-child { margin-bottom: 0; }
.callout p, .callout li { font-size: 14.5px; }
.callout-title { font-weight: 700; margin-bottom: 4px !important; }
.callout-info { background: var(--info-bg); border-color: var(--info-border); }
.callout-info > .bi, .callout-info .callout-title { color: var(--info-text); }
.callout-tip { background: var(--tip-bg); border-color: var(--tip-border); }
.callout-tip > .bi, .callout-tip .callout-title { color: var(--tip-text); }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.callout-warn > .bi, .callout-warn .callout-title { color: var(--warn-text); }

/* Conditions d'accès */
.conditions { display: grid; gap: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--card); margin: 0 0 28px; overflow: hidden; box-shadow: var(--shadow); }
.conditions > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--border); font-size: 14px; }
.conditions > div:first-child { border-top: none; }
.conditions dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.conditions dd { font-weight: 600; }
.conditions .cond-sub { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.g-article table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.g-article th { text-align: left; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; vertical-align: bottom; }
.g-article td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.g-article tbody tr:last-child td { border-bottom: none; }
.g-article tr:target td { background: var(--primary-soft); }
.matrix th:first-child, .matrix td:first-child, .plans td:first-child { position: sticky; left: 0; background: var(--card); min-width: 150px; }
.matrix thead th:first-child { background: var(--bg); }
.matrix-role { text-align: center !important; text-transform: none !important; letter-spacing: 0 !important; font-size: 11.5px !important; min-width: 62px; padding: 10px 4px !important; line-height: 1.3; }
.matrix td.matrix-cell { padding-left: 4px; padding-right: 4px; }
.matrix-group th { background: var(--bg) !important; color: var(--text) !important; text-transform: none !important; letter-spacing: 0 !important; font-size: 13px !important; font-weight: 700 !important; border-top: 1px solid var(--border); position: sticky; left: 0; }
.matrix-cell { text-align: center; }
.matrix-cell.yes { color: var(--yes); font-size: 16px; }
.matrix-cell.no { color: var(--muted); opacity: .45; }
.plans td:first-child { min-width: 200px; }
.plans th:not(:first-child), .plans td:not(:first-child) { text-align: center; min-width: 120px; }

/* Pied d'article */
.g-foot { max-width: 760px; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.g-pager { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.g-pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-weight: 600; font-size: 14px; }
.g-pager a:hover { border-color: var(--primary); text-decoration: none; }
.g-pager span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.g-pager-next { grid-column: 2; text-align: right; }

/* ---------- Accueil ---------- */
.g-hero { margin-bottom: 32px; }
.g-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.g-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.g-card-head { display: flex; gap: 14px; margin-bottom: 12px; }
.g-card-icon { flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.g-card h2 { font-size: 16px; font-weight: 700; }
.g-card-head p { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.g-card ul { list-style: none; flex: 1; }
.g-card li { border-top: 1px solid var(--border); }
.g-card li a { display: block; padding: 8px 0; font-size: 14px; font-weight: 500; }
.g-card-count { font-size: 12px; color: var(--muted); margin-top: 8px; }
.g-more { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 28px; }
.g-more a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-size: 14px; }
.g-more a:hover { border-color: var(--primary); text-decoration: none; }
.g-more .bi { color: var(--primary); font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-layout { grid-template-columns: 252px minmax(0, 1fr); }
  .g-toc { display: none; }
}
@media (max-width: 860px) {
  :root { --top-h: 56px; }
  .g-top { gap: 10px; padding: 0 16px; }
  .g-menu-btn { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .g-brand span, .g-search kbd { display: none; }
  .g-search { margin-left: 0; }
  .g-btn span { display: none; }
  .g-btn { padding: 8px 10px; }
  .g-layout { display: block; }
  .g-nav { position: fixed; z-index: 25; top: var(--top-h); left: 0; bottom: 0; height: auto; width: min(320px, 86vw); background: var(--bg); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 8px 0 30px rgba(15, 23, 42, .15); }
  body.nav-open .g-nav { transform: none; }
  .g-main { padding: 24px 16px 48px; }
  .g-article h1, .g-hero h1 { font-size: 25px; }
  .g-article .anchor { display: none; }
  .conditions > div { grid-template-columns: 1fr; gap: 2px; }
  .g-pager { grid-template-columns: 1fr; }
  .g-pager-next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) { .g-nav { transition: none; } }
