/* Public content pages (/learn, /guides): built by scripts/build-content.mjs.
   Same dark look as the app: bright cards, big tap targets, a quiz on every
   topic page. */
:root {
  --bg: #0b0d1a;
  --card: #141831;
  --card-2: #1a1f3f;
  --line: #262b4d;
  --text: #e9e8f7;
  --muted: #a3a6c4;
  --accent: #8b74ff;
  --cyan: #2fd6ef;
  --easy: #3ef0a0;
  --medium: #ffd23f;
  --hard: #ff6b8a;
  --right: #3ef0a0;
  --wrong: #ff6b8a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font: 16px/1.6 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(900px 500px at 10% -10%, rgba(139, 116, 255, 0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(47, 214, 239, 0.12), transparent 60%), var(--bg);
  background-attachment: fixed;
}
a { color: var(--cyan); }
a:focus-visible, summary:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif; line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(28px, 6vw, 42px); margin: 8px 0 12px; }
h2 { font-size: 22px; margin: 32px 0 12px; }
h2 small { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
h3 { font-size: 19px; margin: 24px 0 8px; }
p, li { max-width: 72ch; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(11, 13, 26, 0.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.brand { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: 2px; color: var(--text); text-decoration: none; }
.brand span { color: var(--cyan); }
.brand small { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.play, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: linear-gradient(100deg, #7c5cff, #b14dff); color: #fff; text-decoration: none; font-weight: 700; padding: 9px 16px; border-radius: 12px; white-space: nowrap; border: 0; box-shadow: 0 6px 20px -8px rgba(124, 92, 255, 0.8); }
.btn { padding: 13px 22px; font-size: 16px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); box-shadow: none; color: var(--text); }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px 48px; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.lede { font-size: 17px; color: var(--muted); }
.muted { color: var(--muted); }

/* ── /learn/ hub ── */
.hub-hero { position: relative; margin: 8px 0 18px; padding: 26px 20px; border-radius: 22px; overflow: hidden;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(47, 214, 239, 0.18)); border: 1px solid rgba(139, 116, 255, 0.45); }
.hub-hero::after { content: '🧮 ➗ 🧠 💯 🧭'; position: absolute; right: -10px; bottom: -14px; font-size: 44px; opacity: 0.16; letter-spacing: 6px; pointer-events: none; }
.hub-eyebrow { margin: 0; font-weight: 700; color: var(--cyan); letter-spacing: 0.06em; }
.hub-hero h1 { margin: 6px 0 8px; }
.hub-sub { margin: 0 0 14px; color: #d6d4f0; font-size: 16px; }
.hub-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.hub-stats span { padding: 5px 12px; border-radius: 999px; background: rgba(11, 13, 26, 0.45); border: 1px solid rgba(255, 255, 255, 0.12); font-size: 14px; color: var(--muted); }
.hub-stats b { color: var(--text); }

.continue { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 14px 16px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: rgba(62, 240, 160, 0.1); border: 1px solid rgba(62, 240, 160, 0.45); }
.continue > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.continue small { color: var(--easy); font-weight: 600; }
.continue b { font-size: 17px; }
.continue-icon { font-size: 30px; }
.continue-go { font-size: 26px; color: var(--easy); }

.hub-tools { position: sticky; top: 58px; z-index: 4; display: grid; gap: 10px; padding: 10px 0; margin: 0 0 4px; background: linear-gradient(var(--bg) 80%, transparent); }
.find { width: 100%; min-height: 48px; padding: 0 16px; font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.find::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 16px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); }
.chip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.cat { scroll-margin-top: 140px; }
.cat h2 { margin-top: 22px; }

.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tcard { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--line); transition: transform 0.12s, border-color 0.12s; }
.tcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.tcard:active { transform: scale(0.98); }
.tcard.s-maths { background: linear-gradient(160deg, rgba(139, 116, 255, 0.16), var(--card) 60%); }
.tcard.s-reasoning { background: linear-gradient(160deg, rgba(47, 214, 239, 0.14), var(--card) 60%); }
.ticon { width: 46px; height: 46px; display: grid; place-items: center; font-size: 26px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); }
.tname { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.tmeta { font-size: 13px; color: var(--muted); }
.tbar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: auto; }
.tbar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--easy)); }
.tcard.complete { border-color: rgba(62, 240, 160, 0.55); }
.tcard.complete .tmeta { color: var(--easy); font-weight: 600; }
.none { text-align: center; padding: 24px 0; }

/* ── Topic page ── */
.t-hero { display: flex; align-items: center; gap: 14px; margin: 10px 0 6px; }
.t-hero h1 { margin: 0; }
.t-hero-icon { flex: none; width: 64px; height: 64px; display: grid; place-items: center; font-size: 36px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.4), rgba(47, 214, 239, 0.25)); border: 1px solid rgba(139, 116, 255, 0.5); }
.t-hero-sub { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

.keys { background: linear-gradient(160deg, rgba(255, 210, 63, 0.1), var(--card) 55%); border: 1px solid rgba(255, 210, 63, 0.35); border-radius: 18px; padding: 4px 18px 12px; margin: 18px 0; }
.keys h2 { margin: 16px 0 8px; font-size: 20px; }
.keys ol { margin: 0; padding-left: 0; list-style: none; counter-reset: tip; display: grid; gap: 10px; }
.keys li { counter-increment: tip; position: relative; padding-left: 36px; }
.keys li::before { content: counter(tip); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 800; color: #1a1300; background: var(--medium); }
.guide-link { font-weight: 600; }

.score { position: sticky; top: 58px; z-index: 4; display: none; align-items: center; gap: 12px; margin: 18px 0 0; padding: 10px 14px; border-radius: 14px; background: rgba(20, 24, 49, 0.94); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.quiz-on .score { display: flex; }
.score-txt { flex: none; font-weight: 700; font-size: 14px; }
.score-track { flex: 1; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.score-bar { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--easy)); transition: width 0.3s; }
.try-h { margin-top: 22px; }

ol.exs { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.ex { scroll-margin-top: 130px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; max-width: none; transition: border-color 0.2s; }
.ex.ok { border-color: rgba(62, 240, 160, 0.6); }
.ex.bad { border-color: rgba(255, 107, 138, 0.55); }
.ex-head { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.ex-mark { margin-left: auto; font-size: 18px; }
.ex.ok .ex-mark::after { content: '✅'; }
.ex.bad .ex-mark::after { content: '❌'; }
.num { font-family: 'Chakra Petch', sans-serif; font-weight: 700; color: var(--accent); }
.lvl { font-weight: 700; font-size: 12px; padding: 1px 10px; border-radius: 999px; border: 1px solid currentColor; }
.lvl-easy { color: var(--easy); }
.lvl-medium { color: var(--medium); }
.lvl-hard { color: var(--hard); }
.q { font-size: 18px; font-weight: 600; margin: 10px 0 12px; overflow-wrap: anywhere; }
ol.opts { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt { width: 100%; min-height: 50px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; font: inherit; font-size: 16px; color: var(--text);
  background: var(--card-2); border: 1.5px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.opt b { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; font-size: 13px; color: var(--accent); background: rgba(139, 116, 255, 0.15); }
.opt:disabled { cursor: default; }
.quiz-on .opt:not(:disabled) { cursor: pointer; }
.quiz-on .opt:not(:disabled):hover { border-color: var(--accent); }
.quiz-on .opt:not(:disabled):active { transform: scale(0.98); }
.opt.right { border-color: var(--right); background: rgba(62, 240, 160, 0.14); }
.opt.right b { color: #062b1a; background: var(--right); }
.opt.wrong { border-color: var(--wrong); background: rgba(255, 107, 138, 0.13); }
.opt.wrong b { color: #2b0610; background: var(--wrong); }
.ex.done .opt:not(.right):not(.wrong) { opacity: 0.55; }
details summary { cursor: pointer; font-weight: 700; color: var(--cyan); }
details[open] summary { margin-bottom: 6px; }
.quiz-on .ex:not(.done) details { display: none; } /* answer after a tap */
.quiz-on .ex.done details summary { display: none; }
.ans { margin: 4px 0; }
.ans b { color: var(--easy); }
.why { margin: 6px 0 0; padding: 10px 12px; border-radius: 12px; background: rgba(255, 210, 63, 0.08); border: 1px solid rgba(255, 210, 63, 0.25); }

.finish { margin: 22px 0; padding: 22px 18px; text-align: center; border-radius: 20px;
  background: linear-gradient(135deg, rgba(62, 240, 160, 0.16), rgba(124, 92, 255, 0.2)); border: 1px solid rgba(62, 240, 160, 0.5); }
.finish p { margin: 0 auto; }
.finish-label { color: var(--muted); font-weight: 600; }
.finish-score { font-family: 'Chakra Petch', sans-serif; font-size: 48px; font-weight: 700; line-height: 1.1; }
.finish-msg { margin: 6px auto 16px !important; }
.finish-actions { display: grid; gap: 10px; max-width: 420px; margin: 0 auto; }
.again { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 8px; }

.related ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.related a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line); }
.related a:hover { border-color: var(--accent); }
.related a span { font-size: 20px; }

/* ── Shared ── */
.ad { margin: 24px 0; text-align: center; min-height: 90px; }
.ad-label { display: block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.in-app .ad { display: none; }

.cta { margin: 32px 0; padding: 24px 20px; border-radius: 20px; background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(47, 214, 239, 0.14)); border: 1px solid rgba(139, 116, 255, 0.45); text-align: center; }
.cta h2 { margin: 0 0 6px; }
.cta p { margin: 0 auto 14px; color: #d6d4f0; }

ul.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
ul.cards li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 4px; max-width: none; }
ul.cards a { text-decoration: none; }
ul.cards span { color: var(--muted); font-size: 14.5px; }

.guide table { border-collapse: collapse; width: 100%; margin: 12px 0; display: block; overflow-x: auto; }
.guide th, .guide td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.guide th { background: var(--card); }

.foot { border-top: 1px solid var(--line); padding: 24px 16px 40px; text-align: center; color: var(--muted); font-size: 14px; }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-bottom: 8px; }
.foot a { color: var(--muted); }

@media (max-width: 520px) {
  .brand small { display: none; }
  h2 { font-size: 20px; }
  .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tcard { padding: 12px; }
  .ticon { width: 40px; height: 40px; font-size: 22px; }
  .tname { font-size: 14.5px; }
  .hub-hero { padding: 22px 16px; }
  .hub-hero::after { display: none; }
  .t-hero-icon { width: 54px; height: 54px; font-size: 30px; }
  .score, .hub-tools { top: 56px; }
}
@media (max-width: 380px) {
  ol.opts { grid-template-columns: minmax(0, 1fr); }
}
