/* The Doorway Buck reader — field-journal look that matches the homepage. */
:root {
  --paper: #f6f1e7;
  --paper-2: #ede5d4;
  --ink: #1f1b16;
  --ink-soft: #5b5248;
  --spruce: #2f4a3a;
  --accent: #a4502a;
  --line: #d8ccb5;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --gutter: clamp(16px, 5vw, 64px);
}

* { box-sizing: border-box; }
body.book-shell { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.65 var(--sans); }
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0; }

/* Top bar */
.book-topbar { display: flex; justify-content: space-between; align-items: center; padding: 18px var(--gutter); position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.wordmark { font-family: var(--serif); font-size: 20px; font-weight: 600; text-decoration: none; }
.wordmark em { font-weight: 400; color: var(--accent); }
.book-brand { font-family: var(--serif); font-style: italic; color: var(--ink-soft); text-decoration: none; }

/* Buttons */
.btn-book { display: inline-block; padding: 13px 22px; border-radius: 999px; font-weight: 600; text-decoration: none; transition: background .15s, transform .15s; }
.btn-book-primary { background: var(--spruce); color: var(--paper); }
.btn-book-primary:hover { background: var(--accent); transform: translateY(-1px); }
.btn-book-ghost { box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-book-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-retry { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

.eyebrow, .section-label, .chapter-eyebrow, .extras-label { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 12px; }

/* ---------- Book index ---------- */
.book-hero { background: var(--spruce); color: var(--paper); }
.book-hero-inner { max-width: 1100px; margin: 0 auto; padding: 72px var(--gutter); display: grid; grid-template-columns: 320px 1fr; gap: 64px; align-items: center; }
.book-cover img { border-radius: 3px 8px 8px 3px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6), inset 4px 0 0 rgba(0,0,0,.15); transform: rotate(-2deg); }
.book-hero .eyebrow { color: #e3b48f; }
.book-title { font-size: clamp(44px, 6vw, 76px); letter-spacing: -.02em; }
.book-byline { font-family: var(--serif); font-style: italic; font-size: 22px; margin: 8px 0 24px; color: #d9e2d6; }
.book-blurb { font-size: 19px; max-width: 46ch; color: #e8ece4; margin: 0 0 32px; }
.book-cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.book-hero .btn-book-primary { background: var(--paper); color: var(--spruce); }
.book-hero .btn-book-primary:hover { background: #e3b48f; }
.book-hero .btn-book-ghost { box-shadow: inset 0 0 0 1.5px var(--paper); color: var(--paper); }
.book-hero .btn-book-ghost:hover { background: var(--paper); color: var(--spruce); }

.chapters-inner { max-width: 860px; margin: 0 auto; padding: 88px var(--gutter); }
.chapters-inner h2 { font-size: clamp(32px, 4vw, 48px); }
.lede { color: var(--ink-soft); font-size: 18px; margin: 14px 0 40px; max-width: 56ch; }

/* Table of contents */
.chapter-grid { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.toc-row { display: grid; grid-template-columns: 44px 64px 1fr auto; gap: 18px; align-items: center; padding: 14px 8px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background .15s; }
a.toc-row:hover { background: var(--paper-2); }
a.toc-row:hover .toc-meta { color: var(--accent); }
.toc-num { font-family: var(--serif); font-size: 26px; color: var(--accent); text-align: right; }
.toc-thumb { width: 64px; height: 64px; border-radius: 6px; overflow: hidden; background: var(--paper-2); }
.toc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.toc-text { display: flex; flex-direction: column; }
.toc-text strong { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.toc-text em { font-style: normal; font-size: 14px; color: var(--ink-soft); }
.toc-meta { font-size: 14px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.toc-muted { opacity: .5; }
.toc-skeleton .skel-line { display: block; height: 14px; width: 40%; border-radius: 4px; background: var(--paper-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- Chapter & cover pages ---------- */
.chapter-hero-img { height: min(62vh, 560px); background: var(--spruce); position: relative; overflow: hidden; }
/* Show the whole image (covers are tall, photos are wide) over a blurred copy of itself. */
.chapter-hero-img img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; }
.chapter-hero-img .hero-backdrop { position: absolute; inset: -40px; z-index: 0; width: auto; height: auto; object-fit: cover; filter: blur(30px) brightness(.7); }
.chapter-hero-img img[src=""] { visibility: hidden; }
.chapter-hero-img::after { z-index: 2; content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 55%, rgba(31,27,22,.35)); }
.chapter-hero-img.no-image { height: 180px; }

.chapter-head { max-width: 720px; margin: -72px auto 0; position: relative; background: var(--paper); padding: 40px var(--gutter) 8px; border-radius: 14px 14px 0 0; }
.chapter-title { font-size: clamp(44px, 7vw, 72px); letter-spacing: -.02em; }
.chapter-subtitle { font-family: var(--serif); font-style: italic; font-size: 24px; color: var(--accent); margin: 6px 0 0; }
.chapter-subtitle:empty { display: none; }
.chapter-author { color: var(--ink-soft); margin: 10px 0 0; }

.chapter-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.chapter-progress b { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.chapter-progress i { display: block; height: 100%; width: 0; background: var(--spruce); transition: width .4s; }
.chapter-progress span { white-space: nowrap; }

.chapter-body { overflow-wrap: anywhere; max-width: 720px; margin: 0 auto; padding: 24px var(--gutter) 80px; }
.chapter-status:empty { display: none; }
.chapter-status { color: var(--ink-soft); font-style: italic; }

.chapter-featured { font-family: var(--serif); font-size: 21px; line-height: 1.6; }
.chapter-featured p { margin: 0 0 1em; }
.chapter-featured a { color: var(--accent); }
.chapter-featured img { border-radius: 8px; margin: 1.2em 0; }

.video-embed { position: relative; aspect-ratio: 16 / 9; margin: 32px 0; border-radius: 12px; overflow: hidden; background: #000; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.chapter-cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 32px 0; padding: 24px; background: var(--paper-2); border-radius: 12px; }
.chapter-cta-row:empty { display: none; }

.extras-list { list-style: none; padding: 0; margin: 0 0 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.extra-card-body ul { padding-left: 1.2em; }
.extra-card { padding: 24px; border: 1px solid var(--line); border-radius: 12px; }
.extra-card h4 { font-size: 22px; margin-bottom: 8px; }
.extra-card-body { color: var(--ink-soft); }
.extra-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.extra-images img { border-radius: 6px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.extra-link a { color: var(--accent); font-weight: 600; }
.extra-place { color: var(--ink-soft); font-size: 14px; }

.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--line); }
.chapter-nav a { text-decoration: none; padding: 18px 20px; border-radius: 12px; border: 1px solid var(--line); color: var(--ink-soft); font-size: 14px; transition: border-color .15s, background .15s; }
.chapter-nav a:hover { border-color: var(--spruce); background: var(--paper-2); }
.chapter-nav strong { display: block; font-family: var(--serif); font-size: 22px; color: var(--ink); }
.chapter-nav .nav-next { text-align: right; grid-column: 2; }
.chapter-nav .nav-disabled { visibility: hidden; }

.book-foot { text-align: center; padding: 32px var(--gutter); border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }

@media (max-width: 760px) {
  .book-brand { display: none; }
  .book-hero-inner { grid-template-columns: 1fr; gap: 40px; padding-top: 48px; }
  .book-cover { max-width: 220px; }
  .toc-row { grid-template-columns: 32px 52px 1fr; gap: 12px; }
  .toc-thumb { width: 52px; height: 52px; }
  .toc-meta { display: none; }
  .chapter-hero-img { height: 52vh; }
  .extra-card { padding: 20px 18px; }
  .extra-card h4 { font-size: 20px; }
  .chapter-head { margin-top: 0; padding-top: 28px; border-radius: 0; }
  .chapter-featured { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
