/*
 * The course flow (src/course-views.ts): a week's objectives and stepper, the
 * step bar on guides, the weekly self-check, Continue, the modules card, and
 * the timeline's module bars and self-check dots. On site.css's tokens and
 * card scale, so light, dark and every palette work. Motion is small and
 * goes away with prefers-reduced-motion.
 */

/* ---- objectives ---- */
.cf-obj { margin: 0 0 var(--stack); padding: var(--card-pad); border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--bg-soft); }
.cf-obj-h { margin: 0 0 12px; font-size: var(--card-title); font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.cf-obj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cf-obj-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; font-size: 16px; line-height: 1.55; color: var(--text-body); }
.cf-obj-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; background: var(--primary-soft); color: var(--link); }
.cf-obj code, .cf-check code { padding: 1px 5px; border-radius: 4px; background: var(--bg-muted); color: var(--text); font-size: 0.86em; overflow-wrap: anywhere; }
.cf-obj code { background: var(--bg); }
/* On a guide: the same, quieter and smaller, under the header. */
.cf-obj-compact { margin: 24px 0 0; padding: 14px 16px; background: none; }
.cf-obj-compact .cf-obj-h { margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.cf-obj-compact .cf-obj-h a { color: inherit; text-decoration: none; }
.cf-obj-compact .cf-obj-h a:hover { color: var(--link); }
.cf-obj-compact .cf-obj-list { gap: 6px; }
.cf-obj-compact .cf-obj-list li { grid-template-columns: 18px minmax(0, 1fr); gap: 10px; font-size: 15px; }
.cf-obj-compact .cf-obj-dot { width: 18px; height: 18px; margin-top: 3px; }

/* ---- the week's stepper ---- */
.cf-stepper { margin: 0 0 var(--stack); }
.cf-stepper-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }
.cf-stepper-h { font-size: var(--h3); font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.cf-steps { list-style: none; margin: 0; padding: 0; display: grid; }
.cf-step { position: relative; }
.cf-step a { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 14px; min-height: 56px; padding: 8px 10px 8px 6px; border-radius: 10px; color: var(--text); text-decoration: none; }
.cf-step a:hover { background: var(--bg-soft); }
.cf-step a:hover .cf-step-title { color: var(--link); }
.cf-step a:focus-visible { outline-offset: -2px; }
/* The line joining the circles: down on phones, across on wider screens. */
.cf-step:not(:last-child)::after { content: ''; position: absolute; left: 21px; top: 44px; bottom: -12px; width: 2px; background: var(--line); }
.cf-step.is-done:not(:last-child)::after { background: var(--ok-line); }
.cf-step-n { position: relative; z-index: 1; display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--bg); color: var(--text-dim); font: 600 14px/1 var(--mono); }
.cf-step-n svg { display: none; }
.cf-step.is-done .cf-step-n { border-color: var(--ok-fg); background: var(--ok-fg); color: var(--bg); }
.cf-step.is-done .cf-step-n svg { display: block; }
.cf-step.is-done .cf-step-num { display: none; }
.cf-step.is-next .cf-step-n { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); box-shadow: 0 0 0 4px var(--primary-soft); }
.cf-step.is-check:not(.is-done):not(.is-next) .cf-step-n { border-style: dashed; }
.cf-step-text { display: grid; gap: 1px; min-width: 0; }
.cf-step-label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.cf-step.is-next .cf-step-label { color: var(--link); }
.cf-step-title { font-size: 15px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.cf-step.is-done .cf-step-title { color: var(--text-body); }
@media (min-width: 760px) {
  .cf-steps { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
  .cf-step a { grid-template-columns: 1fr; align-content: start; justify-items: start; gap: 10px; min-height: 0; padding: 4px 8px 10px 0; }
  .cf-step a:hover { background: none; }
  .cf-step:not(:last-child)::after { left: 40px; right: 8px; top: 19px; bottom: auto; width: auto; height: 2px; }
}

/* ---- the step bar on a guide ---- */
.cf-walk.is-tucked .cf-walk-inner { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .cf-walk .cf-walk-inner { transition: opacity .2s; } }
.cf-walk { position: sticky; bottom: 0; z-index: 20; margin: var(--stack) calc(-1 * var(--gutter)) 0; padding: 0 0 env(safe-area-inset-bottom); pointer-events: none; }
.cf-walk-inner {
  transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s;
  pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 8px var(--gutter);
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
}
.cf-walk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--text); font-size: 15px; font-weight: 500; text-decoration: none; flex-shrink: 0; }
.cf-walk-btn:hover { border-color: var(--text-dim); }
.cf-walk-next { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.cf-walk-next:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.cf-back { transform: scaleX(-1); }
.cf-walk-word { display: none; }
.cf-walk-mid { display: grid; gap: 6px; flex: 1; min-width: 0; padding: 0 4px; }
.cf-walk-where { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 14px; line-height: 1.3; color: var(--text-dim); }
.cf-walk-where strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cf-walk-where a { color: inherit; }
.cf-segs { display: flex; gap: 4px; max-width: 220px; }
.cf-seg { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.cf-seg.is-done { background: var(--ok-fg); }
.cf-seg.is-here { background: var(--primary); }
.cf-walk:has(input[data-task]:checked) .cf-seg.is-here { background: var(--ok-fg); }
.cf-walk-done { display: inline-flex; align-items: center; flex-shrink: 0; font-size: 14px; font-weight: 500; color: var(--text-body); }
.cf-walk-done .task-check { margin: 0 -4px 0 0; }
.cf-walk-done-word { display: none; }
@media (min-width: 640px) {
  .cf-walk { margin-left: 0; margin-right: 0; padding-bottom: 16px; }
  .cf-walk-inner { max-width: 44rem; margin: 0 auto; padding: 8px; border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
  .cf-walk-word { display: inline; }
  .cf-walk-btn { padding: 0 16px; }
  .cf-walk-done-word { display: inline; margin-right: 6px; }
}

/* ---- the slot for a guide's visual (src/visuals.ts) ---- */
.cf-visual { margin: 24px 0 0; }

/* ---- the weekly self-check ---- */
.cf-check { margin-top: var(--stack); padding: 24px 20px; border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--bg); scroll-margin-top: 24px; }
@media (min-width: 640px) { .cf-check { padding: 28px 32px; } }
.cf-check-head .eyebrow { margin-bottom: 6px; color: var(--link); }
.cf-check-title { font-size: var(--h2); font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.cf-check-sub { margin-top: 6px; font-size: 15px; color: var(--text-dim); }
.cf-best { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 1px 10px; border-radius: 999px; background: var(--bg-muted); color: var(--text-body); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cf-best svg { color: var(--ok-fg); }
.cf-qs { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 24px; }
.cf-q fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.cf-q legend { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding: 0; margin-bottom: 12px; font-size: 17px; font-weight: 500; line-height: 1.5; color: var(--text); }
.cf-q-n { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-top: 0; border-radius: 50%; background: var(--bg-muted); color: var(--text-body); font: 600 13px/1 var(--mono); }
.cf-q.is-right .cf-q-n { background: var(--ok-bg); color: var(--ok-fg); }
.cf-q.is-wrong .cf-q-n { background: var(--warn-bg); color: var(--warn-fg); }
.cf-opts { display: grid; gap: 8px; padding-left: 38px; }
.cf-opt { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text-body); font-size: 16px; line-height: 1.45; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.cf-opt:hover { border-color: var(--line-strong); }
.cf-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.cf-opt-mark { display: grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid var(--line-strong); border-radius: 50%; color: transparent; background: var(--bg); transition: background-color 0.15s, border-color 0.15s; }
.cf-opt input:checked + .cf-opt-mark { border: 6px solid var(--primary); }
.cf-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.cf-opt input:focus-visible + .cf-opt-mark { outline: 2px solid var(--primary); outline-offset: 2px; }
.cf-opt-text { min-width: 0; overflow-wrap: anywhere; }
/* Answered: the right option goes green with a tick; a wrong pick goes amber. Never red: it is a check, not a test. */
.cf-q[data-done] .cf-opt, .cf-q.is-right .cf-opt, .cf-q.is-wrong .cf-opt { cursor: default; }
.cf-opt.is-answer, .cf-opt.is-answer:has(input:checked) { border-color: var(--ok-line); background: var(--ok-bg); color: var(--text); }
.cf-opt.is-answer .cf-opt-mark, .cf-opt.is-answer input:checked + .cf-opt-mark { border: 0; background: var(--ok-fg); color: var(--bg); }
.cf-opt.is-picked:not(.is-answer) { border-color: var(--warn-line); background: var(--warn-bg); color: var(--text); }
.cf-opt.is-picked:not(.is-answer) .cf-opt-mark, .cf-opt.is-picked:not(.is-answer) input:checked + .cf-opt-mark { border: 6px solid var(--warn-fg); }
.cf-q:is(.is-right, .is-wrong) .cf-opt:not(.is-answer):not(.is-picked) { opacity: 0.6; }
.cf-why { margin: 12px 0 0 38px; padding: 12px 14px; border-left: 3px solid var(--line-strong); background: var(--bg-soft); font-size: 15px; line-height: 1.6; color: var(--text-body); }
.cf-q.is-right .cf-why { border-left-color: var(--ok-fg); }
.cf-q.is-wrong .cf-why { border-left-color: var(--warn-fg); }
.cf-verdict { color: var(--text); font-weight: 600; }
.cf-check-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 24px; }
.cf-result { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); text-align: center; }
.cf-result:focus { outline: none; }
.cf-score { font-size: clamp(30px, 4vw, 38px); font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.cf-score-line { margin-top: 4px; font-size: 16px; color: var(--text-body); }
.cf-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 20px; }
.cf-saved { margin-top: 14px; }
.cf-xp { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); font-weight: 600; }
@media (max-width: 520px) {
  .cf-opts, .cf-why { padding-left: 0; margin-left: 0; }
  .cf-result-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .cf-why:not([hidden]), .cf-result:not([hidden]) { animation: cf-in 0.24s ease-out; }
  @keyframes cf-in { from { opacity: 0; transform: translateY(-3px); } }
}

/* ---- Continue ---- */
.cf-continue { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 20px 0 8px; }
.cf-continue-btn { max-width: 100%; min-width: 0; }
.cf-continue-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cf-continue-where { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---- modules ---- */
.cf-mods { list-style: none; margin: 0; padding: 0; display: grid; }
.cf-mods li + li { border-top: 1px solid var(--line); }
.cf-mods a { display: grid; grid-template-columns: 28px minmax(0, 1fr) 3.25rem; align-items: center; gap: 14px; min-height: 60px; padding: 10px 0; color: var(--text); text-decoration: none; }
.cf-mods a:hover .cf-mod-title { color: var(--link); }
.cf-mod-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-muted); color: var(--text-dim); font: 600 13px/1 var(--mono); }
.cf-mods .is-started .cf-mod-n { background: var(--primary-soft); color: var(--link); }
.cf-mods .is-done .cf-mod-n { background: var(--ok-bg); color: var(--ok-fg); }
.cf-mod-main { display: grid; gap: 6px; min-width: 0; }
.cf-mod-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.cf-mod-meta { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.cf-mod-pct { text-align: right; font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.cf-bar { display: block; height: 4px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
.cf-bar > span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--primary); }
.cf-mods .is-done .cf-bar > span { background: var(--ok-fg); }

/* ---- the timeline: a phase's percent in its sticky header, a week's self-check dot, its objectives ---- */
.tl-phase-head .tl-phase-text { flex: 1; }
.tl-mod { display: grid; grid-template-columns: minmax(64px, 120px) 3rem; align-items: center; gap: 10px; flex-shrink: 0; }
.tl-mod .cf-bar { height: 5px; }
.tl-mod-pct { text-align: right; font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.tl-status { gap: 6px; align-items: center; }
.tl-sc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.tl-sc.is-perfect { background: var(--ok-fg); }
.tl-obj { list-style: none; margin: 0; padding: 0 0 4px; display: grid; gap: 4px; }
.tl-obj li { position: relative; padding-left: 16px; font-size: 15px; line-height: 1.55; color: var(--text-body); }
.tl-obj li::before { content: ''; position: absolute; left: 2px; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.tl-obj-h { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.tl-obj code { font-size: 0.86em; }
@media (max-width: 599px) {
  .tl-mod { grid-template-columns: 56px 2.5rem; gap: 8px; }
  .tl-mod-pct { font-size: 14px; }
}

@media print {
  .cf-walk { display: none; }
}
