/* GhostSpeak handbook · docs.ghostspeak.eu
   Tokens come from apps/shared/tokens.css (night forest, dark). Light mode
   overrides only colours via prefers-color-scheme. No JavaScript, no theme
   switch: the system decides. */

@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(../fonts/noto-sans-latin-wght-normal.woff2) format('woff2-variations'), url(../fonts/noto-sans-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Exo 2 Wordmark';
  font-style: italic;
  font-display: swap;
  font-weight: 800;
  src: url(../fonts/exo-2-wordmark.woff2) format('woff2');
}

:root {
  --ui: 'Noto Sans', system-ui, sans-serif;
  --display: 'Exo 2 Wordmark', 'Noto Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --text-head: #f4f8f5;
  --gutter: 20px;
  --measure: 46rem;
  color-scheme: dark light;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #f6f9f7; --bg-1: #eef3f0; --bg-2: #e5ece8; --bg-3: #dae4de; --bg-4: #cfdbd4;
    --line: #d2ddd6; --line-2: #b9c8bf;
    --text: #17211c; --text-head: #08100c; --text-2: #3f5147; --text-3: #52645a;
    --accent: #12692f; --accent-hi: #0b4d21; --accent-lo: #12692f;
    --accent-wash: #12692f14; --accent-ring: #12692f55; --on-accent: #ffffff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hi); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-ring); }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -100px; z-index: 20; padding: 10px 16px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
.skip-link:hover { color: var(--on-accent); }

.container {
  width: 100%;
  max-width: calc(1240px + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* wordmark */
.wm { font-family: var(--display); font-style: italic; font-weight: 800; letter-spacing: -0.01em; line-height: 1; white-space: nowrap; }
.wm-ghost { color: var(--text-head); }
.wm-speak { color: var(--accent); }

/* header */
.site-header { background: var(--bg-0); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.home-link { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; }
.home-link img { width: 25px; height: 30px; border: 0; border-radius: 0; }
.home-link .wm { font-size: 1.25rem; }
.docs-link { color: var(--text-head); font-weight: 650; text-decoration: none; padding: 4px 10px; border-left: 1px solid var(--line-2); min-height: 44px; display: inline-flex; align-items: center; }
.docs-link:hover { color: var(--accent); }
.back-link { margin-left: auto; color: var(--text-2); font-size: 0.9375rem; min-height: 44px; display: inline-flex; align-items: center; }

/* layout: nav | content | outline */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px 40px; padding-top: 24px; padding-bottom: 56px; grid-template-areas: "nav" "toc" "main"; }
.side-nav { grid-area: nav; min-width: 0; }
.toc { grid-area: toc; min-width: 0; }
.content { grid-area: main; min-width: 0; }
@media (min-width: 900px) {
  .layout { grid-template-columns: 13rem minmax(0, 1fr); grid-template-areas: "nav main"; }
  .toc { display: none; }
  .side-nav { position: sticky; top: 16px; align-self: start; }
}
@media (min-width: 1200px) {
  .layout { grid-template-columns: 13rem minmax(0, 1fr) 14rem; grid-template-areas: "nav main toc"; }
  .toc { display: block; position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow: auto; }
}

.side-nav ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.side-nav ul { display: flex; flex-wrap: wrap; gap: 6px; }
.side-nav a { display: block; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; background: var(--bg-1); min-height: 44px; line-height: 28px; }
.side-nav a:hover { color: var(--text-head); }
.side-nav a[aria-current="page"] { color: var(--text-head); font-weight: 650; background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent-ring); }
@media (min-width: 900px) {
  .side-nav ul { display: block; border-left: 1px solid var(--line); }
  .side-nav a { background: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; border-left: 2px solid transparent; }
  .side-nav a[aria-current="page"] { box-shadow: none; border-left-color: var(--accent); }
}

.toc { font-size: 0.875rem; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
@media (min-width: 1200px) { .toc { background: none; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 0 0 0 16px; } }
.toc-title { margin: 0 0 8px; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); font-weight: 650; border: 0; padding: 0; }
.toc a { display: block; padding: 3px 0; color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.toc-l3 a { padding-left: 14px; }

/* article */
.content article { max-width: var(--measure); }
h1, h2, h3, h4 { color: var(--text-head); line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); letter-spacing: -0.01em; margin: 0 0 0.6em; }
h2 { font-size: 1.55rem; margin: 2.2em 0 0.6em; padding-top: 0.6em; border-top: 1px solid var(--line); }
h3 { font-size: 1.2rem; margin: 1.8em 0 0.5em; }
h4 { font-size: 1.05rem; margin: 1.5em 0 0.4em; }
.anchor { margin-left: 0.4em; font-weight: 400; text-decoration: none; color: var(--text-3); opacity: 0; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
@media (hover: none) { .anchor { opacity: 0.6; } }
p, ul, ol, pre, blockquote, .table-wrap { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
li { margin: 0.25em 0; }
li > ul, li > ol { margin-bottom: 0; }
blockquote { padding: 0.6em 1em; border-left: 3px solid var(--accent); background: var(--accent-wash); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
blockquote > :last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.1em 0.35em; overflow-wrap: anywhere; }
pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; font-size: 0.875rem; overflow-wrap: normal; white-space: pre; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-2); color: var(--text-head); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
article img { border-radius: var(--radius-sm); border: 1px solid var(--line); }

.pager { display: flex; justify-content: space-between; gap: 16px; max-width: var(--measure); margin-top: 3em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; text-decoration: none; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); min-width: 9rem; color: var(--text-head); font-weight: 650; }
.pager a span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; }
.pager-next { text-align: right; margin-left: auto; }
.pager a:hover { border-color: var(--accent); color: var(--accent); }

/* footer */
.site-footer { background: var(--bg-1); border-top: 1px solid var(--line); padding: 32px 0 calc(32px + env(safe-area-inset-bottom)); color: var(--text-2); font-size: 0.9375rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px 48px; justify-content: space-between; }
.footer-meta p { margin: 0 0 6px; }
.footer-brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.footer-brand .wm { font-size: 1.25rem; }
.footer-links ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 20px; }
.footer-links a { display: inline-block; min-height: 44px; line-height: 44px; }

@media print {
  :root { --bg-0: #fff; --bg-1: #fff; --bg-2: #f2f2f2; --text: #000; --text-head: #000; --text-2: #222; --text-3: #444; --accent: #000; --line: #bbb; --line-2: #888; --accent-wash: #f2f2f2; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .skip-link, .side-nav, .toc, .pager, .back-link, .anchor, .footer-links { display: none !important; }
  .site-header { border: 0; }
  .layout { display: block; padding: 0; }
  .content article { max-width: none; }
  h2, h3 { break-after: avoid; }
  pre, .table-wrap, blockquote { break-inside: avoid; }
  pre { white-space: pre-wrap; overflow: visible; border-color: #888; }
  .table-wrap { overflow: visible; }
  a { text-decoration: underline; }
  .home-link::after, .docs-link::after { content: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; overflow-wrap: anywhere; }
}
