@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/bricolage-grotesque-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #1c2430;
  --muted: #5a6572;
  --faint: #98a1ab;
  --line: #dde2e8;
  --brand: #0b5cad;          /* education blue */
  --brand-dark: #094a8c;
  --brand-deep: #083f77;     /* header band bottom */
  --on-brand: #ffffff;
  --on-brand-soft: #bcd7f2;
  --tint: #f1f6fb;           /* pale blue wash for hover/secondary */
  --badge: #d0451b;
  --shadow: 0 1px 3px rgba(16, 32, 52, 0.10);
  --shadow-lift: 0 2px 6px rgba(16, 32, 52, 0.08), 0 14px 32px -14px rgba(16, 32, 52, 0.22);
  --sheet-shadow: 0 1px 2px rgba(16, 32, 52, 0.14), 0 10px 22px -10px rgba(16, 32, 52, 0.30);
  --navbg: rgba(255, 255, 255, 0.85);

  --f: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fd: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1220px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --ink: #e8ebee;
    --muted: #9aa4ae;
    --faint: #6b7681;
    --line: #2c323b;
    --brand: #2f7fd4;
    --brand-dark: #094a8c;
    --brand-deep: #0a3a66;
    --on-brand: #ffffff;
    --on-brand-soft: #a9cdf0;
    --tint: #1f2937;
    --badge: #e06a44;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 16px 34px -14px rgba(0, 0, 0, 0.7);
    --sheet-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 10px 22px -10px rgba(0, 0, 0, 0.8);
    --navbg: rgba(20, 23, 28, 0.82);
  }
}
:root[data-theme="light"] {
  --bg:#faf9f7; --surface:#ffffff; --ink:#1c2430; --muted:#5a6572; --faint:#98a1ab;
  --line:#dde2e8; --brand:#0b5cad; --brand-dark:#094a8c; --brand-deep:#083f77;
  --on-brand:#ffffff; --on-brand-soft:#bcd7f2; --tint:#f1f6fb; --badge:#d0451b;
  --shadow:0 1px 3px rgba(16,32,52,0.10);
  --shadow-lift:0 2px 6px rgba(16,32,52,0.08), 0 14px 32px -14px rgba(16,32,52,0.22);
  --sheet-shadow:0 1px 2px rgba(16,32,52,0.14), 0 10px 22px -10px rgba(16,32,52,0.30);
  --navbg:rgba(255,255,255,0.85);
}
:root[data-theme="dark"] {
  --bg:#14171c; --surface:#1c2027; --ink:#e8ebee; --muted:#9aa4ae; --faint:#6b7681;
  --line:#2c323b; --brand:#2f7fd4; --brand-dark:#094a8c; --brand-deep:#0a3a66;
  --on-brand:#ffffff; --on-brand-soft:#a9cdf0; --tint:#1f2937; --badge:#e06a44;
  --shadow:0 1px 3px rgba(0,0,0,0.5);
  --shadow-lift:0 2px 6px rgba(0,0,0,0.45), 0 16px 34px -14px rgba(0,0,0,0.7);
  --sheet-shadow:0 1px 2px rgba(0,0,0,0.55), 0 10px 22px -10px rgba(0,0,0,0.8);
  --navbg:rgba(20,23,28,0.82);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body { font-family: var(--f); color: var(--ink); background: var(--bg); line-height: 1.5; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
a { color: var(--brand); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- header band ---------- */
.band {
  background: linear-gradient(175deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: var(--on-brand);
  padding: 30px 0 36px;
}
.band .top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wordmark { font-family: var(--fd); font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.wordmark span { opacity: 0.85; }
.wordmark a { color: inherit; text-decoration: none; }
.theme-btn {
  font: inherit; font-size: 0.75rem; font-weight: 600;
  color: var(--on-brand); background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.35); border-radius: 5px;
  padding: 5px 12px; cursor: pointer;
}
.theme-btn:hover { background: rgba(255,255,255,0.24); }

.herogrid { display: grid; grid-template-columns: 1fr auto; gap: 20px 48px; align-items: center; }
.band h1 {
  font-family: var(--fd);
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 700; letter-spacing: -0.01em; line-height: 1.14;
  margin-top: 24px; max-width: 22ch; text-wrap: balance;
}
.band .sub {
  color: var(--on-brand-soft); font-size: 0.95rem; max-width: 58ch; margin-top: 10px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  font-size: 0.78rem; font-weight: 600; color: var(--on-brand);
  background: rgba(255,255,255,0.13); border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px; padding: 4px 13px; white-space: nowrap;
}
.band .stats { margin-top: 14px; font-size: 0.8rem; color: var(--on-brand-soft); }
.band .stats b { color: var(--on-brand); font-weight: 700; }
.band .stats .sep { margin: 0 8px; opacity: 0.5; }

/* fan of real sample pages — the hero visual */
.herofan { position: relative; width: 330px; height: 252px; margin-top: 12px; }
.herofan img {
  position: absolute; width: 152px; border-radius: 3px; background: #fff;
  box-shadow: 0 2px 4px rgba(5, 18, 34, 0.35), 0 18px 36px -12px rgba(5, 18, 34, 0.55);
}
.herofan img:nth-child(1) { left: 0;     top: 22px; transform: rotate(-7deg); }
.herofan img:nth-child(2) { left: 88px;  top: 2px;  transform: rotate(-1deg); z-index: 1; }
.herofan img:nth-child(3) { left: 176px; top: 18px; transform: rotate(6deg); }
@media (max-width: 920px) { .herofan { display: none; } }

/* ---------- subject nav ---------- */
.subjectnav {
  position: sticky; top: 0; z-index: 10;
  background: var(--navbg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.subjectnav .wrap {
  display: flex; gap: 0 26px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.subjectnav .wrap::-webkit-scrollbar { display: none; }
.subjectnav a {
  text-decoration: none; color: var(--muted);
  font-size: 0.85rem; font-weight: 600; white-space: nowrap;
  padding: 11px 0 9px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.subjectnav a:hover { color: var(--brand); border-bottom-color: var(--line); }
.subjectnav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.subjectnav .n { color: var(--faint); font-weight: 500; margin-left: 3px; font-size: 0.78rem; }

/* ---------- how it works + printing help ---------- */
.how {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px;
  margin-top: 26px;
}
.step { display: flex; gap: 12px; align-items: flex-start; }
.step .ico {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.step .ico svg { width: 19px; height: 19px; }
.step b { display: block; font-size: 0.88rem; margin-top: 1px; }
.step span { color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
@media (max-width: 760px) { .how { grid-template-columns: 1fr; gap: 12px; } }

.printhelp {
  margin-top: 18px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
.printhelp summary {
  cursor: pointer; padding: 10px 16px;
  font-size: 0.85rem; font-weight: 600; color: var(--brand);
  list-style-position: inside;
}
.printhelp p { padding: 0 16px 10px; font-size: 0.82rem; color: var(--muted); max-width: 80ch; }
.printhelp p b { color: var(--ink); }

/* ---------- sections ---------- */
.section { margin-top: 36px; }
.sechead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sechead h2 { font-family: var(--fd); font-size: 1.28rem; font-weight: 700; letter-spacing: -0.01em; }
.sechead h2::after {
  content: ""; display: block; width: 44px; height: 3px;
  background: var(--brand); border-radius: 2px; margin-top: 6px;
}
.sechead .count { color: var(--faint); font-size: 0.85rem; font-weight: 600; }
.sechead .featured {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--badge); border: 1px solid currentColor; border-radius: 4px; padding: 1px 7px;
}
.sechead .secdesc { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

/* ---------- workbook grid ---------- */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 22px 20px;
  margin-top: 18px;
}
.book {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.book:hover { border-color: var(--faint); box-shadow: var(--shadow-lift); transform: translateY(-3px); }

/* scroll reveal (JS adds .in; no-JS and reduced-motion stay visible) */
.reveal .book { opacity: 0; transform: translateY(8px); }
.reveal .book.in { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s ease, border-color .2s, box-shadow .2s; }
.reveal .book.in:hover { transform: translateY(-3px); }
@media (prefers-reduced-motion: reduce) {
  .reveal .book { opacity: 1; transform: none; }
}

/* portrait paper preview — the whole first page, like a workbook on a shelf */
.plate {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--tint); border-bottom: 1px solid var(--line);
}
.tile {
  position: absolute; inset: 0;
  border: 0; padding: 16px; cursor: zoom-in;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.tile img {
  max-width: 100%; max-height: 100%; display: block;
  background: #fff; border-radius: 2px;
  box-shadow: var(--sheet-shadow);
  transition: transform .35s ease;
}
.tile:hover img, .tile:focus-visible img { transform: scale(1.025); }
.tile .placeholder { color: var(--faint); font-size: 0.78rem; font-weight: 600; }
.pages {
  position: absolute; bottom: 10px; right: 10px; pointer-events: none;
  font-size: 0.68rem; font-weight: 600; color: #fff;
  background: rgba(28, 36, 48, 0.72); border-radius: 999px; padding: 3px 10px;
}

.book .body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.book h3 { font-size: 0.98rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.book h3 a { color: inherit; text-decoration: none; }
.book h3 a:hover { color: var(--brand); }
.badge {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--badge); border: 1px solid currentColor; border-radius: 4px;
  padding: 0 5px; margin-left: 6px; vertical-align: 2px; white-space: nowrap;
}
.book .desc {
  color: var(--muted); font-size: 0.8rem; line-height: 1.45; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.get { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; }
.btn {
  display: inline-block; text-decoration: none; border-radius: 6px;
  font-size: 0.78rem; font-weight: 700;
  padding: 7px 12px; line-height: 1.2;
  transition: background .15s, border-color .15s;
}
.btn small { font-weight: 500; opacity: 0.65; font-size: 0.68rem; margin-left: 2px; }
.btn.a5 { background: var(--brand); color: var(--on-brand); }
.btn.a5:hover { background: var(--brand-dark); }
.btn.a4 { color: var(--brand); border: 1px solid var(--line); background: transparent; }
.btn.a4:hover { border-color: var(--brand); background: var(--tint); }
.btn.view { flex: 1; text-align: center; background: var(--brand); color: var(--on-brand); }
.btn.view:hover { background: var(--brand-dark); }

/* ---------- footer ---------- */
footer {
  margin-top: 56px; border-top: 1px solid var(--line);
  padding: 22px 0 34px; color: var(--muted); font-size: 0.82rem;
}
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer .stamp { color: var(--faint); font-size: 0.75rem; }

.loading, .load-error { text-align: center; color: var(--muted); padding: 60px 0; font-size: 0.9rem; }

/* ---------- modal ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(10, 16, 24, 0.85); }
.modal.open { display: block; }
.modal img {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  max-width: min(92vw, 900px); max-height: 88vh;
  background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,0.5); border-radius: 4px;
}
.modal .mclose, .modal .mprev, .modal .mnext {
  position: absolute; z-index: 2; font-size: 1.05rem; line-height: 1;
  color: #eef2f6; background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.3); border-radius: 6px;
  padding: 10px 14px; cursor: pointer;
}
.modal .mclose { top: 18px; right: 18px; }
.modal .mprev { left: 14px; top: 50%; transform: translateY(-50%); }
.modal .mnext { right: 14px; top: 50%; transform: translateY(-50%); }
.modal .mcount {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: 0.78rem; color: #c9d3dc;
}
.modal button:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 640px) {
  .shelf { grid-template-columns: repeat(2, 1fr); gap: 14px 12px; }
  .book .body { padding: 10px 11px 12px; }
  .tile { padding: 10px; }
  .sechead .secdesc { margin-left: 0; width: 100%; }
}

/* ---------- workbook product page ---------- */
.band.slim { padding: 18px 0; }
.crumbs {
  display: inline-block; margin-top: 22px;
  font-size: 0.85rem; font-weight: 600; color: var(--brand); text-decoration: none;
}
.crumbs:hover { text-decoration: underline; }
.prodhead { margin-top: 12px; }
.prodhead h1 {
  font-family: var(--fd); font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700; letter-spacing: -0.01em; line-height: 1.16;
}
.prodhead .desc { color: var(--muted); margin-top: 8px; max-width: 70ch; }
.prodhead .facts { color: var(--faint); font-size: 0.85rem; font-weight: 600; margin-top: 10px; }

.getrow {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 22px 28px; margin-top: 28px; align-items: start;
}
@media (max-width: 760px) { .getrow { grid-template-columns: 1fr; } }
.cta-primary .btn.big { font-size: 0.95rem; padding: 13px 22px; }
.cta-secondary {
  display: block; margin-top: 16px;
  font-size: 0.85rem; color: var(--muted); line-height: 1.5; max-width: 46ch;
}
.cta-secondary a { font-weight: 600; }

.howtoprint {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 16px 18px 18px;
}
.howtoprint h2 { font-size: 0.95rem; font-weight: 700; }
.howtoprint .printfig { display: flex; gap: 18px; align-items: flex-start; margin-top: 12px; }
.howtoprint svg { flex: none; width: 120px; height: auto; color: var(--brand); }
.howtoprint ol { margin: 0 0 0 18px; }
.howtoprint li { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin-top: 6px; }
.howtoprint li b { color: var(--ink); }
@media (max-width: 480px) { .howtoprint .printfig { flex-direction: column; } }

.prodsec { margin-top: 38px; }
.prodsec > h2 { font-family: var(--fd); font-size: 1.28rem; font-weight: 700; letter-spacing: -0.01em; }
.prodsec > h2::after {
  content: ""; display: block; width: 44px; height: 3px;
  background: var(--brand); border-radius: 2px; margin-top: 6px;
}
.prodsec .intro { color: var(--muted); font-size: 0.88rem; margin-top: 10px; max-width: 72ch; }

.chapterlist {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.chapterlist .row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-top: 1px solid var(--line);
}
.chapterlist .row:first-child { border-top: 0; }
.chapterlist .num { flex: none; width: 2.2em; color: var(--faint); font-weight: 700; font-size: 0.8rem; }
.chapterlist .cname { flex: 1; font-size: 0.88rem; font-weight: 600; min-width: 0; }
.chapterlist .cpages { color: var(--faint); font-size: 0.78rem; white-space: nowrap; }
@media (max-width: 640px) {
  .chapterlist .row { flex-wrap: wrap; gap: 6px 14px; }
  .chapterlist .cname { flex-basis: calc(100% - 3em); }
  .chapterlist .row .btn { margin-left: 3.4em; }
}

.gallery .strip { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; }
.gallery .thumb {
  border: 0; padding: 0; background: transparent; cursor: zoom-in; width: 168px;
}
.gallery .thumb img {
  width: 100%; display: block; background: #fff; border-radius: 2px;
  box-shadow: var(--sheet-shadow); transition: transform .25s ease;
}
.gallery .thumb:hover img, .gallery .thumb:focus-visible img { transform: scale(1.03); }

.notfound { text-align: center; padding: 70px 0; }
.notfound h1 { font-family: var(--fd); font-size: 1.5rem; }
.notfound p { color: var(--muted); margin-top: 10px; }
