/* EntityModel.com docs: static pages, no JavaScript. Same tokens as src/ui/styles.css (Studio light, Graphite dark). */
@font-face { font-family: 'Schibsted Grotesk'; font-weight: 400; font-display: swap; src: url(/docs/fonts/schibsted-grotesk-400.woff2) format('woff2'); }
@font-face { font-family: 'Schibsted Grotesk'; font-weight: 600; font-display: swap; src: url(/docs/fonts/schibsted-grotesk-600.woff2) format('woff2'); }
@font-face { font-family: 'DM Serif Display'; font-weight: 400; font-display: swap; src: url(/docs/fonts/dm-serif-display-400.woff2) format('woff2'); }
@font-face { font-family: 'DM Serif Display'; font-weight: 400; font-style: italic; font-display: swap; src: url(/docs/fonts/dm-serif-display-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(/docs/fonts/ibm-plex-mono-400.woff2) format('woff2'); }

:root {
  --canvas: #f4f3f0;
  --sunken: #e9e8e4;
  --surface: #fafaf8;
  --ink: #1f2124;
  --ink-2: #44474c;
  --ink-3: #5e6268;
  --line: #dad9d4;
  --line-strong: #bdbcb6;
  --accent: #f2a67c;
  --link: #3e6a8f;
  --code-bg: #e9e8e4;
  --key: #9a4a10;
  --shadow: 3px 3px 0 0 #1f2124;
  --font: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #17181a;
    --sunken: #101112;
    --surface: #1f2023;
    --ink: #f1f0ec;
    --ink-2: #c9c8c4;
    --ink-3: #a1a19d;
    --line: #34353a;
    --line-strong: #4e5056;
    --link: #7fa6c7;
    --code-bg: #101112;
    --key: #f2a67c;
    --shadow: 3px 3px 0 0 #000;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 16px/1.65 var(--font); }
a { color: var(--link); text-underline-offset: 2px; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--canvas); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; padding: 0 24px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 400 22px/1 var(--display); white-space: nowrap; }
.brand .mark { fill: var(--ink); }
.brand .paper { fill: var(--canvas); }
.brand .wire { stroke: var(--canvas); }
.brand .tag { font: 600 12px/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line-strong); padding: 4px 6px; }
.top nav { display: flex; align-items: center; gap: 18px; font-size: 15px; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--ink); text-decoration: underline; }
.top nav .cta { white-space: nowrap; color: var(--canvas); background: var(--ink); padding: 7px 12px; font-weight: 600; box-shadow: 2px 2px 0 0 var(--accent); }
.top nav .cta:hover { color: var(--canvas); text-decoration: none; }

/* three columns: contents, article, on this page */
.layout { display: grid; grid-template-columns: 240px minmax(0, 760px) 200px; gap: 48px; max-width: 1340px; margin: 0 auto; padding: 0 24px; }
.sidebar { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow-y: auto; padding: 28px 0 40px; }
.mobile-nav { display: none; }
.sidebar h2, .mobile-nav h2, .toc h2 { margin: 22px 0 6px; font: 600 12px/1.4 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.sidebar h2:first-child, .mobile-nav summary + h2 { margin-top: 0; }
.sidebar ul, .mobile-nav ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.sidebar a, .mobile-nav a { display: block; padding: 4px 10px; margin-left: -10px; color: var(--ink-2); text-decoration: none; font-size: 15px; line-height: 1.4; border-left: 2px solid transparent; }
.sidebar a:hover, .mobile-nav a:hover { color: var(--ink); background: var(--sunken); }
.sidebar a[aria-current='page'], .mobile-nav a[aria-current='page'] { color: var(--ink); font-weight: 600; border-left-color: var(--accent); background: var(--sunken); }
.toc { position: sticky; top: 60px; align-self: start; padding: 28px 0; font-size: 14px; }
.toc h2 { margin-top: 0; }
.toc a { display: block; padding: 3px 0; color: var(--ink-3); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--ink); }

main { padding: 24px 0 64px; min-width: 0; }
.crumbs { font-size: 14px; color: var(--ink-3); }
.crumbs a { color: var(--ink-3); }

/* article */
article h1 { margin: 14px 0 22px; font: 400 clamp(34px, 5vw, 48px)/1.08 var(--display); letter-spacing: -0.015em; }
.lede { margin: -8px 0 28px; font-size: 19px; line-height: 1.55; color: var(--ink-2); }
article h2 { margin: 44px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); font: 400 30px/1.2 var(--display); letter-spacing: -0.01em; }
article h3 { margin: 30px 0 8px; font: 600 19px/1.35 var(--font); }
article h4 { margin: 24px 0 6px; font: 600 16px/1.4 var(--font); }
article h2, article h3, article h4 { position: relative; }
.anchor { position: absolute; left: -0.9em; color: var(--ink-3); text-decoration: none; opacity: 0; font-family: var(--font); }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
article p, article ul, article ol { margin: 0 0 16px; }
article li { margin: 4px 0; }
article li > ul, article li > ol { margin: 4px 0 0; }
article strong { font-weight: 600; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
article blockquote { margin: 0 0 18px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); color: var(--ink-2); }
article blockquote p:last-child { margin-bottom: 0; }
article img { max-width: 100%; height: auto; border: 1px solid var(--line-strong); box-shadow: var(--shadow); }

code { font: 0.88em/1.5 var(--mono); background: var(--code-bg); padding: 1px 5px; }
pre { margin: 0 0 18px; padding: 14px 16px; overflow-x: auto; background: var(--code-bg); border: 1px solid var(--line); }
pre code { padding: 0; background: none; font-size: 14px; line-height: 1.6; }

.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.5; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--sunken); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* example model diagrams: inline SVG from src/server/diagram.ts, which also holds their styles */
.erd { margin: 0 0 18px; }
.erd > a { display: block; border: 1px solid var(--line); background: var(--canvas); }
.erd > a:hover { border-color: var(--line-strong); }
.erd-svg { display: block; width: 100%; height: auto; }
.erd figcaption { margin-top: 6px; font-size: 13px; color: var(--ink-3); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 48px 0 0; }
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; }
.pager a:hover { box-shadow: var(--shadow); }
.pager small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.pager .next { text-align: right; grid-column: 2; }
.foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
.foot p { margin: 0 0 4px; }
.foot a { color: var(--ink-3); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .top { padding: 0 16px; }
  .top nav a:not(.cta) { display: none; }
  .layout { display: block; padding: 0 16px; }
  .sidebar { display: none; }
  .mobile-nav { display: block; margin: 0 0 16px; border: 1px solid var(--line-strong); background: var(--surface); }
  .mobile-nav summary { cursor: pointer; padding: 10px 12px; font-weight: 600; }
  .mobile-nav[open] { padding: 0 12px 12px 22px; }
  .mobile-nav[open] summary { margin-left: -10px; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}

.erd-svg .box { fill: var(--surface); stroke: var(--line-strong); }
.erd-svg .name { font: 600 14px var(--font); fill: var(--ink); }
.erd-svg .id, .erd-svg .attr, .erd-svg .type { font: 11.5px var(--mono); }
.erd-svg .id, .erd-svg .type { fill: var(--ink-3); }
.erd-svg .attr { fill: var(--ink-2); }
.erd-svg .attr.label { fill: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); }
.erd-svg .pk { font: 600 9px var(--font); fill: var(--key); }
.erd-svg .badge { font: 600 9px var(--font); letter-spacing: 0.06em; fill: var(--ink-3); }
.erd-svg .foot { font: 11px var(--font); fill: var(--ink-3); }
.erd-svg .rule { stroke: var(--line); }
.erd-svg .line, .erd-svg .mark { fill: none; stroke: var(--ink-2); stroke-width: 1.25; }
.erd-svg .rel-label { font: 11px var(--font); fill: var(--ink-3); paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; stroke-linejoin: round; }
.erd-svg .ref-line { fill: none; stroke: var(--line-strong); stroke-dasharray: 4 4; }
.erd-svg .ref-dot { fill: var(--line-strong); }
.erd-svg .rel:hover .line, .erd-svg .rel:hover .mark { stroke: var(--ink); stroke-width: 2; }
