/* ============================================================
   IGCSE Economics — Theme tokens & shared UI primitives
   Used by every lesson. Change a token here, every deck updates.
   ============================================================ */

:root {
  /* Palette */
  --bg-0:        #07111f;
  --bg-1:        #0c1b2d;
  --bg-2:        #10233a;
  --ink:         #f5f8ff;
  --ink-dim:     #dbe7f6;
  --muted:       #9db0cc;

  --gold:        #ffd166;
  --gold-warm:   #ff9f43;
  --cyan:        #56d8ff;
  --green:       #7ef0b5;
  --rose:        #ff6b8a;
  --violet:      #b79cff;

  --line:        rgba(255, 255, 255, .12);
  --line-strong: rgba(255, 255, 255, .22);
  --card-bg:     linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.03));
  --card-bg-hi:  linear-gradient(145deg, rgba(255,255,255,.11), rgba(255,255,255,.045));

  /* Typography scale — fluid via clamp() */
  --t-hero:   clamp(52px, 5.9vw, 116px);
  --t-h1:     clamp(46px, 5.1vw,  100px);
  --t-h2:     clamp(36px, 3.9vw,  76px);
  --t-h3:     clamp(26px, 2.3vw,  44px);
  --t-lead:   clamp(22px, 2.15vw, 38px);
  --t-body:   clamp(19px, 1.55vw, 30px);
  --t-small:  clamp(15px, 1.12vw, 21px);

  /* Shadows & radii */
  --shadow-sm: 0 8px 24px rgba(0,0,0,.25);
  --shadow-md: 0 18px 50px rgba(0,0,0,.35);
  --shadow-lg: 0 30px 90px rgba(0,0,0,.45);
  --r-sm: 14px;
  --r-md: 22px;
  --r-lg: 30px;
  --r-xl: 40px;

  /* Motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "SF Pro Display", ui-sans-serif, system-ui, -apple-system,
               BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01", "cv02", "cv11";
  color: var(--ink);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Ambient background ---------- */
.bg-ambient::before {
  content: "";
  position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background:
    radial-gradient(circle at 16% 16%, rgba(86,216,255,.14), transparent 32%),
    radial-gradient(circle at 86% 18%, rgba(255,209,102,.10), transparent 30%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1) 48%, var(--bg-0));
}
.bg-ambient::after {
  display: none;
}

/* ---------- Typography primitives ---------- */
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; line-height: 1.12; }
h1 { font-size: var(--t-h1); letter-spacing: -0.035em; line-height: 1.08; }
h2 { font-size: var(--t-h2); letter-spacing: -0.03em; line-height: 1.12; }
h3 { font-size: var(--t-h3); line-height: 1.16; }

p, .text { margin: 0; font-size: var(--t-body); line-height: 1.4; color: var(--ink-dim); }
.lead { font-size: var(--t-lead); line-height: 1.28; color: var(--ink); max-width: 34ch; }
.sub  { font-size: clamp(20px,2.4vw,46px); font-weight: 800; color: var(--cyan); margin: 0 0 .35em; line-height: 1.18; }
.kicker { font-size: clamp(17px,1.7vw,32px); font-weight: 700; color: var(--gold); margin-top: 1.05em; line-height: 1.25; }
.small { font-size: var(--t-small); color: var(--muted); }

:lang(zh),
.zh,
.factZh {
  line-height: 1.38;
  letter-spacing: 0;
}

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .55em 1em; border-radius: 999px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: var(--t-small);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: .6em; height: .6em;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: none;
}
.badge.is-warm::before { background: var(--gold); box-shadow: none; }
.badge.is-green::before { background: var(--green); box-shadow: none; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .35s var(--ease), border-color .35s var(--ease);
}
.card::after { display: none; }
.card b {
  display: block;
  font-size: clamp(23px, 2vw, 36px);
  line-height: 1.08; margin-bottom: .35em;
  color: #fff;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.card span { font-size: clamp(18px, 1.32vw, 25px); line-height: 1.35; color: #ccdaee; }
.card .num {
  font-size: clamp(32px, 3.6vw, 64px);
  font-weight: 900; color: var(--gold);
  line-height: .9; letter-spacing: -0.05em;
  margin-bottom: .15em;
}

/* ---------- Highlight boxes ---------- */
.termBox {
  border-left: 6px solid var(--cyan);
  padding: 1.15rem 1.4rem;
  background: rgba(86, 216, 255, .08);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin: .9rem 0;
  box-shadow: var(--shadow-sm);
}
.termBox b {
  display: block;
  font-size: clamp(22px, 2.2vw, 42px);
  color: #fff; margin-bottom: .35rem;
  letter-spacing: -0.015em;
}
.termBox p { color: var(--ink-dim); }

.formula {
  margin-top: .9rem;
  font-size: clamp(20px, 2vw, 38px);
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.01em;
}

.answerBox {
  padding: 1.2rem 1.4rem;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(126,240,181,.18), rgba(86,216,255,.10));
  border: 1px solid rgba(126,240,181,.32);
  box-shadow: var(--shadow-md);
}
.answerBox .big {
  font-size: clamp(30px, 3.2vw, 64px);
  font-weight: 900; color: var(--green);
  letter-spacing: -0.04em; margin-bottom: .3em; line-height: 1.02;
}
.answerBox p {
  font-size: clamp(23px, 1.9vw, 36px);
  line-height: 1.28;
}

.prompt {
  display: inline-block;
  margin-top: 1em;
  padding: .9em 1.1em;
  background: linear-gradient(135deg, rgba(255,209,102,.15), rgba(86,216,255,.08));
  border: 1px solid rgba(255,209,102,.3);
  border-radius: var(--r-md);
  color: #fff; font-weight: 650;
  font-size: clamp(18px, 1.45vw, 28px);
  line-height: 1.3;
}

/* ---------- Lists ---------- */
ul.clean {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: .7rem;
}
ul.clean li {
  position: relative;
  padding-left: 1.6em;
  font-size: clamp(19px, 1.42vw, 28px);
  line-height: 1.3;
  color: var(--ink-dim);
}
ul.clean li::before {
  content: "";
  position: absolute; left: 0; top: .42em;
  width: .72em; height: .72em;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: none;
}

/* ---------- Choice pills ---------- */
.choices { display: grid; gap: .75rem; margin-top: 1.1rem; }
.choice {
  padding: .9rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.05);
  font-size: clamp(20px, 1.52vw, 30px);
  font-weight: 500;
  color: #fff;
  line-height: 1.25;
  transition: background .3s var(--ease), border-color .3s var(--ease);
}
.choices.is-mcq .choice {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: .85rem;
}
.choiceLetter {
  display: inline-grid;
  place-items: center;
  min-width: 2.1em;
  height: 2.1em;
  border-radius: 999px;
  background: rgba(86,216,255,.18);
  border: 1px solid rgba(86,216,255,.5);
  color: var(--cyan);
  font-size: .72em;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}
.choice:hover { background: rgba(255,255,255,.09); border-color: var(--line-strong); }

/* ---------- Step rows ---------- */
.steps { display: grid; gap: .8rem; margin-top: 1rem; }
.step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem; align-items: start;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: .9rem 1.05rem;
}
.step .label {
  min-width: 2.4em;
  text-align: center;
  font-weight: 900; color: #09111f;
  background: var(--gold);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: clamp(17px, 1.2vw, 25px);
  line-height: 1.1;
  white-space: nowrap;
}
.step .desc { font-size: clamp(19px, 1.48vw, 29px); line-height: 1.3; color: #edf4ff; }

/* ---------- Split columns ---------- */
.splitCols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 900px) { .splitCols { grid-template-columns: 1fr; } }

/* ---------- Card grid ---------- */
.cardgrid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ---------- Flow chips ---------- */
.flowRow {
  display: flex; flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.1rem;
}
.flowChip {
  position: relative;
  flex: 1 1 170px;
  min-width: 160px; max-width: 260px;
  padding: 1rem .95rem;
  text-align: center;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  font-size: clamp(18px, 1.32vw, 26px);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.flowChip:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -1rem; top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 1.7rem;
  z-index: 3;
}
@media (max-width: 700px) {
  .flowChip:not(:last-child)::after { display: none; }
}

/* ---------- Section title (large display) ---------- */
.sectionTitle {
  white-space: pre-line;
  font-size: clamp(56px, 8vw, 148px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  background: linear-gradient(135deg, #ffffff 0%, var(--cyan) 45%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  margin-bottom: .12em;
}

/* ---------- Utilities ---------- */
.stack > * + * { margin-top: var(--stack-gap, 1rem); }
.row { display: flex; gap: 1rem; align-items: center; }
.wrap { flex-wrap: wrap; }
.center { display: grid; place-items: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
