/* CodingMarble Learn — light theme (see QUALITY-STANDARD.md §5) */
@font-face { font-family: "Inter"; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2"); font-weight: 100 900; font-display: swap;
  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+20B9, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url(fonts/inter-cyrillic-wght-normal.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Noto Sans Devanagari"; src: url(fonts/noto-sans-devanagari-devanagari-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans Devanagari"; src: url(fonts/noto-sans-devanagari-devanagari-600-normal.woff2) format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Noto Sans Devanagari"; src: url(fonts/noto-sans-devanagari-devanagari-700-normal.woff2) format("woff2"); font-weight: 700 900; font-display: swap; }

:root {
  --bg: #f6f8fc; --surface: #ffffff; --surface-2: #f1f4fa; --text: #14203a; --muted: #56627a; --line: #e2e7f0;
  --brand: #2451d6; --brand-2: #0f9bd7; --brand-soft: #e8eefc; --ok: #16803c; --ok-soft: #e7f6ec; --bad: #c42b2b; --bad-soft: #fdecec;
  --warn-soft: #fff4de; --leaf-soft: #e9f7ee; --shadow: 0 1px 2px rgba(20,32,58,.06), 0 6px 20px rgba(20,32,58,.06);
  --radius: 16px; --ease-enter: cubic-bezier(.16,1,.3,1); --ease-std: cubic-bezier(.4,0,.2,1); --t-fast: .18s; --t-base: .32s; --t-slow: .5s;
  --stage-bg: radial-gradient(ellipse at 50% 35%, #ffffff 0%, #eef3fb 60%, #e3eaf6 100%);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 17.5px/1.7 "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
:lang(hi) body, body:lang(hi) { font-family: "Noto Sans Devanagari", "Inter", system-ui, sans-serif; line-height: 1.8; }
a { color: var(--brand); text-underline-offset: 3px; }
img, canvas, svg { max-width: 100%; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(255,255,255,.88); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: -.01em; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.langs { display: flex; gap: 6px; flex-wrap: wrap; }
.langs a { text-decoration: none; font-size: 14px; padding: 4px 10px; border-radius: 999px; color: var(--muted); border: 1px solid transparent; }
.langs a[aria-current] { color: var(--brand); background: var(--brand-soft); border-color: #cfdaf8; font-weight: 700; }

/* type */
h1 { font-size: clamp(1.75rem, 4.8vw, 2.6rem); line-height: 1.18; letter-spacing: -.02em; margin: 14px 0 10px; font-weight: 800; }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); line-height: 1.3; letter-spacing: -.01em; margin: 38px 0 12px; font-weight: 750; }
h3 { font-size: 1.08rem; line-height: 1.4; margin: 0 0 6px; font-weight: 700; }
p { margin: 0 0 14px; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 70ch; }
.crumbs { font-size: 14px; color: var(--muted); margin-top: 16px; }
.crumbs a { color: var(--muted); }
#lesson-text { max-width: 75ch; }
#lesson-text strong { color: #0d1a36; }

/* cards & grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: transform var(--t-fast) var(--ease-std), border-color var(--t-fast), box-shadow var(--t-fast); }
.card strong { font-size: 1.04rem; }
.card span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.card.off { opacity: .55; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { a.card:hover { transform: translateY(-3px); border-color: #b9c9f5; box-shadow: 0 10px 30px rgba(36,81,214,.12); } }
.chapter ul { padding-left: 20px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: #fff; border: 0; border-radius: 12px;
  padding: 11px 18px; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; min-height: 44px;
  transition: transform var(--t-fast) var(--ease-std), background var(--t-fast), box-shadow var(--t-fast); box-shadow: 0 2px 8px rgba(36,81,214,.25); }
.btn:hover { background: #1c44bd; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn-soft { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.btn-soft:hover { background: #dbe5fb; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-glow { position: relative; isolation: isolate; }
.btn-glow::before { content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 14px;
  background: linear-gradient(90deg, #2451d6, #0f9bd7, #16a34a, #f59e0b, #2451d6); background-size: 300% 100%; animation: glow 7s linear infinite; }
.btn-glow::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 12px; background: var(--brand); }
@keyframes glow { to { background-position: 300% 0; } }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #7fb4ff; outline-offset: 2px; }

/* 3D stage + story */
.anim { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px; margin: 18px 0; box-shadow: var(--shadow); }
.stage3d { position: relative; width: 100%; border-radius: 14px; overflow: hidden; background: var(--stage-bg); touch-action: pan-y; cursor: grab; }
.stage3d.grab { cursor: grabbing; touch-action: none; }
.stage3d canvas { width: 100% !important; height: 100% !important; display: block; }
.nogl { padding: 40px 16px; text-align: center; color: var(--muted); }
#anim { min-height: 0; }
.ctrl { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; font-size: 15px; }
.ctrl label { display: flex; align-items: center; gap: 8px; }
.ctrl input[type=range] { accent-color: var(--brand); width: min(220px, 60vw); height: 28px; }
.ctrl select, .ctrl button { font: inherit; font-size: 15px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 40px; }
.readout { font-variant-numeric: tabular-nums; font-weight: 650; }
.drag-hint { color: var(--muted); font-size: 13.5px; margin: 8px 2px 0; }
.story { margin-top: 12px; }
.story-h { font-size: 1.05rem; margin: 6px 0; }
.story ol { padding-left: 22px; margin: 6px 0; }
.story.js ol { display: none; }
.story-now { font-size: 1.1rem; line-height: 1.65; min-height: 3.3em; margin: 8px 0 12px; padding: 14px 16px;
  background: var(--brand-soft); border-radius: 14px; border-left: 5px solid var(--brand); color: #0f1d40; }
.story-now b { color: var(--brand); margin-right: 6px; }
.story-now.pop { animation: pop var(--t-base) var(--ease-enter); }
@keyframes pop { from { opacity: .3; transform: translateY(6px); } }
.story-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dots { display: flex; gap: 7px; flex: 1; justify-content: center; min-width: 120px; }
.dots button { width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; background: #cdd6e6; cursor: pointer;
  transition: transform var(--t-fast) var(--ease-std), background var(--t-fast); }
.dots button.done { background: #9db3ec; }
.dots button.on { background: var(--brand); transform: scale(1.4); }

/* lesson blocks */
.twin { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 18px 0; }
.hook, .real { border-radius: var(--radius); padding: 4px 18px 12px; border: 1px solid var(--line); }
.hook { background: var(--warn-soft); border-color: #f6dfae; }
.real { background: var(--leaf-soft); border-color: #bfe5cc; }
.hook h2, .real h2 { font-size: 1.05rem; margin: 14px 0 6px; }
.formulas { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 14px 36px;
  font-family: "Inter", "Noto Sans Devanagari", sans-serif; font-feature-settings: "tnum"; }
.formulas li { margin: 4px 0; }
.ex { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.ex p { margin: 8px 0 0; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin: 10px 0; }
summary { cursor: pointer; }
summary h3 { display: inline; }
.taught { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border-radius: 12px; overflow: hidden; }
.taught td { border-bottom: 1px solid var(--line); padding: 10px 8px; }
.tools { margin: 12px 0; }

/* quiz / practice */
.quiz { position: relative; }
.quiz .q { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 12px; padding: 12px 16px; background: var(--surface); }
.quiz legend { font-weight: 650; padding: 0 4px; }
.quiz label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.quiz label:hover { background: var(--surface-2); }
.quiz input[type=radio], .quiz input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.quiz .right { border-color: #9fd6b1; background: var(--ok-soft); }
.quiz .wrong { border-color: #f0b3b3; background: var(--bad-soft); }
.quiz label.correct { font-weight: 700; color: var(--ok); }
.quiz output { display: block; margin-top: 10px; font-weight: 700; }
.confetti { position: absolute; left: 50%; bottom: 40px; pointer-events: none; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: fly 1.4s var(--ease-enter) var(--d) forwards; }
@keyframes fly { 0% { opacity: 1; transform: translate(0,0) rotate(0); } 100% { opacity: 0; transform: translate(calc(var(--x) * 220px), -240px) rotate(540deg); } }

/* home */
.hero-lead { font-size: 1.15rem; max-width: 640px; }
.hero-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0 4px; }
.hint { color: var(--muted); font-size: 14px; }
.hero3d { margin: 8px 0 0; border-radius: 20px; overflow: hidden; background: var(--stage-bg); border: 1px solid var(--line); }
.why { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.why li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-weight: 550; box-shadow: var(--shadow); }
.subj h3 { display: block; font-size: 1.15rem; margin: 24px 0 10px; }
.revise { background: var(--surface); border: 2px dashed #9fc2f0; border-radius: 16px; padding: 4px 16px 14px; margin: 16px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--brand-soft); border-radius: 999px; padding: 7px 14px; text-decoration: none; font-weight: 650; }

/* footer */
.foot { margin-top: 70px; background: var(--surface); border-top: 1px solid var(--line); padding: 14px 0 34px; }
.foot h2 { font-size: 1.05rem; }
.sisters { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.note { color: var(--muted); font-size: 14px; }

/* motion */
.reveal.rv { opacity: 0; transform: translateY(18px); }
.reveal.in { opacity: 1; transform: none; transition: opacity var(--t-slow) var(--ease-enter), transform var(--t-slow) var(--ease-enter); }

/* phones */
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .wrap { padding: 0 14px; }
  .anim { padding: 8px; margin: 14px -6px; border-radius: 16px; }
  .story-bar .btn { flex: 1; justify-content: center; }
  .story-bar .dots { order: -1; flex-basis: 100%; margin-bottom: 4px; }
  .story-bar .btn-ghost { flex-basis: 100%; }
  .ctrl { gap: 10px; }
  .ctrl label { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* practice questions */
.practice { display: grid; gap: 14px; }
.pq { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 16px; box-shadow: var(--shadow);
  transition: border-color var(--t-fast), background var(--t-fast); }
.pq.right { border-color: #9fd6b1; background: #fbfefc; }
.pq.wrong { border-color: #f0b3b3; }
.pq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pq-n { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.pq-lvl { font-size: 12.5px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.lvl-easy .pq-lvl { background: #e7f6ec; color: #16803c; }
.lvl-medium .pq-lvl { background: #fff4de; color: #9a6400; }
.lvl-hard .pq-lvl { background: #fdecec; color: #b42323; }
.pq-q { font-size: 1.05rem; margin: 6px 0 10px; }
.pq-body label { display: flex; gap: 10px; align-items: flex-start; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.pq-body label:hover { background: var(--surface-2); }
.pq-body input[type=radio], .pq-body input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.pin { display: flex; align-items: center; gap: 8px; }
.pin input, .pq textarea, .pmatch select { font: inherit; padding: 10px 12px; border: 1.5px solid #cfd8e8; border-radius: 12px; background: #fff; color: var(--text); min-height: 46px; }
.pin input { width: min(320px, 100%); }
.pq textarea { width: 100%; resize: vertical; }
.unit { font-weight: 700; color: var(--muted); }
.porder { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: s; }
.porder li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); counter-increment: s; }
.porder li::before { content: counter(s) "."; font-weight: 800; color: var(--brand); margin-right: 4px; }
.porder li > span:first-of-type { flex: 1; }
.mv { display: flex; gap: 4px; }
.mv button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.pmatch { display: grid; gap: 8px; }
.pmatch label { justify-content: space-between; flex-wrap: wrap; background: var(--surface-2); }
.pmatch select { min-width: 180px; max-width: 100%; }
.pq-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pq-hinttext { margin: 10px 0 0; padding: 10px 12px; background: var(--warn-soft); border-radius: 12px; }
.pq-verdict { margin: 12px 0 6px; font-weight: 700; }
.pq-sol { margin-top: 8px; background: var(--brand-soft); border: 0; border-radius: 12px; padding: 10px 14px; }
.pq-points { list-style: none; padding-left: 4px; margin: 6px 0 0; }
.pscore { font-weight: 800; font-size: 1.1rem; color: var(--brand); }

/* 3D labels (HTML over the canvas; see lib3d.js label()) */
.l3d-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.l3d { position: absolute; left: 0; top: 0; max-width: min(78%, 340px); padding: 4px 11px; border-radius: 12px;
  font: 650 var(--fs, 15px)/1.3 "Inter", "Noto Sans Devanagari", system-ui, sans-serif; text-align: center;
  white-space: normal; overflow-wrap: anywhere; box-shadow: 0 2px 8px rgba(15,23,42,.18); will-change: transform; }
@media (max-width: 600px) { .l3d { font-size: max(12.5px, calc(var(--fs, 15px) * .82)); padding: 3px 8px; max-width: 70%; } }
.l3d.pin { width: 24px; height: 24px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; max-width: none; border: 2px solid #fff; }
.l3d-legend { margin: 8px 0 0; padding: 8px 12px 8px 34px; background: var(--surface-2); border-radius: 12px; font-size: 14.5px; line-height: 1.5;
  columns: 2 150px; column-gap: 18px; }
.l3d-legend li { break-inside: avoid; margin: 2px 0; }
.l3d-legend li::marker { font-weight: 800; color: var(--brand); }
@media (min-width: 560px) { .l3d-legend { display: none; } }
.doubts { margin: 18px 0; }
.doubt summary h3 { font-size: 1.02rem; }
.doubt .see3d { margin-top: 4px; }
.l3d-legend[hidden] { display: none; }
.l3d-legend:empty { display: none; }

/* ---- ads: always labelled, height reserved, never over text, collapsed when no ad is filled ---- */
.ad-unit { margin: 2rem auto; max-width: 46rem; clear: both; }
.ad-label { margin: 0 0 .25rem; text-align: center; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #667); opacity: .8; }
.ad-unit .adsbygoogle { min-height: 100px; background: transparent; }
.ad-unit .adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-unit:has(.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-preview { display: grid; place-items: center; min-height: 120px; border: 1px dashed #99a; border-radius: .5rem; color: #667; background: #f4f5fb; }
@media (max-width: 600px) { .ad-unit { margin: 1.5rem auto; } .ad-unit .adsbygoogle { min-height: 250px; } .ad-preview { min-height: 250px; } }
.dev-follow { margin: .75rem 0; }
.dev-follow-t { margin: 0 0 .4rem; font-weight: 600; font-size: .95rem; }
.dev-follow-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.dev-follow .soc { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 1rem; border-radius: 999px; color: #fff; font-weight: 600; text-decoration: none; }
.dev-follow .soc svg { width: 20px; height: 20px; fill: currentColor; }
.dev-follow .soc-ig { background: linear-gradient(45deg, #f09433, #dc2743 55%, #bc1888); }
.dev-follow .soc-yt { background: #d00; }
.dev-follow .soc:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
nav.policy { margin: .25rem 0 .75rem; font-size: .9rem; }
nav.policy a { white-space: nowrap; }
