/* The stylesheet for the indexable pages. Deliberately NOT the app's CSS.
 *
 * These pages are judged on Core Web Vitals, so the rules are:
 *   · no webfont      — a system stack renders on the first paint, so the h1
 *                       is the LCP element and there is no swap-in shift
 *   · no JavaScript   — nothing to block INP
 *   · fixed-height    — every box that could reflow has its space reserved,
 *     furniture         which keeps CLS at 0
 * One small file, one request. Colours match the app so arriving at /app
 * does not feel like a different product.
 */

:root {
  --ink: #16181d;
  --body: #33363f;
  --muted: #6b7280;
  --line: #e6e7ec;
  --bg: #fff;
  --soft: #f7f8fb;
  --primary: #4f46e5;
  --deep: #3730a3;
  --green: #0f766e;
  --amber: #b45309;
  --radius: 12px;
  --wrap: 940px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── header ─────────────────────────────────────────────────────────────
 * Desktop: one row — mark, wordmark, sections, then the two calls to action.
 * Under 720px it becomes two rows: the mark and the Android button stay put
 * (the download must never be the thing you scroll to find), and the section
 * links slide horizontally underneath rather than wrapping into a ragged block.
 */
.hd {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.hd .wrap {
  display: flex;
  align-items: center;
  gap: 10px 22px;
  min-height: 62px;      /* reserved, so the sticky bar never shifts content */
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16.5px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.015em;
  flex: none;
}
.brand img {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 10%, white);
  padding: 3px;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  font-size: 14.5px;
}
.nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease;
}
.nav a:hover { color: var(--ink); background: var(--soft); }
/* The page you are on, marked with a rule rather than a fill — the filled
   shape in this bar is reserved for the download. */
.nav a.on { color: var(--ink); font-weight: 600; }
.nav a.on::after {
  content: '';
  position: absolute;
  left: 11px; right: 11px; bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
}

/* Secondary: available, not advertised. */
.navapp {
  flex: none;
  font-size: 14.5px;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: 8px;
  white-space: nowrap;
}
.navapp:hover { color: var(--primary); background: var(--soft); }

/* Primary: the robot does the work. */
.navget {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, var(--primary), var(--deep));
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
  padding: 9px 15px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.28);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.navget:hover {
  color: #fff;
  box-shadow: 0 5px 18px rgba(79, 70, 229, 0.38);
  transform: translateY(-1px);
}
.navget svg { flex: none; }

@media (max-width: 720px) {
  .hd .wrap {
    flex-wrap: wrap;
    padding-top: 9px;
    padding-bottom: 7px;
    gap: 8px 12px;
  }
  .brand span { font-size: 15.5px; }
  .navapp { display: none; }        /* /app is one tap from the landing CTA */
  .navget { margin-left: auto; padding: 8px 13px; font-size: 14px; }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 6px 10px; font-size: 14px; }
}

/* ── type ───────────────────────────────────────────────────────────── */
main { padding: 26px 20px 60px; }

h1 {
  font-size: clamp(27px, 4.4vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.022em;
  color: var(--ink);
  margin: 8px 0 12px;
}
section + section > h2:first-child,
section:first-child > h2:first-child { border-top: 0; padding-top: 0; }
h2 {
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 38px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
h3 {
  font-size: 17px;
  color: var(--ink);
  margin: 24px 0 8px;
}
p { margin: 0 0 14px; }
a { color: var(--primary); }
.lede {
  font-size: 18.5px;
  line-height: 1.6;
  color: var(--body);
  margin-bottom: 22px;
}
.muted { color: var(--muted); font-size: 14px; }

ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 6px; }

blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--primary);
  background: var(--soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
blockquote p:last-child { margin-bottom: 0; }

code {
  font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 4px;
}
pre {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

/* Wide tables scroll inside their own box — the page body never does. */
.tw { overflow-x: auto; margin: 0 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td {
  border: 1px solid var(--line);
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--soft); font-weight: 600; color: var(--ink); }

/* ── furniture ──────────────────────────────────────────────────────────
 * Every selector below matches markup that tool/seo.py actually emits. It is
 * checked by the class-coverage assertion in that script, because a CSS file
 * written against guessed class names renders as unstyled boxes and nobody
 * notices until it is live.
 */
.crumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }

.meta {
  font-size: 13.5px;
  color: var(--muted);
  margin: -4px 0 16px;
}

/* the FREE badge on a chapter card */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: #dcfce7;
  color: #14532d;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

/* On a chapter page the same badge says which side of the paywall it is on. */
.tag.free { background: #dcfce7; color: #14532d; }
.tag.paid { background: #ede9fe; color: #4c1d95; }

/* ── counters ───────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 0 26px;
}
.stats > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: var(--soft);
}
.stats > div b {
  display: block;             /* the number and its label were running together */
  font-size: 25px;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stats > div span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.stats.sm > div { padding: 10px 13px; }
.stats.sm > div b { font-size: 20px; }

/* ── cards ──────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 13px;
  margin: 18px 0 26px;
}
.list { display: grid; gap: 9px; margin: 18px 0 26px; }

.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.card:hover { border-color: var(--primary); background: var(--soft); }
.card h3 { margin: 0 0 4px; font-size: 15.5px; color: var(--ink); }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* a full-width row: text left, chevron parked right */
.card.wide {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
}
.card.wide > div { flex: 1; min-width: 0; }
.card.wide .tag { margin: 0 0 5px; }
.chev {
  flex: none;
  font-size: 21px;
  line-height: 1;
  color: var(--muted);
}
.card.wide:hover .chev { color: var(--primary); }

/* ── topic pills ────────────────────────────────────────────────────── */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 26px; }
.pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  text-decoration: none;
  color: var(--body);
  background: #fff;
}
.pill:hover { border-color: var(--primary); color: var(--primary); background: var(--soft); }

/* ── the outline shown in place of a locked chapter's body ──────────── */
.outline {
  list-style: none;
  padding: 0;
  margin: 14px 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.outline li {
  margin: 0;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--body);
}
.outline li:last-child { border-bottom: 0; }
.outline li:nth-child(odd) { background: var(--soft); }

/* ── buttons.  .cta is the WRAPPER; .btn is the button. Styling .cta as a
 *    button painted an empty purple slab under every page. ───────────── */
.cta { margin: 22px 0 8px; display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  padding: 12px 22px;
  border-radius: 10px;
}
.btn:hover { background: var(--deep); }
.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: var(--primary); background: var(--soft); }

.ft {
  border-top: 1px solid var(--line);
  background: var(--soft);
  padding: 24px 0 34px;
  margin-top: 40px;
  font-size: 13px;
  color: var(--muted);
}
.ft p { margin: 0 0 8px; }
.ft a { color: var(--muted); }

@media (max-width: 560px) {
  .nav { gap: 13px; font-size: 13.5px; width: 100%; margin-left: 0; }
  main { padding: 18px 16px 44px; }
  .wrap { padding: 0 16px; }
  .cta { flex-direction: column; align-items: stretch; }
  .btn { text-align: center; }
}
