/* ==========================================================================
   doPhysics · CLAUDE_GENERATED_UI · "Paper & Motion"
   A light, mobile-first reader for the doPhysics book.
   Base rules are for a phone; two breakpoints widen it: 720px and 1100px.
   ========================================================================== */

:root {
  /* paper & ink */
  --paper: #FAF8F3;
  --paper-2: #F2EFE7;
  --card: #FFFFFF;
  --ink: #15171C;
  --ink-2: #4A5060;
  --ink-3: #8B91A1;
  --line: rgba(21, 23, 28, 0.10);
  --line-2: rgba(21, 23, 28, 0.18);

  /* the physics palette the figures already use */
  --vel: #2563EB;     /* velocity   */
  --acc: #059669;     /* acceleration */
  --dis: #7C3AED;     /* displacement */
  --frc: #EA580C;     /* force */
  --brand: #D0021B;   /* doPhysics red, for the mark only */

  /* chapter accent = kinematics blue */
  --accent: var(--vel);
  --accent-2: var(--dis);
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-soft-2: rgba(37, 99, 235, 0.16);
  --good: #059669; --good-soft: rgba(5, 150, 105, 0.10);
  --warn: #B45309; --warn-soft: rgba(180, 83, 9, 0.10);

  /* type */
  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs: 17px;
  --lh: 1.65;

  /* shape */
  --r-sm: 10px; --r: 16px; --r-lg: 24px; --r-xl: 32px;
  --sh-1: 0 1px 2px rgba(21,23,28,.05), 0 4px 16px -8px rgba(21,23,28,.12);
  --sh-2: 0 2px 6px rgba(21,23,28,.06), 0 18px 40px -20px rgba(21,23,28,.22);
  --sh-3: 0 30px 70px -30px rgba(37,99,235,.35);

  --gutter: 16px;
  --bar-h: 56px;
  --dock-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs);
  line-height: var(--lh);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img, svg, object { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

/* the ruled ground: a faint grid, like graph paper under everything */
.ground {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(21,23,28,.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(21,23,28,.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.35) 40%, rgba(0,0,0,.15));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.35) 40%, rgba(0,0,0,.15));
}
.ground::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(60vw 40vh at 85% -5%, rgba(124,58,237,.10), transparent 60%),
    radial-gradient(70vw 50vh at -10% 20%, rgba(37,99,235,.10), transparent 60%);
}

/* ---------- app bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 40;
  height: var(--bar-h);
  display: grid; grid-template-columns: auto auto 1fr auto;   /* contents button, brand, crumb, actions */ align-items: center; gap: 10px;
  padding: 0 var(--gutter);
  background: rgba(250,248,243,.82);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  font-family: var(--f-ui);
}
/* the doPhysics wordmark, as on the site's landing page (01_replica landing.css .brand-logo): "do" in Dancing Script,
   "Physics" in Lora, ".in" in the brand red; the same three spans everywhere so the mark never drifts */
.bar__brand { display: inline-flex; align-items: baseline; letter-spacing: -.02em; line-height: 1; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.bar__brand .logo-script { font-family: 'Dancing Script', cursive; font-weight: 700; font-size: 1.55rem; margin-right: 1px; }
.bar__brand .logo-bold { font-family: 'Lora', Georgia, serif; font-weight: 700; font-size: 1.2rem; }
.bar__brand .logo-tld { font-family: 'Lora', Georgia, serif; font-weight: 700; font-size: 1rem; color: var(--brand); }
.bar__crumb { min-width: 0; text-align: center; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__crumb b { color: var(--ink); font-weight: 600; }
.bar__actions { display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center;
  color: var(--ink-2); transition: background .2s, color .2s, transform .15s;
}
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* the progress ring in the bar */
.ringbtn { position: relative; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; }
.ringbtn svg { position: absolute; inset: 0; width: 40px; height: 40px; transform: rotate(-90deg); }
.ringbtn circle { fill: none; stroke-width: 3; }
.ringbtn .track { stroke: var(--line-2); }
.ringbtn .bar { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ringbtn .pct { font-family: var(--f-ui); font-size: 10.5px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }

/* reading progress line */
.readline { position: fixed; top: var(--bar-h); left: 0; height: 3px; width: 100%; z-index: 39; pointer-events: none; }
.readline i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(var(--p, 0)); background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: transform .12s linear; }

/* ---------- layout ---------- */
.shell { display: block; }
.side { display: none; }
main#view { min-height: calc(100vh - var(--bar-h)); padding-bottom: calc(var(--dock-h) + var(--safe-b) + 24px); }
.wrap { padding: 0 var(--gutter); max-width: 760px; margin: 0 auto; }

/* =========================================================================
   HOME  (chapter cover)
   ========================================================================= */
.hero { position: relative; padding: 28px var(--gutter) 22px; overflow: hidden; }
.hero__eyebrow { font-family: var(--f-ui); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.hero__eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--accent); border-radius: 2px; }
.hero__num { font-family: var(--f-display); font-variation-settings: "opsz" 144; font-weight: 400; font-size: 88px; line-height: .9; letter-spacing: -.04em; color: transparent; -webkit-text-stroke: 1.2px rgba(21,23,28,.35); margin: 14px 0 -8px; }
.hero__num b { font-weight: 700; color: var(--ink); -webkit-text-stroke: 0; }
.hero h1 { font-family: var(--f-display); font-variation-settings: "opsz" 144; font-weight: 600; font-size: clamp(34px, 9vw, 54px); line-height: 1.02; letter-spacing: -.025em; margin: 14px 0 12px; text-wrap: balance; }
.hero h1 em { font-style: italic; font-weight: 400; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 20px; max-width: 46ch; text-wrap: pretty; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  font-family: var(--f-ui); font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--primary { background: var(--ink); color: #fff; box-shadow: 0 10px 24px -10px rgba(21,23,28,.6); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(21,23,28,.6); }
.btn--accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: var(--sh-3); }
.btn--accent:hover { transform: translateY(-1px); }
.btn--ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }
.btn--ghost:hover { border-color: var(--ink); }
.btn:active { transform: scale(.97); }

/* the moving-particle scene behind the hero */
.hero__scene { position: relative; margin: 22px calc(-1 * var(--gutter)) 0; height: 150px; }
.hero__scene svg { width: 100%; height: 100%; display: block; }
.scene-track { stroke: rgba(21,23,28,.18); stroke-width: 1.5; fill: none; stroke-dasharray: 3 6; }
.scene-path { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.scene-disp { stroke: var(--dis); stroke-width: 2; stroke-dasharray: 5 5; fill: none; }
.scene-dot { fill: var(--ink); }
.scene-halo { fill: var(--accent); opacity: .18; }
.scene-lab { font-family: var(--f-ui); font-size: 11px; font-weight: 600; fill: var(--ink-2); letter-spacing: .08em; }
.scene-lab.disp { fill: var(--dis); }
.scene-lab.dist { fill: var(--accent); }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 6px var(--gutter) 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 12px; box-shadow: var(--sh-1); }
.stat__n { font-family: var(--f-display); font-variation-settings: "opsz" 72; font-weight: 600; font-size: 30px; line-height: 1; letter-spacing: -.03em; }
.stat__n small { font-size: 14px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; margin-left: 3px; font-family: var(--f-ui); }
.stat__l { font-family: var(--f-ui); font-size: 12px; color: var(--ink-2); margin-top: 6px; font-weight: 500; }
.stat--accent { background: linear-gradient(135deg, var(--accent-soft), rgba(124,58,237,.08)); border-color: rgba(37,99,235,.18); }

/* lesson cards */
.h2 { font-family: var(--f-display); font-variation-settings: "opsz" 72; font-weight: 600; font-size: 24px; letter-spacing: -.02em; margin: 30px 0 4px; padding: 0 var(--gutter); }
.sub { font-family: var(--f-ui); color: var(--ink-3); font-size: 13.5px; margin: 0 0 14px; padding: 0 var(--gutter); }
.lessons { display: grid; gap: 12px; padding: 0 var(--gutter); }
.lcard {
  position: relative; display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 16px 16px 14px; box-shadow: var(--sh-1); text-align: left; width: 100%;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .25s, border-color .2s;
}
.lcard:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: rgba(37,99,235,.35); }
.lcard.is-done { border-color: rgba(5,150,105,.35); }
.lcard.is-next { border-color: rgba(37,99,235,.45); background: linear-gradient(180deg, #fff, rgba(37,99,235,.04)); }
.lcard__ring { position: relative; width: 52px; height: 52px; display: grid; place-items: center; }
.lcard__ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.lcard__ring circle { fill: none; stroke-width: 3.5; }
.lcard__ring .t { stroke: var(--paper-2); }
.lcard__ring .b { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.lcard.is-done .lcard__ring .b { stroke: var(--good); }
.lcard__ring .n { font-family: var(--f-display); font-weight: 600; font-size: 19px; letter-spacing: -.02em; }
.lcard.is-done .lcard__ring .n { color: var(--good); }
.lcard__t { font-family: var(--f-display); font-variation-settings: "opsz" 48; font-weight: 600; font-size: 18px; letter-spacing: -.015em; line-height: 1.2; }
.lcard__d { font-family: var(--f-ui); font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lcard__meta { font-family: var(--f-ui); font-size: 11.5px; color: var(--ink-3); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.lcard__meta i { font-style: normal; display: inline-flex; align-items: center; gap: 4px; }
.lcard__meta svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.lcard__go { width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); transition: background .2s, color .2s, transform .2s; }
.lcard:hover .lcard__go { background: var(--ink); color: #fff; transform: translateX(2px); }
.lcard__go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* "you will be able to" */
.will { margin: 26px var(--gutter) 0; background: var(--ink); color: #fff; border-radius: var(--r-xl); padding: 22px 20px; box-shadow: 0 30px 60px -30px rgba(21,23,28,.8); position: relative; overflow: hidden; }
.will::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 60%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(37,99,235,.55), transparent 65%); filter: blur(10px); }
.will h3 { font-family: var(--f-display); font-weight: 500; font-size: 22px; letter-spacing: -.02em; margin: 0 0 12px; position: relative; }
.will ol { margin: 0; padding: 0; list-style: none; counter-reset: w; display: grid; gap: 9px; position: relative; }
.will li { counter-increment: w; font-family: var(--f-ui); font-size: 14px; line-height: 1.45; color: rgba(255,255,255,.86); position: relative; padding-left: 36px; }   /* not a grid: inline maths (mjx-container) would become its own grid cell */
.will li::before { content: counter(w, decimal-leading-zero); font-family: var(--f-display); color: rgba(255,255,255,.55); font-size: 13px; position: absolute; left: 0; top: 2px; }

/* =========================================================================
   LESSON
   ========================================================================= */
.lesson { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.lhead { padding: 26px var(--gutter) 10px; }
.lhead__eyebrow { font-family: var(--f-ui); font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.lhead h1 { font-family: var(--f-display); font-variation-settings: "opsz" 144; font-weight: 600; font-size: clamp(30px, 8vw, 44px); line-height: 1.05; letter-spacing: -.025em; margin: 8px 0 10px; text-wrap: balance; }
.lhead p { font-size: 17px; color: var(--ink-2); margin: 0 0 14px; text-wrap: pretty; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--f-ui); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pill--acc { background: var(--accent-soft); border-color: rgba(37,99,235,.2); color: var(--accent); }

/* objectives */
.goals { margin: 14px var(--gutter) 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh-1); }
.goals__t { font-family: var(--f-ui); font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.goals__t span { color: var(--accent); letter-spacing: 0; text-transform: none; font-weight: 600; }
.goal { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-top: 1px dashed var(--line); font-family: var(--f-ui); font-size: 14px; line-height: 1.45; color: var(--ink-2); cursor: pointer; width: 100%; text-align: left; }
.goal:first-of-type { border-top: 0; }
.goal__box { width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: background .25s, border-color .25s; }
.goal__box svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.6); transition: .25s; }
.goal.is-seen .goal__box { background: var(--good); border-color: var(--good); }
.goal.is-seen .goal__box svg { opacity: 1; transform: none; }
.goal.is-seen { color: var(--ink); }

/* the article */
.article { padding: 8px var(--gutter) 0; }
.block { margin: 18px 0; }
.block[data-topic] { scroll-margin-top: 80px; }
.topic-mark { font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; margin: 30px 0 -6px; }
.topic-mark::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(37,99,235,.35), transparent); }

.concept-section h3, .concept-section h4 {
  font-family: var(--f-display); font-variation-settings: "opsz" 72; letter-spacing: -.02em; line-height: 1.15; text-wrap: balance;
}
.concept-section h3 { font-size: 27px; font-weight: 600; margin: 30px 0 10px; }
.concept-section h4 { font-size: 20px; font-weight: 600; margin: 24px 0 8px; }
.concept-section p { margin: 0 0 14px; text-wrap: pretty; }
.concept-section strong { font-weight: 600; color: var(--ink); background: linear-gradient(transparent 62%, rgba(37,99,235,.14) 62%); padding: 0 .05em; }
.concept-section em { font-style: italic; }
.concept-section ul, .concept-section ol { padding-left: 22px; margin: 0 0 14px; }
.concept-section li { margin: 4px 0; }
mjx-container[display="true"] { margin: 10px 0 16px !important; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
mjx-container { font-size: 108% !important; }

/* the worked example */
.problem-box {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent-2);
  border-radius: var(--r); padding: 14px 16px 4px; margin: 16px 0 10px; box-shadow: var(--sh-1);
}
.problem-box h4 { margin: 0 0 8px !important; font-size: 18px !important; display: flex; gap: 8px; align-items: center; }
.problem-box h4::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px rgba(124,58,237,.15); flex: none; }

details { margin: 6px 0 18px; border-radius: var(--r); background: var(--paper-2); border: 1px solid var(--line); overflow: hidden; }
details summary { list-style: none; cursor: pointer; padding: 12px 16px; font-family: var(--f-ui); font-size: 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 10px; user-select: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 22px; height: 22px; border-radius: 999px; background: var(--ink); flex: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'><path d='M12 5v14M5 12h14'/></svg>"); background-size: 14px; background-position: center; background-repeat: no-repeat; transition: transform .25s; }
details[open] summary::before { transform: rotate(45deg); }
details summary strong { font-weight: 600; }
details .solution { padding: 2px 16px 6px; border-top: 1px solid var(--line); background: var(--card); animation: rise .35s both; }
details .solution p:first-child { margin-top: 12px; }

/* =========================================================================
   FIGURE CARD
   ========================================================================= */
.fig {
  --w: 100%;
  margin: 22px auto; width: 100%; max-width: var(--w);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-2); overflow: hidden; position: relative;
}
.fig__plate { position: relative; padding: 12px 10px 8px; background: #fff; }
.fig__plate object { display: block; width: 100%; height: auto; aspect-ratio: var(--ar, 660 / 400); }
.fig.is-loading .fig__plate { background: linear-gradient(90deg, #fff, var(--paper-2), #fff); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* the dock: a glass island under the plate */
.fig__dock {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(250,248,243,.7), rgba(250,248,243,1));
  font-family: var(--f-ui);
}
.fig__dock:not(.has-controls) { display: none; }
.play {
  position: relative; width: 44px; height: 44px; padding: 0; border: 0; box-sizing: border-box; border-radius: 999px; flex: none;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(21,23,28,.25); transition: transform .15s, background .2s;
}
.play:active { transform: scale(.93); }
.play .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; max-width: none; }   /* a 56 px ring around a 44 px disc: concentric, with a clear gap */
.play .ring circle { fill: none; stroke-width: 2.2; }
.play .ring .t { stroke: var(--line-2); }
.play .ring .b { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--u, 0) * 100); }
.play .ic { width: 18px; height: 18px; fill: #fff; display: none; }
.play[data-state="paused"] .ic--play, .play[data-state="ended"] .ic--replay, .play[data-state="playing"] .ic--pause { display: block; }
.play[data-state="playing"] { background: var(--accent); }

.scrub { flex: 1; min-width: 90px; display: flex; align-items: center; }
.scrub input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
.scrub input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) calc(var(--u,0) * 100%), var(--line-2) calc(var(--u,0) * 100%)); }
.scrub input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(21,23,28,.25); }
.scrub input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
.scrub input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.scrub input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font-family: var(--f-ui); font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line-2); color: var(--ink-2); transition: .2s; min-height: 34px; }
.chip mjx-container { font-size: 100% !important; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip--listen::before { content: '\266A'; margin-right: 6px; }   /* a scene's `sound` (units 10, 11) */
.chip--reset { width: 34px; padding: 0; display: grid; place-items: center; }
.chip--reset svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dock__sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 2px; }
.dock__label { font-size: 11px; font-weight: 600; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }

.fig__cap { padding: 10px 14px 12px; font-family: var(--f-ui); font-size: 13.5px; line-height: 1.5; color: var(--ink-2); display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; border-top: 1px solid var(--line); }
.fig__num { font-weight: 700; color: var(--accent); white-space: nowrap; letter-spacing: .02em; }
.fig.is-played .fig__num::after { content: " ✓"; color: var(--good); }

/* =========================================================================
   CHECKPOINT (MCQ)
   ========================================================================= */
.check {
  margin: 26px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 16px 14px; box-shadow: var(--sh-2); position: relative; overflow: hidden;
}
.check::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.check__eyebrow { font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.check__eyebrow svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.check__state { margin-left: auto; color: var(--ink-3); letter-spacing: .04em; }
.check.is-solved .check__state { color: var(--good); }
.check__q { font-family: var(--f-body); font-size: 18px; font-weight: 500; line-height: 1.45; margin: 8px 0 14px; text-wrap: pretty; }
.opts { display: grid; gap: 8px; }
.opt {
  display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: center; text-align: left;
  padding: 11px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper);
  transition: border-color .2s, background .2s, transform .15s;
}
.opt:hover { border-color: var(--ink); background: #fff; }
.opt:active { transform: scale(.985); }
.opt__key { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-family: var(--f-ui); font-weight: 700; font-size: 13px; background: #fff; border: 1px solid var(--line-2); color: var(--ink-2); }
.opt__text { font-size: 16px; line-height: 1.45; }
.opt.is-correct { border-color: var(--good); background: var(--good-soft); }
.opt.is-correct .opt__key { background: var(--good); color: #fff; border-color: var(--good); }
.opt.is-wrong { border-color: var(--warn); background: var(--warn-soft); animation: shake .4s; }
.opt.is-wrong .opt__key { background: var(--warn); color: #fff; border-color: var(--warn); }
.opt[disabled] { cursor: default; opacity: .7; }
.opt.is-correct[disabled], .opt.is-wrong[disabled] { opacity: 1; }
@keyframes shake { 20%,60% { transform: translateX(-3px); } 40%,80% { transform: translateX(3px); } }
.check__fb { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px; line-height: 1.5; font-family: var(--f-ui); animation: rise .3s both; }
.check__fb.is-good { background: var(--good-soft); color: #065F46; }
.check__fb.is-bad { background: var(--warn-soft); color: #7C2D12; }
.check__fb b { font-weight: 700; }
.check__retry { margin-top: 10px; font-family: var(--f-ui); font-size: 13.5px; font-weight: 600; color: var(--accent); }

/* lesson foot */
.lfoot { margin: 34px var(--gutter) 0; display: grid; gap: 10px; }
.lfoot__done { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh-1); }
.lfoot__done b { font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.lfoot__done small { display: block; font-family: var(--f-ui); font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.lfoot__nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.navcard { display: grid; gap: 4px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; transition: .2s; }
.navcard:hover { border-color: var(--ink); transform: translateY(-1px); }
.navcard small { font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.navcard b { font-family: var(--f-display); font-weight: 600; font-size: 15px; line-height: 1.2; letter-spacing: -.01em; }
.navcard--next { text-align: right; background: var(--ink); color: #fff; border-color: var(--ink); }
.navcard--next small { color: rgba(255,255,255,.6); }
.navcard[disabled] { opacity: .4; pointer-events: none; }

/* =========================================================================
   DOCK (mobile bottom bar)
   ========================================================================= */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--dock-h) + var(--safe-b)); padding: 8px var(--gutter) var(--safe-b);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  background: rgba(250,248,243,.86); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-top: 1px solid var(--line); font-family: var(--f-ui);
}
.dock__btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding: 10px 6px; border-radius: 10px; min-width: 0; }
.dock__btn:hover { color: var(--ink); }
.dock__btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dock__btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock__btn--next { justify-content: flex-end; }
.dock__btn[disabled] { opacity: .35; pointer-events: none; }
.dock__contents { width: 48px; height: 48px; border-radius: 999px; background: var(--ink); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 22px -10px rgba(21,23,28,.7); }
.dock__contents svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* =========================================================================
   DRAWER (contents) & SHEET (progress)
   ========================================================================= */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(21,23,28,.35); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 84vh;
  background: var(--paper); border-radius: 28px 28px 0 0; box-shadow: 0 -20px 60px -20px rgba(21,23,28,.4);
  transform: translateY(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; font-family: var(--f-ui);
}
.drawer.is-open { transform: none; }
.drawer__grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 10px auto 4px; flex: none; }
.drawer__head { padding: 8px var(--gutter) 10px; display: flex; align-items: center; justify-content: space-between; }
.drawer__head b { font-family: var(--f-display); font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.drawer__body { overflow: auto; padding: 0 var(--gutter) calc(20px + var(--safe-b)); }
.toc { display: grid; gap: 6px; }
.toc__home { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 14px; color: var(--ink-2); width: 100%; text-align: left; }
.toc__home:hover, .toc__home.is-active { background: var(--accent-soft); color: var(--accent); }
.toc__home svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.toc__item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 14px; text-align: left; transition: background .2s; border: 1px solid transparent; width: 100%; }
.toc__item:hover { background: var(--card); }
.toc__item.is-active { background: var(--card); box-shadow: var(--sh-1); border-color: rgba(37,99,235,.25); }
.toc__ring { position: relative; width: 34px; height: 34px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.toc__ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.toc__ring circle { fill: none; stroke-width: 3; }
.toc__ring .t { stroke: var(--paper-2); }
.toc__ring .b { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset .6s; }
.toc__item.is-done .toc__ring .b { stroke: var(--good); }
.toc__item.is-done .toc__ring { color: var(--good); }
.toc__t { font-size: 14px; font-weight: 600; line-height: 1.25; }
.toc__s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.toc__p { font-size: 11.5px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* progress sheet */
.sheet__hero { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; padding: 6px 0 14px; }
.bigring { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.bigring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.bigring circle { fill: none; stroke-width: 7; }
.bigring .t { stroke: var(--paper-2); }
.bigring .b { stroke: url(#gradRing); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.bigring b { font-family: var(--f-display); font-size: 26px; font-weight: 600; letter-spacing: -.03em; }
.bigring b small { font-size: 13px; color: var(--ink-3); font-weight: 400; }
.sheet__hero h4 { font-family: var(--f-display); font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.02em; }
.sheet__hero p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.kpi b { display: block; font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.kpi small { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.kpi--good b { color: var(--good); }
/* the link at the top of the progress drawer to the full progress page (progress.html) */
.prog__open { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; padding: 12px 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line-2); color: var(--ink); text-decoration: none; font-family: var(--f-ui); font-weight: 600; font-size: 14px; }
.prog__open small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.prog__open:hover { border-color: var(--ink-3); }
.bars { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 24px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.barrow small { color: var(--ink-3); font-weight: 700; }
.barrow .track { height: 8px; border-radius: 4px; background: var(--paper-2); overflow: hidden; }
.barrow .fill { height: 100%; width: calc(var(--p, 0) * 1%); border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.barrow.is-done .fill { background: var(--good); }
.barrow em { font-style: normal; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 12px; }
.sheet__foot { margin-top: 16px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.linkbtn { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.linkbtn:hover { color: var(--brand); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--dock-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); z-index: 60; background: var(--ink); color: #fff; font-family: var(--f-ui); font-size: 14px; font-weight: 500; padding: 10px 16px; border-radius: 999px; box-shadow: 0 14px 30px -10px rgba(21,23,28,.7); opacity: 0; pointer-events: none; transition: .3s cubic-bezier(.2,.8,.2,1); display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }

/* confetti burst for a correct first try */
.burst { position: absolute; width: 6px; height: 6px; border-radius: 2px; pointer-events: none; animation: burst .8s cubic-bezier(.2,.8,.2,1) forwards; z-index: 2; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; } }

/* reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s cubic-bezier(.2,.8,.2,1), transform .55s cubic-bezier(.2,.8,.2,1); }
.reveal.is-in { opacity: 1; transform: none; }

/* =========================================================================
   TABLET  ≥ 720px
   ========================================================================= */
@media (min-width: 720px) {
  :root { --gutter: 28px; --fs: 18px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .hero { padding-top: 44px; }
  .hero__scene { height: 190px; }
  .lessons { grid-template-columns: 1fr 1fr; }
  .fig { --w: min(100%, var(--fw, 100%)); }
  .drawer { left: auto; right: 0; top: 0; bottom: 0; max-height: none; width: 380px; border-radius: 0; transform: translateX(105%); }
  .drawer.is-open { transform: none; }
  .drawer__grip { display: none; }
  .drawer__head { padding-top: 22px; }
  .hero, .stats, .lessons, .will, .lhead, .goals, .article, .lfoot, .h2, .sub { max-width: 820px; margin-left: auto; margin-right: auto; }
  .toast { bottom: calc(var(--dock-h) + 20px); }
}

/* =========================================================================
   DESKTOP  ≥ 1100px : a persistent contents sidebar, no bottom dock
   ========================================================================= */
@media (min-width: 1100px) {
  :root { --gutter: 40px; }
  .shell { display: grid; grid-template-columns: 300px 1fr; }
  .side { display: block; position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); overflow: auto; padding: 22px 18px 30px; border-right: 1px solid var(--line); font-family: var(--f-ui); background: rgba(250,248,243,.6); }
  .side .toc { gap: 4px; }
  .side__title { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); padding: 0 12px 10px; }
  .side__prog { margin: 14px 0 18px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--sh-1); display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; cursor: pointer; }
  .side__prog b { font-size: 14px; display: block; line-height: 1.3; }
  .side__prog small { color: var(--ink-3); font-size: 12px; display: block; line-height: 1.35; margin-top: 3px; }
  .dock { display: none; }
  main#view { padding-bottom: 60px; }
  .hero { padding-top: 56px; }
  .hero__num { font-size: 120px; }
  .hero__scene { height: 220px; }
  .lfoot__nav .navcard { padding: 16px 18px; }
  .bar__crumb { text-align: left; font-size: 13.5px; }
  .toast { bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Contents: the navigation drawer (left panel on wide screens, bottom sheet on a phone) ---------- */
.bar__nav { margin-right: 4px; }
.nav__unit { display: flex; align-items: baseline; gap: 10px; margin: 18px 4px 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.nav__unit .nav__unitn { color: var(--accent); }
.nav__unit.is-soon { opacity: .55; }
.nav__unit small { margin-left: auto; font-size: 10.5px; letter-spacing: .06em; border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 8px; }
.nav__ch summary { list-style: none; cursor: pointer; }
.nav__ch summary::-webkit-details-marker { display: none; }
.nav__chev { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.nav__ch[open] > summary .nav__chev { transform: rotate(90deg); }
.nav__lessons { display: grid; gap: 4px; padding: 4px 0 6px 12px; border-left: 2px solid var(--line-2); margin: 2px 0 6px 26px; }
.nav__lesson .toc__ring { width: 30px; height: 30px; font-size: 11px; }
.nav__lesson { grid-template-columns: 30px 1fr; padding: 7px 10px; }
.nav__link { display: inline-block; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 6px 10px; border-radius: 10px; }
.nav__link:hover, .nav__link.is-active { background: var(--accent-soft); color: var(--accent); }
.nav__extras { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 2px; }
.nav__continue { display: grid; gap: 2px; padding: 12px 14px; margin: 4px 0 10px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.nav__continue small { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.nav__continue b { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.navpin { display: none; }
@media (min-width: 720px) {
  .drawer--nav { left: 0; right: auto; top: var(--bar-h); bottom: 0; width: min(360px, 92vw); max-height: none; border-radius: 0 20px 20px 0; transform: translateX(-105%); box-shadow: 20px 0 60px -30px rgba(21,23,28,.45); }
  .drawer--nav .drawer__grip { display: none; }
  .drawer--nav .drawer__head { padding-top: 16px; }
}
@media (min-width: 1500px) {
  .navpin { display: inline-flex; }
  body.has-nav .drawer--nav { transform: none; box-shadow: none; border-right: 1px solid var(--line-2); border-radius: 0; z-index: 30; }
  body.has-nav main#view { margin-left: 360px; }
  body.has-nav .readline { left: 360px; width: calc(100% - 360px); }
}
/* the nav's <details> is a tree row, not a solution box: undo the global details styling */
.nav__ch { margin: 0; border: 0; border-radius: 0; background: none; overflow: visible; }
.nav__ch > summary { display: grid; padding: 9px 10px; font-size: inherit; font-weight: inherit; }
.nav__ch > summary::before { content: none; display: none; }
.toc__item > span:not(.toc__ring) { display: grid; min-width: 0; }
.toc__t, .toc__s { display: block; }
/* planned chapters: listed in the syllabus and the Contents, not yet written */
.nav__planned { opacity: .55; cursor: default; }
.nav__planned .toc__ring { font-size: 12px; color: var(--ink-3); }
.sy__ch--planned { opacity: .55; cursor: default; }
/* the author's id badges (Alt+I) */
.idbadge { position: absolute; top: 4px; right: 4px; z-index: 6; font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #15171c; color: #fff; padding: 3px 7px; border-radius: 6px; opacity: .88; cursor: copy; border: 0; max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.idbadge:hover { opacity: 1; background: var(--accent); }
.idbadge--page { position: fixed; top: calc(var(--bar-h) + 8px); left: 12px; right: auto; z-index: 60; font-size: 12px; padding: 5px 9px; }
body.show-ids [data-block] { outline: 1px dashed rgba(37,99,235,.35); outline-offset: 2px; }
