/* ================================================
   Columbus application · book-style page-turner
   ================================================ */
:root {
  --bg: #fbfaf7;
  --bg-2: #f3efe5;
  --surface: #ffffff;
  --line: #e6e0d2;
  --line-2: #d4ccb7;

  --text: #1a1815;
  --text-dim: #3a3530;
  --text-mute: #6e6a62;

  --accent: #8b3a1f;
  --accent-hi: #a8462a;
  --ok: #2f5233;

  --radius-sm: 4px;
  --radius: 6px;

  --serif: 'Fraunces', 'Iowan Old Style', 'Georgia', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --topbar-h: 64px;
  --pagenav-h: 72px;
  --page-transition: 280ms;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  background: var(--bg);
  height: 100%;
}
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul, ol { list-style: none; padding: 0; margin: 0; }

/* ================================================
   Intro overlay · brain + welcome
   ================================================ */
.intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #0b0a08;
  overflow: hidden;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
.intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.intro-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at center, rgba(11,10,8,0) 0%, rgba(11,10,8,0.55) 70%, rgba(11,10,8,0.88) 100%);
  pointer-events: none;
}
.intro-card {
  text-align: center;
  max-width: 620px;
  color: #f7f2e6;
  pointer-events: auto;
}

/* Brain-mesh node labels · track 3D positions each frame from intro.js */
.intro-nodes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.intro-node-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(11, 10, 8, 0.72);
  border: 1px solid rgba(233, 196, 106, 0.35);
  color: rgba(247, 242, 230, 0.92);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
  will-change: transform, opacity;
  user-select: none;
}
.intro-node-label:hover,
.intro-node-label:focus-visible {
  background: rgba(233, 196, 106, 0.18);
  border-color: rgba(255, 224, 176, 0.8);
  color: #ffe0b0;
  outline: none;
}
.intro-node-label.is-behind {
  opacity: 0 !important;
  pointer-events: none;
}
/* Tier tinting — cheap hue hint on the left edge */
.intro-node-label--ch1        { border-left: 3px solid #f4a261; }
.intro-node-label--ch2        { border-left: 3px solid #5bc0be; }
.intro-node-label--ch2-extra  { border-left: 3px solid #ef476f; }
.intro-node-label--ch3        { border-left: 3px solid #83d2cc; }
.intro-node-label--repo       { border-left: 3px solid #b24592; }

.intro-node-label.is-selected {
  background: rgba(233, 196, 106, 0.22);
  border-color: rgba(255, 224, 176, 0.85);
  color: #ffe0b0;
}

@media (max-width: 520px) {
  .intro-node-label {
    font-size: 0.62rem;
    padding: 0.25rem 0.55rem;
  }
}

/* Brain-mesh node panel · mwmai.no-style side card */
.intro-node-panel {
  position: absolute;
  top: 5vh;
  right: 3vh;
  width: 360px;
  max-width: calc(100vw - 2rem);
  max-height: 85vh;
  overflow-y: auto;
  z-index: 10;
  background: rgba(11, 10, 8, 0.88);
  border: 1px solid rgba(247, 242, 230, 0.10);
  border-left: 4px solid rgba(233, 196, 106, 0.7);
  padding: 28px 26px 24px 26px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  color: #f7f2e6;
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.intro-node-panel.is-open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.intro-node-panel-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(247, 242, 230, 0.55);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}
.intro-node-panel-close:hover { color: #ffe0b0; }

.intro-node-panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.intro-node-panel-swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}
.intro-node-panel-title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  color: #e9c46a;
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.intro-node-panel-summary {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.58;
  color: rgba(247, 242, 230, 0.82);
  margin: 0 0 18px 0;
}
.intro-node-panel-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(247, 242, 230, 0.10);
}
.intro-node-panel-link {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #e9c46a;
  text-decoration: none;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(233, 196, 106, 0.35);
  border-radius: 4px;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.intro-node-panel-link:hover {
  background: rgba(233, 196, 106, 0.14);
  color: #ffe0b0;
  border-color: rgba(255, 224, 176, 0.75);
}

@media (max-width: 520px) {
  .intro-node-panel {
    top: auto;
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    max-height: 65vh;
    padding: 22px 20px 20px 20px;
  }
  .intro-node-panel-title { font-size: 1.2rem; }
  .intro-node-panel-summary { font-size: 0.88rem; }
}
.intro-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(247, 242, 230, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-bottom: 1.6rem;
}
.intro-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  color: #f7f2e6;
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.intro-sub {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.6;
  color: rgba(247, 242, 230, 0.82);
  margin: 0 0 2rem;
  font-style: italic;
}
.intro-btn {
  background: #f7f2e6;
  color: #0b0a08;
  border-color: #f7f2e6;
  font-size: 0.95rem;
  padding: 0.9rem 1.7rem;
}
.intro-btn:hover { background: #d9a46b; border-color: #d9a46b; color: #0b0a08; }
.intro-hint {
  margin-top: 1.8rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: rgba(247, 242, 230, 0.45);
  letter-spacing: 0.08em;
}

/* Site starts hidden; fades in after intro */
.site { opacity: 0; transition: opacity 0.9s ease 0.1s; }
.site.revealed { opacity: 1; }

/* ================================================
   Top bar · sticky, minimal
   ================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 2rem;
  padding: 1rem 2rem;
  height: var(--topbar-h);
  background: rgba(251, 250, 247, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: baseline; gap: 0.55rem;
  font-size: 0.92rem;
  cursor: pointer;
}
.brand-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.02rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand-sep { color: var(--line-2); font-weight: 300; }
.brand-role { color: var(--text-mute); font-weight: 400; font-size: 0.85rem; }
.topnav { display: flex; gap: 1.6rem; margin-left: auto; }
.topnav a {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-mute);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.topnav a::before {
  content: attr(data-num);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--line-2);
  margin-right: 0.5rem;
  transition: color 0.15s;
}
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--text); border-bottom-color: var(--accent); }
.topnav a.active::before { color: var(--accent); }

.cta-small {
  padding: 0.5rem 1rem;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.cta-small:hover { background: var(--accent); border-color: var(--accent); }

/* ================================================
   Reading progress bar
   ================================================ */
.progress-track {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  height: 2px;
  background: var(--line);
  width: 100%;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width var(--page-transition) ease;
}

/* ================================================
   Book stage · single page in view
   ================================================ */
.book {
  display: flex;
  justify-content: center;
  padding: 1rem;
  min-height: calc(100vh - var(--topbar-h) - var(--pagenav-h));
}
.page-stage {
  position: relative;
  width: 100%;
  max-width: 720px;
  min-height: calc(100vh - var(--topbar-h) - var(--pagenav-h) - 2rem);
  padding: 3.2rem 3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(26, 24, 21, 0.04),
    0 20px 40px -20px rgba(26, 24, 21, 0.08);
  overflow: hidden;
  /* subtle inner page edge */
  background-image: linear-gradient(to right, rgba(230, 224, 210, 0.5) 0, rgba(230, 224, 210, 0) 8px);
}

/* One page at a time. Page is in normal flow so stage grows with content. */
.page {
  position: relative;
  opacity: 1;
  transform: translateX(0);
  transition: opacity var(--page-transition) ease, transform var(--page-transition) ease;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h) - var(--pagenav-h) - 10rem);
}
.page.from-right { opacity: 0; transform: translateX(28px); }
.page.from-left  { opacity: 0; transform: translateX(-28px); }

/* ================================================
   Page navigation · Prev / counter / Next
   ================================================ */
.page-nav {
  position: sticky;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--pagenav-h);
  padding: 0 2rem;
  background: rgba(251, 250, 247, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.page-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1.3rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  min-width: 130px;
  justify-content: center;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-btn-arrow { font-family: var(--serif); font-size: 1.2rem; line-height: 1; }
.page-counter {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-mute);
  letter-spacing: 0.1em;
}

/* ================================================
   Page type · COVER
   ================================================ */
.page-cover {
  justify-content: center;
  text-align: left;
  padding-left: 0.5rem;
}
.cover-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-bottom: 2rem;
}
.cover-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 6.5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 2rem;
  color: var(--text);
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.cover-title .italic { color: var(--accent); font-style: italic; font-weight: 400; }
.cover-para {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.75;
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 0 1.2rem;
  text-wrap: pretty;
}
.cover-cta {
  align-self: flex-start;
  margin-top: 2rem;
}

/* ================================================
   Page type · CHAPTER COVER
   ================================================ */
.page-chapter-cover {
  justify-content: center;
  padding-left: 0.5rem;
}
.cc-kicker {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  margin-bottom: 1.5rem;
}
.cc-numeral {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(7rem, 18vw, 13rem);
  line-height: 0.85;
  color: var(--accent);
  letter-spacing: -0.05em;
  margin: 0 0 1.4rem;
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.cc-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 1.4rem;
  max-width: 560px;
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.cc-epigraph {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-mute);
  max-width: 480px;
  margin: 1.4rem 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}

/* ================================================
   Page type · PROSE
   ================================================ */
.page-prose .prose {
  max-width: 580px;
}
.page-prose p {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.85;
  color: var(--text);
  margin: 0 0 1.25rem;
  text-wrap: pretty;
  hyphens: auto;
  font-variation-settings: 'opsz' 14;
}
.page-prose p.lead {
  font-style: italic;
  color: var(--text-dim);
  font-size: 1.25rem;
  margin-bottom: 1.7rem;
}
.page-prose p strong { font-weight: 600; color: var(--text); }
.page-prose em { font-style: italic; }

/* Drop cap · applied to first non-lead body paragraph */
.page-prose.with-dropcap .prose p:not(.lead):first-of-type::first-letter,
.page-prose.with-dropcap .prose p.lead + p::first-letter {
  float: left;
  font-family: var(--serif);
  font-style: normal;
  font-weight: 400;
  font-size: 4.4rem;
  line-height: 0.88;
  padding: 0.35rem 0.6rem 0 0;
  margin: 0.15rem 0 0 -0.1rem;
  color: var(--accent);
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}

/* Chapter-end quiet link line */
.page-prose .end-links {
  margin-top: auto;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 1.2rem;
  max-width: 580px;
}
.page-prose .end-links .kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  flex-shrink: 0;
}
.page-prose .end-links a {
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  border-bottom: 1px solid rgba(139, 58, 31, 0.45);
  transition: border-color 0.15s, color 0.15s;
  margin-right: 1rem;
}
.page-prose .end-links a:hover { color: var(--accent-hi); border-bottom-color: var(--accent-hi); }

/* ================================================
   Page type · BACK
   ================================================ */
.page-back {
  justify-content: center;
  text-align: left;
}
.back-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-bottom: 1.4rem;
}
.back-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
  color: var(--text);
  font-variation-settings: 'SOFT' 30, 'opsz' 144;
}
.back-body {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-dim);
  margin: 0 0 2rem;
  max-width: 520px;
}
.back-actions {
  display: flex; gap: 0.7rem; flex-wrap: wrap;
}
.back-closing {
  margin: 2rem 0 0;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dim);
}
.back-closing-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-mute);
  padding-bottom: 1px;
}
.back-closing-link:hover {
  border-bottom-color: var(--text);
}
.back-closing-desc {
  color: var(--text-mute);
}

/* ================================================
   Shared buttons
   ================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--text); }
.btn-arrow { transition: transform 0.15s; }
.btn:hover .btn-arrow { transform: translateX(3px); }

/* ================================================
   Footer · small on every page
   ================================================ */
.site-footer {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 2rem 2rem 3rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  font-size: 0.86rem;
  color: var(--text-dim);
}
.footer-col { display: flex; flex-direction: column; gap: 0.4rem; }
.footer-col strong {
  color: var(--text);
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-family: var(--serif);
  font-size: 1rem;
}
.footer-col a:hover { color: var(--accent); }

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: 0.9rem 1.1rem; gap: 0.8rem; height: auto; }
  .topnav { order: 3; width: 100%; overflow-x: auto; gap: 1.2rem; padding: 0.2rem 0; }
  .topnav a { white-space: nowrap; }
  .cta-small { order: 2; }
  .book { padding: 0.5rem; }
  .page-stage {
    padding: 2rem 1.4rem;
    border-radius: 0;
    border-left: 0; border-right: 0;
    box-shadow: none;
  }
  .page { inset: 2rem 1.4rem; }
  .page-nav { padding: 0 1rem; gap: 0.5rem; }
  .page-btn { min-width: 0; padding: 0.65rem 0.9rem; font-size: 0.86rem; }
  .page-btn-text { display: none; }
  .page-counter { font-size: 0.76rem; }
  .page-prose p { font-size: 1.08rem; line-height: 1.75; }
  .page-prose.with-dropcap .prose p:not(.lead):first-of-type::first-letter,
  .page-prose.with-dropcap .prose p.lead + p::first-letter {
    font-size: 3.4rem;
  }
  .site-footer { grid-template-columns: 1fr; padding: 1.4rem 1.2rem 2rem; }
  .intro-card { padding: 0 0.4rem; }
  .intro-sub { font-size: 1rem; }
}
