/* ═══════════════════════════════════════════════════════════════════
   NOVABERG — shared design system
   Single source of truth for fonts, palette, typography and the masthead.
   Fonts are self-hosted (assets/fonts/) — no third-party font CDN.
   IBM Plex Serif · IBM Plex Sans · IBM Plex Mono — SIL OFL 1.1
   ═══════════════════════════════════════════════════════════════════ */

/* ── Self-hosted fonts (IBM Plex, OFL) ─────────────────────────────── */
@font-face {
  font-family: 'IBM Plex Serif'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('fonts/IBMPlexSerif-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif'; font-style: italic; font-weight: 400;
  font-display: swap; src: url('fonts/IBMPlexSerif-Italic.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('fonts/IBMPlexSerif-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif'; font-style: italic; font-weight: 500;
  font-display: swap; src: url('fonts/IBMPlexSerif-MediumItalic.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif'; font-style: normal; font-weight: 600;
  font-display: swap; src: url('fonts/IBMPlexSerif-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 300;
  font-display: swap; src: url('fonts/IBMPlexSans-Light.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('fonts/IBMPlexSans-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: italic; font-weight: 400;
  font-display: swap; src: url('fonts/IBMPlexSans-Italic.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('fonts/IBMPlexSans-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600;
  font-display: swap; src: url('fonts/IBMPlexSans-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('fonts/IBMPlexMono-Medium.woff2') format('woff2');
}

/* ── Type stacks & layout measures ─────────────────────────────────── */
:root {
  --font-serif: 'IBM Plex Serif', Georgia, serif;
  --font-sans:  'IBM Plex Sans', sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, monospace;

  --page-max:      1180px;   /* full sheet width  */
  --page-pad:      48px;     /* sheet side gutter */
  --measure:       720px;    /* default reading column */
  --measure-wide:  820px;    /* wide reading column    */
}

/* ── Palette (one unified register) ────────────────────────────────── */
:root {
  --paper:        #f6f3ec;
  --paper-2:      #efeadf;
  --paper-edge:   #e7e0d0;
  --ink:          #1a1a1a;
  --ink-2:        #3d3a34;
  --ink-muted:    #6b675e;
  --ink-dim:      #9a958a;
  --rule:         #d8d2c4;
  --rule-soft:    #e7e0d0;
  --accent:       oklch(0.45 0.14 25);   /* oxblood / madder */
  --accent-2:     oklch(0.55 0.12 25);
  --accent-wash:  oklch(0.93 0.03 25);
  --figure-bg:    #fbf9f3;
  --marginalia:   #8a8578;
  --code-bg:      #efeadf;
  --code-border:  #d8d2c4;
  --terminal-bg:  #14120f;
  --terminal-fg:  #ece6d8;
  --terminal-border: #2a251e;
  --bubble-user-bg:  #2a3340;
  --bubble-user-fg:  #f6f3ec;
  --bubble-nova-bg:  #e7e0d0;
  --bubble-nova-fg:  #1a1a1a;
}

/* ── Reset & base ──────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 17px; }
body {
  font-family: 'IBM Plex Serif', Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
  transition: background 0.35s ease, color 0.35s ease;
}
::selection { background: var(--accent-wash); color: var(--accent); }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, rgba(0,0,0,0.015), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(0,0,0,0.02), transparent 70%);
  mix-blend-mode: multiply;
  z-index: 1;
}

/* ── Typography ────────────────────────────────────────────────────── */
.small-caps {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

h1, h2, h3, h4 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(2.4rem, 5.2vw, 4.0rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
}
h1 em { font-style: italic; font-weight: 500; }
h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.0rem);
  line-height: 1.18;
  font-weight: 500;
  letter-spacing: -0.018em;
  margin-bottom: 24px;
  max-width: 22em;
  text-wrap: balance;
}
h3 {
  font-size: 1.18rem;
  line-height: 1.3;
  font-weight: 600;
  margin-bottom: 10px;
  margin-top: 36px;
  letter-spacing: -0.01em;
}
h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 8px;
}

p {
  font-size: 1.02rem;
  line-height: 1.65;
  margin-bottom: 1.1em;
  color: var(--ink-2);
  text-wrap: pretty;
  hyphens: auto;
}
p.lead {
  font-size: 1.26rem;
  line-height: 1.48;
  color: var(--ink);
  font-weight: 400;
  margin-bottom: 1.4em;
  max-width: 32em;
  text-wrap: balance;
  letter-spacing: -0.005em;
}

em { font-style: italic; }
strong { font-weight: 600; color: var(--ink); }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-wash);
  transition: border-color 0.2s, color 0.2s;
}
a:hover { border-bottom-color: var(--accent); }

code, .mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.86em;
  color: var(--ink);
  letter-spacing: -0.005em;
}
p code, li code, td code, th code {
  background: var(--accent-wash);
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--accent);
  font-size: 0.82em;
}

ul, ol { margin: 0 0 1.1em 0; padding-left: 1.3em; }
li { margin-bottom: 0.35em; color: var(--ink-2); font-size: 1.02rem; line-height: 1.65; }

/* ── Masthead ──────────────────────────────────────────────────────── */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.masthead.scrolled { border-bottom-color: var(--rule); }
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px 0;
  gap: 20px;
  flex-wrap: wrap;
}
.mast-brand {
  font-family: 'IBM Plex Serif', serif;
  font-size: 1.12rem;
  font-style: italic;
  color: var(--ink);
  border: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.mast-brand .logo-mark { height: 14px; width: auto; flex-shrink: 0; }
.mast-links {
  display: flex;
  gap: 22px;
  align-items: baseline;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.mast-links a { color: var(--ink-muted); border: none; font-weight: 400; }
.mast-links a:hover { color: var(--ink); }
.lang-toggle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  padding: 4px 10px;
  text-transform: none;
  transition: border-color 0.2s, color 0.2s;
}
.lang-toggle:hover { border-color: var(--ink-dim); color: var(--ink); }
.colo-end a { color: var(--ink-dim); border: none; }
.colo-end a:hover { color: var(--ink-muted); }
@media (max-width: 720px) {
  .mast-links a:not(:last-child) { display: none; }
}

/* ── Layout: sheet, columns, chapters ──────────────────────────────── */
.sheet {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad);
  position: relative;
  z-index: 2;
}
.column { max-width: var(--measure); }
.column-wide { max-width: var(--measure-wide); }

section.chapter {
  padding: 88px 0;
  border-top: 1px solid var(--rule);
  position: relative;
}
section.chapter:first-of-type { border-top: none; }
