/* ============================================================================
   coglogic.css · ONE stylesheet for coglogic.ai and the engram canon papers.
   Everything above the guide-only marker below is the proposed shared sheet.
   The site links it as a file; each canon paper inlines it verbatim.
   Rules it obeys for the canon form gate (records/canon/check.exs): no at-import,
   no remote url(), no source attribute, no character-measure cap (site measures are in em).
   ============================================================================ */

/* ---- tokens: the room, dark by default ---- */
:root {
  --canvas: #0b0a08;             /* the room */
  --panel: #15110e;              /* oak: cards, table surfaces, callouts */
  --raised: #1d1813;             /* a lifted panel: code, formula, table heads */
  --ink: #f3efe6;                /* primary text */
  --muted: #c8c2b6;              /* body copy on the site, secondary text */
  --faint: #8d867a;              /* labels, bylines, captions (AA at 12.5px) */
  --line: rgba(243, 239, 230, 0.10);
  --line-strong: rgba(243, 239, 230, 0.24);
  --brass: #e6b45c;              /* where you are, what to do */
  --brass-hover: #edc06e;
  --brass-soft: rgba(230, 180, 92, 0.14);
  --claret: #c66478;             /* a voice: the accent phrase, quotation, caution */
  --claret-deep: #7a2f3d;
  --claret-soft: rgba(198, 100, 120, 0.14);
  --verdigris: #7fa897;          /* the machine: code, formula, data strokes */
  --verdigris-deep: #2f5a4a;
  --verdigris-soft: rgba(127, 168, 151, 0.14);
  --selection: rgba(230, 180, 92, 0.30);
  /* the names the canon papers' blocks and figures already read */
  --bg: var(--canvas); --surface: var(--panel); --tint: var(--raised); --code-bg: var(--raised);
  --fg: var(--ink); --accent: var(--brass); --accent-soft: var(--brass-soft);
  /* type */
  --serif: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
  --sans: "Schibsted Grotesk", -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  /* rhythm and shape */
  --gutter: clamp(16px, 4vw, 72px);
  --section: clamp(64px, 9vh, 128px);
  --r-1: 2px; --r-2: 6px;
  color-scheme: dark;
}
/* ---- daylight: a reading mode, chosen, never inferred from the OS ---- */
:root[data-theme="light"], [data-theme="light"] {
  --canvas: #f1ece2; --panel: #faf7f1; --raised: #e8e1d3;
  --ink: #1a1510; --muted: #5a5247; --faint: #6b635a;
  --line: rgba(26, 21, 16, 0.12); --line-strong: rgba(26, 21, 16, 0.30);
  --brass: #7f5311; --brass-hover: #6d4710; --brass-soft: rgba(127, 83, 17, 0.12);
  --claret: #7d2f3f; --claret-deep: #5a1f2c; --claret-soft: rgba(125, 47, 63, 0.10);
  --verdigris: #2f6b57; --verdigris-deep: #1f4a3c; --verdigris-soft: rgba(47, 107, 87, 0.10);
  --selection: rgba(127, 83, 17, 0.22);
  --bg: var(--canvas); --surface: var(--panel); --tint: var(--raised); --code-bg: var(--raised);
  --fg: var(--ink); --accent: var(--brass); --accent-soft: var(--brass-soft);
  color-scheme: light;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 clamp(16px, 0.75vw + 8.5px, 24px)/1.6 var(--serif);
  font-optical-sizing: auto; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); color: var(--ink); }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 0.16em; transition: color 0.2s; }
a:hover { color: var(--brass); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
p, ul, ol { margin: 0 0 1.05em; }
p { text-wrap: pretty; }
li { margin-block: 0.35em; }
li::marker { color: var(--faint); }
strong { font-weight: 600; }
code { font: 0.86em/1 var(--mono); color: var(--verdigris); background: var(--code-bg); padding: 0.12em 0.38em; border-radius: var(--r-1); }
pre { font: 0.82em/1.55 var(--mono); color: var(--muted); background: var(--raised); padding: 16px 20px; border-radius: var(--r-2); overflow-x: auto; margin: 1.2em 0 1.4em; }
pre code { background: none; padding: 0; color: inherit; font-size: 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* ---- labels shared by both templates ---- */
.eyebrow { font: 500 12.5px/1.3 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 0 0 14px; }
.kicker { font: 500 12.5px/1.3 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--claret); margin: 0 0 28px; }
.byline { font: 14px/1.45 var(--sans); color: var(--faint); margin: 0; }
.byline time { font-variant-numeric: tabular-nums; }
.nw { white-space: nowrap; }

/* ---- the paper template ---- */
.page { max-width: 2000px; margin: 0 auto; padding-inline: var(--gutter); padding-bottom: 72px; }
.masthead { padding-block: 56px 28px; border-bottom: 3px double var(--line-strong); }
.masthead .eyebrow { color: var(--claret); }
.masthead h1 { font: 500 clamp(30px, 3.2vw, 54px)/1.1 var(--serif); letter-spacing: -0.005em; margin: 0 0 14px; text-wrap: balance; }
.toc { padding-block: 24px; border-bottom: 1px solid var(--line); }
.toc ol { margin: 0; padding-left: 1.6em; font: 15px/1.5 var(--sans); columns: 2; column-gap: 32px; }
.toc li { break-inside: avoid; padding-block: 2px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--brass); }
.toc a[aria-current="true"] { color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--brass); }
@media (max-width: 560px) { .toc ol { columns: 1; } }
main { counter-reset: section; min-width: 0; }
@media (min-width: 1100px) {
  .page { display: grid; grid-template-columns: clamp(200px, 17vw, 300px) minmax(0, 1fr); column-gap: clamp(32px, 4vw, 80px); align-items: start; }
  .masthead { grid-column: 1 / -1; }
  .toc { grid-column: 1; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding-block: 28px; border-bottom: 0; }
  .toc ol { columns: 1; font-size: 14.5px; padding-left: 2.2em; }
  .toc li { padding-block: 4px; }
  main { grid-column: 2; padding-top: 12px; }
}
section { padding-block: 8px; }
section + section { margin-top: 40px; }
main > section > h2 { font: 500 1.5em/1.2 var(--serif); letter-spacing: -0.005em; margin: 28px 0 16px; text-wrap: balance; counter-increment: section; }
main > section > h2::before { content: counter(section); font: 500 0.55em/1 var(--sans); color: var(--faint); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; vertical-align: 0.32em; margin-right: 0.9em; }
h3 { font: 500 1.15em/1.3 var(--serif); margin: 1.6em 0 0.5em; }
.formula { margin: 1.2em 0 1.4em; padding: 16px 20px; background: var(--raised); border-left: 3px solid var(--verdigris); border-radius: 0 var(--r-2) var(--r-2) 0; font: 1em/1.7 var(--serif); overflow-x: auto; }
.formula .f { display: block; white-space: nowrap; }
.formula var { font-style: italic; }
.formula sub { font-size: 0.75em; }
.formula .where { display: block; margin-top: 0.4em; font: max(13px, 0.8em)/1.5 var(--sans); color: var(--faint); }
.formula p.where { margin: 0.6em 0 0; }
.sig { border-collapse: collapse; }
.sig td { padding: 2px 6px 2px 0; white-space: nowrap; vertical-align: baseline; }
.sig td:first-child { text-align: right; }
.table-wrap { overflow-x: auto; margin: 1.2em 0 1.6em; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--panel); }
table { border-collapse: collapse; width: 100%; min-width: 680px; font: max(13px, 0.76em)/1.45 var(--sans); }
.matrix table { font-size: max(12.5px, 0.7em); min-width: 68em; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
thead th { font-size: 0.82em; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); background: var(--raised); position: sticky; top: 0; }
tbody th { font-weight: 500; white-space: normal; min-width: 11ch; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.matrix tbody th { position: sticky; left: 0; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
figure { margin: 1.6em 0 2em; max-width: 100%; }
.fig-scroll { overflow-x: auto; }
figure svg { display: block; width: 100%; min-width: 640px; height: auto; font-family: var(--sans); }
figcaption { font: max(13px, 0.74em)/1.5 var(--sans); color: var(--faint); margin-top: 8px; }
.note, .caution, .pull { margin: 1.3em 0 1.5em; padding: 14px 20px; border-left: 3px solid var(--line-strong); background: var(--panel); border-radius: 0 var(--r-2) var(--r-2) 0; }
.note p:last-child, .caution p:last-child { margin: 0; }
.caution { border-left-color: var(--claret); }
.label { display: block; font: 500 12px/1.3 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.caution .label { color: var(--claret); }
.pull { border-left-color: var(--claret); background: transparent; padding-block: 2px; font: italic 400 1.25em/1.4 var(--serif); color: var(--ink); }
.pull p { margin: 0; }
.pull cite { display: block; font: 14px/1.4 var(--sans); font-style: normal; color: var(--faint); margin-top: 10px; }
.provenance { margin-top: 48px; padding-top: 20px; border-top: 3px double var(--line-strong); font: max(13px, 0.8em)/1.55 var(--sans); color: var(--faint); }
.provenance p { margin: 0; }

/* ---- the site template ---- */
.site { position: relative; min-height: 100vh; }
.grain { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.04; mix-blend-mode: overlay; background-image: url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22200%22 height=%22200%22><filter id=%22n%22><feTurbulence type=%22fractalNoise%22 baseFrequency=%220.9%22 numOctaves=%222%22/></filter><rect width=%22200%22 height=%22200%22 filter=%22url(%23n)%22/></svg>'); }
.nav { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 24px; padding: 16px var(--gutter); background: color-mix(in srgb, var(--canvas) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-dot { width: 8px; height: 8px; background: var(--brass); border-radius: var(--r-1); }
.brand-name { font: 500 22px/1 var(--serif); letter-spacing: -0.01em; }
.nav-links { display: flex; align-items: center; gap: clamp(18px, 2.6vw, 36px); font: 400 15px/1 var(--sans); }
.nav-links a { color: var(--muted); text-decoration: none; padding-block: 6px; border-bottom: 1px solid transparent; transition: color 0.2s, border-color 0.2s; }
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }
.hero { position: relative; overflow: hidden; padding: clamp(72px, 12vh, 160px) var(--gutter) clamp(64px, 10vh, 128px); }
.lamp { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(70% 55% at 50% 115%, var(--brass-soft), transparent 65%); }
.hero .wrap { position: relative; z-index: 1; }
.hero h1, .display { font: 500 clamp(36px, 4.6vw, 72px)/1.08 var(--serif); letter-spacing: -0.01em; margin: 0; text-wrap: balance; max-width: 14em; }
.hero-sub { font: 400 clamp(18px, 1.15em, 24px)/1.5 var(--serif); color: var(--muted); margin: 28px 0 0; max-width: 30em; }
.actions { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; margin-top: 40px; }
.section { position: relative; padding: var(--section) var(--gutter); }
.section--rule { border-top: 1px solid var(--line); }
.wrap { max-width: 1200px; margin: 0 auto; }
.wrap--narrow { max-width: 960px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: clamp(32px, 5vw, 80px); align-items: start; }
.lead { font: 500 clamp(26px, 2.6vw, 40px)/1.22 var(--serif); letter-spacing: -0.008em; margin: 0; text-wrap: balance; }
.body { color: var(--muted); margin: 0; }
.body + .body { margin-top: 1em; }
.accent { font-style: italic; font-weight: 400; color: var(--claret); }
.accent--line { display: block; margin-top: 0.15em; }
.wordmark { font: 500 clamp(40px, 6vw, 96px)/1 var(--serif); letter-spacing: -0.02em; margin: 0 0 24px; }
.cells { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); grid-template-columns: repeat(auto-fit, minmax(min(100%, max(300px, 40%)), 1fr)); }
.cell { background: var(--panel); padding: clamp(24px, 3vw, 40px); }
.cell h3 { font: 500 1.2em/1.25 var(--serif); margin: 0 0 10px; }
.cell p { font-size: 0.95em; color: var(--muted); margin: 0; }
.cell--wide { grid-column: 1 / -1; }
.mark { display: block; width: 18px; height: 1px; background: var(--brass); margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; gap: 10px; font: 500 15px/1 var(--sans); text-decoration: none; border-radius: var(--r-1); padding: 13px 20px; transition: background 0.2s, border-color 0.2s, color 0.2s; }
.btn .arrow { transition: transform 0.2s; }
.btn:hover .arrow { transform: translateX(3px); }
.btn--solid { background: var(--brass); color: var(--canvas); }
.btn--solid:hover { background: var(--brass-hover); color: var(--canvas); }
.btn--ghost { border: 1px solid var(--line-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--brass); color: var(--ink); }
.textlink { font: 500 15px/1 var(--sans); }
.footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 40px var(--gutter); border-top: 3px double var(--line-strong); }
.footer .brand-name { font-size: 18px; }
.footer-meta { font: 14px/1.4 var(--sans); color: var(--faint); }

/* ---- motion: three permitted movements ---- */
.reveal { animation: reveal both linear; animation-timeline: view(); animation-range: entry 0% cover 30%; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { animation: none; }
  .btn .arrow, .nav-links a, a, .btn { transition: none; }
}

/* ---- print: daylight, one column ---- */
@media print {
  :root { --canvas: #ffffff; --panel: #faf7f1; --raised: #efe9de; --ink: #1a1510; --muted: #5a5247; --faint: #6b635a; --line: rgba(26,21,16,0.14); --line-strong: rgba(26,21,16,0.32); --brass: #7f5311; --claret: #7d2f3f; --verdigris: #2f6b57; --bg: var(--canvas); --surface: var(--panel); --tint: var(--raised); --code-bg: var(--raised); --fg: var(--ink); --accent: var(--brass); color-scheme: light; }
  body { font-size: 11pt; }
  .page { display: block; padding: 0; }
  .toc { position: static; break-after: page; }
  .nav, .grain, .lamp { display: none; }
  .table-wrap { border: 0; }
  h2 { break-after: avoid; }
  figure, .formula, tr, .cell { break-inside: avoid; }
}


/* ---- roles the pages need beyond the guide's first cut ---- */
.hero h1.wordmark { font-size: clamp(48px, 6.4vw, 96px); line-height: 1; letter-spacing: -0.02em; }
.cols--label { grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); }
@media (max-width: 700px) { .cols--label { grid-template-columns: 1fr; gap: 12px; } }
.mail { display: inline-block; font: 500 clamp(26px, 3.2vw, 44px)/1.2 var(--serif); letter-spacing: -0.01em; text-decoration-thickness: 1px; text-underline-offset: 0.12em; }
.cell .label { margin-bottom: 10px; }
.after { margin-top: clamp(32px, 4vw, 56px); }
.hero-sub + .hero-sub { margin-top: 18px; }
.closing { text-align: center; }
.closing .body { margin: 20px auto 0; max-width: 36em; }
.closing .actions { justify-content: center; margin-top: 32px; }
.lead + .body { margin-top: 20px; }
