/* ============================================================
   CYBERENTA · Documentation Integra
   « Encre & sable » · papier chaud, encre profonde, terracotta
   Palette reprise du design-system CyberEntaSITE.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg-primary: #faf8f3;
  --bg-secondary: #f3efe7;
  --bg-tertiary: #f7f3ec;
  --bg-elevated: #fffdfa;

  --surface: #fffdfa;
  --surface-hover: #fbf7f0;
  --surface-active: #f5efe4;

  --border: #e2dbce;
  --border-light: #ece6da;
  --border-strong: #d6ccbb;

  --accent: #b4552e;
  --accent-hover: #9c4626;
  --accent-active: #87391e;
  --accent-light: rgba(180, 85, 46, 0.10);
  --accent-lighter: rgba(180, 85, 46, 0.05);
  --accent-text: #98401f;
  --accent-tint: #f4e2d6;
  --accent-tint-strong: #ecccba;

  --text-primary: #1b1a17;
  --text-secondary: #574f44;
  --text-tertiary: #8c8475;
  --text-inverse: #ffffff;

  --success: #1f7a4d;  --success-bg: rgba(31,122,77,.10);  --success-border: rgba(31,122,77,.22);
  --warning: #b4791b;  --warning-bg: rgba(180,121,27,.12); --warning-border: rgba(180,121,27,.24);
  --danger:  #c0392b;  --danger-bg:  rgba(192,57,43,.10);  --danger-border:  rgba(192,57,43,.22);
  --info:    #2440d6;  --info-bg:    rgba(36,64,214,.08);  --info-border:    rgba(36,64,214,.20);

  --shadow-xs: 0 1px 2px rgba(40,33,22,.05);
  --shadow-sm: 0 2px 8px rgba(40,33,22,.06);
  --shadow-md: 0 10px 30px rgba(40,33,22,.08);
  --shadow-lg: 0 24px 60px rgba(40,33,22,.10);

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 9999px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 288px;
  --topbar-h: 64px;
  --content-max: 860px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

/* Dark mode : encre comme fond, sable comme texte */
html[data-theme="dark"] {
  --bg-primary: #14130f;
  --bg-secondary: #1b1a16;
  --bg-tertiary: #1f1d18;
  --bg-elevated: #211f1a;

  --surface: #1d1b16;
  --surface-hover: #24221c;
  --surface-active: #2a2720;

  --border: #322e26;
  --border-light: #2a2720;
  --border-strong: #423d33;

  --accent: #d9774e;
  --accent-hover: #e08a64;
  --accent-text: #e7a384;
  --accent-light: rgba(217,119,78,.14);
  --accent-lighter: rgba(217,119,78,.07);
  --accent-tint: #3a2a22;
  --accent-tint-strong: #4a3328;

  --text-primary: #f3efe6;
  --text-secondary: #c3bcae;
  --text-tertiary: #8c8475;
  --text-inverse: #14130f;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.34);
  --shadow-md: 0 10px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.5);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  font-family: var(--font);
  font-size: 16px; line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* Ambient grain glow */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 80% -60px, var(--accent-lighter), transparent 60%),
    radial-gradient(700px 480px at 0% 320px, rgba(27,26,23,.025), transparent 55%);
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 200;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; color: var(--text-primary); }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-active));
  color: #fff; box-shadow: var(--shadow-sm);
}
.topbar .brand b { color: var(--accent-text); }
.topbar .brand small { font-weight: 600; color: var(--text-tertiary); font-size: .7rem; padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius-full); }
.topbar .spacer { flex: 1; }
.topbar .search {
  position: relative; width: min(360px, 38vw);
}
.topbar .search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: var(--radius-full);
  background: var(--surface); color: var(--text-primary); font: inherit; font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.topbar .search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.topbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary); }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-secondary); cursor: pointer; transition: all .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--accent-text); border-color: var(--border-strong); }
.menu-btn { display: none; }

/* ── Layout shell ───────────────────────────────────────────── */
.shell { display: flex; padding-top: var(--topbar-h); }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 150;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 14px 60px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 2px solid var(--bg-secondary); }
.nav-group { margin-bottom: 22px; }
.nav-group h4 {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
  color: var(--text-tertiary); padding: 0 12px; margin-bottom: 8px;
}
.nav-group a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: .9rem; font-weight: 500;
  text-decoration: none; transition: all .13s; position: relative;
}
.nav-group a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-group a:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-group a.active {
  background: var(--accent-light); color: var(--accent-text); font-weight: 600;
}
.nav-group a.active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}

/* ── Main / article ─────────────────────────────────────────── */
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; justify-content: center; }
.article { width: 100%; max-width: var(--content-max); padding: 44px 40px 120px; }

.breadcrumb { font-size: .82rem; color: var(--text-tertiary); margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.breadcrumb a { color: var(--text-tertiary); }
.breadcrumb svg { width: 13px; height: 13px; }

.article h1 { font-size: 2.4rem; line-height: 1.12; letter-spacing: -.03em; font-weight: 800; margin-bottom: 12px; }
.article .lead { font-size: 1.16rem; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.6; }
.article h2 {
  font-size: 1.6rem; letter-spacing: -.02em; font-weight: 700; margin: 52px 0 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); scroll-margin-top: 84px;
}
.article h3 { font-size: 1.22rem; font-weight: 700; margin: 34px 0 12px; letter-spacing: -.01em; scroll-margin-top: 84px; }
.article h4 { font-size: 1.02rem; font-weight: 700; margin: 24px 0 8px; }
.article p { margin: 14px 0; color: var(--text-secondary); }
.article strong { color: var(--text-primary); font-weight: 600; }
.article ul, .article ol { margin: 14px 0 14px 4px; padding-left: 22px; color: var(--text-secondary); }
.article li { margin: 7px 0; }
.article li::marker { color: var(--accent); }
.article hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* Inline code */
:not(pre) > code {
  font-family: var(--mono); font-size: .85em;
  background: var(--accent-lighter); color: var(--accent-text);
  padding: .12em .42em; border-radius: 6px; border: 1px solid var(--border-light);
}

/* Code blocks */
pre {
  position: relative; margin: 18px 0; padding: 18px 20px;
  background: #1b1a16; color: #e9e3d6;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  overflow-x: auto; font-family: var(--mono); font-size: .84rem; line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
html[data-theme="dark"] pre { background: #0e0d0a; }
pre code { font-family: inherit; color: inherit; background: none; border: none; padding: 0; }
pre .c-key { color: #e0a06a; } pre .c-str { color: #9ec98b; } pre .c-com { color: #7d7567; font-style: italic; } pre .c-fn { color: #d9774e; }

/* ── Callouts ───────────────────────────────────────────────── */
.callout {
  display: flex; gap: 13px; margin: 22px 0; padding: 15px 18px;
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-md);
  background: var(--surface); font-size: .92rem;
}
.callout svg { width: 19px; height: 19px; flex: none; margin-top: 2px; }
.callout .c-body { color: var(--text-secondary); }
.callout .c-body strong { display: block; color: var(--text-primary); margin-bottom: 2px; }
.callout.note    { border-left-color: var(--info);    background: var(--info-bg); }
.callout.note svg { color: var(--info); }
.callout.tip     { border-left-color: var(--success); background: var(--success-bg); }
.callout.tip svg { color: var(--success); }
.callout.warn    { border-left-color: var(--warning); background: var(--warning-bg); }
.callout.warn svg { color: var(--warning); }
.callout.danger  { border-left-color: var(--danger);  background: var(--danger-bg); }
.callout.danger svg { color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left; padding: 11px 16px; background: var(--bg-tertiary);
  font-weight: 700; color: var(--text-primary); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
td code, th code { white-space: nowrap; }

/* ── Steps ──────────────────────────────────────────────────── */
.steps { counter-reset: step; margin: 22px 0; padding: 0; list-style: none; }
.steps > li {
  position: relative; padding: 2px 0 22px 46px; margin: 0;
  border-left: 2px solid var(--border); margin-left: 15px;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: -16px; top: -2px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: var(--radius-full);
  background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem;
  box-shadow: 0 0 0 4px var(--bg-primary);
}
.steps > li strong { color: var(--text-primary); }

/* ── Cards grid ─────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 24px 0; }
.card {
  display: block; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); text-decoration: none; color: inherit; transition: all .16s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); text-decoration: none; }
.card .ico { width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--accent-light); color: var(--accent-text); margin-bottom: 13px; }
.card .ico svg { width: 21px; height: 21px; }
.card h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 5px; color: var(--text-primary); }
.card p { font-size: .86rem; color: var(--text-tertiary); margin: 0; }

/* ── Badges / pills ─────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: var(--radius-full); font-size: .76rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); }
.pill.core   { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent-tint-strong); }
.pill.ok     { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.pill.beta   { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.pill.route  { font-family: var(--mono); font-weight: 500; }
.kbd { font-family: var(--mono); font-size: .8em; padding: 2px 7px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--bg-tertiary); color: var(--text-primary); }

/* ── Mock UI (faux captures d'écran) ────────────────────────── */
.mock {
  margin: 24px 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-md); background: var(--surface);
}
.mock .bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
.mock .bar .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border-strong); }
.mock .bar .dot:nth-child(1){ background:#e0695c; } .mock .bar .dot:nth-child(2){ background:#e0b34e; } .mock .bar .dot:nth-child(3){ background:#5cb87a; }
.mock .bar .url { margin-left: 10px; font-family: var(--mono); font-size: .76rem; color: var(--text-tertiary); }
.mock .screen { padding: 18px; background: var(--bg-primary); }
.mock-caption { font-size: .82rem; color: var(--text-tertiary); text-align: center; margin: -12px 0 24px; font-style: italic; }

/* faux table inside mock */
.fake-tbl { width: 100%; border-collapse: collapse; font-size: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.fake-tbl th { background: var(--bg-tertiary); text-align: left; padding: 8px 12px; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); border-bottom: 1px solid var(--border); }
.fake-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.fake-tbl tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 9px; border-radius: var(--radius-full); font-size: .72rem; font-weight: 600; }
.tag.green { background: var(--success-bg); color: var(--success); }
.tag.amber { background: var(--warning-bg); color: var(--warning); }
.tag.red { background: var(--danger-bg); color: var(--danger); }
.tag.blue { background: var(--info-bg); color: var(--info); }
.tag.gray { background: var(--bg-tertiary); color: var(--text-tertiary); }

.btn-demo { display: inline-flex; align-items: center; gap: 7px; padding: 7px 15px; border-radius: var(--radius-md); background: var(--accent); color: #fff; font-size: .82rem; font-weight: 600; border: none; }
.btn-demo.ghost { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-strong); }

/* ── KPI tiles (dashboard mock) ─────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.kpi .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); font-weight: 600; }
.kpi .val { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); letter-spacing: -.02em; margin-top: 4px; }
.kpi .delta { font-size: .76rem; font-weight: 600; }
.kpi .delta.up { color: var(--success); } .kpi .delta.down { color: var(--danger); }

/* ── On this page (TOC) ─────────────────────────────────────── */
.toc { position: fixed; top: calc(var(--topbar-h) + 44px); right: max(20px, calc((100vw - var(--sidebar-w) - var(--content-max))/2 - 200px)); width: 190px; font-size: .82rem; display: none; }
@media (min-width: 1340px) { .toc { display: block; } }
.toc h5 { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-tertiary); margin-bottom: 10px; font-weight: 700; }
.toc a { display: block; padding: 4px 0 4px 12px; color: var(--text-tertiary); border-left: 2px solid var(--border); transition: all .13s; }
.toc a:hover, .toc a.active { color: var(--accent-text); border-left-color: var(--accent); text-decoration: none; }

/* ── Pager (prev/next) ──────────────────────────────────────── */
.pager { display: flex; gap: 14px; margin-top: 60px; }
.pager a {
  flex: 1; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); text-decoration: none; transition: all .15s;
}
.pager a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; }
.pager small { color: var(--text-tertiary); font-size: .76rem; }
.pager .t { display: block; font-weight: 700; color: var(--text-primary); margin-top: 3px; }
.pager .next { text-align: right; }

/* ── Hero (index) ───────────────────────────────────────────── */
.hero { padding: 30px 0 10px; }
.hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); background: var(--accent-light); padding: 5px 13px; border-radius: var(--radius-full); border: 1px solid var(--accent-tint-strong); }
.hero h1 { font-size: 3rem; margin: 18px 0 14px; }
.hero .lead { font-size: 1.25rem; max-width: 620px; }

/* ── Diagram helpers ────────────────────────────────────────── */
.diagram { margin: 26px 0; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-tertiary); overflow-x: auto; }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.flow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.flow .node { padding: 10px 16px; border: 1.5px solid var(--accent-tint-strong); border-radius: var(--radius-md); background: var(--surface); font-weight: 600; font-size: .85rem; color: var(--text-primary); text-align: center; box-shadow: var(--shadow-xs); }
.flow .node.alt { border-color: var(--border-strong); background: var(--bg-secondary); }
.flow .arrow { color: var(--accent); font-size: 1.3rem; }

/* ── Definition list ────────────────────────────────────────── */
dl.fields { margin: 18px 0; }
dl.fields dt { font-weight: 700; color: var(--text-primary); margin-top: 14px; font-family: var(--mono); font-size: .88rem; }
dl.fields dt .pill { font-family: var(--font); margin-left: 8px; }
dl.fields dd { margin: 4px 0 0; color: var(--text-secondary); font-size: .92rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.doc-footer { margin-top: 70px; padding-top: 26px; border-top: 1px solid var(--border); font-size: .84rem; color: var(--text-tertiary); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ── Responsive ─────────────────────────────────────────────── */
.backdrop { display: none; }
@media (max-width: 1024px) {
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .sidebar { transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(20,15,8,.4); z-index: 140; }
  .topbar .search { width: auto; flex: 1; }
}
@media (max-width: 640px) {
  .article { padding: 28px 20px 90px; }
  .hero h1, .article h1 { font-size: 2rem; }
  .topbar .brand small { display: none; }
  .pager { flex-direction: column; }
}

/* print */
@media print {
  .topbar, .sidebar, .toc, .pager, .menu-btn { display: none; }
  .main { margin: 0; } .article { max-width: none; padding: 0; }
}
