/* Lesson infographics.
 *
 * All of these are HTML and CSS rather than SVG, for the reason documented in
 * CLAUDE.md: text inside an SVG viewBox is scaled by the viewBox-to-viewport
 * ratio, so a font-size you set is not the font-size you get, and it silently
 * gets worse on narrow screens. Bars sized with percentage widths and labels
 * that are ordinary text have no such indirection — 13px is 13px, and the whole
 * thing reflows on a phone for free.
 */

.dg {
  margin: 1.8rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.1rem 1.2rem 1.2rem;
}
.dg-title {
  font-family: "IBM Plex Mono", monospace; font-size: 0.66rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 0.9rem;
}
.dg-note {
  font-size: 0.8rem; color: var(--ink-faint); margin: 0.9rem 0 0;
  line-height: 1.5;
}

/* ---------- flow: boxes joined by arrows ---------- */
.dg-flow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.dg-step {
  flex: 1 1 120px; min-width: 110px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 0.6rem 0.7rem; background: var(--bg);
}
.dg-step-label {
  font-family: "IBM Plex Mono", monospace; font-size: 0.6rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint);
  margin-bottom: 0.2rem;
}
.dg-step-val { font-size: 0.92rem; line-height: 1.35; }
.dg-arrow {
  flex: 0 0 auto; align-self: center; padding: 0 0.45rem;
  color: var(--gold); font-size: 1.1rem; line-height: 1;
}
.dg-step.accent { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 8%, var(--bg)); }
.dg-step.warn { border-color: var(--warn); }
.dg-step.good { border-color: var(--good); }

/* ---------- waterfall: what's left after each claim ---------- */
.dg-fall { display: flex; flex-direction: column; gap: 0.35rem; }
.dg-fall-row { display: grid; grid-template-columns: 8.5rem 1fr 4rem; gap: 0.7rem;
  align-items: center; }
.dg-fall-name { font-size: 0.84rem; color: var(--ink-soft); }
.dg-fall-track { background: var(--surface-2); border-radius: 3px; height: 22px;
  position: relative; overflow: hidden; }
.dg-fall-bar { height: 100%; border-radius: 3px; }
.dg-fall-bar.cost { background: color-mix(in srgb, var(--ink-faint) 45%, transparent); }
.dg-fall-bar.claim { background: color-mix(in srgb, var(--navy) 50%, transparent); }
.dg-fall-bar.you { background: var(--gold); }
.dg-fall-val { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  text-align: right; font-variant-numeric: tabular-nums; }
.dg-fall-row.highlight .dg-fall-name { color: var(--ink); font-weight: 600; }

/* ---------- ladder: comparison bars, signed ---------- */
.dg-ladder { display: flex; flex-direction: column; gap: 0.45rem; }
.dg-lrow { display: grid; grid-template-columns: 7rem 1fr 4.5rem; gap: 0.7rem;
  align-items: center; }
.dg-lname { font-size: 0.84rem; color: var(--ink-soft); }
.dg-ltrack { position: relative; height: 20px; background: var(--surface-2);
  border-radius: 3px; }
.dg-lmid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px;
  background: var(--line-strong); }
.dg-lbar { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.dg-lbar.neg { background: var(--warn); right: 50%; }
.dg-lbar.pos { background: var(--good); left: 50%; }
.dg-lval { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- seesaw: two things that must move oppositely ---------- */
.dg-seesaw { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem;
  align-items: center; }
.dg-see-side { text-align: center; padding: 0.9rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); }
.dg-see-side .up { font-size: 1.5rem; color: var(--good); line-height: 1; }
.dg-see-side .down { font-size: 1.5rem; color: var(--warn); line-height: 1; }
.dg-see-name { font-size: 0.88rem; margin-top: 0.4rem; }
.dg-see-sub { font-size: 0.74rem; color: var(--ink-faint); margin-top: 0.15rem; }
.dg-see-pivot { font-family: "IBM Plex Mono", monospace; font-size: 0.7rem;
  color: var(--ink-faint); text-align: center; letter-spacing: 0.08em; }

/* ---------- cycle: a loop that returns to its start ---------- */
.dg-cycle { display: flex; flex-direction: column; gap: 0; }
.dg-cyc-step { display: grid; grid-template-columns: 1.7rem 1fr; gap: 0.8rem;
  align-items: start; padding: 0.55rem 0; }
.dg-cyc-n {
  font-family: "IBM Plex Mono", monospace; font-size: 0.7rem;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  border: 1px solid var(--gold); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
}
.dg-cyc-body { font-size: 0.88rem; line-height: 1.5; }
.dg-cyc-body b { display: block; margin-bottom: 0.1rem; }
.dg-cyc-link { grid-column: 2; font-size: 0.72rem; color: var(--ink-faint);
  font-style: italic; }
.dg-cyc-close {
  margin-top: 0.6rem; padding-top: 0.7rem; border-top: 1px dashed var(--gold);
  font-size: 0.82rem; color: var(--gold); display: flex; gap: 0.5rem;
}

/* ---------- timeline ---------- */
.dg-time { display: flex; flex-direction: column; gap: 0; }
.dg-trow { display: grid; grid-template-columns: 4.5rem 1.5rem 1fr; gap: 0.6rem; }
.dg-tyear { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  color: var(--gold); padding-top: 0.15rem; }
.dg-trail { position: relative; display: flex; justify-content: center; }
.dg-trail::before { content: ""; position: absolute; top: 0; bottom: 0;
  width: 1px; background: var(--line-strong); }
.dg-tdot { position: relative; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 1.5px solid var(--gold); margin-top: 0.35rem; }
.dg-trow.end .dg-tdot { background: var(--gold); }
.dg-tbody { font-size: 0.88rem; line-height: 1.5; padding-bottom: 1rem; }
.dg-tbody b { display: block; }
.dg-tbody span { color: var(--ink-soft); }

/* ---------- T-account ---------- */
.dg-t { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong);
  border-radius: 6px; overflow: hidden; }
.dg-t-head { font-family: "IBM Plex Mono", monospace; font-size: 0.64rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint);
  padding: 0.5rem 0.8rem; background: var(--surface-2); }
.dg-t-col { border-right: 1px solid var(--line-strong); }
.dg-t-col:last-child { border-right: 0; }
.dg-t-item { padding: 0.7rem 0.8rem; border-top: 1px solid var(--line);
  font-size: 0.88rem; }
.dg-t-item b { font-family: "IBM Plex Mono", monospace; font-size: 0.92rem; }
.dg-t-item.new { background: color-mix(in srgb, var(--gold) 10%, transparent); }
.dg-t-sub { font-size: 0.75rem; color: var(--ink-faint); margin-top: 0.15rem; }

/* ---------- stack: layers built on a base ---------- */
.dg-stack { display: flex; flex-direction: column-reverse; gap: 0.3rem; }
.dg-layer { display: grid; grid-template-columns: 1fr auto; gap: 0.8rem;
  align-items: center; padding: 0.55rem 0.8rem; border-radius: 5px;
  border: 1px solid var(--line-strong); background: var(--bg); }
.dg-layer-name { font-size: 0.88rem; }
.dg-layer-who { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem;
  letter-spacing: 0.06em; color: var(--ink-faint); text-align: right; }
.dg-layer.base { border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, var(--bg)); }
.dg-layer.base .dg-layer-who { color: var(--gold); }

/* ---------- two-column transfer (winners / losers) ---------- */
.dg-transfer { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.dg-tcol { padding: 0.8rem 1rem; }
.dg-tcol:first-child { border-right: 1px solid var(--line-strong); }
.dg-tcol h5 { margin: 0 0 0.6rem; font-family: "IBM Plex Mono", monospace;
  font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 500; }
.dg-tcol.win h5 { color: var(--good); }
.dg-tcol.lose h5 { color: var(--warn); }
.dg-tcol ul { margin: 0; padding-left: 1rem; }
.dg-tcol li { font-size: 0.85rem; margin-bottom: 0.35rem; }

@media (max-width: 560px) {
  .dg-fall-row { grid-template-columns: 6rem 1fr 3.4rem; }
  .dg-lrow { grid-template-columns: 5rem 1fr 3.6rem; }
  .dg-seesaw { grid-template-columns: 1fr; }
  .dg-transfer { grid-template-columns: 1fr; }
  .dg-tcol:first-child { border-right: 0; border-bottom: 1px solid var(--line-strong); }
}

/* ---------- "see more": a sub-idea that stays out of the way ---------- */
/* Native <details> rather than a JS accordion — it is keyboard accessible,
   findable by the browser's own in-page search, and works before any script
   runs. */
.seemore {
  border: 1px solid var(--line); border-left: 2px solid var(--gold);
  border-radius: 0 6px 6px 0; margin: 1.4rem 0; background: var(--surface);
}
.seemore > summary {
  cursor: pointer; list-style: none; padding: 0.7rem 1rem;
  display: flex; align-items: baseline; gap: 0.6rem;
  font-size: 0.92rem;
}
.seemore > summary::-webkit-details-marker { display: none; }
.seemore > summary::after {
  content: "see more"; margin-left: auto; flex: 0 0 auto;
  font-family: "IBM Plex Mono", monospace; font-size: 0.62rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 999px; padding: 0.1rem 0.5rem;
}
.seemore[open] > summary::after { content: "close"; }
.seemore > summary:hover { background: var(--surface-2); }
.seemore > summary b { color: var(--ink); }
.seemore-body { padding: 0 1rem 0.9rem; font-size: 0.94rem; }
.seemore-body > *:first-child { margin-top: 0; }
.seemore-body p { margin: 0 0 0.85rem; }
.sm-tag {
  font-family: "IBM Plex Mono", monospace; font-size: 0.58rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint);
  border: 1px solid var(--line-strong); border-radius: 3px;
  padding: 0.05rem 0.35rem; flex: 0 0 auto;
}

/* ---------- inline live-data panel ---------- */
.dg-live { margin: 1.6rem 0; }
.dgl-chart { margin-bottom: 0.7rem; }
.dgl-chart svg { display: block; }
.dgl-legend {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--ink-soft); margin-bottom: 0.8rem;
}
.dgl-key { width: 14px; height: 2px; display: inline-block; }
.dgl-key.gold { background: var(--gold); }
.dgl-key.navy { background: var(--navy); margin-left: 0.9rem; }
.dgl-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 5px; overflow: hidden; margin-bottom: 0.8rem;
}
.dgl-stat { background: var(--bg); padding: 0.55rem 0.7rem; }
.dgl-label {
  font-family: "IBM Plex Mono", monospace; font-size: 0.58rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint);
}
.dgl-val { font-family: "IBM Plex Mono", monospace; font-size: 0.95rem;
  margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.dgl-val .nodata { font-size: 0.75rem; font-style: italic; color: var(--ink-faint);
  font-family: "Public Sans", sans-serif; }
.dgl-basis { font-size: 0.75rem; color: var(--ink-faint); line-height: 1.6; }
.dgl-src { margin-top: 0.35rem; font-style: italic; }
.dg-live-loading, .dg-live-err {
  padding: 1.2rem; border: 1px dashed var(--line-strong); border-radius: 6px;
  font-size: 0.86rem; color: var(--ink-faint); margin: 1.4rem 0;
}
.dg-live-err { color: var(--warn); border-color: var(--warn); }

/* ---------- animation ---------- */
/* Every animated diagram must be legible with motion switched off — the motion
   is emphasis, never the only carrier of the information. */
.anim-step { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .dg-anim.play .anim-step { opacity: 0; animation: aFade 0.5s ease forwards; }
  .dg-anim.play .anim-step.s1 { animation-delay: 0.1s; }
  .dg-anim.play .anim-step.s2 { animation-delay: 0.8s; }
  .dg-anim.play .anim-step.s3 { animation-delay: 1.5s; }
  .dg-anim.play .anim-step.s4 { animation-delay: 2.2s; }
  .dg-anim.play .anim-flow { stroke-dasharray: 6 5; animation: aDash 1.1s linear infinite; }
  .dg-anim.play .anim-pulse { animation: aPulse 2.4s ease-in-out infinite; }
}
@keyframes aFade { from { opacity: 0; transform: translateY(6px); }
                   to { opacity: 1; transform: none; } }
@keyframes aDash { to { stroke-dashoffset: -44; } }
@keyframes aPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.dg-replay {
  font-family: "IBM Plex Mono", monospace; font-size: 0.62rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: none; color: var(--gold); border: 1px solid var(--gold);
  border-radius: 999px; padding: 0.15rem 0.6rem; cursor: pointer;
  margin-left: auto;
}
.dg-head-row { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.9rem; }
.dg-head-row .dg-title { margin-bottom: 0; }

/* the money-creation ripple */
.ripple { display: flex; flex-direction: column; gap: 0.5rem; }
.ripple-row { display: grid; grid-template-columns: 8.5rem 1fr auto; gap: 0.7rem;
  align-items: center; }
.ripple-who { font-size: 0.82rem; color: var(--ink-soft); }
.ripple-bar { height: 20px; border-radius: 3px; background: var(--gold);
  opacity: 0.85; }
.ripple-amt { font-family: "IBM Plex Mono", monospace; font-size: 0.78rem;
  color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- money creation ---------- */
/* Rebuilt from SVG to HTML after testing at 375px: the SVG version had its
   labels inside a 640-unit viewBox, so at a 303px render they scaled to about
   6px on screen. Exactly the failure mode the top of this file warns about —
   and it only showed up on a phone. */
.mint {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.9rem;
  align-items: center;
}
.mint-side {
  border: 1.5px solid var(--gold); border-radius: 6px;
  padding: 0.75rem 0.85rem; background: var(--bg);
}
.mint-kind {
  font-family: "IBM Plex Mono", monospace; font-size: 0.58rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold);
}
.mint-amt {
  font-family: "IBM Plex Mono", monospace; font-size: 1.15rem;
  margin: 0.3rem 0 0.25rem; font-variant-numeric: tabular-nums;
}
.mint-what { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.4; }

.mint-bank { text-align: center; padding: 0 0.3rem; }
.mint-roof {
  width: 0; height: 0; margin: 0 auto;
  border-left: 42px solid transparent; border-right: 42px solid transparent;
  border-bottom: 20px solid var(--gold);
}
.mint-body {
  width: 84px; height: 46px; margin: 0 auto;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-top: 0; display: flex; justify-content: center;
  align-items: flex-end; gap: 7px; padding-bottom: 0;
}
.mint-body span { width: 12px; height: 32px; background: var(--bg); opacity: 0.75; }
.mint-label {
  font-size: 0.76rem; color: var(--ink-soft); margin-top: 0.4rem;
}
.mint-caption {
  text-align: center; font-size: 0.78rem; color: var(--ink-faint);
  margin-top: 0.9rem; font-style: italic;
}
/* the two flows into the bank */
@media (prefers-reduced-motion: no-preference) {
  .dg-anim.play .mint-side { position: relative; }
  .dg-anim.play .mint-side::after {
    content: ""; position: absolute; top: 50%; width: 0.9rem; height: 2px;
    background: var(--gold); opacity: 0.8;
    animation: aPulse 1.6s ease-in-out infinite;
  }
  .dg-anim.play .mint-side:first-child::after { right: -0.9rem; }
  .dg-anim.play .mint-side:last-child::after { left: -0.9rem; }
}
@media (max-width: 620px) {
  .mint { grid-template-columns: 1fr; }
  .mint-bank { order: -1; }
  .dg-anim.play .mint-side::after { display: none; }
}

/* Uppercase mono micro-labels bottom out around 9px on a phone, which is below
   comfortable reading. Raise the floor where the space exists to do it. */
@media (max-width: 620px) {
  .mint-kind, .dg-step-label, .dgl-label, .dg-fall-name, .dg-lname { font-size: 0.7rem; }
  .dg-title { font-size: 0.72rem; }
  .sm-tag { font-size: 0.64rem; }
  .seemore > summary { flex-wrap: wrap; }
  .seemore > summary::after { margin-left: 0; }
}

/* ---------- series chart chrome ---------- */
.sc-wrap { position: relative; }
.sc-svg { display: block; overflow: visible; }
.sc-wrap { cursor: crosshair; }
.sc-annlabel {
  position: absolute; top: -3px; transform: translateX(-50%);
  font-family: "IBM Plex Mono", monospace; font-size: 0.6rem;
  letter-spacing: 0.03em; color: var(--ink-faint);
  background: var(--surface); padding: 0 0.3rem; white-space: nowrap;
  pointer-events: none;
}
.sc-tip {
  position: absolute; top: 8px; z-index: 5; pointer-events: none;
  background: var(--ink); color: var(--bg);
  border-radius: 5px; padding: 0.45rem 0.6rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.sc-tip[hidden] { display: none; }
.sc-tip-d {
  font-family: "IBM Plex Mono", monospace; font-size: 0.66rem;
  opacity: 0.72; margin-bottom: 0.2rem;
}
.sc-tip-v {
  font-family: "IBM Plex Mono", monospace; font-size: 0.74rem;
  display: flex; align-items: center; gap: 0.35rem; white-space: nowrap;
}
.sc-tip-v i { width: 9px; height: 2px; display: inline-block; flex: 0 0 auto; }
.sc-tip-v i.gold { background: var(--gold); }
.sc-tip-v i.navy { background: var(--navy); }
.sc-annlabel { font-size: 0.68rem; }

/* ---------- 0-100 gauges ---------- */
.gg { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.gg-row { display: grid; grid-template-columns: 10rem 1fr 2.6rem; gap: 0.8rem;
  align-items: center; }
.gg-name { font-size: 0.84rem; color: var(--ink-soft); }
.gg-track {
  position: relative; height: 10px; border-radius: 999px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--good) 30%, transparent),
    color-mix(in srgb, var(--gold) 30%, transparent),
    color-mix(in srgb, var(--warn) 34%, transparent));
}
.gg-fill { display: none; }
.gg-pin {
  position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px;
  background: var(--ink); transform: translateX(-50%);
}
.gg-row.overall .gg-track { height: 14px; }
.gg-row.overall .gg-pin { top: -3px; height: 20px; width: 4px; background: var(--gold); }
.gg-row.overall .gg-name { color: var(--ink); font-weight: 600; }
.gg-val { font-family: "IBM Plex Mono", monospace; font-size: 0.86rem;
  text-align: right; font-variant-numeric: tabular-nums; }
.gg-val.nodata { font-size: 0.7rem; font-style: italic; color: var(--ink-faint);
  font-family: "Public Sans", sans-serif; }
.gg-ends {
  display: flex; justify-content: space-between; margin: 0 0 0.9rem;
  padding-left: 10.8rem;
  font-family: "IBM Plex Mono", monospace; font-size: 0.6rem;
  letter-spacing: 0.06em; color: var(--ink-faint);
}
@media (max-width: 620px) {
  .gg-row { grid-template-columns: 7rem 1fr 2.4rem; }
  .gg-ends { padding-left: 0; font-size: 0.62rem; }
}

/* ---------- compounding calculator ---------- */
.cw-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem; margin-bottom: 1.2rem; }
.cw-controls label { display: block; font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); }
.cw-controls input[type=range] { display: block; width: 100%; margin: 0.45rem 0 0.2rem;
  accent-color: var(--gold); }
.cw-controls output { font-family: "IBM Plex Mono", monospace; font-size: 0.9rem;
  color: var(--ink); letter-spacing: 0; text-transform: none; }
.cw-out { border-top: 1px solid var(--line); padding-top: 1rem; }
.cw-big { display: flex; align-items: baseline; gap: 0.7rem; margin-bottom: 0.9rem; }
.cw-big span:first-child { font-family: "IBM Plex Mono", monospace;
  font-size: 2rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.cw-big-label { font-size: 0.8rem; color: var(--ink-faint); }
.cw-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 5px; overflow: hidden; }
.cw-split > div { background: var(--bg); padding: 0.5rem 0.7rem; }
.cw-k { display: block; font-family: "IBM Plex Mono", monospace; font-size: 0.58rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.cw-split span:last-child { font-family: "IBM Plex Mono", monospace; font-size: 0.95rem;
  font-variant-numeric: tabular-nums; }
.cw-bars { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 1rem; }
.cw-row { display: grid; grid-template-columns: 3rem 1fr; gap: 0.6rem; align-items: center; }
.cw-yr { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--ink-faint); }
.cw-stack { display: flex; height: 15px; border-radius: 3px; overflow: hidden;
  background: var(--surface-2); }
.cw-paid { background: color-mix(in srgb, var(--ink-faint) 50%, transparent); }
.cw-grow { background: var(--gold); }
