@font-face { font-family: "TeX Gyre Pagella"; src: local("TeX Gyre Pagella"), url("../fonts/pagella-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Pagella"; src: local("TeX Gyre Pagella Italic"), url("../fonts/pagella-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "TeX Gyre Pagella"; src: local("TeX Gyre Pagella Bold"), url("../fonts/pagella-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Pagella"; src: local("TeX Gyre Pagella Bold Italic"), url("../fonts/pagella-bolditalic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }

/* The book's own typography: Palatino for text, Optima for titles and labels, a Luxi-like mono for code. */
:root {
  --read: Palatino, "Palatino Linotype", "Book Antiqua", "TeX Gyre Pagella", "URW Palladio L", Georgia, serif;
  --ui: "Raleway", "Segoe UI", system-ui, -apple-system, sans-serif;
  --book-sans: Optima, "Optima Nova", Candara, "URW Classico", "Segoe UI", sans-serif;
  --mono: "Luxi Mono", Menlo, Consolas, "IBM Plex Mono", "DejaVu Sans Mono", monospace;
  --navy: #2c365e;
  --navy-deep: #1f2745;
  --slate: #2f3a55;
  --teal: #3f9a8c;
  --teal-deep: #2f7a6f;
  --orange: #e1a64a;
  --red: #d7263d;
  --red-deep: #b01c30;
  --ink: #1d2233;
  --muted: #5b6275;
  --line: #e4e0d6;
  --paper: #fffdf8;
  --wash: #f6f1e6;
  --parchment: #efe4cc;
  --think: #fcdcef;
  --think-edge: #d7263d;
  --exercise: #e7defc;
  --exercise-edge: #6b3fa0;
  --challenge: #e3f5ea;
  --challenge-edge: #2e7a3c;
  --charge: #dff1fd;
  --charge-edge: #2a6bb5;
  --nt-a: #a03881;
  --nt-c: #64b0f4;
  --nt-g: #ff4363;
  --nt-t: #66cc66;
  --radius: 10px;
  --shadow: 0 14px 34px rgba(31,39,69,0.12);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --navy: #c9d3f5;
  --navy-deep: #0f1426;
  --slate: #151b2e;
  --teal: #4fb3a4;
  --teal-deep: #7fd1c4;
  --ink: #e7e9f1;
  --muted: #a4abc0;
  --line: #2c3450;
  --paper: #121728;
  --wash: #1a2036;
  --parchment: #232a44;
  --think: #3a2231;
  --exercise: #2c2545;
  --challenge: #1d3328;
  --charge: #1b2c40;
  --think-edge: #ff6b7d;
  --exercise-edge: #b79cf0;
  --challenge-edge: #6fcf86;
  --charge-edge: #7fb4f0;
  --shadow: 0 14px 34px rgba(0,0,0,0.45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #c9d3f5; --navy-deep: #0f1426; --slate: #151b2e; --teal: #4fb3a4; --teal-deep: #7fd1c4;
    --ink: #e7e9f1; --muted: #a4abc0; --line: #2c3450; --paper: #121728; --wash: #1a2036; --parchment: #232a44;
    --think: #3a2231; --exercise: #2c2545; --challenge: #1d3328; --charge: #1b2c40;
    --think-edge: #ff6b7d; --exercise-edge: #b79cf0; --challenge-edge: #6fcf86; --charge-edge: #7fb4f0;
    --shadow: 0 14px 34px rgba(0,0,0,0.45); color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--ui); font-size: 17px; line-height: 1.6; }
img { max-width: 100%; height: auto; }
a { color: var(--teal-deep); }
a:hover { color: var(--navy); }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: #fff; padding: 8px 12px; }

/* Buttons */
.btn { display: inline-block; font-family: var(--ui); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; text-decoration: none; padding: 0.7em 1.25em; border-radius: 999px; border: 2px solid transparent; line-height: 1.2; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); color: #fff; }
.btn-buy { background: var(--teal); color: #fff; }
.btn-buy:hover { background: var(--teal-deep); color: #fff; }
.btn-ghost { border-color: currentColor; color: var(--navy); background: transparent; }
.btn-ghost:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-small { padding: 0.5em 1em; font-size: 0.85rem; background: var(--orange); color: var(--navy-deep); }
.btn-small:hover { background: #fff; color: var(--navy-deep); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 96%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(6px); }
.header-row { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); margin-right: auto; }
.brand-monkey { width: 64px; height: auto; flex: 0 0 auto; transition: transform 0.25s; }
.brand:hover .brand-monkey { transform: rotate(-4deg) translateY(-1px); }
.brand-words { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-family: var(--ui); font-weight: 800; font-size: 1.18rem; letter-spacing: 0.01em; color: var(--navy); }
.brand-sub { font-family: var(--ui); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.header-tools { display: flex; align-items: center; gap: 2px; order: 3; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--navy); cursor: pointer; font-size: 1.6rem; line-height: 1; }
.icon-btn:hover { background: var(--wash); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; } :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; } }
.menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 10px; }
.menu-btn span { display: block; width: 22px; height: 2px; background: var(--navy); margin: 5px 0; }
.site-nav { display: flex; align-items: center; gap: 2px; order: 2; font-family: var(--ui); }
.site-nav > a, .nav-group > a { color: var(--navy); text-decoration: none; font-weight: 600; font-size: 0.98rem; padding: 8px 10px; border-radius: 6px; }
.site-nav > a:hover, .nav-group > a:hover { background: var(--wash); }
.site-nav > .nav-cta { color: #fff; margin-left: 8px; padding: 0.62em 1.1em; }
.site-nav > .nav-cta:hover { background: var(--red-deep); color: #fff; }
.nav-group { position: relative; }
.nav-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; min-width: 260px; }
.nav-group:hover .nav-menu, .nav-group:focus-within .nav-menu { display: block; }
.nav-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.nav-menu a:hover { background: var(--wash); }
.nav-num { display: inline-block; width: 1.6em; color: var(--orange); font-weight: 800; }
@media (max-width: 1080px) { .brand-sub { display: none; } .brand-title { font-size: 1.12rem; } }
@media (max-width: 980px) {
  .menu-btn { display: block; }
  .site-nav { display: none; }
  .site-nav.open { display: flex; flex-direction: column; align-items: stretch; position: absolute; left: 0; right: 0; top: 72px; background: var(--paper); border-bottom: 1px solid var(--line); padding: 10px 20px 20px; box-shadow: var(--shadow); max-height: calc(100vh - 72px); overflow: auto; }
  .nav-menu { display: block; position: static; border: 0; box-shadow: none; padding: 0 0 0 10px; min-width: 0; }
  .site-nav > .nav-cta { margin: 8px 0 0; text-align: center; }
}
@media (max-width: 420px) { .brand-monkey { width: 52px; } .brand-title { font-size: 1rem; } }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--orange); transition: width 0.1s linear; }

/* Generic page */
.page { padding: 40px 20px 60px; }
.page-title { font-size: clamp(2rem, 4vw, 2.8rem); color: var(--navy); line-height: 1.15; margin: 0 0 12px; font-weight: 800; }
.page-title::before { content: ""; display: block; width: 56px; height: 5px; background: var(--orange); border-radius: 3px; margin-bottom: 18px; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 46em; margin: 0 0 24px; }
.kicker { font-weight: 700; font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal-deep); margin: 0 0 10px; }
h2, h3 { color: var(--navy); line-height: 1.25; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 4px; }

/* Home hero */
.hero { background: linear-gradient(180deg, #fff 0%, var(--wash) 100%); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding-top: 40px; padding-bottom: 48px; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.05; color: var(--navy); margin: 0 0 16px; font-weight: 800; }
.hero .lede { color: var(--ink); font-size: 1.25rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 10px; }
.hero-note { font-size: 0.92rem; color: var(--muted); margin: 6px 0 0; }
.hero-art img { display: block; width: 100%; max-width: 520px; margin: 0 auto; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 26px; }
.stat strong { display: block; font-size: 1.6rem; color: var(--navy); font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } .hero-art { order: -1; } .hero-art img { max-width: 320px; } }

/* Sections */
.section { padding: 60px 0; }
.section-alt { background: var(--wash); }
.section-dark { background: var(--navy); color: #fff; }
.section-dark h2, .section-dark h3 { color: #fff; }
.section-title { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 0 0 10px; font-weight: 800; }
.section-lede { color: var(--muted); max-width: 44em; margin: 0 0 30px; font-size: 1.08rem; }
.section-dark .section-lede { color: #cfd5e6; }

/* Chapter cards */
.chapter-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.chapter-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.chapter-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(31,39,69,0.12); color: var(--ink); }
.chapter-card img { width: 100%; aspect-ratio: 7 / 10; object-fit: cover; background: var(--wash); }
.chapter-card .cc-body { padding: 14px 16px 18px; }
.chapter-card .cc-num { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal-deep); }
.chapter-card .cc-q { display: block; font-weight: 700; color: var(--navy); line-height: 1.3; margin-top: 4px; }
.chapter-card .cc-tag { display: inline-block; margin-top: 10px; font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--teal) 16%, var(--paper)); color: var(--teal-deep); }
.chapter-card.locked .cc-tag { background: color-mix(in srgb, var(--orange) 22%, var(--paper)); color: var(--ink); }

/* Features */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.feature h3 { margin: 0 0 8px; font-size: 1.15rem; }
.feature p { margin: 0; color: var(--muted); }
.feature .icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--teal) 16%, var(--paper)); color: var(--teal-deep); font-weight: 800; margin-bottom: 12px; }

/* Buy panel */
.buy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.buy-card { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 24px; border: 1px solid var(--line); display: flex; flex-direction: column; }
.buy-card h3 { margin: 0 0 4px; }
.buy-card .price { font-size: 1.9rem; font-weight: 800; color: var(--navy); margin: 6px 0; }
.buy-card .price small { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.buy-card ul { padding-left: 1.1em; color: var(--muted); margin: 8px 0 18px; }
.buy-card .btn { margin-top: auto; text-align: center; }
.buy-card.best { border: 2px solid var(--teal); position: relative; }
.buy-card.best::before { content: attr(data-label); position: absolute; top: -12px; left: 20px; background: var(--teal); color: #fff; font-size: 0.75rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.05em; }

/* Quotes */
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.quote { margin: 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); border-radius: var(--radius); padding: 24px; }
.quote p { font-family: var(--ui); font-weight: 500; font-size: 1.15rem; line-height: 1.5; margin: 0 0 14px; }
.quote footer { color: var(--orange); font-weight: 700; font-size: 0.92rem; }

/* Chapter page */
.chapter-hero { background: var(--wash); border-bottom: 1px solid var(--line); }
.chapter-hero-grid { display: grid; grid-template-columns: 240px 1fr; gap: 40px; align-items: center; padding-top: 36px; padding-bottom: 40px; }
.chapter-cover { width: 100%; border-radius: var(--radius); box-shadow: 0 16px 36px rgba(31,39,69,0.18); }
.chapter-hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); color: var(--navy); line-height: 1.1; margin: 0 0 14px; font-weight: 800; }
@media (max-width: 720px) { .chapter-hero-grid { grid-template-columns: 1fr; } .chapter-cover { max-width: 200px; } }
.chapter-body { padding: 36px 20px 60px; max-width: 900px; }
.lesson-list { list-style: none; padding: 0; margin: 0 0 30px; counter-reset: none; }
.lesson-list li { border-bottom: 1px solid var(--line); }
.lesson-list a { display: flex; gap: 16px; align-items: baseline; padding: 14px 6px; text-decoration: none; color: var(--ink); }
.lesson-list a:hover { background: var(--wash); }
.ll-num { flex: 0 0 72px; font-weight: 800; color: var(--orange); font-size: 0.95rem; }
.ll-text strong { display: block; color: var(--navy); font-size: 1.08rem; }
.ll-text small { color: var(--muted); font-size: 0.92rem; }
.chapter-extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 10px 0 36px; }
.extra { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); }
.extra:hover { border-color: var(--teal); }
.extra strong { display: block; color: var(--navy); }
.extra span { color: var(--muted); font-size: 0.93rem; }

/* Lesson page */
.lesson-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; padding-top: 30px; padding-bottom: 60px; }
.lesson-toc { position: sticky; top: 90px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; font-size: 0.9rem; }
.lesson-toc summary { font-weight: 800; color: var(--navy); cursor: pointer; margin-bottom: 8px; }
.lesson-toc summary a { color: var(--navy); text-decoration: none; }
.lesson-toc ol { list-style: none; padding: 0; margin: 0; }
.lesson-toc li a { display: flex; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.lesson-toc li a:hover { background: var(--wash); }
.lesson-toc li.current a { background: color-mix(in srgb, var(--teal) 16%, var(--paper)); color: var(--teal-deep); font-weight: 700; }
.toc-num { flex: 0 0 auto; min-width: 2.2em; color: var(--muted); font-weight: 700; }
.toc-faq { display: block; margin-top: 14px; font-weight: 700; }
.lesson { max-width: 760px; min-width: 0; }
.lesson-kicker { font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange); font-size: 0.85rem; margin: 0 0 6px; }
.lesson h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.15; color: var(--navy); margin: 0 0 24px; font-weight: 800; }
@media (max-width: 960px) { .lesson-grid { grid-template-columns: 1fr; gap: 10px; } .lesson-toc { position: static; max-height: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; } .lesson-toc details:not([open]) summary { margin: 0; } }

/* Reading typography */
.prose { font-family: var(--read); font-size: 1.12rem; line-height: 1.72; color: var(--ink); overflow-wrap: break-word; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font-family: var(--ui); font-size: 1.55rem; margin: 1.9em 0 0.6em; font-weight: 800; }
.prose h3 { font-family: var(--ui); font-size: 1.25rem; margin: 1.6em 0 0.5em; }
.prose img { display: inline-block; max-width: 100%; height: auto; }
.prose .center { display: block; text-align: center; margin: 1.2em 0; }
.prose samp, .prose code, .prose tt { font-family: var(--mono); font-size: 0.9em; }
.prose samp { letter-spacing: 0.02em; }
.prose pre { font-family: var(--mono); font-size: 0.88rem; line-height: 1.55; background: #f7f8fb; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 8px; padding: 16px 18px; overflow-x: auto; white-space: pre; }
.prose pre small { font-size: inherit; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.prose li { margin: 0.25em 0; }
.prose blockquote { margin: 1.2em 0; padding: 0.4em 1.2em; border-left: 4px solid var(--orange); color: var(--muted); }
.prose small { font-size: 0.88em; }
.prose table { border-collapse: collapse; margin: 1em auto; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line); padding: 4px 8px; }
/* Callouts, styled after the book's own boxes and road signs */
.callout { position: relative; font-family: var(--read); border-radius: 8px; padding: 14px 18px 14px 70px; margin: 1.4em 0; min-height: 64px; }
.callout::before { content: ""; position: absolute; left: 14px; top: 14px; width: 42px; height: 42px; background: center / contain no-repeat; }
.callout-label { display: inline; font-family: var(--ui); font-weight: 700; margin-right: 0.35em; }
.callout-think { background: var(--think); }
.callout-think::before { background-image: url("../images/signs/stop.png"); }
.callout-think .callout-label { color: var(--think-edge); }
.callout-exercise { background: var(--exercise); }
.callout-exercise::before { background-image: url("../images/signs/exercise.png"); }
.callout-exercise .callout-label { color: var(--exercise-edge); }
.callout-challenge { background: var(--challenge); border-top: 3px solid var(--challenge-edge); border-bottom: 3px solid var(--challenge-edge); border-radius: 2px; }
.callout-challenge::before { background-image: url("../images/signs/charging.png"); width: 30px; left: 20px; }
.callout-challenge .callout-label { color: var(--challenge-edge); }
.cc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 10px; font-family: var(--ui); }
.btn-solve { background: var(--challenge-edge); color: #fff; }
.btn-solve:hover { background: var(--navy); color: #fff; }
.cc-note { font-size: 0.85rem; color: var(--muted); }
@media (max-width: 520px) { .callout { padding-left: 16px; padding-top: 62px; } .callout::before { top: 12px; left: 14px; } }
.prose .animation { margin: 1.4em 0; }
.prose .animation-media { text-align: center; background: #fff; border-radius: 8px; padding: 6px; }
.prose .animation-media img, .prose .animation-media video { display: block; width: 100%; max-width: 800px; height: auto; margin: 0 auto; cursor: pointer; }

/* Pager and CTA */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 44px 0 30px; }
.pager a { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; text-decoration: none; color: var(--navy); font-weight: 700; line-height: 1.35; }
.pager a:hover { border-color: var(--teal); background: var(--wash); }
.pager a span { display: block; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.pager-next { text-align: right; grid-column: 2; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: 1; } }
.cta-book { display: flex; gap: 22px; align-items: center; background: var(--navy); color: #fff; border-radius: 14px; padding: 22px 24px; margin: 30px 0 10px; }
.cta-book img { flex: 0 0 auto; width: 110px; border-radius: 6px; box-shadow: 0 10px 22px rgba(0,0,0,0.3); }
.cta-book p { margin: 0 0 10px; color: #dfe4f1; }
.cta-book .cta-head { font-weight: 800; font-size: 1.25rem; color: #fff; margin-bottom: 6px; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px !important; }
.cta-book .btn-ghost { color: #fff; }
.cta-book .btn-ghost:hover { background: #fff; color: var(--navy); border-color: #fff; }
@media (max-width: 600px) { .cta-book { flex-direction: column; align-items: flex-start; } }

/* FAQ */
.faq-list { margin: 20px 0 40px; max-width: 860px; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; background: #fff; }
.faq-item > summary { cursor: pointer; list-style: none; padding: 16px 48px 16px 18px; font-weight: 700; color: var(--navy); position: relative; line-height: 1.4; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after { content: "+"; position: absolute; right: 18px; top: 12px; font-size: 1.5rem; color: var(--teal); font-weight: 600; }
.faq-item[open] > summary::after { content: "\2212"; }
.faq-answer { padding: 0 18px 8px; font-size: 1.05rem; }
.faq-answer .figure { text-align: center; }
.faq-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 20px 0 40px; }
.faq-index a { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.faq-index a:hover { border-color: var(--teal); }
.faq-index strong { display: block; color: var(--navy); }
.faq-index span { color: var(--muted); font-size: 0.92rem; }

/* Videos */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 26px; }
.video-card h3 { margin: 12px 0 2px; font-size: 1.1rem; }
.video-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Team */
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 26px; }
.person img { width: 140px; height: 140px; object-fit: cover; border-radius: 50%; }
.person h3 { margin: 12px 0 6px; }
.person p { color: var(--muted); margin: 0 0 8px; font-size: 0.97rem; }
.authors { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin-bottom: 40px; }
.authors .person img { width: 180px; height: 180px; }
@media (max-width: 760px) { .authors { grid-template-columns: 1fr; } }

/* Product page */
.product { display: grid; grid-template-columns: minmax(0, 460px) 1fr; gap: 48px; align-items: start; }
.product img { width: 100%; border-radius: 8px; box-shadow: 0 20px 40px rgba(31,39,69,0.18); }
.product .price { font-size: 2.2rem; font-weight: 800; color: var(--navy); margin: 8px 0; }
.product .price small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.product-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
@media (max-width: 800px) { .product { grid-template-columns: 1fr; } .product img { max-width: 320px; } }
.notice { background: #fff8ea; border: 1px solid #f0d7a8; border-radius: 8px; padding: 12px 16px; color: #6b4a10; }

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; }
@media (max-width: 800px) { .contact-grid { grid-template-columns: 1fr; } }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: #fff; }

/* Footer */
.site-footer { background: var(--slate); color: #cdd3e1; padding: 48px 0 20px; font-size: 0.95rem; }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 30px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: 0 0 6px; }
.footer-brand { font-weight: 800; color: #fff; font-size: 1.15rem; margin: 0 0 8px; }
.footer-head { font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; margin: 0 0 10px; }
.footer-legal { border-top: 1px solid rgba(255,255,255,0.15); margin-top: 30px; padding-top: 16px; font-size: 0.85rem; color: #aab3c7; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

/* Keep grid children from growing past the viewport on phones */
.hero-grid > *, .lesson-grid > *, .chapter-hero-grid > *, .product > *, .contact-grid > *, .buy-grid > *, .features > *, .authors > * { min-width: 0; }
.prose pre { max-width: 100%; }
@media (max-width: 960px) { .lesson-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .hero-grid { grid-template-columns: minmax(0, 1fr); } }

/* Type: Optima for titles and interface, Palatino for reading */
body { background: var(--paper); color: var(--ink); font-family: var(--ui); }
h1, h2, h3, .page-title, .section-title { font-family: var(--ui); letter-spacing: 0.005em; }
.lede, .section-lede { font-family: var(--ui); font-weight: 500; }
.prose h2, .prose h3 { font-family: var(--ui); }
.prose samp, .prose code, .prose tt, .prose pre { font-family: var(--mono); }
.prose pre { background: var(--wash); border-color: var(--line); border-left-color: var(--navy); color: var(--ink); }
:root[data-theme="dark"] .prose img, :root[data-theme="dark"] .chapter-card img { background: #fff; border-radius: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prose img { background: #fff; border-radius: 6px; } }
.site-footer { background: var(--slate); }
.cta-book { background: var(--navy-deep); }
:root:not([data-theme="dark"]) .cta-book { background: var(--navy); }
.hero { background: linear-gradient(180deg, var(--paper) 0%, var(--wash) 100%); }
.feature, .buy-card, .chapter-card, .extra, .pager a, .faq-item, .card, .faq-index a, .lesson-list a:hover { background: var(--paper); }

/* Interactive widgets (shared frame) */
.widget { margin: 1.8em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; font-family: var(--ui); }
.widget-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 18px; background: var(--parchment); color: var(--navy); font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
.widget-kicker { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: #fff; background: var(--red); padding: 2px 8px; border-radius: 999px; }
.widget-foot { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 0.93rem; color: var(--muted); background: var(--wash); }
.widget .btn-small { background: var(--navy); color: var(--paper); border: 0; cursor: pointer; }
.widget .btn-small:hover { background: var(--teal); color: #fff; }
.widget .btn-small:disabled { opacity: 0.45; cursor: default; }

/* Lecture panel at the top of a lesson */
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: var(--muted); font-size: 0.92rem; margin: -10px 0 22px; }
.lesson-meta .done-badge { display: none; color: var(--teal-deep); font-weight: 700; }
.lesson-meta.is-done .done-badge { display: inline; }
.lecture { margin: 0 0 28px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--wash); }
.lecture > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 10px 14px; }
.lecture > summary::-webkit-details-marker { display: none; }
.lecture-thumb { position: relative; flex: 0 0 auto; width: 128px; aspect-ratio: 16 / 9; border-radius: 6px; background: #000 center / cover no-repeat; }
.lecture-thumb::after { content: ""; position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(215,38,61,0.92) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 7l8 5-8 5z' fill='white'/></svg>") center / 20px no-repeat; }
.lecture-text strong { display: block; color: var(--navy); }
.lecture-text span { color: var(--muted); font-size: 0.9rem; }
.lecture[open] > summary { border-bottom: 1px solid var(--line); }
.lecture .embed { border-radius: 0; }

/* End-of-lesson conversion box: interactive text first, print second */
.next-steps { margin: 40px 0 10px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.ns-main { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 22px 24px; background: var(--navy); color: #fff; }
:root[data-theme="dark"] .ns-main { background: var(--navy-deep); }
.ns-main p { margin: 0 0 6px; color: #dfe4f1; }
.ns-main .ns-head { font-size: 1.3rem; font-weight: 700; color: #fff; }
.ns-main ul { margin: 8px 0 0; padding-left: 1.1em; color: #dfe4f1; }
.ns-print { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--wash); font-size: 0.95rem; }
.ns-print img { width: 54px; border-radius: 4px; }
@media (max-width: 640px) { .ns-main { grid-template-columns: 1fr; } }

/* Reading strip across the top of lesson pages */
.course-strip { background: var(--parchment); border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.course-strip .wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: center; padding-top: 7px; padding-bottom: 7px; }
.course-strip a { font-weight: 700; }

/* Search */
.search-panel { position: fixed; inset: 0; z-index: 80; background: rgba(15, 20, 38, 0.55); padding: 8vh 16px 16px; }
.search-panel[hidden] { display: none; }
.search-box { display: flex; gap: 8px; max-width: 680px; margin: 0 auto; background: var(--paper); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1.1rem; color: var(--ink); padding: 8px 10px; outline: none; }
.search-results { list-style: none; max-width: 680px; margin: 10px auto 0; padding: 0; max-height: 70vh; overflow: auto; }
.search-results li a { display: block; background: var(--paper); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.search-results li a:hover, .search-results li a:focus { outline: 2px solid var(--teal); }
.search-results .sr-kind { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal-deep); font-weight: 700; }
.search-results .sr-title { display: block; font-weight: 700; color: var(--navy); }
.search-results .sr-snip { display: block; font-family: var(--read); color: var(--muted); font-size: 0.95rem; }
.search-results mark { background: #ffe9a8; color: inherit; border-radius: 2px; }

/* Progress marks in tables of contents */
.lesson-toc li.read a::after, .lesson-list li.read .ll-text strong::after { content: " \2713"; color: var(--teal); font-weight: 800; }
.resume { display: none; margin: 0 0 22px; padding: 12px 16px; border-radius: 10px; background: var(--parchment); }
.resume.show { display: block; }

/* Instructors */
.adopt-map { width: 100%; height: 440px; border-radius: 12px; border: 1px solid var(--line); background: var(--wash); }
.adopt-stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 16px 0 26px; }
.logo-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 20px 0; }
.logo-wall figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; place-items: center; min-height: 92px; }
.logo-wall img { max-height: 56px; width: auto; }
.logo-wall figcaption { font-size: 0.8rem; color: #555; text-align: center; margin-top: 6px; }

/* Monkey flourishes */
.monkey-float { float: right; width: 220px; margin: 0 0 12px 24px; }
@media (max-width: 640px) { .monkey-float { float: none; display: block; width: 180px; margin: 0 auto 12px; } }
@media (max-width: 640px) { .course-strip .cs-long { display: none; } }
@media (min-width: 641px) { .course-strip .cs-short { display: none; } }
.stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 18px 34px; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } }
.prose pre { position: relative; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: 600 0.75rem var(--ui); padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.prose pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.heading-anchor { margin-left: 0.35em; color: var(--line); text-decoration: none; font-weight: 400; opacity: 0; }
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus { opacity: 1; color: var(--muted); }
@media print {
  .site-header, .course-strip, .lesson-toc, .lecture, .next-steps, .pager, .site-footer, .read-progress, .copy-btn, .heading-anchor, .widget, .search-panel { display: none !important; }
  .lesson-grid { display: block; }
  .prose { font-size: 11pt; }
  body { background: #fff; color: #000; }
}
.play-card { text-decoration: none; color: var(--ink); transition: transform 0.15s, box-shadow 0.15s; }
.play-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); color: var(--ink); }
.play-card .widget-kicker { display: inline-block; margin-bottom: 10px; }

/* Chapter banners cut from the book's chapter-opener art */
.chapter-banner { position: relative; overflow: hidden; background: var(--navy-deep); color: #fff; min-height: 460px; display: flex; align-items: flex-end; }
.chapter-banner .banner-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
.chapter-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(15,20,38,0.92) 0%, rgba(15,20,38,0.72) 45%, rgba(15,20,38,0.15) 100%); }
.chapter-banner .banner-text { position: relative; z-index: 1; padding-top: 70px; padding-bottom: 46px; max-width: 1160px; }
.chapter-banner h1 { color: #fff; font-size: clamp(2.1rem, 4.6vw, 3.3rem); line-height: 1.08; margin: 0 0 14px; max-width: 15em; }
.chapter-banner .lede { color: #e6e9f3; max-width: 36em; }
.chapter-banner .kicker { color: var(--orange); }
.btn-light { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.7); }
.btn-light:hover { background: #fff; color: var(--navy-deep); }
@media (max-width: 720px) { .chapter-banner { min-height: 0; } .chapter-banner::after { background: linear-gradient(180deg, rgba(15,20,38,0.35) 0%, rgba(15,20,38,0.92) 55%); } .chapter-banner .banner-text { padding-top: 180px; } }

/* Wanted posters that turn into photos */
.wanted { position: relative; width: 220px; aspect-ratio: 440 / 512; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; }
.wanted img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.45s ease; border-radius: 0; }
.wanted .photo { opacity: 0; }
.wanted:hover .photo, .wanted:focus .photo, .wanted.flipped .photo { opacity: 1; }
.wanted:hover .poster, .wanted:focus .poster, .wanted.flipped .poster { opacity: 0; }
.wanted-hint { font-size: 0.82rem; color: var(--muted); margin: 8px 0 0; }
@media (prefers-reduced-motion: reduce) { .wanted img { transition: none; } }
.authors .person .wanted img, .person .wanted img { width: 100%; height: 100%; border-radius: 0; }
.wanted { aspect-ratio: 440 / 508; }

/* Friendlier, lighter surfaces: Raleway for the site, Palatino only where people read the book */
h1, h2, h3, .page-title, .section-title { font-weight: 800; letter-spacing: -0.01em; }
.hero h1 { font-size: clamp(2.4rem, 5.4vw, 3.9rem); }
.hero .lede { font-size: 1.22rem; line-height: 1.55; color: var(--muted); }
.search-results .sr-snip, .callout, .faq-answer { font-family: var(--read); }
.lesson h1, .prose h2, .prose h3 { font-family: var(--ui); font-weight: 800; }
.lesson-kicker, .kicker { font-weight: 800; }
.chapter-banner .lede { font-size: 1.12rem; }
.site-nav > a, .nav-group > a { white-space: nowrap; font-size: 0.95rem; padding: 8px 9px; }
.site-nav > .nav-cta { white-space: nowrap; }
.brand-title { white-space: nowrap; }
@media (max-width: 1240px) { .brand-sub { display: none; } }
@media (max-width: 1140px) and (min-width: 981px) { .brand-title { font-size: 1rem; } .site-nav > a, .nav-group > a { padding: 8px 6px; font-size: 0.9rem; } }
