/* ============================================================================
   lesson.css · lesson reading layout, callouts, code, and interactive widgets
   ============================================================================ */

/* ============================ LESSON HEADER =============================== */
.lesson-hero { margin-bottom: var(--s-7); }
.crumbs { display: flex; align-items: center; gap: .5em; font-size: .85rem; color: var(--text-muted); margin-bottom: var(--s-4); flex-wrap: wrap; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--ocean-700); }
.crumbs .sep { opacity: .5; }

.lesson-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; margin: var(--s-4) 0 var(--s-5); color: var(--text-soft); font-size: .9rem; }
.lesson-meta .meta-item { display: inline-flex; align-items: center; gap: .45em; }
.lesson-meta svg { width: 16px; height: 16px; stroke: var(--ocean-600); }
.lesson-title { margin: var(--s-2) 0; }
.lesson-lede { font-size: 1.18rem; line-height: 1.6; color: var(--text-soft); max-width: 64ch; }

/* Goal banner */
.goal {
  display: flex; gap: var(--s-4); align-items: flex-start;
  margin: var(--s-6) 0; padding: var(--s-5) var(--s-5);
  background: linear-gradient(135deg, var(--ink-800), var(--ink-700));
  color: var(--text-invert); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.goal::before {
  content:""; position: absolute; inset: 0;
  background: radial-gradient(120% 160% at 0% 0%, rgba(0,174,214,.28), transparent 55%);
  pointer-events: none;
}
.goal .goal-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--ocean-600); border-radius: var(--r-md); box-shadow: var(--shadow-ocean); position: relative; }
.goal .goal-icon svg { width: 22px; height: 22px; stroke: #fff; }
.goal h2 { color: var(--ice-300); font-size: .76rem; letter-spacing: .16em; text-transform: uppercase; margin-bottom: .25em; }
.goal p { color: #eaf6f9; font-size: 1.06rem; max-width: 60ch; position: relative; }

/* ============================ PROSE ====================================== */
.prose > * + * { margin-top: var(--s-4); }
.prose h2 { margin-top: var(--s-9); padding-top: var(--s-2); scroll-margin-top: calc(var(--header-h) + 18px); }
.prose h3 { margin-top: var(--s-6); }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-top: .35em; }
.prose li::marker { color: var(--ocean-600); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ocean) 40%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--ocean-600); }
.prose img { border-radius: var(--r-md); box-shadow: var(--shadow-md); margin-block: var(--s-4); }

/* numbered section heading */
.section-h { display: flex; align-items: center; gap: var(--s-3); }
.section-h .num {
  font-family: var(--font-accent); font-size: 1rem; color: #fff;
  background: linear-gradient(180deg, var(--ocean-400), var(--ocean-600));
  width: 1.9em; height: 1.9em; border-radius: var(--r-sm); display: grid; place-items: center;
  box-shadow: var(--shadow-sm); flex: none;
}

/* figure / diagram */
.figure { margin: var(--s-5) 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.figure .figure-body { padding: var(--s-5); display: grid; place-items: center; background: var(--ice-50); }
.figure figcaption { padding: var(--s-3) var(--s-4); font-size: .86rem; color: var(--text-muted); border-top: 1px solid var(--line); }

/* ASCII / diagram block */
.diagram {
  font-family: var(--font-mono); font-size: .86rem; line-height: 1.55;
  white-space: pre; overflow-x: auto; color: var(--code-text);
  background: var(--code-bg); border-radius: var(--r-md); padding: var(--s-5);
  border: 1px solid var(--code-line);
}
.diagram .hl { color: var(--ocean-300); }
.diagram .dim { color: var(--code-dim); }

/* ============================ CALLOUTS =================================== */
.callout {
  --c: var(--ocean-600); --c-bg: var(--ice-50);
  display: grid; grid-template-columns: auto 1fr; gap: var(--s-3) var(--s-4);
  padding: var(--s-5); margin: var(--s-6) 0;
  background: var(--c-bg); border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  border-left: 4px solid var(--c); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.callout .c-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--c); display: grid; place-items: center; flex: none; grid-row: span 1; }
.callout .c-icon svg { width: 18px; height: 18px; stroke: #fff; }
.callout .c-title { font-family: var(--font-display); font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--c); align-self: center; }
.callout .c-body { grid-column: 1 / -1; }
.callout .c-body > * + * { margin-top: var(--s-3); }
.callout .c-body p { max-width: none; }
@media (min-width: 640px) { .callout .c-body { grid-column: 2 / -1; } }

.callout--why     { --c: #b8632e; --c-bg: #fdf3ec; }
.callout--verified{ --c: var(--good); --c-bg: var(--good-bg); }
.callout--pitfall { --c: var(--bad);  --c-bg: var(--bad-bg); }
.callout--season  { --c: var(--warn); --c-bg: var(--warn-bg); }
.callout--tip     { --c: var(--ocean-600); --c-bg: var(--ice-100); }
.callout--note    { --c: var(--slate-600); --c-bg: var(--slate-50); }

/* war-story flourish */
.callout--why .c-title::after { content:" · war story"; color: #c98a5e; }

/* ============================ VOCABULARY ================================= */
.vocab { display: grid; gap: var(--s-3); margin: var(--s-5) 0; }
@media (min-width: 680px) { .vocab { grid-template-columns: 1fr 1fr; } }
.vocab-term {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4); box-shadow: var(--shadow-sm); transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-med);
}
.vocab-term:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.vocab-term dt { font-family: var(--font-mono); font-weight: 600; color: var(--ocean-800); font-size: .98rem; margin-bottom: .3em; }
.vocab-term dd { color: var(--text-soft); font-size: .94rem; line-height: 1.55; }

/* ============================ CODE BLOCKS =============================== */
.code {
  margin: var(--s-5) 0; border-radius: var(--r-md); overflow: hidden;
  background: var(--code-bg); border: 1px solid var(--code-line);
  box-shadow: var(--shadow-lg);
}
.code-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: .55em .8em .55em 1em; background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
}
.code-dots { display: flex; gap: 6px; }
.code-dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.code-dots i:nth-child(1){ background:#ff5f57; } .code-dots i:nth-child(2){ background:#febc2e; } .code-dots i:nth-child(3){ background:#28c840; }
.code-file { font-family: var(--font-mono); font-size: .8rem; color: var(--code-dim); margin-left: .4em; }
.code-lang { font-family: var(--font-display); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ice-300); background: rgba(0,174,214,.14); padding: .25em .6em; border-radius: 99px; }
.code-spacer { flex: 1; }
.copy-btn {
  display: inline-flex; align-items: center; gap: .4em; cursor: pointer;
  background: transparent; border: 1px solid var(--code-line); color: var(--code-dim);
  font-family: var(--font-display); font-size: .72rem; padding: .35em .7em; border-radius: 99px;
  transition: transform var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}
.copy-btn:hover { color: var(--ice-300); border-color: var(--ocean-600); }
.copy-btn:active { transform: scale(.97); }
.copy-btn svg { width: 13px; height: 13px; stroke: currentColor; }
.copy-btn.copied { color: #28c840; border-color: #28c840; }

.code pre { margin: 0; overflow-x: auto; padding: var(--s-4) 0; }
.code pre code { display: block; font-family: var(--font-mono); font-size: .88rem; line-height: 1.75; color: var(--code-text); padding: 0 var(--s-5); }
.code.with-lines pre code { counter-reset: ln; }
.code.with-lines .line { counter-increment: ln; display: block; position: relative; padding-left: 2.6em; }
.code.with-lines .line::before { content: counter(ln); position: absolute; left: 0; width: 2em; text-align: right; color: var(--code-dim); opacity: .55; user-select: none; }
.code .line.added { background: rgba(31,157,107,.14); box-shadow: inset 3px 0 var(--good); }
.code .line.note  { background: rgba(0,174,214,.1); }
.code-cap { padding: .55em 1em; font-size: .8rem; color: var(--code-dim); border-top: 1px solid var(--code-line); background: var(--code-bg-2); }

/* highlight.js token theme (Penguin Ocean) */
.hljs-comment, .hljs-quote { color: #6b7a82; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name { color: #59d0ea; }
.hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: #ffd479; }
.hljs-string, .hljs-meta-string { color: #9be7a4; }
.hljs-number, .hljs-literal { color: #f7a36b; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: #e7eef2; }
.hljs-attr, .hljs-variable, .hljs-template-variable { color: #c8d3da; }
.hljs-meta { color: #8aa0ab; }
.hljs-symbol, .hljs-bullet, .hljs-link { color: #7fe0f1; }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }
.hljs-deletion { color: #ff8d85; } .hljs-addition { color: #9be7a4; }

/* ============================ LIVE SANDBOX ============================== */
.sandbox { margin: var(--s-6) 0; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--code-line); box-shadow: var(--shadow-xl); background: var(--code-bg); }
.sandbox-head {
  display: flex; align-items: center; gap: var(--s-3); padding: .7em 1em;
  background: linear-gradient(180deg, #1b2228, var(--code-bg-2)); border-bottom: 1px solid var(--code-line);
}
.sandbox-head .live-dot { width: 9px; height: 9px; border-radius: 50%; background: #28c840; box-shadow: 0 0 0 0 rgba(40,200,64,.6); animation: livepulse 2.4s var(--ease-out) infinite; }
@keyframes livepulse { 0%{ box-shadow: 0 0 0 0 rgba(40,200,64,.5);} 70%{ box-shadow: 0 0 0 7px rgba(40,200,64,0);} 100%{ box-shadow: 0 0 0 0 rgba(40,200,64,0);} }
.sandbox-title { font-family: var(--font-display); font-size: .8rem; color: var(--ice-300); letter-spacing: .04em; }
.sandbox-title b { color: #fff; }
.sandbox-editor { width: 100%; min-height: 230px; resize: vertical; border: 0; outline: none;
  font-family: var(--font-mono); font-size: .88rem; line-height: 1.7; tab-size: 2;
  color: var(--code-text); background: var(--code-bg); padding: var(--s-4) var(--s-5); display: block; }
/* Honesty banner on PenguinSim sandboxes: the student must never think these
   stand-in classes are the real WPILib ones. */
.sim-banner {
  display: flex; align-items: flex-start; gap: .6em;
  padding: .7em .9em; background: rgba(0,174,214,.12);
  border-bottom: 1px solid var(--code-line);
  font-size: .82rem; line-height: 1.5; color: var(--ice-300);
}
.sim-banner svg { width: 16px; height: 16px; flex: none; margin-top: .15em; stroke: var(--ocean-300); }
.sim-banner b { color: #fff; }
.sim-banner code { background: rgba(255,255,255,.1); border: 0; color: var(--ice-300); padding: .05em .35em; border-radius: 4px; font-size: .95em; }

.sandbox-bar { display: flex; align-items: center; gap: var(--s-3); padding: .6em .8em; background: var(--code-bg-2); border-top: 1px solid var(--code-line); flex-wrap: wrap; }
.sandbox-bar .grow { flex: 1; }
.run-btn { display: inline-flex; align-items: center; gap: .5em; cursor: pointer; border: 0; border-radius: 99px;
  font-family: var(--font-display); font-size: .9rem; color: #04222a; padding: .55em 1.15em;
  background: linear-gradient(180deg, #2ee06a, #18b955); box-shadow: 0 6px 16px -6px rgba(40,200,64,.7); transition: transform var(--t-fast) var(--ease-spring); }
.run-btn:hover { transform: translateY(-2px); } .run-btn:active { transform: translateY(0); }
.run-btn svg { width: 15px; height: 15px; fill: #04222a; }
.run-btn[disabled] { opacity: .6; cursor: wait; }
.sandbox-link { font-family: var(--font-display); font-size: .78rem; color: var(--code-dim); display: inline-flex; align-items: center; gap: .35em; }
.sandbox-link:hover { color: var(--ice-300); }
.sandbox-out { border-top: 1px solid var(--code-line); background: #0c0f12; padding: var(--s-4) var(--s-5); font-family: var(--font-mono); font-size: .85rem; color: #cdd7dd; white-space: pre-wrap; max-height: 280px; overflow:auto; }
.sandbox-out:empty { display: none; }
.sandbox-out .ok { color: #9be7a4; } .sandbox-out .err { color: #ff8d85; } .sandbox-out .muted { color: var(--code-dim); }
.sandbox-frame { width: 100%; height: 460px; border: 0; background: #fff; display: block; }

/* ============================ CHALLENGES =============================== */
.challenge {
  margin: var(--s-6) 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden;
}
.challenge-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); background: linear-gradient(180deg, var(--ice-100), var(--ice-50)); border-bottom: 1px solid var(--line); }
.challenge-head .ch-kind { font-family: var(--font-display); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #fff; background: var(--ocean-600); padding: .3em .7em; border-radius: 99px; }
.challenge-head .ch-title { font-family: var(--font-display); color: var(--ink); font-size: 1.02rem; }
.challenge-body { padding: var(--s-5); }
.challenge-body > * + * { margin-top: var(--s-4); }
.challenge-prompt { color: var(--text); }
.challenge-prompt b { color: var(--ink); }

/* fill-in-the-blank code */
.fib { font-family: var(--font-mono); font-size: .88rem; line-height: 2.15; background: var(--code-bg); color: var(--code-text); border-radius: var(--r-md); padding: var(--s-4) var(--s-5); overflow-x: auto; border: 1px solid var(--code-line); white-space: pre; }
.blank {
  display: inline-block; min-width: 7ch; width: auto; text-align: center;
  font-family: var(--font-mono); font-size: .92em; color: #fff;
  background: rgba(0,174,214,.16); border: 1.5px dashed var(--ocean-400); border-radius: 6px;
  padding: .04em .4em; margin: 0 .12em; outline: none; transition: all var(--t-fast);
  /* Its own tight line-height + middle alignment: inheriting the .fib
     line-height made the box taller than its line, so blanks on consecutive
     lines overlapped each other. */
  line-height: 1.35; vertical-align: middle;
}
.blank:focus { background: rgba(0,174,214,.28); border-style: solid; border-color: var(--ocean-300); }
.blank.correct { background: rgba(31,157,107,.28); border-color: #2ee06a; border-style: solid; color: #d6ffe6; }
.blank.wrong { background: rgba(214,69,61,.26); border-color: #ff8d85; border-style: solid; color: #ffe0dd; }

/* MCQ */
.options { display: grid; gap: var(--s-2); }
.option {
  display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer;
  padding: var(--s-3) var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); transition: all var(--t-fast) var(--ease-out);
}
.option:hover { border-color: var(--ocean-400); background: var(--ice-50); }
.option input { position: absolute; opacity: 0; }
.option .opt-mark { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--slate-300); flex: none; display: grid; place-items: center; margin-top: 1px; transition: all var(--t-fast); }
.option .opt-mark svg { width: 12px; height: 12px; opacity: 0; }
.option .opt-text { line-height: 1.45; }
.option:has(input:checked) { border-color: var(--ocean-500); background: var(--ice-100); box-shadow: var(--shadow-sm); }
.option:has(input:checked) .opt-mark { border-color: var(--ocean-500); background: var(--ocean-500); }
.option:has(input:checked) .opt-mark svg { opacity: 1; stroke: #fff; }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.correct .opt-mark { border-color: var(--good); background: var(--good); }
.option.correct .opt-mark svg { opacity: 1; stroke: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .opt-mark { border-color: var(--bad); background: var(--bad); }
.option.wrong .opt-mark svg { opacity: 1; stroke: #fff; }
.option.dim { opacity: .55; }

/* predict-output / short answer */
.answer-row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: stretch; }
.answer-input { flex: 1; min-width: 220px; font-family: var(--font-mono); font-size: .92rem; padding: .7em .9em; border: 1.5px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); transition: border var(--t-fast), box-shadow var(--t-fast); }
.answer-input:focus { border-color: var(--ocean-400); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.answer-input.correct { border-color: var(--good); background: var(--good-bg); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* challenge controls + feedback */
.challenge-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
/* The "did I get it right?" moment. Enters on a short ease-out; a wrong→right
   correction keeps .show, so display never re-toggles and the colours retarget
   smoothly instead of replaying the entrance. */
.feedback {
  display: none; align-items: flex-start; gap: .6em; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); font-size: .94rem; line-height: 1.5;
  opacity: 0; transform: translateY(-3px);
  transition: opacity var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out),
              display var(--t-fast) allow-discrete;
}
.feedback.show { display: flex; opacity: 1; transform: none; }
@starting-style { .feedback.show { opacity: 0; transform: translateY(-3px); } }
.feedback svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.feedback.good { background: var(--good-bg); color: #176848; border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); }
.feedback.good svg { stroke: var(--good); }
.feedback.bad { background: var(--bad-bg); color: #9a2c26; border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.feedback.bad svg { stroke: var(--bad); }

/* reveal (hint / solution) */
.reveal { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); overflow: hidden; }
.reveal > summary { cursor: pointer; list-style: none; padding: var(--s-3) var(--s-4); display: flex; align-items: center; gap: .6em; font-family: var(--font-display); font-size: .9rem; color: var(--ocean-800); user-select: none; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary .rv-chev { width: 16px; height: 16px; stroke: var(--ocean-700); transition: transform var(--t-med) var(--ease-spring); }
.reveal[open] > summary .rv-chev { transform: rotate(90deg); }
.reveal[open] > summary { border-bottom: 1px solid var(--line); }
.reveal::details-content {
  block-size: 0; opacity: 0; overflow: hidden;
  transition: block-size var(--t-med) var(--ease-out),
              opacity var(--t-med) var(--ease-out),
              content-visibility var(--t-med) allow-discrete;
}
.reveal[open]::details-content { block-size: auto; opacity: 1; }
.reveal-body { padding: var(--s-4); }
.reveal-body > * + * { margin-top: var(--s-3); }

/* drag-to-order (lifecycle) */
.order-list { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
.order-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: grab; box-shadow: var(--shadow-sm); transition: border var(--t-fast), box-shadow var(--t-fast), transform var(--t-med) var(--ease-spring); }
.order-item:active { cursor: grabbing; }
.order-item.dragging { opacity: .4; }
.order-item.over { border-color: var(--ocean-400); box-shadow: var(--shadow-md); }
.order-item .grip { color: var(--slate-400); }
.order-item .grip svg { width: 18px; height: 18px; stroke: currentColor; }
.order-item code { background: none; border: 0; color: var(--ocean-800); padding: 0; }
.order-item.correct { border-color: var(--good); background: var(--good-bg); }
.order-item.wrong { border-color: var(--bad); }

/* ============================ EXERCISE ================================= */
.exercise {
  margin: var(--s-7) 0; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ocean) 30%, transparent);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.exercise-head { padding: var(--s-5); background: linear-gradient(135deg, var(--ocean-700), var(--ocean-800)); color: #fff; display: flex; gap: var(--s-4); align-items: center; position: relative; overflow: hidden; }
.exercise-head::after { content:""; position:absolute; right:-30px; top:-30px; width:160px; height:160px; background: radial-gradient(circle, rgba(146,220,229,.4), transparent 65%); }
.exercise-head .ex-icon { width: 46px; height: 46px; background: rgba(255,255,255,.16); border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.exercise-head .ex-icon svg { width: 26px; height: 26px; stroke: #fff; }
.exercise-head .ex-kicker { font-family: var(--font-display); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ice-300); }
.exercise-head h3 { color: #fff; font-size: 1.3rem; }
.exercise-body { padding: var(--s-5); }
.exercise-body > * + * { margin-top: var(--s-4); }
.task-list { list-style: none; padding: 0; counter-reset: task; display: grid; gap: var(--s-3); }
/* The number badge is absolutely positioned rather than a grid column: a grid
   li would make every child (<b>, <code>, <em>, and each bare text node) its
   own grid item, so a task with any inline markup scattered across rows. */
.task-list li { position: relative; padding-left: 2.5em; counter-increment: task; }
.task-list li::before { content: counter(task); position: absolute; left: 0; top: .12em; font-family: var(--font-accent); font-size: .82rem; color: #fff; background: var(--ocean-600); width: 1.8em; height: 1.8em; border-radius: 8px; display: grid; place-items: center; }
.task-list li b { color: var(--ink); }
.starter-note { font-size: .9rem; color: var(--text-muted); display: flex; align-items: center; gap: .5em; }

/* ============================ CHECKPOINT QUIZ ========================== */
.checkpoint { margin: var(--s-7) 0; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden; }
.checkpoint-head { padding: var(--s-4) var(--s-5); background: var(--ink-800); color: #fff; display: flex; align-items: center; gap: var(--s-3); }
.checkpoint-head svg { width: 22px; height: 22px; stroke: var(--ice-300); }
.checkpoint-head h3 { color: #fff; font-size: 1.05rem; }
.checkpoint-head .cp-score { margin-left: auto; font-family: var(--font-accent); font-size: .85rem; color: var(--ice-300); background: rgba(0,174,214,.18); padding: .3em .7em; border-radius: 99px; }
.checkpoint-body { padding: var(--s-5); display: grid; gap: var(--s-6); }
.cp-q > .cp-prompt { font-weight: 600; color: var(--ink); margin-bottom: var(--s-3); display: flex; gap: .6em; }
.cp-q > .cp-prompt .qn { font-family: var(--font-accent); color: var(--ocean-700); }

/* ============================ LESSON FOOTER NAV ======================= */
.mark-complete { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin: var(--s-8) 0 var(--s-6); padding: var(--s-5); border-radius: var(--r-lg); background: linear-gradient(135deg, var(--ice-100), var(--ice-50)); border: 1px solid color-mix(in srgb, var(--ocean) 22%, transparent); }
.mark-complete .mc-text { flex: 1; min-width: 200px; }
.mark-complete .mc-text b { font-family: var(--font-display); color: var(--ink); display:block; }
.mark-complete .mc-text span { font-size: .9rem; color: var(--text-soft); }
.complete-btn {
  display: inline-flex; align-items: center; gap: .5em; cursor: pointer;
  border: 1.5px solid var(--good); color: var(--good); background: var(--white);
  border-radius: 99px; font-family: var(--font-display); padding: .6em 1.2em;
  /* press is fast; the done-state colour swap is a calmer, critically-damped beat */
  transition: transform var(--t-fast) var(--ease-out),
              background var(--t-med) var(--ease-out),
              border-color var(--t-med) var(--ease-out),
              color var(--t-med) var(--ease-out);
}
.complete-btn:hover { background: var(--good-bg); }
.complete-btn:active { transform: scale(.97); }
.complete-btn.done { background: var(--good); color: #fff; }
.complete-btn svg { width: 17px; height: 17px; stroke: currentColor; }
/* the pop fires only on the click that completes the lesson — .just-done is added
   in widgets.js on toggle, never on page load, so revisiting a done lesson is calm */
.complete-btn.just-done svg { animation: check-pop 320ms cubic-bezier(.34,1.56,.64,1); }
@keyframes check-pop {
  0%   { transform: scale(.5); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); margin-top: var(--s-6); }
.lesson-nav a { display: flex; flex-direction: column; gap: .2em; padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); transition: all var(--t-fast) var(--ease-out); box-shadow: var(--shadow-sm); }
.lesson-nav a:hover { border-color: var(--ocean-400); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lesson-nav a .ln-dir { font-family: var(--font-display); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.lesson-nav a .ln-title { font-weight: 600; color: var(--ink); }
.lesson-nav a.next { text-align: right; }
.lesson-nav a.next .ln-title { color: var(--ocean-800); }
.lesson-nav a.disabled { opacity: .4; pointer-events: none; }

@media (max-width: 560px){ .lesson-nav { grid-template-columns: 1fr; } .lesson-nav a.next { text-align: left; } }

/* on-page TOC */
.toc { margin: var(--s-5) 0; padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-left: 3px solid var(--ocean-500); border-radius: var(--r-md); background: var(--surface-2); }
.toc strong { font-family: var(--font-display); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ocean-700); }
.toc ol { margin-top: var(--s-2); padding-left: 1.3em; columns: 2; column-gap: var(--s-6); }
.toc li { margin-top: .3em; }
.toc a { color: var(--text-soft); }
.toc a:hover { color: var(--ocean-700); }
@media (max-width: 560px){ .toc ol { columns: 1; } }

/* ============================================================ signal path ==
   Unit 1's hardware interactive: a clickable RIO -> CAN -> controller -> motor
   chain where cutting a wire kills everything downstream. Wired in widgets.js. */
.sigpath { margin: var(--s-5) 0; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.sp-chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--s-2); }
.sp-node { flex: 1 1 122px; display: flex; flex-direction: column; gap: .15em; justify-content: center; min-width: 0; padding: var(--s-3); text-align: center; cursor: pointer; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); transition: border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast); }
.sp-node:hover, .sp-node:focus-visible { border-color: var(--ocean-400); box-shadow: var(--shadow-md); outline: none; }
.sp-node .sp-name { font-family: var(--font-display); font-size: .8rem; letter-spacing: .02em; color: var(--ocean-800); overflow-wrap: anywhere; }
.sp-node .sp-sub { font-size: .68rem; color: var(--text-muted); }
.sp-node.dead { opacity: .32; border-style: dashed; }
.sp-wire { flex: 0 0 30px; align-self: center; position: relative; height: 30px; padding: 0; cursor: pointer; background: none; border: 0; }
.sp-wire::before { content: ""; position: absolute; inset: 50% 0 auto 0; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--ocean-400); transition: background var(--t-fast); }
.sp-wire::after { content: "\2192"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .8rem; color: var(--ocean-700); }
.sp-wire:hover::before { background: var(--ocean-600); }
.sp-wire.cut::before { background: var(--bad); }
.sp-wire.cut::after { content: "\2715"; color: var(--bad); font-weight: 700; }
.sp-wire.dead::before { opacity: .3; }
.sp-wire.dead::after { opacity: .3; }
.sp-panel { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); min-height: 3.2em; display: flex; flex-direction: column; gap: .2em; border-radius: var(--r-md); border: 1px dashed var(--line); background: var(--surface); font-size: .9rem; color: var(--text-soft); }
.sp-panel .sp-hint { color: var(--text-muted); font-size: .84rem; }
.sp-panel b { font-family: var(--font-display); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ocean-700); }
.sp-panel.show { border-style: solid; border-color: var(--ocean-300, var(--ocean-400)); }
.sp-panel.bad { border-color: var(--bad); background: var(--bad-bg, var(--surface)); }
.sp-panel.bad b { color: var(--bad); }
.sp-actions { margin-top: var(--s-3); display: flex; justify-content: flex-end; }
@media (max-width: 620px){
  .sp-chain { flex-direction: column; }
  .sp-node { flex: 1 1 auto; }
  .sp-wire { flex: 0 0 24px; width: 100%; height: 24px; }
  .sp-wire::before { inset: 0 auto 0 50%; width: 3px; height: 100%; margin: 0 0 0 -1.5px; }
  .sp-wire::after { content: "\2193"; }
  .sp-wire.cut::after { content: "\2715"; }
}

/* ================================================================ tables ==
   Comparison tables (failure symptoms, motor families, relative vs absolute).
   Always wrapped in .tablewrap so a wide table scrolls itself instead of
   scrolling the page at 390px. */
.tablewrap { margin: var(--s-5) 0; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 460px; }
table.data th, table.data td { padding: var(--s-3) var(--s-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.data thead th { font-family: var(--font-display); font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ocean-800); background: var(--surface-2); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data code { white-space: nowrap; }
table.data td:first-child { color: var(--ink); font-weight: 600; }

/* =========================================================== match pairs ==
   Two-column matching (hardware -> vendor docs, tool -> device). Several left
   items may share one right key, so only left items lock. Wired in widgets.js. */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); margin: var(--s-4) 0; }
.match-col { display: grid; gap: var(--s-2); align-content: start; }
.match-head { font-family: var(--font-display); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.match-item { width: 100%; text-align: left; padding: var(--s-3) var(--s-4); font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.match-item:hover { border-color: var(--ocean-400); }
.match-item.picked { border-color: var(--ocean-600); background: var(--surface-2); box-shadow: var(--shadow-sm); }
.match-item.locked { border-color: var(--good); background: var(--good-bg); color: var(--text-soft); cursor: default; }
.match-item.locked::after { content: " \2713"; color: var(--good); font-weight: 700; }
.match-item.hit { border-color: var(--good); }
.match-item.miss { border-color: var(--bad); animation: match-shake 320ms ease; }
@keyframes match-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@media (prefers-reduced-motion: reduce) { .match-item.miss { animation: none; } }
@media (max-width: 560px){ .match { grid-template-columns: 1fr; } }

/* ============================================================= checklist ==
   Persistent install checklist (localStorage), keyed by data-key. */
.checklist { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
.checklist .cl-item { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin: 0; }
.checklist .cl-item::marker { content: none; }
.checklist .cl-item.checked { border-color: var(--good); background: var(--good-bg); }
.checklist .cl-item.checked > *:not(.cl-box) { opacity: .62; }
.cl-box { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px; padding: 0; border: 2px solid var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.cl-box:hover { border-color: var(--ocean-500); }
.cl-item.checked .cl-box { background: var(--good); border-color: var(--good); }
.cl-item.checked .cl-box::after { content: "\2713"; display: block; color: #fff; font-size: .78rem; line-height: 16px; text-align: center; }
.cl-count { font-family: var(--font-display); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--text-muted); }

/* ======================================================= driver station ==
   Mock Driver Station bar used for triage practice in Unit 2. */
.dspanel { margin: var(--s-5) 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.ds-bar { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-4); background: #1d2530; }
.ds-leds { display: grid; gap: 6px; }
.ds-led { display: flex; align-items: center; gap: var(--s-2); font-size: .8rem; color: #c7d2df; }
.ds-led i { width: 13px; height: 13px; border-radius: 4px; background: #4a2b2b; box-shadow: inset 0 0 0 1px #00000055; }
.ds-led.on i { background: #35c463; box-shadow: 0 0 8px #35c46388; }
.ds-led.off i { background: #e0574c; box-shadow: 0 0 8px #e0574c66; }
.ds-ops { display: grid; gap: 6px; text-align: right; }
.ds-cap { font-family: var(--font-display); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: #8798a8; margin-right: var(--s-2); }
.ds-mode, .ds-state { font-size: .84rem; color: #e6edf3; }
.ds-state-v.en { color: #35c463; }
.ds-state-v.dis { color: #e0574c; }
.ds-console { padding: var(--s-3) var(--s-4); background: #141a22; border-top: 1px solid #2a3441; }
.ds-console pre { margin-top: 4px; font-family: var(--font-mono, monospace); font-size: .78rem; color: #d5b06b; white-space: pre-wrap; overflow-wrap: anywhere; }
.ds-quiz { padding: var(--s-4); }
.ds-situation { font-size: .93rem; color: var(--text-soft); }
.ds-choices { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.ds-choice { padding: var(--s-2) var(--s-4); font: inherit; font-size: .86rem; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.ds-choice:hover { border-color: var(--ocean-400); }
.ds-choice.right { border-color: var(--good); background: var(--good-bg); }
.ds-choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.ds-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-3); }
.ds-pos { font-size: .78rem; color: var(--text-muted); }

/* =========================================================== CAN ID map ==
   Assign IDs, get told about duplicates and reserved numbers. Unit 2. */
.canid { margin: var(--s-5) 0; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.ci-row { display: grid; grid-template-columns: max-content 1fr 84px; gap: var(--s-3); align-items: center; padding: var(--s-2) var(--s-3); border: 1.5px solid transparent; border-radius: var(--r-md); }
.ci-row + .ci-row { margin-top: 6px; }
.ci-name { font-weight: 600; color: var(--ink); font-size: .93rem; }
.ci-hint { font-size: .78rem; color: var(--text-muted); }
.ci-input { width: 100%; padding: 6px var(--s-3); font: inherit; font-family: var(--font-mono); font-size: .9rem; text-align: center; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); }
.ci-input:focus { outline: none; border-color: var(--ocean-500); }
.ci-row.ok { border-color: var(--good); background: var(--good-bg); }
.ci-row.bad { border-color: var(--bad); background: var(--bad-bg); }
.canid .challenge-actions { margin-top: var(--s-3); }
@media (max-width: 480px){
  .ci-row { grid-template-columns: 1fr 76px; }
  .ci-hint { grid-column: 1 / -1; order: 3; }
}

/* ============================================================= file tree ==
   Clickable project map for Unit 3. Depth is set from data-depth. */
.ftree { margin: var(--s-5) 0; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.ft-row { display: flex; gap: var(--s-3); align-items: center; justify-content: space-between; width: 100%; padding: 7px var(--s-3); padding-left: calc(var(--s-3) + var(--ft-depth, 0) * 20px); font: inherit; text-align: left; background: none; border: 1.5px solid transparent; border-radius: var(--r-md); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.ft-row:hover { background: var(--surface); border-color: var(--line); }
.ft-row.sel { background: var(--surface); border-color: var(--ocean-500); }
.ft-name { font-family: var(--font-mono); font-size: .87rem; color: var(--ocean-800); overflow-wrap: anywhere; }
.ft-badge { flex: 0 0 auto; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ft-often { background: var(--good-bg); color: var(--good); }
.ft-rarely { background: var(--surface-sunken, var(--surface)); color: var(--text-muted); }
.ft-never { background: var(--bad-bg); color: var(--bad); }
.ft-folder { background: var(--surface-sunken, var(--surface)); color: var(--ocean-700); }
.ft-copy { background: var(--surface-sunken, var(--surface)); color: var(--ocean-700); }
.ft-panel { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); min-height: 3.4em; display: flex; flex-direction: column; gap: .2em; border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface); font-size: .9rem; color: var(--text-soft); }
.ft-panel.show { border-style: solid; border-color: var(--ocean-300); }
.ft-panel b { font-family: var(--font-mono); font-size: .84rem; color: var(--ocean-700); }
.ft-panel .ft-hint { color: var(--text-muted); font-size: .84rem; }
@media (max-width: 560px){
  .ft-row { flex-wrap: wrap; gap: 4px; }
  .ft-badge { font-size: .6rem; }
}
