/* The Privacy Cookbook, site stylesheet.
   No frameworks, no external fonts. System font stacks only.
   Light and dark palettes are drawn from the site mark:
   slate blue-gray, warm tan, paper, and a muted salmon. */

/* ---------- Design tokens ---------- */

:root {
  --bg: #f5f3ee;
  --surface: #fdfcfa;
  --surface-2: #edeae2;
  --ink: #24292f;
  --muted: #5b6570;
  --accent: #3d5a75;
  --accent-strong: #2c4763;
  --tan: #8a7440;
  --salmon: #b3554a;
  --border: #d9d3c6;
  --border-strong: #b9b1a0;
  --code-bg: #edeae2;
  --mark-bg: #f4e8c8;

  --font-body: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-ui: system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;

  --content-width: 46rem;
  --sidebar-width: 17rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --surface: #1d2126;
    --surface-2: #23282e;
    --ink: #d7dbdf;
    --muted: #98a2ac;
    --accent: #8fb0cc;
    --accent-strong: #aecbe3;
    --tan: #c4ac79;
    --salmon: #d98a7e;
    --border: #303740;
    --border-strong: #46505b;
    --code-bg: #23282e;
    --mark-bg: #4a4023;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15181c;
  --surface: #1d2126;
  --surface-2: #23282e;
  --ink: #d7dbdf;
  --muted: #98a2ac;
  --accent: #8fb0cc;
  --accent-strong: #aecbe3;
  --tan: #c4ac79;
  --salmon: #d98a7e;
  --border: #303740;
  --border-strong: #46505b;
  --code-bg: #23282e;
  --mark-bg: #4a4023;
  color-scheme: dark;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-body);
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
}

h1 { font-size: 1.9rem; margin-top: 0; }
h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

/* Heading self-links from markdown-it-anchor */
h2 a, h3 a, h4 a {
  color: inherit;
  text-decoration: none;
}

h2 a:hover, h3 a:hover, h4 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
}

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

mark {
  background: var(--mark-bg);
  color: inherit;
}

/* ---------- Code ---------- */

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.85rem;
}

/* ---------- Tables ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}

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

th {
  background: var(--surface-2);
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

/* ---------- Callouts ---------- */

.callout {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  margin: 1.25rem 0;
}

.callout > :last-child { margin-bottom: 0; }
.callout > .callout__label + * { margin-top: 0.4rem; }

.callout__label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  color: var(--accent);
}

.callout--tip { border-left-color: var(--tan); }
.callout--tip .callout__label { color: var(--tan); }

.callout--warning { border-left-color: var(--tan); }
.callout--warning .callout__label { color: var(--tan); }
.callout--warning .callout__label::before { content: "⚠ "; }

.callout--danger { border-left-color: var(--salmon); }
.callout--danger .callout__label { color: var(--salmon); }

/* ---------- Layout ---------- */

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-ui);
}

.site-header__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
  min-width: 0;
}

.brand__name {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.header-link {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0.1rem;
}

.header-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.theme-toggle {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
}

.layout {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.main {
  padding: 1.5rem 0 3rem;
  min-width: 0;
}

/* ---------- Sidebar navigation ---------- */

.sidebar {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
}

.sidebar__sections {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar__section + .sidebar__section {
  margin-top: 0.25rem;
}

.sidebar__section summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.35rem 0.4rem 0.35rem 1.3rem;
  border-radius: 4px;
  list-style: none;
  position: relative;
}

.sidebar__section summary::-webkit-details-marker {
  display: none;
}

.sidebar__section summary::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 50%;
  translate: 0 -50%;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: rotate 0.15s ease;
}

.sidebar__section details[open] > summary::before {
  rotate: 90deg;
}

.sidebar__section summary:hover {
  background: var(--surface-2);
}

.sidebar__pages {
  list-style: none;
  margin: 0.15rem 0 0.6rem;
  padding: 0 0 0 0.95rem;
  border-left: 1px solid var(--border);
  margin-left: 0.55rem;
}

.sidebar__pages a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 0.22rem 0.5rem;
  border-radius: 4px;
}

.sidebar__pages a:hover {
  background: var(--surface-2);
  color: var(--accent-strong);
}

.sidebar__pages a[aria-current="page"] {
  color: var(--accent-strong);
  font-weight: 600;
  background: var(--surface-2);
}

.sidebar__meta {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.header-link--menu {
  display: inline;
}

@media (min-width: 64rem) {
  .layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-areas: "nav main";
    gap: 2.5rem;
  }

  .main {
    grid-area: main;
    max-width: var(--content-width);
  }

  .sidebar {
    grid-area: nav;
    border-top: 0;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding-top: 1.5rem;
  }

  .sidebar__meta a[href="#top"] { display: none; }

  .header-link--menu {
    display: none;
  }
}

/* ---------- Article ---------- */

.article__crumb {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

.article__crumb a {
  color: var(--muted);
  text-decoration: none;
}

.article__crumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article__lede {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.article__meta {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: 0.8rem 0 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.status {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.status--draft, .status--review { border-color: var(--accent); color: var(--accent); }
.status--needs-review { border-color: var(--tan); color: var(--tan); }
.status--deprecated, .status--archived { border-color: var(--salmon); color: var(--salmon); }

.tag {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.45rem;
  margin-right: 0.3rem;
  font-size: 0.78rem;
}

.toc {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 0.55rem 0.9rem;
  margin: 1.25rem 0;
}

.toc summary {
  cursor: pointer;
  font-weight: 600;
}

.toc ol {
  margin: 0.5rem 0 0.25rem;
  padding-left: 1.4rem;
}

.toc li {
  margin: 0.15rem 0;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.article__body > :first-child {
  margin-top: 1.25rem;
}

.article__footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

/* Footnotes */
.footnotes {
  font-size: 0.9rem;
  color: var(--muted);
}

.footnotes-sep {
  margin-top: 2.5rem;
}

/* ---------- Section page lists ---------- */

.page-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.page-list__item a {
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--ink);
}

.page-list__item a:hover {
  border-color: var(--accent);
}

.page-list__title {
  display: block;
  font-weight: 700;
  color: var(--accent);
}

.page-list__item a:hover .page-list__title {
  text-decoration: underline;
}

.page-list__desc {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ---------- Home ---------- */

.home__intro {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 1.5rem 0 1rem;
}

.home__intro-text h1 {
  font-size: 2.1rem;
  margin: 0 0 0.5rem;
}

.home__tagline {
  font-size: 1.2rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.home__mark {
  flex: 0 0 auto;
  width: 130px;
}

.home__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-family: var(--font-ui);
}

.button {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 1.1rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
}

.button--primary {
  background: var(--accent);
  color: var(--bg);
}

.button--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--bg);
}

.button--secondary {
  color: var(--accent);
  background: transparent;
}

.button--secondary:hover {
  background: var(--surface-2);
}

.home__sections {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
}

.home__sections a {
  display: block;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--ink);
}

.home__sections a:hover {
  border-color: var(--accent);
}

.home__section-title {
  display: block;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.home__section-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.home h2 {
  margin-top: 2.25rem;
}

@media (max-width: 26rem) {
  .brand__name {
    font-size: 0.92rem;
  }

  .site-header__inner {
    gap: 0.6rem;
  }

  .site-header__actions {
    gap: 0.6rem;
  }
}

@media (max-width: 40rem) {
  .home__intro {
    flex-direction: column-reverse;
    text-align: left;
    gap: 1rem;
    align-items: flex-start;
  }

  .home__mark {
    width: 96px;
  }

  .home__intro-text h1 {
    font-size: 1.7rem;
  }
}

/* ---------- Search page ---------- */

.search-page {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--ink);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--surface-2);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 4px;
  --pagefind-ui-font: var(--font-ui);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.75rem;
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ---------- Print ---------- */

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

  body {
    background: #fff;
    color: #000;
  }

  a {
    color: #000;
  }
}
