/* GoNcerts · warm paper + saffron star · Literata (display) / IBM Plex Sans (text) */
:root {
  --paper: oklch(98.4% 0.007 85);
  --paper-2: oklch(95.6% 0.011 85);
  --card: oklch(100% 0 0);
  --ink: oklch(23% 0.02 60);
  --ink-2: oklch(46% 0.02 60);
  --rule: oklch(89% 0.012 80);
  --accent: oklch(72% 0.16 65);        /* star / highlights */
  --accent-text: oklch(52% 0.14 55);   /* saffron dark enough for text */
  --ok: oklch(52% 0.13 150);
  --ok-bg: oklch(95% 0.04 150);
  --bad: oklch(53% 0.18 27);
  --bad-bg: oklch(95% 0.035 27);
  --focus: oklch(52% 0.18 255);
  --reader-bg: oklch(92% 0.006 85);
  /* subject tint recipe; each tile sets its own --h (hue) */
  --tl: 95%; --tl-hover: 92%; --tc: 0.04; --tb: 87%; --tf: 47%; --tfc: 0.13;
  --font-display: "Literata", Georgia, serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: oklch(19% 0.012 60);
    --paper-2: oklch(23.5% 0.014 60);
    --card: oklch(22% 0.013 60);
    --ink: oklch(93% 0.01 85);
    --ink-2: oklch(73% 0.015 80);
    --rule: oklch(33% 0.015 60);
    --accent: oklch(78% 0.15 70);
    --accent-text: oklch(80% 0.13 70);
    --ok: oklch(74% 0.14 150);
    --ok-bg: oklch(28% 0.05 150);
    --bad: oklch(72% 0.15 27);
    --bad-bg: oklch(28% 0.05 27);
    --focus: oklch(75% 0.14 255);
    --reader-bg: oklch(15% 0.01 60);
    --tl: 25%; --tl-hover: 29%; --tc: 0.035; --tb: 34%; --tf: 82%; --tfc: 0.1;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--font-body); -webkit-text-size-adjust: 100%; }
body.lock { overflow: hidden; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 30; background: var(--card); padding: 10px 14px; }

/* header */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; font: 700 1.3rem/1 var(--font-display); letter-spacing: -.01em; text-decoration: none; }
.brand b { color: var(--accent-text); font-weight: 700; }
.brand .star { width: 16px; height: 16px; margin: -10px 0 0 3px; fill: var(--accent); }
nav { display: flex; align-items: center; }
nav a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center; padding: 0 12px; border-radius: 10px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
nav a:hover { color: var(--ink); background: var(--paper-2); }
nav a[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
nav .x svg { width: 17px; height: 17px; fill: currentColor; }
@media (max-width: 359px) { nav a { padding: 0 8px; } }

/* hero + search */
.hero { padding-top: 32px; padding-bottom: 4px; }
@media (min-width: 720px) { .hero { padding-top: 56px; } }
.eyebrow { margin: 0 0 12px; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.hero h1 { margin: 0 0 12px; max-width: 17ch; font: 700 clamp(2rem, 6vw, 3.4rem)/1.08 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.lede { margin: 0; max-width: 54ch; font-size: 1.08rem; color: var(--ink-2); }
.searchbar { position: sticky; top: 0; z-index: 10; padding: 16px 0 12px; background: var(--paper); }
.search { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; border: 1.5px solid var(--rule); border-radius: 14px; background: var(--card); color: var(--ink-2); cursor: text; }
.search:focus-within { border-color: var(--ink-2); outline: 2.5px solid var(--focus); outline-offset: 2px; }
.search input { flex: 1; min-width: 0; padding: 14px 0; border: 0; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 1.08rem; }
.search input::placeholder { color: var(--ink-2); opacity: .8; }
.search kbd { padding: 2px 8px; border: 1px solid var(--rule); border-radius: 6px; font: 500 .8rem var(--font-body); }
@media (hover: none) { .search kbd { display: none; } }

main { min-height: 50vh; padding-bottom: 64px; }
main:focus { outline: none; }
.sec-h { margin: 28px 0 14px; font: 700 1.35rem/1.2 var(--font-display); }

/* subject tiles */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 960px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { aspect-ratio: 1; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(14px, 4vw, 22px); border: 1px solid oklch(var(--tb) var(--tc) var(--h)); border-radius: 18px; background: oklch(var(--tl) var(--tc) var(--h)); color: var(--ink); text-decoration: none; transition: transform .18s var(--ease), background-color .18s var(--ease); }
.tile:hover { background: oklch(var(--tl-hover) var(--tc) var(--h)); transform: translateY(-2px); }
.tile .ic { width: clamp(30px, 9vw, 44px); height: clamp(30px, 9vw, 44px); stroke-width: 1.5; color: oklch(var(--tf) var(--tfc) var(--h)); }
.tile-name { display: block; font: 700 clamp(1.02rem, 3.8vw, 1.35rem)/1.15 var(--font-display); overflow-wrap: anywhere; }
.tile-meta { display: block; margin-top: 4px; font-size: .82rem; color: var(--ink-2); }

/* continue reading */
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 8px; }
.recent-item { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.recent-item .ic { color: var(--accent-text); }
.recent-item:hover { border-color: var(--ink-2); }

.quiz-band { margin-top: 36px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 22px; border: 1px solid var(--rule); border-radius: 18px; background: var(--paper-2); }
.quiz-band .sec-h { margin: 0 0 4px; }
.quiz-band p { margin: 0; color: var(--ink-2); }

/* subject page */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--ink); }
.subj-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 20px; padding: 20px; border: 1px solid oklch(var(--tb) var(--tc) var(--h)); border-radius: 18px; background: oklch(var(--tl) var(--tc) var(--h)); }
.subj-head .ic { width: 44px; height: 44px; stroke-width: 1.5; color: oklch(var(--tf) var(--tfc) var(--h)); }
.subj-head h1, .page-h { margin: 0; font: 700 clamp(1.6rem, 5vw, 2.2rem)/1.1 var(--font-display); letter-spacing: -.01em; }
.subj-head p { margin: 4px 0 0; color: var(--ink-2); }
.results-n { margin: 8px 0 16px; color: var(--ink-2); }

/* book cards */
.books { display: grid; gap: 12px; }
.book { border: 1px solid var(--rule); border-radius: 16px; background: var(--card); }
.book summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 16px 18px; cursor: pointer; border-radius: 16px; }
.book summary::-webkit-details-marker { display: none; }
.book-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.book-t { font: 600 1.08rem/1.3 var(--font-display); }
.book summary:hover .book-t { color: var(--accent-text); }
.book-m { font-size: .86rem; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { padding: 1px 9px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-2); font-size: .74rem; font-weight: 500; color: var(--ink-2); }
.tag.quiz { color: var(--accent-text); }
.chev { color: var(--ink-2); transition: transform .2s var(--ease); }
.book[open] .chev { transform: rotate(90deg); }
.book-body { padding: 0 18px 18px; border-top: 1px solid var(--rule); }
.chs { list-style: none; margin: 16px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.ch { display: flex; overflow: hidden; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); }
.ch-read { flex: 1; min-width: 0; min-height: 60px; display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.ch-n { font: 700 .95rem/1.25 var(--font-display); overflow-wrap: break-word; hyphens: auto; }
.ch-l { font-size: .78rem; color: var(--ink-2); }
.ch-read:hover { background: var(--paper-2); }
.ch-read:hover .ch-l { color: var(--accent-text); }
.ch-dl { display: grid; place-items: center; width: 44px; border-left: 1px solid var(--rule); color: var(--ink-2); }
.ch-dl:hover { background: var(--paper-2); color: var(--ink); }
.ch :focus-visible { outline-offset: -3px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--ink); color: var(--paper); font: 500 .95rem/1.25 var(--font-body); text-align: center; text-decoration: none; cursor: pointer; }
.btn .ic { width: 18px; height: 18px; }
.btn:hover { background: color-mix(in oklch, var(--ink) 82%, var(--paper)); }
.btn.ghost { border-color: var(--rule); background: transparent; color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }

/* quiz */
.quiz-head p { margin: 6px 0 0; color: var(--ink-2); }
.field { display: grid; gap: 6px; max-width: 560px; margin-top: 18px; }
.field span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field select { width: 100%; min-height: 48px; padding: 0 12px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; }
.qs { list-style: none; max-width: 780px; margin: 24px 0; padding: 0; display: grid; gap: 14px; }
.q { padding: 18px; border: 1px solid var(--rule); border-radius: 16px; background: var(--card); }
.q-t { display: flex; gap: 12px; margin: 0 0 14px; font-size: 1.04rem; font-weight: 600; }
.q-n { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--paper-2); font-size: .85rem; }
.opts { display: grid; gap: 8px; }
@media (min-width: 640px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s; }
.opt:hover:not(:disabled) { border-color: var(--ink-2); }
.opt:disabled { cursor: default; }
.opt-k { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 1.5px solid var(--rule); border-radius: 7px; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.q.done .opt:not(.right):not(.wrong) { opacity: .55; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .opt-k { border-color: var(--ok); background: var(--ok); color: var(--paper); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .opt-k { border-color: var(--bad); background: var(--bad); color: var(--paper); }
.why { margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--paper-2); font-size: .95rem; }
.why.ok strong { color: var(--ok); }
.why.no strong { color: var(--bad); }
.score-card { max-width: 780px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 22px; border: 1px solid var(--rule); border-radius: 18px; background: var(--paper-2); }
.score-n { margin: 0; font: 700 2.4rem/1 var(--font-display); }
.score-card p { margin: 4px 0 0; color: var(--ink-2); }

/* footer */
footer.site { border-top: 1px solid var(--rule); padding: 24px 0 40px; font-size: .88rem; color: var(--ink-2); }
footer.site p { margin: 0 0 8px; max-width: 70ch; }
footer.site a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; color: var(--ink); }

/* reader */
#reader { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--reader-bg); color: var(--ink); }
#reader[open] { display: flex; flex-direction: column; }
#reader::backdrop { background: oklch(0% 0 0 / .6); }
.rbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--rule); background: var(--paper); }
.rtitle { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rctl { display: flex; align-items: center; gap: 6px; }
.rcount { font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.zoom { display: inline-flex; align-items: center; gap: 2px; }
#rzoom { min-width: 3.4em; text-align: center; font-size: .88rem; font-variant-numeric: tabular-nums; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); color: var(--ink); font: 500 .9rem var(--font-body); text-decoration: none; cursor: pointer; }
.ibtn:hover { border-color: var(--ink-2); }
.ibtn:disabled { opacity: .4; cursor: default; }
@media (max-width: 680px) {
  .rtitle { flex-basis: calc(100% - 64px); }
  #rclose { order: 1; }
  .rctl { order: 2; width: 100%; justify-content: space-between; }
  .ibtn .lbl { display: none; }
}
.rbody { position: relative; flex: 1; min-height: 0; }
.rpages { --zoom: 1; position: absolute; inset: 0; overflow: auto; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.page { width: calc(100% * var(--zoom)); margin: 0 auto 12px; background: #fff; box-shadow: 0 1px 4px oklch(0% 0 0 / .22); }
.page canvas { display: block; width: 100%; height: 100%; }
.rstate { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; background: var(--reader-bg); text-align: center; }
.rstate p { margin: 0; max-width: 40ch; }
.rstate progress { width: min(260px, 70vw); accent-color: var(--accent-text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
