/* ═══════════════════════════════════════════════════════════
   THE SKILL STACK — Design System
   By Anup Neupane

   Every pixel is psychologically intentional.
   BIAS-designed components. Psych-scored spacing.
   Growth Writing + Growth Design at maximum depth.
   ═══════════════════════════════════════════════════════════ */

/* ─── Color System (16 semantic tokens) ─── */
:root {
  --bg: #faf8f5; --bg2: #f3f0eb; --bg3: #ebe7e0;
  --fg: #1a1917; --fg2: #6b6860; --fg3: #9e9a90;
  --red: #c4392a; --red2: #e05a4a;
  --red-bg: rgba(196,57,42,.06);
  --border: #ddd8d0; --card: #f7f5f1;
  --highlight: #fff8e1;
  --nav-bg: rgba(250,248,245,.88);
}
[data-theme="dark"] {
  --bg: #111110; --bg2: #1a1918; --bg3: #222120;
  --fg: #ede9e0; --fg2: #9e9a90; --fg3: #6b6860;
  --red: #e05a4a; --red2: #ff8a7a;
  --red-bg: rgba(224,90,74,.08);
  --border: #2a2825; --card: #1a1918;
  --highlight: rgba(255,248,225,.06);
  --nav-bg: rgba(17,17,16,.88);
}

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

/* ─── Typography (1.25 modular scale, 8px grid) ─── */
html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}
body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg); color: var(--fg);
  line-height: 1.82;
  transition: background .4s ease, color .4s ease;
  overflow-x: hidden;
}

/* ─── Navigation ─── */
.nav {
  position: fixed; top:0; left:0; right:0; height: 48px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 100;
  transition: transform .3s ease;
}
.nav.hidden { transform: translateY(-100%); }
.nav-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg3); text-decoration: none;
}
.nav-title a { color: inherit; text-decoration: none; }
.nav-meta {
  font-family: -apple-system, sans-serif;
  font-size: .62rem; color: var(--fg3); letter-spacing: .05em;
}
.nav-controls { display: flex; gap: 8px; align-items: center; }
.nav-btn {
  background: none; border: 1px solid var(--border);
  color: var(--fg3); cursor: pointer;
  font-family: -apple-system, sans-serif; font-size: .65rem;
  padding: 3px 8px; border-radius: 4px; transition: all .2s;
}
.nav-btn:hover { border-color: var(--fg2); color: var(--fg2); }

/* ─── Progress Bar ─── */
.progress {
  position: fixed; top: 0; left: 0;
  height: 2px; background: var(--red);
  z-index: 101; transition: width .1s linear; width: 0;
}

/* ─── Content Container ─── */
.c { max-width: 640px; margin: 0 auto; padding: 72px 24px 80px; }

/* ─── Scroll Reveal ─── */
.reveal {
  opacity: 0; transform: translateY(20px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ─── Cover (index.html) ─── */
.cover {
  text-align: center; padding: 100px 0 72px;
  border-bottom: 1px solid var(--border); margin-bottom: 72px;
}
.cover h1 {
  font-size: 2.6rem; font-weight: 400;
  line-height: 1.15; letter-spacing: -.04em; margin-bottom: 16px;
}
.cover .sub {
  font-size: 1.05rem; color: var(--fg2);
  font-style: italic; margin-bottom: 32px;
}
.cover .author {
  font-family: -apple-system, sans-serif;
  font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--fg3);
}

/* ─── Start Reading CTA ─── */
.cta {
  display: inline-block; margin-top: 40px;
  padding: 14px 36px; background: var(--red); color: #fff;
  font-family: -apple-system, sans-serif; font-size: .82rem;
  font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  text-decoration: none; border-radius: 6px;
  transition: background .2s, transform .1s;
}
.cta:hover { background: var(--red2); }
.cta:active { transform: scale(.97); }
.cta-secondary {
  display: inline-block; margin-top: 14px;
  padding: 10px 28px; background: none; color: var(--fg2);
  font-family: -apple-system, sans-serif; font-size: .72rem;
  font-weight: 500; letter-spacing: .04em;
  text-decoration: none; border-radius: 6px;
  border: 1px solid var(--border);
  transition: all .2s;
}
.cta-secondary:hover { border-color: var(--red); color: var(--red); }
.cta-secondary:active { transform: scale(.97); }

/* ─── Chapter Grid (index.html) ─── */
.chapter-grid {
  display: grid; grid-template-columns: 1fr;
  gap: 2px; margin: 48px 0;
}
.chapter-card {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 24px; background: var(--bg2);
  text-decoration: none; color: var(--fg);
  transition: background .2s;
  border-bottom: 1px solid var(--border);
}
.chapter-card:first-child { border-radius: 8px 8px 0 0; }
.chapter-card:last-child { border-radius: 0 0 8px 8px; border-bottom: none; }
.chapter-card:hover { background: var(--bg3); }
.chapter-card .num {
  font-family: -apple-system, sans-serif;
  font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--red); min-width: 32px; flex-shrink: 0;
}
.chapter-card .title {
  font-size: .95rem; font-weight: 400;
}
.chapter-card .hook {
  font-size: .78rem; color: var(--fg2); margin-top: 2px;
}
.chapter-card .arrow {
  margin-left: auto; color: var(--fg3); font-size: .8rem; flex-shrink: 0;
}

/* ─── Part Label (in chapter grid and chapter pages) ─── */
.part-label {
  font-family: -apple-system, sans-serif;
  font-size: .56rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--red); padding: 24px 24px 8px; margin-top: 8px;
}

/* ─── Part Banner (chapter pages) ─── */
.part {
  background: var(--bg2); margin: 0 -24px 56px; padding: 56px 24px;
  text-align: center;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.part .part-num {
  font-family: -apple-system, sans-serif;
  font-size: .6rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--red); margin-bottom: 12px;
}
.part h2 { font-size: 1.7rem; font-weight: 400; letter-spacing: -.02em; }

/* ─── Chapter Header ─── */
.ch-header { padding: 48px 0 8px; margin-bottom: 36px; }
.ch-num {
  font-family: -apple-system, sans-serif;
  font-size: .58rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--red); margin-bottom: 8px;
}
.ch-title {
  font-size: 1.55rem; font-weight: 400;
  line-height: 1.28; letter-spacing: -.02em;
}

/* ─── Text ─── */
p { margin-bottom: 20px; }
h3 { font-size: 1.08rem; font-weight: 600; margin: 44px 0 16px; letter-spacing: -.01em; }
strong { font-weight: 600; }
em { font-style: italic; }
code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: .84em; background: var(--bg2);
  padding: 2px 6px; border-radius: 3px;
}

/* ─── Blockquote ─── */
blockquote {
  border-left: 3px solid var(--red); background: var(--red-bg);
  padding: 16px 20px; margin: 32px 0; font-style: italic;
}
blockquote p { margin-bottom: 0; }

/* ─── Pull Quote (+BIAS Store: screenshot-worthy) ─── */
.pull {
  font-size: 1.35rem; font-weight: 400; line-height: 1.45;
  text-align: center; margin: 48px 0; padding: 0 16px;
  color: var(--fg); letter-spacing: -.01em;
}
.pull strong { color: var(--red); font-weight: 600; }

/* ─── Key Insight Box (+Psych: Progress) ─── */
.insight {
  background: var(--highlight); border-left: 3px solid var(--red);
  padding: 20px 24px; margin: 36px 0; border-radius: 0 6px 6px 0;
}
.insight p { margin-bottom: 0; font-size: .95rem; }

/* ─── Stat Card (+BIAS Interpret: anchoring) ─── */
.stat { text-align: center; margin: 40px 0; padding: 32px 0; }
.stat .num {
  font-size: 3.2rem; font-weight: 300; color: var(--red);
  letter-spacing: -.04em; line-height: 1;
}
.stat .label {
  font-family: -apple-system, sans-serif;
  font-size: .72rem; color: var(--fg2); margin-top: 8px; letter-spacing: .04em;
}

/* ─── SVG Figure ─── */
.fig { margin: 36px 0; max-width: 100%; overflow: hidden; }
.fig svg { width: 100%; height: auto; display: block; }
.fig figcaption, .fig-img figcaption {
  font-family: -apple-system, sans-serif;
  font-size: .68rem; color: var(--fg3);
  text-align: center; margin-top: 12px; letter-spacing: .02em;
}

/* ─── Reference Image ─── */
.fig-img { margin: 36px 0; max-width: 100%; overflow: hidden; }
.fig-img img {
  width: 100%; max-width: 100%; height: auto;
  display: block; border-radius: 6px; border: 1px solid var(--border);
}

/* ─── Data Table ─── */
table { width: 100%; border-collapse: collapse; margin: 28px 0; font-size: .86rem; }
th {
  font-family: -apple-system, sans-serif;
  font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg3); text-align: left; padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* ─── Diagnostic — Engineering action prompt ─── */
/* Looks like a terminal/system diagnostic — not a worksheet.
   Monospace font signals "this is code-level thinking."
   Dark background separates it from the reading flow.
   Context paragraph above explains WHY this diagnostic matters. */
.diagnostic {
  background: #1a1917; color: #e0ddd8; border-radius: 8px;
  padding: 24px 28px; margin: 36px 0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: .82rem; line-height: 1.7;
  border: 1px solid #2a2825;
}
[data-theme="dark"] .diagnostic {
  background: #0a0a09; border-color: #333;
}
.diagnostic-title {
  font-family: -apple-system, sans-serif;
  font-size: .58rem; letter-spacing: .16em; text-transform: uppercase;
  color: #e05a4a; margin-bottom: 16px; font-weight: 600;
}
.diagnostic p {
  margin-bottom: 6px; color: #c4c0b8;
}
.diagnostic strong { color: #fff; font-weight: 500; }
.diagnostic .field {
  display: inline-block; border-bottom: 1px solid #555;
  min-width: 120px; color: #e05a4a; margin: 0 2px;
}
.diagnostic .context {
  font-family: Georgia, serif; font-size: .88rem;
  color: var(--fg2); margin-bottom: 20px; line-height: 1.65;
  font-style: normal;
}

/* ─── Chapter Summary (+Psych: Clear Feedback) ─── */
.sum {
  border-top: 2px solid var(--border);
  margin: 48px 0 0; padding-top: 24px;
}
.sum-title {
  font-family: -apple-system, sans-serif;
  font-size: .6rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--fg3); margin-bottom: 14px;
}
.sum ul { list-style: none; padding: 0; }
.sum li {
  margin-bottom: 10px; font-size: .9rem;
  padding-left: 18px; position: relative; color: var(--fg2);
}
.sum li::before { content: '—'; position: absolute; left: 0; color: var(--red); }

/* ─── Chapter Navigation (prev/next) ─── */
.ch-nav {
  display: flex; justify-content: space-between; align-items: stretch;
  margin: 64px 0 0; padding-top: 32px;
  border-top: 1px solid var(--border); gap: 16px;
}
.ch-nav a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 20px; background: var(--bg2);
  text-decoration: none; color: var(--fg);
  border-radius: 8px; transition: background .2s; flex: 1;
}
.ch-nav a:hover { background: var(--bg3); }
.ch-nav .dir {
  font-family: -apple-system, sans-serif;
  font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--red);
}
.ch-nav .ch-nav-title { font-size: .9rem; font-weight: 400; }
.ch-nav .ch-nav-hook {
  font-size: .76rem; color: var(--fg2); font-style: italic; margin-top: 4px;
}
.ch-nav .next { text-align: right; }

/* ─── Transition Text ─── */
.transition {
  font-style: italic; color: var(--fg2);
  text-align: center; margin: 48px 0; font-size: .92rem; line-height: 1.6;
}

/* ─── Footnote Tooltip ─── */
.ref {
  color: var(--red); cursor: pointer; font-size: .72em;
  vertical-align: super; font-weight: 600; position: relative; padding: 0 2px;
}
.ref:hover { color: var(--fg); }
.ref-tip {
  opacity: 0; visibility: hidden; position: absolute;
  bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  font-size: .76rem; font-style: normal; font-weight: 400;
  line-height: 1.5; padding: 12px 16px; border-radius: 8px;
  width: max-content; max-width: 360px; white-space: normal;
  z-index: 200; box-shadow: 0 8px 32px rgba(0,0,0,.2);
  pointer-events: auto; transition: opacity .15s ease, visibility .15s ease;
}
.ref-tip a { color: var(--red2); text-decoration: underline; }
.ref-tip a:hover { color: #fff; }
.ref-tip::after {
  content: ''; position: absolute; top: 100%;
  left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--fg);
}
.ref::before {
  content: ''; position: absolute;
  bottom: 100%; left: -10px; right: -10px; height: 16px;
}
.ref:hover .ref-tip, .ref-tip:hover { opacity: 1; visibility: visible; }

/* ─── Divider ─── */
hr {
  border: none; text-align: center; margin: 56px 0; color: var(--fg3);
}
hr::after { content: '\2022  \2022  \2022'; font-size: .7rem; letter-spacing: .4em; }

/* ─── Kicker ─── */
.kicker {
  font-size: 1.1rem; font-weight: 500; font-style: italic;
  text-align: center; margin: 48px 0; color: var(--fg); line-height: 1.5;
}

/* ─── Colophon ─── */
.colophon {
  text-align: center; padding: 64px 0;
  border-top: 1px solid var(--border);
  margin-top: 88px; color: var(--fg3); font-size: .84rem;
}

/* ─── Responsive ─── */
@media (max-width: 680px) {
  html { font-size: 16px; }
  .c { padding: 64px 18px 80px; }
  .cover h1 { font-size: 2rem; }
  .part { margin: 0 -18px 48px; padding: 40px 18px; }
  .pull { font-size: 1.15rem; }
  .ch-nav { flex-direction: column; }
  .ch-nav .next { text-align: left; }
  .ref-tip { max-width: 280px; left: 0; transform: none; }
  .ref-tip::after { left: 20px; }
  .chapter-card { padding: 16px 18px; }
}
