/* ============ Course handbooks ============ */
.hb-cover { position: relative; color: #fff; padding: clamp(48px, 7vw, 88px) 0; overflow: hidden; isolation: isolate;
  background: radial-gradient(circle at 80% 20%, rgba(255, 255, 255, .16), transparent 45%), linear-gradient(135deg, var(--book), color-mix(in srgb, var(--book) 55%, #000)); }
.hb-cover::after { content: ""; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px); background-size: 22px 22px; }
.hb-cover__inner { display: grid; grid-template-columns: 1fr 280px; gap: 64px; align-items: center; }
.hb-cover h1 { color: #fff; font-size: clamp(2.6rem, 5.5vw, 4.4rem); }
.hb-cover__lead { font-size: 1.12rem; color: rgba(255, 255, 255, .9); max-width: 620px; }
.hb-cover__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hb-cover .btn--white { color: color-mix(in srgb, var(--book) 80%, #000); }
.hb-cover__book .book { transform: rotateY(-12deg) rotateZ(2deg); box-shadow: 24px 30px 50px -16px rgba(0, 0, 0, .55); }
.hb-cover__book .book__cover { background:
  radial-gradient(circle at 85% 10%, rgba(255, 255, 255, .25), transparent 45%),
  linear-gradient(160deg, color-mix(in srgb, var(--book) 80%, #fff), var(--book) 50%, color-mix(in srgb, var(--book) 65%, #000)); }

.hb-layout { display: grid; grid-template-columns: 260px 1fr; gap: 56px; padding: clamp(48px, 6vw, 80px) 0 clamp(72px, 9vw, 110px); align-items: start; }
.hb-toc { position: sticky; top: 100px; padding: 24px; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--line); }
.hb-toc__title { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.hb-toc ol { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 2px; }
.hb-toc a { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; color: var(--body); font-size: .92rem; line-height: 1.35; }
.hb-toc a span { flex: none; width: 22px; font-family: var(--font-head); font-weight: 700; color: var(--teal); }
.hb-toc a:hover, .hb-toc a.is-active { background: var(--surface); color: var(--ink); }
.hb-toc a.is-active span { color: var(--red); }

.hb-content { min-width: 0; max-width: 760px; font-size: 1.04rem; color: var(--ink); }
.hb-content p, .hb-content li { color: var(--body); }
.hb-content h2 { font-size: clamp(2rem, 3.6vw, 2.6rem); }
.hb-content h3 { font-size: 1.45rem; margin-top: 1.4em; color: var(--accent-ink); }
.hb-content ul { padding-left: 1.2em; }
.hb-content ul li { margin-bottom: .45em; }
.hb-content ul li::marker { color: var(--teal); }
.hb-content .checklist { padding-left: 0; }
.hb-intro, .hb-chapter { padding: 40px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 100px; }
.hb-intro { padding-top: 32px; }
.hb-chapter__num { font-family: var(--font-head); font-weight: 700; font-size: 1rem; letter-spacing: .14em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }

.hb-steps { list-style: none; counter-reset: s; padding: 0; margin: 1.2em 0; display: grid; gap: 12px; }
.hb-steps li { counter-increment: s; position: relative; padding: 16px 18px 16px 64px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--line); margin: 0; }
.hb-steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }

.hb-key { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 1.4em 0; }
.hb-key div { padding: 16px 18px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); border-top: 4px solid var(--red); }
.hb-key span { display: block; font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; color: var(--red); line-height: 1.1; }
.hb-key strong { font-weight: 600; font-size: .95rem; color: var(--ink); }

.hb-callout { margin: 1.5em 0; padding: 18px 22px 18px 58px; border-radius: 14px; position: relative; }
.hb-callout::before { position: absolute; left: 18px; top: 16px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .95rem; }
.hb-callout > strong { display: block; margin-bottom: 4px; font-size: 1rem; }
.hb-callout p { margin: 0; font-size: .97rem; }
.hb-callout--warn { background: var(--tint-red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.hb-callout--warn::before { content: "!"; background: var(--red); }
.hb-callout--warn > strong { color: var(--red-ink); }
.hb-callout--tip { background: var(--tint); border: 1px solid color-mix(in srgb, var(--teal) 25%, transparent); }
.hb-callout--tip::before { content: "✓"; background: var(--teal); }
.hb-callout--tip > strong { color: var(--accent-ink); }
.hb-callout--info { background: var(--surface-2); border: 1px solid var(--line); }
.hb-callout--info::before { content: "i"; background: #4b6478; font-family: Georgia, serif; font-style: italic; }
.hb-disclaimer { margin-top: 0; }

.hb-table { overflow-x: auto; margin: 1.4em 0; border-radius: 14px; border: 1px solid var(--line); }
.hb-table table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 520px; }
.hb-table th { background: var(--teal-800); color: #fff; text-align: left; padding: 12px 16px; font-weight: 600; }
.hb-table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.hb-table tr:nth-child(even) td { background: var(--bg-soft); }
.hb-table td:first-child { font-weight: 600; color: var(--ink); }

.hb-q { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; background: var(--surface); }
.hb-q summary { color: var(--ink); cursor: pointer; list-style: none; display: flex; gap: 14px; align-items: center; padding: 16px 18px; font-weight: 600; }
.hb-q summary::-webkit-details-marker { display: none; }
.hb-q summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; color: var(--teal); transition: transform .3s; }
.hb-q[open] summary::after { transform: rotate(45deg); }
.hb-q summary span { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--accent-ink); font-family: var(--font-head); font-weight: 700; }
.hb-q p { margin: 0; padding: 0 18px 18px 62px; color: var(--accent-ink); font-weight: 500; }

.hb-notes { padding: 40px 0; }
.hb-notes__lines { height: 220px; background: repeating-linear-gradient(transparent 0 35px, var(--line) 35px 36px); }

.hb-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 16px; }
.hb-pager__link { display: block; padding: 20px 22px; border-radius: 14px; border: 1px solid var(--line); font-weight: 700; color: var(--ink); transition: border-color .3s, transform .3s var(--ease); }
.hb-pager__link:hover { border-color: var(--teal); transform: translateY(-2px); color: var(--ink); }
.hb-pager__link small { display: block; font-weight: 600; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.hb-pager__link--next { text-align: right; }

@media (max-width: 960px) {
  .hb-cover__inner { grid-template-columns: 1fr; gap: 40px; }
  .hb-cover__book { max-width: 220px; }
  .hb-layout { grid-template-columns: 1fr; gap: 24px; }
  .hb-toc { position: static; }
  .hb-content { max-width: none; }
}
@media (max-width: 640px) {
  .hb-cover__actions .btn { width: 100%; }
  .hb-cover__book { max-width: 170px; }
  .hb-steps li { padding: 14px 14px 14px 56px; }
  .hb-steps li::before { left: 12px; }
  .hb-q p { padding-left: 18px; }
  .hb-pager { grid-template-columns: 1fr; }
}

/* Print / PDF */
.print-only { display: none; }
@media print {
  :root, :root[data-theme] { color-scheme: light; --bg: #fff; --bg-soft: #f3f8f8; --surface: #fff; --surface-2: #f6fafa; --ink: #0d2322; --body: #2b4341; --muted: #708583; --line: #dde9e8; --line-strong: #c9dddc; --tint: #e7f6f5; --tint-red: #fde9ea; --accent-ink: #035c58; --link: #008a84; }
  .progress, .to-top, .skip-link { display: none !important; }
  @page { size: A4; margin: 16mm 15mm 18mm; }
  @page :first { margin: 0; }
  body { font-size: 10.5pt; color: #000; background: #fff; }
  .topbar, .header, .footer, .fab, .hb-toc, .hb-cover__actions, .crumbs, .hb-pager, .hb-notes, .hb-disclaimer .no-print { display: none !important; }
  .print-only { display: block; }

  /* Full-page colour cover */
  .hb-cover { height: 297mm; padding: 26mm 20mm 18mm; display: flex; flex-direction: column; break-after: page; }
  .hb-cover .container { width: auto; margin: 0; }
  .hb-cover__inner { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14mm; }
  .hb-cover__book { order: -1; width: 92mm; max-width: none; }
  .hb-cover__book .book { transform: none; }
  .hb-cover h1 { font-size: 44pt; }
  .hb-cover__lead { font-size: 13pt; max-width: 150mm; }
  .hb-cover__foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10mm; padding-top: 8mm; border-top: 1px solid rgba(255,255,255,.35); font-size: 9.5pt; color: rgba(255,255,255,.9); }
  .hb-cover__foot img { width: 34mm; }
  .hb-cover__foot strong { font-size: 18pt; font-family: var(--font-head); display: block; color: #fff; }

  .hb-layout { display: block; padding: 0; width: auto; }
  .hb-content { max-width: none; font-size: 10.5pt; }
  .hb-intro { padding-top: 0; border: 0; }
  .hb-chapter { break-before: page; border: 0; padding: 0; }
  .hb-steps li, .hb-callout, .hb-key div, .hb-table, .hb-q, .hb-back { break-inside: avoid; }
  .hb-content h3 { break-after: avoid; }
  .hb-q { border: 0; border-bottom: 1px solid #ccc; border-radius: 0; }
  .hb-q summary::after { display: none; }
  .hb-q p { padding-left: 44px; }
  .hb-q::details-content { content-visibility: visible; display: block; }
  .hb-back { margin-top: 14mm; padding: 8mm; border-radius: 4mm; background: #e7f6f5; border: 1px solid #c4e9e7; }
  .hb-back h2 { font-size: 20pt; }
  .hb-back p { margin: 0 0 2mm; }
  .reveal { opacity: 1 !important; transform: none !important; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; }
}

/* Letter keys with longer text (DRS ABC, FAST) */
.hb-key--rows { grid-template-columns: 1fr 1fr; }
.hb-key--rows div { display: flex; gap: 14px; align-items: flex-start; border-top: 1.5px solid var(--line); border-left: 4px solid var(--red); }
.hb-key--rows span { flex: none; width: 28px; font-size: 1.7rem; line-height: 1; }
@media (max-width: 640px) { .hb-key--rows { grid-template-columns: 1fr; } }

/* Reading meta & chapter progress */
.hb-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 6px; }
.hb-meta span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); font-size: .84rem; font-weight: 600; color: #fff; }
.hb-meta svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hb-toc__progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 0 0 6px; }
.hb-toc__progress span { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(90deg, var(--teal), var(--red)); border-radius: inherit; transition: width .2s linear; }
.hb-toc__pct { font-size: .78rem; color: var(--muted); margin: 0 0 14px; }
.hb-toc a.is-done span { color: var(--teal); }
.hb-toc a.is-done span::before { content: ""; }
.hb-cover__book { perspective: 1200px; }
.hb-cover__book .book { transform: rotateY(calc(-12deg + var(--ry, 0deg))) rotateX(var(--rx, 0deg)) rotateZ(2deg); }
@media print { .hb-meta { display: none; } .hb-cover__book .book { transform: none; } }
