/* The Narrow Path — Single stylesheet. No framework. Content is the design. */

/* IBM Plex Mono — headings (SIL OFL license, see /fonts/LICENSE.txt) */
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Inter — body copy (SIL OFL license, see /fonts/Inter-LICENSE.txt) */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-BoldItalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* Color tokens — light theme */
:root {
  --color-bg: #fafaf8;
  --color-text: #1a1a1a;
  --color-muted: #999;
  --color-subtle: #666;
  --color-secondary: #444;
  --color-border: #ddd;
  --color-border-light: #eee;
  --color-hr: #bbb;
  --color-endmatter-bg: #f4f4f2;
  --color-endmatter-border: #e0e0dc;
  --color-hover-bg: #f5f5f3;
}

/* Color tokens — dark theme */
html.dark {
  --color-bg: #1a1a1e;
  --color-text: #d4d4d4;
  --color-muted: #777;
  --color-subtle: #999;
  --color-secondary: #aaa;
  --color-border: #333;
  --color-border-light: #2a2a2e;
  --color-hr: #555;
  --color-endmatter-bg: #222226;
  --color-endmatter-border: #333338;
  --color-hover-bg: #252529;
}

/* Smooth theme transition */
html.transition,
html.transition *,
html.transition *::before,
html.transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
}

/* Smooth scroll for anchor links */
html {
  scroll-behavior: smooth;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base typography */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

main {
  max-width: 38em;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Headings — IBM Plex Mono */
h1, h2, h3, h4 {
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.25;
}

h4 {
  font-size: 0.875rem;
  font-weight: 400;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 400;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Paragraphs and inline */
p {
  margin-bottom: 1rem;
}

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

a {
  color: var(--color-text);
  text-decoration-color: var(--color-muted);
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-color: var(--color-text);
}

/* Lists */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.35rem;
}

/* Task list checkboxes */
li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.5em;
  padding-left: 0;
}

li > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.9em;
  height: 0.9em;
  border: 1.5px solid var(--color-muted);
  border-radius: 2px;
  vertical-align: -0.05em;
  margin-right: 0.4em;
  background: transparent;
  cursor: default;
}

/* Blockquotes */
blockquote {
  margin: 1.5rem 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--color-border);
  color: var(--color-secondary);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Section breaks (--- in markdown) */
hr {
  border: none;
  text-align: center;
  margin: 2.5rem 0;
}

hr::after {
  content: "* * *";
  color: var(--color-hr);
  font-size: 0.85rem;
  letter-spacing: 0.5em;
}

/* ===== Site header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

.site-header nav {
  max-width: 38em;
  margin: 0 auto;
}

/* Top row: title + toggle */
.nav-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.site-title {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--color-text);
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  color: var(--color-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-subtle);
}

.toggle-icon::before {
  content: '[ dark ]';
}

html.dark .toggle-icon::before {
  content: '[ light ]';
}

/* Nav items: stacked rows */
.nav-items {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--color-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text);
}

.nav-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.nav-sep {
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* ===== Site footer ===== */
.site-footer {
  font-family: 'IBM Plex Mono', monospace;
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ===== Home page ===== */
.start-here {
  padding-top: 2rem;
}

.home-content {
  margin-top: 1.5rem;
}

.home-content p {
  margin-bottom: 1rem;
}

/* ===== Level landing pages ===== */
.level-landing {
  padding-top: 1rem;
}

.level-description {
  margin-bottom: 2rem;
  color: var(--color-secondary);
}

.chapter-list {
  list-style: none;
  padding-left: 0;
}

.chapter-list li {
  margin-bottom: 0;
}

.chapter-list a {
  display: flex;
  align-items: baseline;
  gap: 0.75em;
  text-decoration: none;
  color: var(--color-text);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border-light);
}

.chapter-list a:hover {
  background: var(--color-hover-bg);
}

.chapter-list .chapter-number {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--color-muted);
  min-width: 6em;
  flex-shrink: 0;
}

.chapter-list .chapter-title {
  font-size: 1.05rem;
}

/* Page list (Resources section) */
.page-list {
  list-style: none;
  padding-left: 0;
}

.page-list li {
  margin-bottom: 0.5rem;
}

.page-list a {
  font-size: 1.05rem;
}

/* ===== Chapter pages ===== */
.chapter-header {
  margin-bottom: 2.5rem;
}

.chapter-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
  display: flex;
  gap: 1.5em;
}

.chapter-meta .level-indicator {
  text-decoration: none;
  color: var(--color-muted);
}

.chapter-meta .level-indicator:hover {
  color: var(--color-subtle);
}

.chapter-body {
  margin-bottom: 2rem;
}

/* ===== Chapter navigation ===== */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
}

.chapter-nav a {
  text-decoration: none;
  color: var(--color-text);
  max-width: 48%;
}

.chapter-nav a:hover .nav-title {
  text-decoration: underline;
  text-decoration-color: var(--color-muted);
  text-underline-offset: 0.15em;
}

.nav-label {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 0.25rem;
}

.nav-title {
  display: block;
  font-size: 0.95rem;
}

.nav-next {
  text-align: right;
  margin-left: auto;
}

.nav-disabled {
  visibility: hidden;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  main {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.4rem;
  }

  .chapter-nav {
    flex-direction: column;
    gap: 1.25rem;
  }

  .chapter-nav a {
    max-width: 100%;
  }

  .nav-next {
    text-align: left;
  }

  .nav-levels {
    flex-direction: column;
    gap: 0.2rem;
  }

  .nav-sep {
    display: none;
  }
}

/* ===== Chapter end-matter (Summary, Action Items, etc.) ===== */
.chapter-endmatter {
  margin-top: 3rem;
  padding: 1.5rem 1.5rem 0.5rem;
  background: var(--color-endmatter-bg);
  border: 1px solid var(--color-endmatter-border);
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.chapter-endmatter h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-secondary);
}

.chapter-endmatter h2:first-child {
  margin-top: 0;
}

.chapter-endmatter p {
  margin-bottom: 0.6rem;
}

.chapter-endmatter ul,
.chapter-endmatter ol {
  margin-bottom: 0.6rem;
}

.chapter-endmatter li {
  margin-bottom: 0.25rem;
}

/* ===== 404 page ===== */
.error-404 {
  padding-top: 3rem;
  padding-bottom: 3rem;
  text-align: center;
}

.error-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 4rem;
  font-weight: 700;
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* ===== Print styles ===== */
@media print {
  /* Force light theme */
  :root {
    --color-bg: #fff;
    --color-text: #000;
    --color-muted: #555;
    --color-subtle: #444;
    --color-secondary: #333;
    --color-border: #ccc;
    --color-border-light: #ddd;
    --color-hr: #999;
    --color-endmatter-bg: #f5f5f5;
    --color-endmatter-border: #ddd;
    --color-hover-bg: transparent;
  }

  /* Hide chrome */
  .site-header,
  .site-footer,
  .chapter-nav {
    display: none !important;
  }

  /* Clean layout */
  body {
    font-size: 11pt;
    line-height: 1.4;
    background: #fff;
    color: #000;
  }

  main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* Page title */
  h1 {
    font-size: 16pt;
    margin-bottom: 0.5rem;
  }

  /* Level headings — page break before each level */
  h2 {
    font-size: 13pt;
    margin-top: 1.5rem;
    page-break-before: auto;
  }

  /* Chapter headings — keep with content */
  h2, h3, strong {
    page-break-after: avoid;
  }

  /* Don't break a chapter's items across pages */
  p + ul {
    page-break-before: avoid;
  }

  /* Checkbox lists — compact for paper */
  ul {
    page-break-inside: avoid;
  }

  li {
    margin-bottom: 0.15rem;
    line-height: 1.35;
  }

  /* Strip link underlines, show as plain text */
  a {
    color: #000;
    text-decoration: none;
  }

  /* Checkboxes — crisp border for print */
  li > input[type="checkbox"] {
    border-color: #000;
    border-width: 1.5px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide the jump links and print CTA */
  main > ul:first-child,
  main > ul:first-child + p,
  main > ul:first-child + p + hr {
    display: none !important;
  }
}
