/* Books */
.nav nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--trace); }

/* Series hero */
.books-hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 48px; align-items: center;
  padding: var(--hero-top) var(--gutter) clamp(56px, 6vw, 88px); color: var(--on-night); overflow: hidden;
  background:
    radial-gradient(760px 460px at 82% 40%, rgba(94, 234, 212, 0.16), transparent 62%),
    radial-gradient(760px 420px at 0% 100%, rgba(11, 79, 179, 0.32), transparent 65%),
    var(--night);
}
.books-hero .eyebrow { color: var(--trace); }
.books-hero h1 { font-size: var(--h1); }
.books-hero .lede { max-width: 33em; }
.books-jump { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 560px; }
.books-jump a {
  display: grid; gap: 2px; padding: 14px 18px 15px; border: 1px solid var(--night-line); border-radius: var(--r-md);
  background: rgba(11, 26, 46, 0.55); text-decoration: none; transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.books-jump a:hover { border-color: rgba(94, 234, 212, 0.55); background: rgba(11, 26, 46, 0.85); transform: translateY(-2px); }
.books-jump b { font-size: 16px; color: #fff; }
.books-jump b::after { content: " \2193"; color: var(--trace); }
.books-jump span { font-size: 14px; color: var(--on-night-muted); }

.books-hero-stack { position: relative; height: clamp(340px, 34vw, 440px); }
.books-hero-stack .book3d { position: absolute; width: clamp(200px, 19vw, 260px); }
.books-hero-stack .book3d-back { right: 4%; top: 0; --tilt: -30deg; }
.books-hero-stack .book3d-front { left: 10%; bottom: 0; --tilt: -18deg; }
.books-hero-stack .book3d-back .book3d-body { animation-delay: -3.5s; }

/* A title page standing as a book: a slight turn, page edges and a soft shadow. */
.book3d { --tilt: -22deg; --depth: 22px; display: block; perspective: 1500px; text-decoration: none; position: relative; }
.book3d-body {
  position: relative; display: block; transform-style: preserve-3d;
  transform: rotateY(var(--tilt)) rotateX(3deg); transition: transform 0.7s cubic-bezier(.2, .7, .2, 1);
  animation: book-float 8s ease-in-out infinite;
}
.book3d img {
  position: relative; width: 100%; height: auto; border-radius: 2px 5px 5px 2px; transform: translateZ(calc(var(--depth) / 2));
  box-shadow: 0 0 0 1px rgba(16, 29, 46, 0.07), 18px 28px 40px -18px rgba(4, 10, 20, 0.45);
}
.book3d-body::before {
  /* The spine side of the cover: a fold shadow and a highlight. */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; z-index: 1; border-radius: 2px 0 0 2px; pointer-events: none;
  transform: translateZ(calc(var(--depth) / 2 + 0.5px));
  background: linear-gradient(90deg, rgba(16, 29, 46, 0.16), rgba(255, 255, 255, 0.5) 38%, rgba(16, 29, 46, 0.08) 70%, transparent);
}
.book3d-body::after {
  /* The shadow the book casts. */
  content: ""; position: absolute; left: 6%; right: -4%; bottom: -4%; height: 12%; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), transparent); filter: blur(10px);
  transform: translateZ(calc(var(--depth) / -2)) rotateX(80deg) translateY(30%);
}
.book3d-edge {
  /* Page edges along the fore-edge. */
  position: absolute; top: 1.2%; bottom: 1.2%; left: calc(100% - var(--depth) / 2); width: var(--depth);
  transform: rotateY(90deg) translateZ(-1px); border-radius: 1px;
  background: repeating-linear-gradient(90deg, #f7f4ee 0 1.5px, #ddd6c9 1.5px 2.4px), #f2eee6;
  box-shadow: inset 0 0 6px rgba(16, 29, 46, 0.25);
}
.book3d:hover .book3d-body, .book3d:focus-visible .book3d-body { transform: rotateY(calc(var(--tilt) * 0.35)) rotateX(1deg); }
@keyframes book-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }

/* One section per book */
.book {
  display: grid; grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr); gap: clamp(40px, 6vw, 88px); align-items: start;
  padding: var(--section-y) var(--gutter); scroll-margin-top: 64px;
}
.book-flip { background: var(--paper-2); border-top: 1px solid var(--line); grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.78fr); }
.book-flip .book-visual { order: 2; }
.book-visual { position: sticky; top: 104px; display: flex; justify-content: center; padding: 12px 0 40px; }
.book-visual .book3d { width: min(320px, 100%); cursor: pointer; }
.book-flip .book-visual .book3d { --tilt: 22deg; }
.book-flip .book3d-body::before { inset: 0 0 0 auto; transform: translateZ(calc(var(--depth) / 2 + 0.5px)) scaleX(-1); border-radius: 0 2px 2px 0; }
.book-flip .book3d-edge { left: calc(var(--depth) / -2); transform: rotateY(-90deg) translateZ(-1px); }
.book3d-cue {
  position: absolute; left: 50%; bottom: -30px; translate: -50% 0; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 7px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 650;
  box-shadow: 0 10px 24px -8px rgba(16, 29, 46, 0.5); transition: transform 0.25s ease, background 0.2s ease;
}
.book3d-cue::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--trace); box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.25); }
.book3d:hover .book3d-cue { transform: translateY(-3px); background: var(--blue); }

.book-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.book-kicker span:first-child { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); }
.book-kicker span + span { font-size: 13px; font-weight: 650; padding: 4px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.book h2 { font-size: var(--h2); max-width: 17em; }
.book-subtitle { margin-top: 10px; font-family: var(--serif); font-style: italic; font-size: clamp(19px, 1.8vw, 23px); color: #0f766e; }
.book-byline { margin-top: 12px; color: var(--muted); font-size: 15.5px; font-weight: 550; }
.book-desc { margin-top: 20px; font-size: 17.5px; max-width: 38em; }

.book-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 28px 0 0; max-width: 620px; }
.book-stats div { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 13px 14px 12px; background: #fff; }
.book-stats dt { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1; color: var(--ink); white-space: nowrap; }
.book-stats dd { margin: 7px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.3; }

.book-inside { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 30px; }
.book-highlights { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 9px; max-width: 40em; }
.book-highlights li { position: relative; padding-left: 30px; font-size: 16px; }
.book-highlights li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(160deg, #14b8a6, #0b4fb3);
}
.book-highlights li::after {
  content: ""; position: absolute; left: 6px; top: 7px; width: 5px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.book-quote { margin: 28px 0 0; padding: 4px 0 4px 20px; border-left: 3px solid #14b8a6; max-width: 38em; }
.book-quote p { font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 1.45; }
.book-quote footer { margin-top: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

.book-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.book-actions .btn { gap: 10px; }
.btn svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-buy { background: var(--ink); color: #fff; }
.btn-buy:hover { background: var(--blue-deep); }
.btn-preview { background: #fff; color: var(--blue); border-color: rgba(11, 79, 179, 0.35); }
.btn-preview:hover { border-color: var(--blue); background: #f4f8ff; }

.book-toc { margin-top: 36px; max-width: 640px; border-top: 1px solid var(--line); }
.book-toc summary {
  display: flex; align-items: center; gap: 12px; padding: 16px 4px; cursor: pointer; list-style: none;
  font-family: var(--serif); font-size: 21px; font-weight: 600;
}
.book-toc summary::-webkit-details-marker { display: none; }
.book-toc summary span { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--muted); }
.book-toc summary::after {
  content: ""; margin-left: auto; width: 9px; height: 9px; border: solid var(--ink); border-width: 0 2px 2px 0;
  transform: translateY(-3px) rotate(45deg); transition: transform 0.2s ease;
}
.book-toc[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.toc { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.toc li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 56px; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.toc-n { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.toc-title { font-weight: 550; font-size: 15.5px; }
.toc a { font-size: 13.5px; font-weight: 650; color: var(--blue); text-decoration: none; white-space: nowrap; }
.toc a::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #14b8a6; box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18); vertical-align: 1px; }
.toc a.toc-preview::before { border-radius: 2px; background: var(--blue); box-shadow: 0 0 0 3px rgba(11, 79, 179, 0.15); }
.toc a:hover { text-decoration: underline; }
.toc-page { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; grid-column: 4; }

.save { padding: var(--section-y) var(--gutter); background: var(--paper-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.save-head { max-width: 46em; }
.save-head h2 { font-size: var(--h2); }
.save-head p:not(.eyebrow) { color: var(--muted); margin-top: 14px; font-size: 18px; }
.save-steps { list-style: none; padding: 0; margin: 40px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.save-step { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.save-step h3 { font-size: 22px; margin: 16px 0 8px; }
.save-step p { color: var(--muted); font-size: 15.5px; }
.save-hex {
  display: inline-grid; place-items: center; width: 52px; height: 58px; font-family: var(--sans); font-weight: 750; font-size: 24px; color: #fff;
  background: linear-gradient(160deg, #14b8a6, #0b4fb3); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.save-hex-sm { width: 30px; height: 34px; font-size: 15px; flex: none; }

.practice { padding: var(--section-y) var(--gutter); }
.practice-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }
.practice-head h2 { font-size: var(--h2); }
.practice-head p:not(.eyebrow) { color: var(--muted); margin-top: 12px; font-size: 17px; max-width: 40em; }
.practice-actions .btn { min-height: 48px; border: 0; cursor: pointer; font-family: var(--sans); }
.practice-strip { margin: 28px 0 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: 0 16px 36px rgba(16, 29, 46, 0.08); }
.practice-strip canvas { display: block; width: 100%; height: 170px; border-radius: 12px; }
.practice-strip figcaption { font-size: 13px; color: var(--muted); padding: 8px 4px 2px; font-family: var(--mono); }
.practice-answers { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pa { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.pa-head { display: flex; align-items: center; gap: 12px; }
.pa-head b { flex: 1; font-size: 16.5px; }
.pa-reveal { font: 650 14px var(--sans); color: var(--blue); background: #eef4ff; border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.pa-reveal:hover { background: #dfeaff; }
.pa-body { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); animation: pa-in 0.25s ease; }
.pa-body dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 15px; }
.pa-body dt { color: var(--muted); font-weight: 600; }
.pa-body dd { margin: 0; }
.pa-body p { color: var(--muted); font-size: 15px; }
.pa-final { grid-column: 1 / -1; background: transparent; border: 0; padding: 0; display: flex; justify-content: center; }
.pa-name { cursor: pointer; font-family: var(--sans); background: transparent; color: var(--ink); }
@keyframes pa-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.practice-result { margin-top: 16px; padding: 22px 24px; border-radius: 16px; background: var(--night); color: var(--on-night); animation: pa-in 0.3s ease; }
.practice-result p:first-child { display: flex; flex-direction: column; gap: 2px; }
.practice-result p:first-child span { font-size: 12.5px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; color: var(--trace); }
.practice-result p:first-child b { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.pr-summary { color: var(--on-night-muted); margin-top: 8px; max-width: 46em; }
.pr-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.pr-links .btn { min-height: 40px; font-size: 15px; color: var(--on-night); }

@media (max-width: 980px) {
  .books-hero { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .books-hero-stack { height: clamp(300px, 52vw, 400px); max-width: 560px; width: 100%; margin: 0 auto; }
  .books-hero-stack .book3d { width: clamp(170px, 30vw, 230px); }
  .book, .book-flip { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .book-visual, .book-flip .book-visual { position: static; order: 0; padding-bottom: 44px; }
  .save-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .books-jump { grid-template-columns: minmax(0, 1fr); }
  .books-hero-stack { display: none; }
  .books-hero-stack .book3d { width: 168px; }
  .books-hero-stack .book3d-front { left: 4%; }
  .books-hero-stack .book3d-back { right: 2%; }
  .book-visual .book3d { width: min(220px, 62vw); }
  .book-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-actions .btn { flex: 1 1 100%; }
  .save-steps, .practice-answers { grid-template-columns: minmax(0, 1fr); }
  .toc li { grid-template-columns: 28px minmax(0, 1fr) 48px; row-gap: 3px; }
  .toc li a { grid-column: 2; grid-row: 2; justify-self: start; }
  .toc-page { grid-column: 3; grid-row: 1; }
  .practice-strip canvas { height: 130px; }
}
@media (prefers-reduced-motion: reduce) {
  .book3d-body { animation: none; transition: none; }
  .books-jump a, .book3d-cue { transition: none; }
  .pa-body, .practice-result { animation: none; }
}
.book-copy .book-badges { margin-top: 12px; }
