/* ==========================================================================
   CodeGuard Documentation — design system
   Pure CSS. Dark-first with a light theme. Matches the CodeGuard AppSec brand.
   ========================================================================== */

/* ----------------------------------------------------------------- Tokens */
:root {
  /* dark theme (default) */
  --bg:            #080b12;
  --bg-elev:       #0d1220;
  --bg-elev-2:     #131a2a;
  --sidebar-bg:    #0a0e18;
  --code-bg:       #0b101c;

  --border:        rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);

  --text:          #d7deeb;
  --text-strong:   #f6f8fc;
  --text-muted:    #8a97ad;
  --text-faint:    #5c6a82;

  --primary:       #10b981;
  --primary-2:     #34d399;
  --primary-hover: #0ea171;
  --primary-soft:  rgba(16,185,129,.12);
  --primary-line:  rgba(16,185,129,.34);
  --on-primary:    #04140d;

  /* severity / semantic */
  --sev-critical:  #f43f5e;
  --sev-high:      #fb923c;
  --sev-medium:    #fbbf24;
  --sev-low:       #38bdf8;
  --sev-info:      #94a3b8;

  --blue:          #60a5fa;
  --violet:        #a78bfa;

  --radius:        14px;
  --radius-sm:     10px;
  --radius-xs:     7px;

  --shadow:        0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.55);
  --shadow-lg:     0 24px 60px -20px rgba(0,0,0,.7);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo,
          Consolas, "Liberation Mono", monospace;

  --sidebar-w: 288px;
  --toc-w:     220px;
  --content-max: 860px;
  --topbar-h:  60px;
}

:root[data-theme="light"] {
  --bg:            #f4f7fb;
  --bg-elev:       #ffffff;
  --bg-elev-2:     #f7f9fc;
  --sidebar-bg:    #ffffff;
  --code-bg:       #0d1220;   /* keep code blocks dark for contrast */

  --border:        rgba(15,23,42,.09);
  --border-strong: rgba(15,23,42,.16);

  --text:          #33415a;
  --text-strong:   #0f172a;
  --text-muted:    #5f6d83;
  --text-faint:    #8593a8;

  --primary:       #059669;
  --primary-2:     #10b981;
  --primary-hover: #047857;
  --primary-soft:  rgba(5,150,105,.10);
  --primary-line:  rgba(5,150,105,.28);
  --on-primary:    #ffffff;

  --shadow:        0 1px 2px rgba(15,23,42,.06), 0 14px 34px -18px rgba(15,23,42,.22);
  --shadow-lg:     0 24px 60px -24px rgba(15,23,42,.28);
}

/* --------------------------------------------------------------- Base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
::selection { background: var(--primary-soft); }

/* subtle page glow in dark mode */
:root:not([data-theme="light"]) body {
  background-image:
    radial-gradient(900px 500px at 78% -8%, rgba(16,185,129,.10), transparent 60%),
    radial-gradient(700px 500px at -5% 4%, rgba(56,120,255,.07), transparent 55%);
  background-attachment: fixed;
}

/* --------------------------------------------------------------- Layout */
.layout { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: none;                 /* shown on mobile */
  align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
  overflow: hidden;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.brandmark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--primary-2), var(--primary));
  color: var(--on-primary);
  box-shadow: 0 6px 18px -6px rgba(16,185,129,.6);
}
.brandmark svg { width: 19px; height: 19px; }
.brand-name { font-weight: 700; color: var(--text-strong); font-size: 15px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub  { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }

.sidebar__search { padding: 14px 16px 6px; }
.nav-filter {
  width: 100%; padding: 8px 11px; font-size: 13px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-family: inherit;
}
.nav-filter::placeholder { color: var(--text-faint); }
.nav-filter:focus { outline: none; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }

.sidebar__nav { overflow-y: auto; padding: 8px 12px 28px; flex: 1; }
.nav-group { margin-top: 16px; }
.nav-group__label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); padding: 6px 12px;
}
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px; margin: 1px 0;
  border-radius: var(--radius-xs);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--bg-elev); color: var(--text-strong); text-decoration: none; }
.nav-link.is-active {
  background: var(--primary-soft); color: var(--primary-2);
  border-color: var(--primary-line); font-weight: 600;
}
.nav-link .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; flex: none; }
.nav-link.is-active .dot { opacity: 1; }

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.main-grid {
  max-width: calc(var(--content-max) + var(--toc-w) + 96px);
  margin: 0 auto;
  padding: 44px 48px 120px;
  display: grid;
  grid-template-columns: minmax(0,1fr) var(--toc-w);
  gap: 56px;
}
.article { max-width: var(--content-max); min-width: 0; }

/* right rail: on this page */
.toc-wrap { position: relative; }
.toc {
  position: sticky; top: 40px;
  font-size: 13px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}
.toc__title { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.toc a { display: block; color: var(--text-muted); padding: 4px 0; line-height: 1.4; border-left: 2px solid transparent; margin-left: -18px; padding-left: 16px; }
.toc a:hover { color: var(--text-strong); text-decoration: none; }
.toc a.lvl-3 { padding-left: 28px; font-size: 12.5px; }
.toc a.is-active { color: var(--primary-2); border-left-color: var(--primary); font-weight: 600; }

.scrim {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: rgba(4,7,12,.6); backdrop-filter: blur(2px);
}

/* --------------------------------------------------------------- Typography */
.article h1 {
  font-size: 34px; line-height: 1.15; letter-spacing: -.02em;
  color: var(--text-strong); font-weight: 800; margin: 0 0 14px;
}
.article h2 {
  font-size: 23px; line-height: 1.25; letter-spacing: -.015em;
  color: var(--text-strong); font-weight: 700;
  margin: 52px 0 16px; padding-top: 8px;
  scroll-margin-top: 80px;
}
.article h3 {
  font-size: 17.5px; color: var(--text-strong); font-weight: 650; font-weight: 600;
  margin: 32px 0 12px; scroll-margin-top: 80px;
}
.article h2 + h3 { margin-top: 18px; }
.article p { margin: 0 0 16px; }
.article ul, .article ol { margin: 0 0 18px; padding-left: 22px; }
.article li { margin: 6px 0; }
.article li::marker { color: var(--text-faint); }
.article strong { color: var(--text-strong); font-weight: 650; font-weight: 600; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary-2); margin-bottom: 14px;
}
.eyebrow .bar { width: 22px; height: 2px; background: var(--primary); border-radius: 2px; }
.lede { font-size: 18.5px; line-height: 1.6; color: var(--text-muted); margin: 0 0 8px; }

/* anchor link on headings */
.anchor { opacity: 0; margin-left: 8px; color: var(--text-faint); font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

/* --------------------------------------------------------------- Code */
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--primary-soft); color: var(--primary-2);
  padding: .12em .4em; border-radius: 5px;
  border: 1px solid var(--primary-line);
}
pre {
  background: var(--code-bg); color: #e6edf7;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 16px 18px; overflow-x: auto; margin: 0 0 20px;
  font-size: 13.5px; line-height: 1.6;
}
pre code { background: none; border: none; color: inherit; padding: 0; font-size: inherit; }
.kbd {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-elev-2); color: var(--text-strong);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 6px;
}

/* --------------------------------------------------------------- Cards */
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card-grid { display: grid; gap: 16px; margin: 22px 0; }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.feature-card__icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-2);
  border: 1px solid var(--primary-line); margin-bottom: 14px;
}
.feature-card__icon svg { width: 21px; height: 21px; }
.feature-card h3 { margin: 0 0 6px; font-size: 16px; }
.feature-card p { margin: 0; font-size: 14px; color: var(--text-muted); }
.card--link { transition: border-color .15s, transform .15s; display: block; color: inherit; }
.card--link:hover { border-color: var(--primary-line); transform: translateY(-2px); text-decoration: none; }
.card--link .go { color: var(--primary-2); font-weight: 600; font-size: 13.5px; margin-top: 12px; display: inline-flex; gap: 4px; }

/* --------------------------------------------------------------- Callouts */
.callout {
  display: flex; gap: 13px; margin: 22px 0;
  padding: 15px 17px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  font-size: 14.5px;
}
.callout__icon { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.callout__body { min-width: 0; }
.callout__body > :last-child { margin-bottom: 0; }
.callout__title { font-weight: 650; font-weight: 600; color: var(--text-strong); display: block; margin-bottom: 3px; }
.callout.note    { border-left-color: var(--blue); }
.callout.note .callout__icon { color: var(--blue); }
.callout.tip     { border-left-color: var(--primary); }
.callout.tip .callout__icon { color: var(--primary-2); }
.callout.warning { border-left-color: var(--sev-medium); }
.callout.warning .callout__icon { color: var(--sev-medium); }
.callout.danger  { border-left-color: var(--sev-critical); }
.callout.danger .callout__icon { color: var(--sev-critical); }

/* --------------------------------------------------------------- Steps */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 24px 0; }
.steps > li {
  position: relative; padding: 0 0 26px 52px; margin: 0;
}
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-2);
  border: 1px solid var(--primary-line);
  font-weight: 700; font-size: 14px; font-family: var(--mono);
}
.steps > li::after {
  content: ""; position: absolute; left: 15.5px; top: 34px; bottom: 2px;
  width: 1px; background: var(--border-strong);
}
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.steps > li .step-title { font-weight: 650; font-weight: 600; color: var(--text-strong); font-size: 16px; display: block; margin-bottom: 4px; }
.steps > li > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------- Figures */
.figure { margin: 26px 0; }
.figure__frame {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elev-2);
  box-shadow: var(--shadow-lg);
}
.figure__frame img { display: block; width: 100%; }
.figure__bar {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 13px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.figure__bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.figure__bar .url {
  margin-left: 10px; font-size: 12px; color: var(--text-faint); font-family: var(--mono);
}
.figure figcaption { margin-top: 11px; font-size: 13.5px; color: var(--text-muted); text-align: center; }
.figure__placeholder {
  aspect-ratio: 16 / 9; display: grid; place-items: center; gap: 8px;
  color: var(--text-faint); text-align: center; padding: 24px;
}
.figure__placeholder svg { width: 34px; height: 34px; opacity: .5; }
.figure__placeholder .ph-label { font-size: 13px; font-family: var(--mono); }

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 650; font-weight: 600; line-height: 1;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
  background: var(--bg-elev-2);
}
.badge .tick { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.critical { color: var(--sev-critical); border-color: color-mix(in srgb, var(--sev-critical) 40%, transparent); background: color-mix(in srgb, var(--sev-critical) 12%, transparent); }
.badge.high     { color: var(--sev-high);     border-color: color-mix(in srgb, var(--sev-high) 40%, transparent);     background: color-mix(in srgb, var(--sev-high) 12%, transparent); }
.badge.medium   { color: var(--sev-medium);   border-color: color-mix(in srgb, var(--sev-medium) 40%, transparent);   background: color-mix(in srgb, var(--sev-medium) 12%, transparent); }
.badge.low      { color: var(--sev-low);      border-color: color-mix(in srgb, var(--sev-low) 40%, transparent);      background: color-mix(in srgb, var(--sev-low) 12%, transparent); }
.badge.info     { color: var(--sev-info);     border-color: color-mix(in srgb, var(--sev-info) 40%, transparent);     background: color-mix(in srgb, var(--sev-info) 12%, transparent); }
.badge.ok       { color: var(--primary-2);    border-color: var(--primary-line); background: var(--primary-soft); }

.pill { display:inline-block; font-size:12.5px; padding:3px 10px; border-radius:999px; background:var(--bg-elev-2); border:1px solid var(--border); color:var(--text-muted); margin:0 4px 6px 0; }

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
thead th {
  text-align: left; font-weight: 650; font-weight: 600; color: var(--text-strong);
  background: var(--bg-elev); padding: 11px 15px; white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
tbody td { padding: 11px 15px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev); }
td .yes { color: var(--primary-2); font-weight: 600; }
td .no  { color: var(--text-faint); }

/* --------------------------------------------------------------- Page nav (prev/next) */
.page-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); }
.page-nav a {
  display: flex; flex-direction: column; gap: 3px;
  padding: 15px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-strong); background: var(--bg-elev); transition: border-color .15s;
}
.page-nav a:hover { border-color: var(--primary-line); text-decoration: none; }
.page-nav a.next { text-align: right; }
.page-nav .lbl { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.page-nav .ttl { font-weight: 650; font-weight: 600; }

/* --------------------------------------------------------------- Misc content */
.breadcrumb { font-size: 13px; color: var(--text-faint); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 26px; }
.def-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 20px 0; font-size: 14.5px; }
.def-list dt { color: var(--text-strong); font-weight: 600; }
.def-list dd { margin: 0; color: var(--text-muted); }

.theme-toggle, .menu-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover, .menu-btn:hover { color: var(--text-strong); border-color: var(--border-strong); }
.theme-toggle svg, .menu-btn svg { width: 18px; height: 18px; }
.sidebar__foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar__foot .muted { font-size: 12px; color: var(--text-faint); }

/* --------------------------------------------------------------- Responsive */
@media (max-width: 1180px) {
  .main-grid { grid-template-columns: minmax(0,1fr); }
  .toc-wrap { display: none; }
}
@media (max-width: 920px) {
  :root { --sidebar-w: 300px; }
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; }
  .main { margin-left: 0; }
  .main-grid { padding: 28px 22px 100px; }
  .article h1 { font-size: 28px; }
  .card-grid.cols-2, .card-grid.cols-3 { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
}
