/* Learn: the course and the lessons. Tokens and shared parts are in base.css. */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Course page ---------- */
.learn-home { padding-top: 24px; padding-bottom: 32px; }

.resume { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 10px 6px 10px 10px; background: var(--btn); color: var(--btn-ink); border-radius: var(--r); text-decoration: none; }
.resume .kick { color: inherit; opacity: .85; display: block; }
.resume strong { display: block; font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.resume .small { color: inherit; opacity: .85; display: block; margin-top: 2px; font-size: 1.125rem; }
.resume-text { flex: 1; min-width: 0; }
.resume-img { width: 76px; height: 96px; flex: none; }
.resume-go { flex: none; width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.5rem; font-weight: 700; }
.all-done { margin-top: 16px; padding: 16px; background: var(--soft); border-radius: var(--r); }

.chap-strip { display: grid; grid-template-columns: repeat(auto-fit, 44px); justify-content: space-between; gap: 8px 4px; margin-top: 20px; }
@media (min-width: 720px) { .chap-strip { justify-content: start; gap: 8px 10px; } }
.chap-dot { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-weight: 700; font-size: 1rem; cursor: pointer; transition: transform 160ms var(--out); }
.chap-dot.done { background: var(--good); border-color: var(--good); color: var(--surface); }
.chap-dot.now { border: 3px solid var(--ink); font-weight: 800; }
.chap-dot:active { transform: scale(.95); }
.course-count { margin-top: 10px; font-size: 1rem; font-weight: 600; }
.saved { margin-top: 4px; font-size: 1.125rem; line-height: 1.4; color: var(--ink2); }

.chaps { margin-top: 20px; border-bottom: 1px solid var(--hair); }
.chap { border-top: 1px solid var(--hair); }
.chap-h { font: inherit; letter-spacing: normal; }
.chap-btn { display: grid; grid-template-columns: auto minmax(0, 1fr) 24px; align-items: center; gap: 14px; width: 100%; min-height: 96px; padding: 12px 0; border: 0; background: none; text-align: left; cursor: pointer; }
.chap-btn:focus-visible { outline-offset: -3px; }
.chap-img { width: 56px; height: 72px; }
.chap-text { display: grid; gap: 4px; min-width: 0; }
.chap-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chap-name { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; min-width: 0; }
.chap-count { font-size: 1rem; color: var(--ink2); }
.chap-bar { display: block; height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.chap-bar i { display: block; height: 100%; background: var(--good); transform-origin: left; transition: transform 200ms var(--out); }
.chev { width: 24px; height: 24px; flex: none; transition: transform 180ms var(--out); }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }

.nb { flex: none; width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.nb.done { background: var(--good); border-color: var(--good); color: var(--surface); }

.les-list { display: grid; padding-bottom: 12px; }
@media (min-width: 720px) { .les-list { grid-template-columns: 1fr 1fr; column-gap: 28px; } }
.les-list > li { border-top: 1px solid var(--hair); min-width: 0; }
.les-row { display: grid; grid-template-columns: 32px 72px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 96px; padding-block: 10px; text-decoration: none; transition: transform 160ms var(--out); }
.les-row:active { transform: scale(.98); }
.les-row:focus-visible { outline-offset: -3px; }
.les-img { width: 72px; height: 96px; }
.les-text { display: grid; gap: 2px; min-width: 0; }
.les-text strong { font-size: 1.125rem; font-weight: 700; line-height: 1.25; }
.les-blurb { font-size: 1.125rem; line-height: 1.35; color: var(--ink2); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.st { font-size: 1rem; font-weight: 700; color: var(--ink2); }
.st-done { color: var(--good); font-weight: 700; }
.st-next { color: var(--accent); }
.st-bad { color: var(--bad); font-weight: 700; }

/* ---------- Lesson: the bar that stays ---------- */
.lesson-bar { position: sticky; top: 65px; z-index: 10; min-height: 56px; margin: -16px -16px 14px; padding: 2px 16px 10px; background: var(--bg); border-bottom: 1px solid var(--hair); }
@supports selector(:has(*)) {
  /* In a lesson the site header scrolls away, so this bar is the one thing at the top. */
  body:has(.lesson) .top { position: static; }
  .lesson-bar { top: 0; }
  html:has(.lesson) { scroll-padding-top: 76px; scroll-padding-bottom: 96px; }
  html:has(.lesson-next) { scroll-padding-bottom: 170px; }
}
.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; min-width: 44px; margin-left: -6px; padding-right: 6px; font-weight: 700; text-decoration: none; }
.chev-back { width: 24px; height: 24px; flex: none; }
.q-count { font-size: 1rem; font-weight: 600; text-align: right; }
.qbar { display: flex; gap: 6px; margin-top: 4px; padding-inline: 2px; }
.qbar span { flex: 1; height: 6px; border-radius: 3px; background: var(--soft); outline: 1px solid var(--line); outline-offset: -1px; overflow: hidden; }
.qbar span.on { outline: 2px solid var(--good); outline-offset: 0; }
.qbar i { display: block; height: 100%; background: var(--good); transform-origin: left; transition: transform 180ms var(--out); }

/* ---------- Lesson: the head ---------- */
.lesson > .kick { margin-bottom: 4px; }
.lesson.going h1 { font-size: 1.5rem; }
.lesson p, .lesson li { max-width: 38rem; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 0 0; border: 1px solid var(--hair); border-radius: var(--r-in); }
.facts > div { padding: 8px 12px; min-width: 0; }
.facts > div + div { border-left: 1px solid var(--hair); }
.facts dt { font-size: .9375rem; font-weight: 700; color: var(--ink2); }
.facts dd { margin: 0; font-size: 1rem; line-height: 1.3; font-weight: 600; }
.lesson-hero { aspect-ratio: 16 / 10; margin-top: 16px; }
.lesson-hero img { object-position: top; }
.start-btn { margin-top: 22px; }
.build-seg { margin-top: 20px; grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.no-list { margin-top: 12px; }
.tip-list li { padding-block: 10px; border-top: 1px solid var(--hair); }
.tip-list li:first-child { border-top: 0; }
.tip-list strong { display: block; }
.code-row { padding-block: 16px; border-top: 1px solid var(--hair); }
.code-row h3 { margin-bottom: 2px; }
.code-row p + p { margin-top: 4px; }
.code-row .link { margin-top: 2px; }

/* ---------- Lesson: the question ---------- */
.lesson h2[tabindex] { scroll-margin-top: 12px; }
.lesson [tabindex="-1"]:focus { outline: none; }
.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; border-radius: var(--r-in); color: inherit; }
button.choice { cursor: pointer; transition: transform 150ms var(--out); }
button.choice:active { transform: scale(.98); }
.choice[aria-pressed="true"] .photo { outline: 3px solid var(--ink); outline-offset: -3px; }
.pick-tag { display: flex; align-items: center; min-height: 32px; margin-top: 4px; font-size: 1rem; font-weight: 600; color: var(--ink2); }
.choice[aria-pressed="true"] .pick-tag { color: var(--ink); font-weight: 800; }
.choice.good .photo { outline: 3px solid var(--good); outline-offset: -3px; }
.verdict { display: block; margin-top: 8px; font-size: 1.125rem; line-height: 1.35; }
.verdict b { display: block; }
.verdict.good b { color: var(--good); }
.verdict.bad b { color: var(--bad); }
.check-btn { margin-top: 12px; min-height: 52px; }
.lesson .opt { flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.lesson .opt[aria-pressed="true"] { border: 1px solid var(--ink); padding: 12px 16px; outline: 3px solid var(--ink); outline-offset: -1px; }
.lesson .opt[aria-pressed="true"]:focus-visible { outline-color: var(--accent); outline-offset: 2px; }
.lesson .opt[aria-pressed="true"]::after { content: none; }
.opt-text { flex: 1 1 12rem; min-width: 0; }
.opt-mark { flex: none; font-size: 1rem; font-weight: 800; }
div.opt { cursor: default; }
.opt.right { border: 2px solid var(--good); padding: 11px 15px; color: var(--good); }
.opt.wrong { border: 2px solid var(--bad); padding: 11px 15px; color: var(--bad); }
.opt.off { color: var(--ink2); border: 1px dashed var(--line); }
.photo-err { display: grid; gap: 10px; justify-items: start; margin-top: 12px; padding: 14px 16px; background: var(--soft); border-radius: 12px; }
.photo.broke img { visibility: hidden; }
.photo.broke::after { content: "Photo didn\2019t load"; position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 1rem; line-height: 1.3; color: var(--ink2); }

/* The result: the same place and the same shape every time. */
.panel { margin-top: 14px; padding: 16px; border: 2px solid; border-radius: var(--r); background: var(--soft); scroll-margin-bottom: 16px; }
.panel.good { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.panel.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.panel-h { font-size: 1.25rem; font-weight: 800; line-height: 1.25; }
.panel.good .panel-h { color: var(--good); }
.panel.bad .panel-h { color: var(--bad); }
.panel-a, .panel-why { margin-top: 6px; font-size: 1.125rem; }
.panel .btn { margin-top: 14px; min-height: 52px; }

/* A question already answered: one line, opens in place. */
.qrow { margin-top: 10px; border-bottom: 1px solid var(--hair); }
.qrow-btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 6px 0; border: 0; background: none; font-weight: 600; font-size: 1.0625rem; text-align: left; cursor: pointer; }
.qrow-btn:focus-visible { outline-offset: -3px; }
.qrow-body { padding-bottom: 16px; }
.qrow-body > h3 { margin-block: 4px 12px; }
.qrow-body .step:first-child { margin-top: 8px; }
.teach-row { margin-top: 14px; }

/* ---------- Lesson: the end ---------- */
.recap { padding-top: 20px; border-top: 2px solid var(--ink); }
.recap h2 { font-size: 1.75rem; }
.recap p + p { margin-top: 4px; }
.recap h3 { margin-block: 18px 8px; }
.tryit .chip { margin-top: 12px; }
.redo { margin-top: 20px; }
.redo .text-btn { padding-inline: 0; }
.lesson-next { position: sticky; bottom: calc(61px + env(safe-area-inset-bottom, 0px)); z-index: 10; margin: 20px -16px -48px; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--hair); }
.lesson-next .btn { min-height: 52px; }
@media (min-width: 900px) { .lesson-next { bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- A soft arrival for what changes in place. Opacity only. ---------- */
.lesson .verdict, .panel, .recap { transition: opacity 200ms var(--out); }
@starting-style {
  .lesson .verdict, .panel, .recap { opacity: 0; }
}

@media (hover: hover) and (pointer: fine) {
  .chap-dot:hover { border-color: var(--ink); }
  .les-row:hover strong, .chap-btn:hover .chap-name, .qrow-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
  button.choice:hover .photo img { transform: scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  .chap-dot:active, .les-row:active, button.choice:active { transform: none; }
  .chap-bar i, .qbar i, .chev { transition: none; }
}
@media print {
  .lesson-bar, .lesson-next { position: static; }
}
