/* Tight Core, Open Edge — typeset theme
 * Matches the overall style of the other Nex books (centered single-column,
 * EB Garamond / Outfit / JetBrains Mono) with a teal accent for this title.
 */

:root {
  --paper:     #fbfbfc;
  --paper2:    #f1f1f3;
  --ink:       #0a0a0b;
  --ink-mid:   #3d3d40;
  --ink-faint: #6b6b6f;
  --rule:      #e6e6ea;
  --rule2:     #d3d3da;
  --accent:    #1c7a6b;   /* teal */
  --accent2:   #135b50;
  --accent-tint: #e7f2f0;
  --code-bg:   #f1f1f3;
  --rule-bg:   #f5f5f8;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-ui:   'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --text-xs:   0.72rem;
  --text-sm:   0.85rem;
  --text-base: 1.175rem;
  --text-md:   1.32rem;
  --text-lg:   1.65rem;
  --text-xl:   2rem;
  --text-2xl:  2.8rem;
  --lh-body:   1.76;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #12140f;
    --paper2:    #1b1e17;
    --ink:       #eef1e8;
    --ink-mid:   #cfd4c6;
    --ink-faint: #9ea695;
    --rule:      rgba(238, 241, 232, 0.12);
    --rule2:     rgba(238, 241, 232, 0.22);
    --accent:    #6fd0bf;
    --accent2:   #8fe2d3;
    --accent-tint: rgba(111, 208, 191, 0.14);
    --code-bg:   #1b1e17;
    --rule-bg:   #171a14;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-body);
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
}

/* ---- site header ---- */
.site-header { border-bottom: 1px solid var(--rule); padding: 1.1rem 2rem; position: sticky; top: 0; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); z-index: 10; }
.site-header-inner { max-width: 52rem; margin: 0 auto; display: flex; align-items: baseline; gap: 2rem; flex-wrap: wrap; }
a.book-title { font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500; letter-spacing: 0.01em; color: var(--ink-mid); text-decoration: none; transition: color 0.15s; }
a.book-title:hover { color: var(--ink); }
.book-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-left: auto; }
.book-nav a { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); text-decoration: none; transition: color 0.15s; }
.book-nav a:hover, .book-nav a.active { color: var(--accent); }

/* ---- page frame ---- */
.page { max-width: 52rem; margin: 0 auto; padding: 5rem 2rem 8rem; }

.opener { margin-bottom: 4rem; padding-bottom: 3rem; border-bottom: 1px solid var(--rule); }
.opener-label { display: block; font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 1.25rem; }
.opener-title { font-family: var(--font-body); font-size: var(--text-2xl); font-weight: 400; line-height: 1.08; letter-spacing: -0.01em; color: var(--ink); max-width: 26ch; }
.opener-lede { margin-top: 1.5rem; max-width: 60ch; font-size: var(--text-md); font-style: italic; color: var(--ink-mid); line-height: 1.5; }

/* ---- prose ---- */
.prose { max-width: 66ch; }
.prose section { display: block; }
.prose p { margin-top: 1.2em; }
.prose p:first-child { margin-top: 0; }
.prose p.signoff { margin-top: 2.5rem; font-family: var(--font-ui); font-style: normal; color: var(--ink-faint); }
.prose h2 { font-family: var(--font-body); font-size: var(--text-lg); font-weight: 400; line-height: 1.2; color: var(--ink); margin-top: 3rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.prose h2 .secno { font-family: var(--font-mono); font-size: 0.66em; color: var(--accent); margin-right: 0.6em; }
.prose h3 { font-family: var(--font-body); font-size: var(--text-md); font-weight: 400; font-style: italic; color: var(--ink); margin-top: 2rem; margin-bottom: 0.75rem; }
.prose h3 .secno { font-family: var(--font-mono); font-style: normal; font-size: 0.62em; color: var(--ink-faint); margin-right: 0.6em; }
.prose h2 .header-section-number, .prose h3 .header-section-number { font-family: var(--font-mono); font-size: 0.66em; color: var(--accent); margin-right: 0.6em; }
.prose h4 { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-top: 1.5rem; margin-bottom: 0.5rem; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-top: 1em; margin-bottom: 1em; }
.prose li { margin-top: 0.3em; }
.prose li p { margin-top: 0.3em; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--rule2); text-underline-offset: 3px; transition: color 0.15s; }
.prose a:hover { color: var(--accent2); text-decoration-color: var(--accent); }
.prose blockquote { margin: 1.5em 0; padding: 0.75em 1.25em; border-left: 3px solid var(--rule2); color: var(--ink-mid); font-style: italic; }
.prose blockquote p { margin-top: 0.5em; }
.prose blockquote p:first-child { margin-top: 0; }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.prose code { font-family: var(--font-mono); font-size: 0.8em; background: var(--code-bg); padding: 0.15em 0.4em; border-radius: 3px; }

/* code blocks */
.prose pre { background: var(--code-bg); border: 1px solid var(--rule2); border-radius: 6px; padding: 1.1rem 1.25rem; overflow-x: auto; margin: 1.5rem 0; font-size: 0.8rem; line-height: 1.7; font-family: var(--font-mono); }
.prose pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; }
.codeblock { position: relative; }
.copy-btn { position: absolute; top: 0.5rem; right: 0.5rem; background: color-mix(in srgb, var(--paper) 80%, transparent); border: 1px solid var(--rule2); border-radius: 3px; padding: 0.2rem 0.5rem; font-family: var(--font-ui); font-size: 0.65rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); cursor: pointer; transition: color 0.15s, background 0.15s; }
.copy-btn:hover { color: var(--ink); }

/* keyword colouring for Nex code */
.prose pre .kw { color: var(--accent2); }
.prose pre .ty { color: #2c6f6a; }
.prose pre .co { color: var(--ink-faint); font-style: italic; }
.prose pre .st { color: #7d5a00; }
@media (prefers-color-scheme: dark) {
  .prose pre .ty { color: #8fd0c8; }
  .prose pre .st { color: #d8b878; }
}

/* ---- callouts (Nex Note, aside, etc.) ---- */
.note { margin: 1.6rem 0; padding: 0.85rem 1.15rem; background: var(--accent-tint); border-left: 3px solid var(--accent); border-radius: 4px; font-size: var(--text-sm); color: var(--ink-mid); }
.note .note-label { display: block; font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.35rem; }
.note p { margin-top: 0.6em; }
.note p:first-child { margin-top: 0; }
.note code { font-size: 0.82em; }

/* pull-quote / thesis statement */
.thesis { margin: 2.25rem 0; padding: 1.4rem 1.6rem; border-left: 3px solid var(--accent); background: var(--rule-bg); font-family: var(--font-body); font-size: var(--text-md); font-style: italic; line-height: 1.5; color: var(--ink); }
.thesis strong { font-style: normal; font-weight: 600; }

/* tables */
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: var(--text-sm); }
.prose th { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1.5px solid var(--ink); }
.prose td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--rule); color: var(--ink-mid); vertical-align: top; }
.prose td code { font-size: 0.82em; }
.prose tr:last-child td { border-bottom: none; }

/* ---- reference list (hanging indent) ---- */
.prose ul.reflist { list-style: none; padding-left: 0; margin-top: 1.5rem; }
.prose ul.reflist li { padding-left: 1.8rem; text-indent: -1.8rem; margin-top: 1.05em; line-height: 1.55; }
.prose ul.reflist li code { font-size: 0.78em; }

/* ---- chapter navigation ---- */
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 5rem; padding-top: 2rem; border-top: 1px solid var(--rule); }
.chapter-nav .prev a, .chapter-nav .next a { display: inline-block; font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); text-decoration: none; transition: color 0.15s; }
.chapter-nav .next { text-align: right; }
.chapter-nav .label { display: block; }
.chapter-nav .ttl { display: block; font-family: var(--font-body); font-size: var(--text-base); font-style: italic; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-mid); margin-top: 0.3rem; transition: color 0.15s; }
.chapter-nav a:hover { color: var(--accent); }
.chapter-nav a:hover .ttl { color: var(--accent); }
.chapter-nav .next:only-child { grid-column: 2; }

/* ---- cover / contents page ---- */
.cover { max-width: 52rem; margin: 0 auto; padding: 7rem 2rem 6rem; }
.cover-eyebrow { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin-bottom: 2rem; }
.cover-title { font-family: var(--font-body); font-size: clamp(2.8rem, 7vw, 4.6rem); font-weight: 400; line-height: 1.02; letter-spacing: -0.02em; color: var(--ink); max-width: 18ch; }
.cover-sub { margin-top: 1.6rem; max-width: 40ch; font-size: var(--text-md); font-style: italic; color: var(--ink-mid); line-height: 1.5; }
.cover-rule { width: 4rem; height: 3px; background: var(--accent); margin: 2.5rem 0; }
.cover-meta { font-family: var(--font-ui); font-size: var(--text-sm); color: var(--ink-faint); line-height: 1.9; }
.cover-meta strong { color: var(--ink-mid); font-weight: 500; }

.part-head { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 2.5rem 0 0; padding-top: 1.5rem; }
.part-head:first-of-type { border-top: none; }
.toc-list { list-style: none; padding: 0; margin: 1rem 0 0; border-top: 1px solid var(--rule); }
.toc-entry { display: grid; grid-template-columns: 3.5rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.toc-entry .tn { font-family: var(--font-ui); font-size: var(--text-sm); color: var(--ink-faint); }
.toc-entry a { font-family: var(--font-body); font-size: var(--text-md); color: var(--ink); text-decoration: none; }
.toc-entry a:hover { color: var(--accent); }
.toc-entry .desc { display: block; font-size: var(--text-sm); font-style: italic; color: var(--ink-faint); margin-top: 0.25rem; }
.toc-entry.todo a { color: var(--ink-faint); }
.toc-entry.todo .tn::after { content: " ·"; }

@media (max-width: 640px) {
  .page { padding: 3rem 1.25rem 5rem; }
  .cover { padding: 4rem 1.25rem 4rem; }
  .site-header { padding: 1rem 1.25rem; }
  .book-nav { display: none; }
  .opener-title { font-size: var(--text-xl); }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav .next { text-align: left; }
  .toc-entry { grid-template-columns: 2.5rem 1fr; }
}
