/* Padhai — design system.
   Mobile-first: this audience is ~90% phones, often on slow connections and
   often at night. So: system fonts (no webfont round-trip), no client-side JS,
   generous tap targets, high contrast, and a real dark mode. */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light dark;

  --brand: #2c5fd4;
  --brand-ink: #1c3f96;
  --brand-tint: #eef3fe;
  --answer: #0b7a53;
  --answer-tint: #eaf7f1;
  --warn: #a35a00;
  --warn-tint: #fdf5e8;

  --ink: #131a26;
  --ink-2: #3d4a5c;
  --ink-3: #6b7789;
  --bg: #ffffff;
  --surface: #f7f9fc;
  --line: #e2e7ef;
  --line-2: #cdd5e2;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(19, 26, 38, .06), 0 4px 14px rgba(19, 26, 38, .05);
  --shadow-lift: 0 2px 6px rgba(19, 26, 38, .08), 0 12px 28px rgba(19, 26, 38, .10);

  --wrap: 1120px;
  --measure: 68ch;

  /* Subject colour-coding. Students scan a long subject list far faster when
     each one has a stable colour than when it is 8 identical grey boxes. */
  --subj: var(--brand);
  --subj-maths: #2c5fd4;
  --subj-science: #0b7a53;
  --subj-english: #b2403a;
  --subj-hindi: #a35a00;
  --subj-history: #7145bd;
  --subj-geography: #0d7b85;
  --subj-civics: #c04a12;
  --subj-economics: #4a7a10;
  --subj-evs: #0e8a76;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7aa2f7;
    --brand-ink: #a9c3ff;
    --brand-tint: #17203a;
    --answer: #4ec99a;
    --answer-tint: #12261f;
    --warn: #e0a458;
    --warn-tint: #2a2115;

    --ink: #e7ecf5;
    --ink-2: #b4bfd0;
    --ink-3: #8590a3;
    --bg: #0e131c;
    --surface: #151c28;
    --line: #263141;
    --line-2: #33415a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 12px 28px rgba(0, 0, 0, .45);

    --subj-maths: #7aa2f7;
    --subj-science: #4ec99a;
    --subj-english: #f08a84;
    --subj-hindi: #e0a458;
    --subj-history: #b699f0;
    --subj-geography: #4dc4cf;
    --subj-civics: #f2905c;
    --subj-economics: #a8c95a;
    --subj-evs: #4fd0b8;
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 18px; }

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { left: 0; top: 0; z-index: 100; }

/* ---------------------------------------------------------------- header */
.site-head {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap {
  display: flex; align-items: center; gap: 14px;
  min-height: 64px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em;
  color: var(--ink); white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand), var(--brand-ink));
  color: #fff; font-size: .95rem; font-weight: 800;
}
.brand em { font-style: normal; color: var(--brand-ink); }

.searchbox { flex: 1 1 260px; display: flex; gap: 8px; margin-left: auto; min-width: 0; }
.searchbox input {
  flex: 1; min-width: 0;
  padding: 11px 15px; font: inherit; font-size: .97rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 999px;
}
.searchbox input::placeholder { color: var(--ink-3); }
.searchbox input:focus { border-color: var(--brand); background: var(--bg); }
.searchbox button {
  flex: none; padding: 11px 20px; font: inherit; font-size: .95rem; font-weight: 600;
  color: #fff; background: var(--brand); border: 0; border-radius: 999px; cursor: pointer;
}
.searchbox button:hover { background: var(--brand-ink); }

/* ----------------------------------------------------------- breadcrumbs */
.crumbs {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-size: .84rem; color: var(--ink-3);
  padding: 18px 0 4px;
}
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--brand-ink); }
.crumbs i { font-style: normal; opacity: .45; }

/* ------------------------------------------------------------ typography */
h1 {
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.1rem);
  line-height: 1.25; letter-spacing: -.02em;
  margin: 14px 0 10px; font-weight: 700;
}
h2 {
  font-size: clamp(1.15rem, 1rem + .7vw, 1.4rem);
  line-height: 1.35; letter-spacing: -.01em;
  margin: 38px 0 14px; font-weight: 700;
}
h3 { font-size: 1.02rem; margin: 24px 0 8px; font-weight: 650; }

.lede { color: var(--ink-2); font-size: 1.03rem; max-width: var(--measure); margin: 0 0 26px; }
.muted { color: var(--ink-3); font-size: .9rem; }
main { padding-bottom: 40px; }

/* ------------------------------------------------------------------ hero */
.hero {
  background: linear-gradient(160deg, var(--brand-tint), transparent 70%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 30px 24px 26px;
  margin: 18px 0 10px;
}
.hero h1 { margin-top: 0; }
.hero .lede { margin-bottom: 0; }

/* ----------------------------------------------------------------- grids */
.grid { display: grid; gap: 12px; }
.grid.classes { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid.subjects { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.chapters { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  display: block; position: relative;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--subj);
}
.card .t { display: block; font-weight: 650; line-height: 1.35; }
.card .s { display: block; margin-top: 5px; font-size: .84rem; color: var(--ink-3); }

/* class tiles read as a numeric ladder, so the number carries the weight */
.card.klass { text-align: center; padding: 20px 12px 16px; }
.card.klass .n {
  display: block; font-size: 1.85rem; font-weight: 800; line-height: 1;
  letter-spacing: -.03em; color: var(--brand-ink);
}
.card.klass .t { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.card.klass .s { margin-top: 6px; font-size: .78rem; }

/* subject + chapter cards carry the subject colour */
.card.subject, .card.chapter { border-left: 4px solid var(--subj); }
.card.chapter .num {
  display: inline-block; min-width: 1.6em;
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--subj);
}
.card.empty { opacity: .62; }

/* ------------------------------------------------------------ badges */
.tag {
  display: inline-block; padding: 2px 9px;
  border-radius: 999px; font-size: .72rem; font-weight: 650;
  letter-spacing: .01em; white-space: nowrap;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.easy   { color: var(--answer); border-color: color-mix(in srgb, var(--answer) 35%, var(--line)); }
.tag.medium { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.tag.hard   { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

/* ---------------------------------------------------------- question list */
.qlist { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.qlist > li { margin: 0; }
.qlist a {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  padding: 15px 17px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink); line-height: 1.5;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.qlist a:hover {
  text-decoration: none; border-color: var(--subj);
  box-shadow: var(--shadow); transform: translateY(-1px);
}
.qlist .idx {
  grid-row: 1 / span 2;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: .95rem;
  color: var(--subj); padding-top: 1px;
}
.qlist .qt { font-weight: 500; }
.qlist .qm {
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
  font-size: .8rem; color: var(--ink-3);
}

/* ------------------------------------------------------- question page */
.qhead { margin: 6px 0 0; }
.qhead h1 { margin-bottom: 12px; }
.qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .84rem; color: var(--ink-3); }

.panel {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; margin: 22px 0;
  background: var(--surface);
}
.panel.options ol { margin: 0; padding-left: 26px; }
.panel.options li { margin: 6px 0; }

.answer-card {
  border: 1px solid color-mix(in srgb, var(--answer) 32%, var(--line));
  border-left: 5px solid var(--answer);
  background: var(--answer-tint);
  border-radius: var(--r);
  padding: 16px 18px; margin: 22px 0 30px;
}
.answer-card .label {
  display: block; margin-bottom: 6px;
  font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--answer);
}
.answer-card .val { font-size: 1.12rem; font-weight: 600; }

/* Numbered steps with a connecting rail — the visual rhythm is what makes a
   worked solution scannable, and it is where a student finds the step they
   got wrong. */
ol.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
ol.steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 22px 46px;
  max-width: var(--measure);
}
ol.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-tint); color: var(--brand-ink);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  font-size: .84rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
ol.steps li::after {
  content: ""; position: absolute; left: 15px; top: 32px; bottom: 6px;
  width: 1px; background: var(--line-2);
}
ol.steps li:last-child { padding-bottom: 4px; }
ol.steps li:last-child::after { display: none; }

.mistake {
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line));
  border-left: 5px solid var(--warn);
  background: var(--warn-tint);
  border-radius: var(--r);
  padding: 14px 17px; margin: 26px 0;
  font-size: .96rem; max-width: var(--measure);
}
.mistake b { color: var(--warn); }

.concept { font-size: .88rem; color: var(--ink-3); margin: 18px 0 0; }
.concept b { color: var(--ink-2); }

/* ------------------------------------------------------------- pager */
.pager { display: grid; gap: 10px; grid-template-columns: 1fr; margin: 34px 0 10px; }
.pager a {
  display: block; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink); font-size: .93rem; line-height: 1.45;
}
.pager a:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
.pager .dir {
  display: block; margin-bottom: 3px;
  font-size: .73rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
}
.pager .next { text-align: left; }

.backlink { display: inline-block; margin-top: 28px; font-weight: 600; }

/* --------------------------------------------------------------- ads */
/* Height is reserved whether or not a unit renders, so switching ads on later
   shifts nothing and does not damage CLS. */
.adslot { margin: 26px 0; min-height: 90px; text-align: center; overflow: hidden; }
.adslot.incontent { min-height: 250px; }

/* ------------------------------------------------------------ footer */
.site-foot {
  margin-top: 56px; padding: 30px 0 36px;
  border-top: 1px solid var(--line); background: var(--surface);
  font-size: .89rem; color: var(--ink-3);
}
.site-foot nav { display: flex; gap: 8px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.site-foot a { color: var(--ink-2); }
.site-foot p { max-width: var(--measure); margin: 0; }

/* ---------------------------------------------------------- prose pages */
.prose { max-width: var(--measure); }
.prose h2 { margin-top: 32px; }
.prose p { margin: 0 0 16px; }

/* ------------------------------------------------------------- overflow */
/* Long equations and wide tables scroll inside themselves. The page body must
   never scroll sideways on a phone.
   KaTeX sets white-space: nowrap on .katex, so a single long inline formula
   like 9 x 22338 = 201042 = 306 x 657 cannot wrap. Left alone it widens its
   container, which widens the page, and every line on the phone gets clipped
   at the right edge. Making it an inline-block that scrolls on its own axis
   confines the problem to the formula. */
.katex-display, .scrollx { overflow-x: auto; overflow-y: hidden; }
.katex-display { padding: 4px 0; }
.katex {
  font-size: 1.04em;
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  vertical-align: middle;
}

/* Grid and flex children default to min-width:auto, which lets wide content
   push a track wider than its container. */
.wrap, main, .qlist a, .qlist .qt, .card, .pager a,
ol.steps li, .answer-card, .mistake, .panel { min-width: 0; }

h1, h2, .qt, .lede, .answer-card .val, ol.steps li, .mistake, .panel {
  overflow-wrap: break-word;
}

/* ------------------------------------------------------------ responsive */
@media (min-width: 640px) {
  .pager { grid-template-columns: 1fr 1fr; }
  .pager .next { text-align: right; }
  .grid.classes { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (min-width: 900px) {
  .wrap { padding: 0 24px; }
  .hero { padding: 40px 34px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .card:hover, .qlist a:hover { transform: none; }
}

@media print {
  .site-head, .site-foot, .adslot, .pager, .searchbox { display: none; }
  body { font-size: 12pt; }
  .answer-card, .mistake { border: 1px solid #999; background: none; }
}
