/* Lessons, exercises, the quiz and the XP bits. Phone first; tokens come from site.css. */

/* ---- the lesson path on a page ---- */

.lpath {
  max-width: 720px;
  margin: 0 0 28px;
  padding: 18px 16px 12px;
  border-radius: 16px;
  background: rgba(255, 248, 236, 0.08);
  border: 2px dashed rgba(255, 248, 236, 0.3);
}

.lpath-head { display: grid; grid-template-columns: 1fr; gap: 2px; }
.lpath-title { margin: 0; font-size: 24px; }
.lpath-line { margin: 0; font-size: 14px; font-weight: 600; color: var(--chalk-dim); }
.lpath-go { justify-self: start; margin-top: 12px; max-width: 100%; background: var(--jot); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lpath-stops {
  display: flex;
  gap: 6px;
  margin: 16px -16px 0;
  padding: 6px 16px 10px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.lpath-stops::-webkit-scrollbar { display: none; }
.lpath-stops li { flex: 0 0 76px; display: grid; justify-items: center; gap: 6px; }

.lstop {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 248, 236, 0.45);
  background: transparent;
  color: var(--chalk);
  font: inherit;
  cursor: pointer;
  transition: transform 180ms var(--spring);
  -webkit-tap-highlight-color: transparent;
}
.lstop:active { transform: scale(0.94); }
.lstop.done { background: var(--pc); border: 0; color: var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); }
.lstop.next { border: 3px solid var(--jot); animation: stop-pulse 1.8s ease-in-out infinite; }
.lstop-n { font-family: "Permanent Marker", cursive; font-size: 22px; line-height: 1; }
.lstop-stars { position: absolute; bottom: -9px; padding: 1px 5px; border-radius: 999px; background: var(--ink); color: var(--jot); font-size: 10px; letter-spacing: 1px; line-height: 1.4; }
.lstop:not(.done) .lstop-stars { display: none; }
.lstop-name { max-width: 76px; font-size: 11px; font-weight: 700; line-height: 1.2; text-align: center; color: var(--chalk-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

@keyframes stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 225, 77, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255, 225, 77, 0); }
}

.practise-btn {
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  background: var(--jot);
  border: 0;
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.xcard > .practise-btn { display: block; margin: 12px 0 0; }

/* ---- the lesson player ---- */

html.lesson-open, html.lesson-open body { overflow: hidden; }

/* not the lesson cards on linear-algebra.html, which are articles with the same class */
.lesson:not(.problem) {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: var(--chalk);
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 248, 236, 0.13) 1px, transparent 1.5px) 0 0 / 28px 28px,
    var(--wall);
  animation: sheet-up 280ms ease-out both;
}
@keyframes sheet-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.lesson-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.lesson-x {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: rgba(255, 248, 236, 0.14);
  color: var(--chalk);
  font: inherit; font-size: 26px; line-height: 1;
  cursor: pointer;
}
.lesson-bar { flex: 1 1 auto; height: 12px; border-radius: 999px; background: rgba(255, 248, 236, 0.16); overflow: hidden; }
.lesson-bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--c2); transition: width 320ms var(--spring); }

.lesson-body { overflow-y: auto; padding: 8px 16px 24px; -webkit-overflow-scrolling: touch; }
.lesson-body > * { max-width: 620px; margin-left: auto; margin-right: auto; }

.lesson-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--wall-deep);
  border-top: 2px solid rgba(255, 248, 236, 0.12);
}
.lesson-foot > * { max-width: 620px; }
.lesson-go { flex: 1 1 auto; padding: 14px 20px; font-size: 17px; background: var(--c2); color: var(--ink); }

.hint-btn {
  font: inherit;
  font-weight: 800;
  color: var(--chalk);
  background: transparent;
  border: 2px solid rgba(255, 248, 236, 0.4);
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}
.hint-btn:disabled { opacity: 0.35; cursor: default; }

.lesson-read {
  padding: 22px 18px 20px;
  border-radius: 6px 16px 16px 6px;
  border-left: 10px solid var(--pc);
  background: var(--chalk);
  color: var(--ink);
  box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.22);
  animation: note-drop 360ms var(--spring) both;
}
.lesson-read p { margin: 0 0 12px; font-size: 17px; line-height: 1.5; }
.lesson-read p:last-child { margin-bottom: 0; }
.lesson-kicker { font-size: 13px !important; font-weight: 800; color: var(--ink-soft); margin-bottom: 4px !important; }
.lesson-h { margin: 0 0 12px; font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; }
h2.lesson-h { font-family: "Permanent Marker", cursive; font-weight: 400; font-size: 28px; }
.lesson-img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin: 0 0 14px; }
.lesson-note { font-size: 14px !important; font-weight: 600; color: var(--ink-soft); }
.lesson-list { margin: 0; padding-left: 22px; }
.lesson-list li { margin-bottom: 8px; line-height: 1.45; }

.lesson-card { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 2px dashed rgba(28, 20, 64, 0.16); }
.lesson-card:first-of-type { border-top: 0; }
.lesson-card strong { display: block; font-size: 18px; }
.lesson-card-a { display: block; font-size: 15px; line-height: 1.4; }
.lesson-card-x { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; font-style: italic; color: var(--ink-soft); }
.lesson-flag { flex: 0 0 72px; width: 72px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; border: 1px solid rgba(28, 20, 64, 0.15); }

.lesson-end { display: grid; justify-items: center; gap: 4px; padding: 28px 0 0; text-align: center; }
.lesson-end .lesson-h { color: var(--chalk); }
.lesson-stars { margin: 0 0 8px; font-size: 64px; line-height: 1; letter-spacing: 6px; color: rgba(255, 248, 236, 0.2); }
.lesson-stars .on { display: inline-block; color: var(--jot); animation: star-pop 520ms var(--spring) both; }
@keyframes star-pop { from { opacity: 0; transform: scale(2.4) rotate(-40deg); } to { opacity: 1; transform: none; } }
.lesson-score { margin: 0; font-weight: 700; }
.lesson-end .lesson-note { margin: 6px 0 0; color: var(--chalk-dim); }
.lesson-acts { display: grid; gap: 10px; width: 100%; max-width: 360px; margin-top: 22px; }

/* ---- one exercise ---- */

.chk { display: grid; gap: 12px; animation: note-drop 320ms var(--spring) both; }
.chk-lead { margin: 0; font-size: 13px; font-weight: 800; color: var(--chalk-dim); }
.chk-q { margin: 0; font-size: clamp(19px, 5.2vw, 23px); font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.chk-img { width: 60%; max-width: 220px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.chk-blank { display: inline-block; min-width: 4.5em; padding: 0 6px; border-bottom: 3px dashed var(--jot); text-align: center; }
.chk-blank.filled { border-bottom-style: solid; color: var(--jot); }
.chk-hint { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 225, 77, 0.16); border: 2px dashed var(--jot); font-size: 15px; font-weight: 600; animation: word-in 320ms var(--spring) both; }
.chk-hint::before { content: "Hint: "; font-weight: 800; color: var(--jot); }
.chk-note { margin: 0; font-size: 13px; font-weight: 600; color: var(--chalk-dim); }

.chk-body { display: grid; gap: 10px; }
.chk-body.two { grid-template-columns: 1fr 1fr; }

.chk-opt, .chk-row, .chk-side {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
  color: var(--ink);
  background: var(--chalk);
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 160ms var(--spring), background-color 160ms, opacity 160ms;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
.chk-body.two .chk-opt { text-align: center; font-size: 18px; font-weight: 800; }
.chk-opt:active, .chk-row:active, .chk-side:active { transform: translateY(2px); }
.chk-opt:disabled, .chk-row:disabled, .chk-side:disabled { cursor: default; color: var(--ink); }
.chk-opt:disabled:not(.right):not(.wrong) { opacity: 0.5; box-shadow: none; }
.chk-opt.gone { opacity: 0.25 !important; text-decoration: line-through; }
.chk-opt.right, .chk-row.right { background: var(--c2); animation: pop 380ms var(--spring); }
.chk-opt.wrong, .chk-row.wrong { background: var(--c1); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.05); } 100% { transform: scale(1); } }

.chk-rows { display: grid; gap: 10px; }
.chk-row { display: flex; align-items: center; gap: 12px; }
.chk-num {
  flex: 0 0 30px;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px dashed rgba(28, 20, 64, 0.35);
  font-weight: 800; font-size: 15px;
}
.chk-row.picked { background: var(--pc); }
.chk-row.picked .chk-num, .chk-row:disabled .chk-num { border: 0; background: var(--ink); color: var(--chalk); }
.chk-row.locked { outline: 3px solid var(--jot); }
.chk-go { justify-self: start; background: var(--jot); color: var(--ink); }
.chk-go:disabled { opacity: 0.4; cursor: default; transform: none; }

.chk-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chk-side { font-size: 14px; padding: 10px 12px; display: flex; align-items: center; }
.chk-side.held { background: var(--jot); transform: scale(1.03); }
.chk-side.paired { background: var(--pc); box-shadow: none; opacity: 0.9; }
.chk-side.shake { animation: shake 320ms; background: var(--c1); }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.chk-after { padding: 14px 16px; border-radius: 14px; background: rgba(255, 248, 236, 0.1); animation: word-in 320ms var(--spring) both; }
.chk-after p { margin: 0; }
.chk-verdict { font-family: "Permanent Marker", cursive; font-size: 24px; line-height: 1.1; }
.is-right .chk-verdict { color: var(--c2); }
.is-wrong .chk-verdict { color: var(--c1); }
.chk-answer { margin-top: 6px !important; font-weight: 800; }
.chk-why { margin-top: 6px !important; font-size: 15px; line-height: 1.45; color: var(--chalk); }

/* ---- home page: XP strip, quiz and badges ---- */

.xp {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 8px 0 14px;
}
.xp-level {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--jot); color: var(--ink);
  font-family: "Permanent Marker", cursive; font-size: 24px; line-height: 1;
  transform: rotate(-6deg);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.25);
}
.xp-level small { display: block; font-family: "Bricolage Grotesque", sans-serif; font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.xp-mid { display: grid; gap: 5px; min-width: 0; }
.xp-line { margin: 0; font-size: 13px; font-weight: 700; color: var(--chalk-dim); }
.xp-bar { height: 10px; border-radius: 999px; background: rgba(255, 248, 236, 0.16); overflow: hidden; }
.xp-mid .streak { justify-self: start; margin-top: 3px; padding: 3px 11px; font-size: 12px; }
.xp-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--c4); transition: width 400ms var(--spring); }
.xp-goal { position: relative; width: 56px; height: 56px; }
.xp-goal svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.xp-goal circle { fill: none; stroke-width: 6; }
.xp-goal .track { stroke: rgba(255, 248, 236, 0.16); }
.xp-goal .ring { stroke: var(--c0); stroke-linecap: round; transition: stroke-dashoffset 400ms var(--spring); }
.xp-goal.met .ring { stroke: var(--c2); }
.xp-goal-n { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 800; line-height: 1; text-align: center; }
.xp-goal-n small { display: block; font-size: 9px; font-weight: 700; color: var(--chalk-dim); }

.quiz-chips { display: flex; gap: 8px; margin: 0 -14px 14px; padding: 2px 14px; overflow-x: auto; scrollbar-width: none; }
.quiz-chips::-webkit-scrollbar { display: none; }
.quiz-chip {
  flex: 0 0 auto;
  font: inherit; font-size: 13px; font-weight: 800;
  color: var(--chalk);
  background: transparent;
  border: 2px solid rgba(255, 248, 236, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.quiz-chip[aria-pressed="true"] { background: var(--chalk); color: var(--ink); border-color: var(--chalk); }

.quiz-tally { display: flex; gap: 14px; margin: 0 0 12px; font-size: 13px; font-weight: 800; color: var(--chalk-dim); font-variant-numeric: tabular-nums; }
.quiz-tally strong { color: var(--chalk); }
.quiz-combo.hot strong { color: var(--c0); }
.quiz-combo.pop { animation: pop 380ms var(--spring); }

.quiz-from { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 12px; }
.quiz-from a { padding: 3px 12px; border-radius: 999px; background: var(--chalk); color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: none; }
.quiz-from span { min-width: 0; font-size: 13px; font-weight: 700; color: var(--chalk-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quiz-acts { display: flex; gap: 10px; margin-top: 14px; }
.quiz-acts .hint-btn { padding: 10px 16px; font-size: 15px; }
.quiz-acts .quiz-next { flex: 1 1 auto; background: var(--c2); color: var(--ink); }
.quiz-verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.quiz-verdict .verdict-btn {
  font: inherit; font-weight: 800; font-size: 17px;
  color: var(--ink);
  border: 0; border-radius: 999px;
  padding: 14px 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
.quiz-verdict .nope { background: var(--c1); }
.quiz-verdict .yep { background: var(--c2); }
#mix-stage > .chk-hint { margin-bottom: 12px; }
.chk-hint > span { display: block; }
.chk-hint > span + span { margin-top: 6px; }
.chk-hint > span:first-child { display: inline; }
.quiz-skeleton { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; letter-spacing: 0.04em; overflow-wrap: anywhere; }

.badges { max-width: 720px; margin: 0 0 32px; }
.badges-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--chalk-dim); }
.badges-line { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--chalk-dim); }
.badge-row { display: flex; gap: 12px; margin: 0 -16px; padding: 8px 16px 12px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.badge-row::-webkit-scrollbar { display: none; }
.badge {
  flex: 0 0 82px;
  display: grid; place-items: center;
  width: 82px; height: 82px;
  padding: 8px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 248, 236, 0.3);
  color: var(--chalk-dim);
  font-family: "Permanent Marker", cursive;
  font-size: 14px; line-height: 1.05; text-align: center;
}
.badge { cursor: pointer; }
.badge.on { background: var(--ink); color: var(--jot); border-color: var(--jot); box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.3); }
.badge:nth-child(odd) { transform: rotate(-6deg); }
.badge:nth-child(even) { transform: rotate(5deg); }

.topic-stars { display: block; margin: 10px 0 0; font-size: 12px; font-weight: 800; color: var(--ink); }
.topic-stars + .meta { margin-top: 6px; }

/* ---- XP chip, level-up and badge pop-ups (every page) ---- */

.xp-tray { position: fixed; z-index: 70; left: 0; right: 0; bottom: 96px; display: grid; justify-items: center; gap: 6px; pointer-events: none; }
.xp-chip {
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--jot); color: var(--ink);
  font-weight: 800; font-size: 15px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  animation: chip-up 1300ms ease-out both;
}
@keyframes chip-up {
  0% { opacity: 0; transform: translateY(16px) scale(0.8); }
  15% { opacity: 1; transform: none; }
  75% { opacity: 1; transform: translateY(-18px); }
  100% { opacity: 0; transform: translateY(-34px); }
}

.slap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(29, 17, 80, 0.72); overflow: hidden; cursor: pointer; }
.slap-disc {
  display: grid; place-items: center; align-content: center; gap: 4px;
  width: 230px; height: 230px;
  padding: 24px;
  border-radius: 50%;
  background: var(--ink); color: var(--jot);
  border: 5px dashed var(--jot);
  text-align: center;
  box-shadow: 6px 8px 0 rgba(0, 0, 0, 0.35);
  animation: sticker-slap 520ms var(--spring) both;
}
.slap-kicker { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chalk); }
.slap-title { font-family: "Permanent Marker", cursive; font-size: 36px; line-height: 1.05; }
.slap-sub { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--chalk-dim); }
.confetti {
  position: absolute; top: -20px; left: var(--x);
  width: 10px; height: 16px;
  animation: confetti 1700ms cubic-bezier(.3, .6, .5, 1) var(--d) both;
}
@keyframes confetti {
  from { transform: translateY(0) rotate(0); opacity: 1; }
  to { transform: translateY(105vh) rotate(var(--r)); opacity: 0.9; }
}

@media (min-width: 761px) {
  .lesson-body { padding-top: 32px; }
  .lesson-foot { justify-content: center; }
  .lesson-go { flex: 0 1 420px; }
}
