/*
  privden documentation site.

  Palette, type and spacing follow
  docs/brand/brandbook/brandbook-privden-confirmed.md — the same tokens the
  landing page uses (privden-web/landing/styles.css): about 90% Linen and
  Graphite, Den Red for the one primary action, Mist Blue for links.
  No JavaScript on this site.
*/

:root {
  /* Brand palette (brandbook §6) */
  --linen: #f6f4ee;
  --graphite: #1f2329;
  --den-red: #c23a2b;
  --mist-blue: #6c8db5;
  --sage: #5f7b6b;
  --sand: #c2a27a;
  --stone: #ece9e0;

  /* Derived */
  --bg: var(--linen);
  --ink: var(--graphite);
  --ink-soft: #4a4f56;
  --surface: #ffffff;
  --surface-alt: var(--stone);
  --border: #d8d4c9;
  --link: #4a6f96;

  /* Type scale (brandbook §7) */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo,
    Consolas, monospace;

  --fs-display: 2.25rem;
  --fs-h1: 2rem;
  --fs-h2: 1.5rem;
  --fs-h3: 1.25rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;

  /* Layout */
  --max-w: 1440px;
  --sidebar-w: 250px;
  --toc-w: 200px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --ink: #ece7dd;
    --ink-soft: #b8b2a6;
    --surface: #1b2026;
    --surface-alt: #232a31;
    --border: #2f353d;
    --link: #8fb0d4;
  }
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-alt);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: var(--fs-small);
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 2rem 0 0.6em;
  letter-spacing: -0.01em;
  scroll-margin-top: 5rem;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  margin-top: 0;
}

h2 {
  font-size: var(--fs-h2);
  font-weight: 600;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: var(--fs-h3);
  font-weight: 500;
}

p {
  margin: 0 0 1em;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

li {
  margin-bottom: 0.4em;
}

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

blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 1.25rem;
  border-left: 3px solid var(--mist-blue);
  color: var(--ink-soft);
}

:focus-visible {
  outline: 2px solid var(--den-red);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) 0;
  padding: 0.75rem 1rem;
  z-index: 20;
}

.skip-link:focus {
  left: 0;
}

/* Navigation toggle — a checkbox and a label, no script.
   Wide screens show the sidebar and hide the button; narrow screens show the
   button and hide the sidebar until it is ticked. */
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.nav-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  background: var(--surface);
}

.nav-toggle:focus-visible + .nav-button {
  outline: 2px solid var(--den-red);
  outline-offset: 2px;
}

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

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.75rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand picture {
  display: inline-flex;
}

.brand img {
  width: 132px;
  height: 44px;
}

.site-section {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-soft);
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.site-nav {
  margin-left: auto;
  font-size: var(--fs-small);
}

/* Layout */
.layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 4rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 3rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  font-size: var(--fs-small);
  padding-right: 0.5rem;
}

.nav-group {
  margin-bottom: 1.75rem;
}

.nav-title,
.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
}

.sidebar ul,
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li {
  margin: 0;
}

.sidebar a {
  display: block;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
}

.sidebar a:hover,
.sidebar a:focus-visible {
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
}

.sidebar a.current {
  color: var(--ink);
  font-weight: 500;
  border-left-color: var(--den-red);
  background: var(--surface-alt);
}

/* Content */
.content {
  min-width: 0;
  max-width: 74ch;
}

.content--single {
  margin: 0 auto;
}

.page > h1 {
  margin-bottom: 1.5rem;
}

.page li strong {
  color: var(--ink);
}

/* Table of contents */
.toc {
  position: sticky;
  top: 5.5rem;
  font-size: var(--fs-small);
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
}

.toc li {
  margin: 0.35rem 0;
}

.toc-l3 {
  padding-left: 0.85rem;
}

.toc a {
  color: var(--ink-soft);
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--ink);
}

/* Figures */
figure {
  margin: 1.75rem 0;
}

figure.shot img {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  /* min() keeps the picture at its natural size on wide screens and stops it
     from overflowing on narrow ones. */
  max-width: min(520px, 100%);
}

figure.diagram {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

figure.diagram img {
  margin: 0 auto;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-small);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

thead th {
  background: var(--surface-alt);
  font-weight: 600;
  white-space: nowrap;
}

/* Page navigation */
.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
}

.page-nav .next {
  margin-left: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: var(--fs-small);
}

.site-footer p {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-footer p:first-child {
  padding-top: 1.5rem;
}

.site-footer p:last-child {
  padding-bottom: 2rem;
}

/* Narrow screens: the navigation moves above the text, the contents list goes. */
@media (max-width: 1180px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
    padding-top: 1.5rem;
  }

  .nav-button {
    display: inline-flex;
  }

  .brand img {
    width: 110px;
    height: 37px;
  }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: var(--surface);
  }

  .site-header:has(.nav-toggle:checked) ~ .layout .sidebar {
    display: block;
  }

  .nav-group {
    margin-bottom: 1rem;
  }
}

/* Very narrow screens: the "Documentation" label is redundant — the burger
   button already says "Menu" — and it pushes the header past the edge. */
@media (max-width: 480px) {
  .site-section {
    display: none;
  }

  .header-inner {
    gap: 0.75rem;
  }
}

@media print {
  .site-header,
  .sidebar,
  .toc,
  .page-nav,
  .skip-link {
    display: none;
  }

  .layout {
    display: block;
    padding: 0;
  }
}
