/* Code page — in-browser Python playground (editor + console + tasks). */

/* ---- Lesson prose (rendered markdown) ---- */
.code-prose h2 { font-size: 1.5rem; font-weight: 600; color: #e2e8f0; margin: 1.7rem 0 .6rem; }
.code-prose h3 { font-size: 1.25rem; font-weight: 600; color: #cbd5e1; margin: 1.3rem 0 .45rem; }
.code-prose p { margin: .9rem 0; }
.code-prose ul, .code-prose ol { margin: .9rem 0 .9rem 1.5rem; list-style: revert; }
.code-prose li { margin: .4rem 0; }
.code-prose strong { color: #f1f5f9; }
/* Links in lesson prose (the usage → setup cross-reference, resource links). The
   lesson page has no [data-course], so --accent-rgb is unset here — use a fixed
   sky accent rather than the per-course variable. */
.code-prose a {
  color: #7dd3fc;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(125, 211, 252, .5);
  transition: color .15s ease, text-decoration-color .15s ease;
}
.code-prose a:hover { color: #bae6fd; text-decoration-color: #bae6fd; }
/* Lesson images (markdown ![](…)). Wide self-drawn SVGs (intrinsic ~720px) scale to
   the column; small logos keep their intrinsic size. Centered as their own block. */
.code-prose img {
  display: block;
  margin: 1.4rem auto;
  max-width: 100%;
  max-height: 18rem;
  height: auto;
  border-radius: 0.75rem;
}
/* A paragraph holding several images → a centered logo strip (not stacked blocks). */
.code-prose p:has(img + img) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  margin: 1.4rem 0;
}
.code-prose p:has(img + img) img { display: inline-block; margin: 0; max-height: 2.6rem; width: auto; border-radius: 0; }
/* `![alt](src)` immediately followed by `*caption*` → an em caption under the image. */
.code-prose img + em {
  display: block;
  margin: -0.6rem auto 0;
  text-align: center;
  font-style: normal;
  font-size: 0.8rem;
  color: #94a3b8;
}
/* Inline Lucide icons from the {icon:NAME} shortcode (e.g. on section headings) —
   the same icon set the Know page uses. Sized to the surrounding text, accent-tinted. */
.code-prose .code-ico {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.16em;
  margin-right: 0.42em;
  color: #7dd3fc;
}
.code-prose code {
  background: rgba(148, 163, 184, .16);
  padding: .08em .35em;
  border-radius: .3rem;
  font-size: .92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.code-prose pre {
  background: #0b1020;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: .6rem;
  padding: .7rem .9rem;
  overflow-x: auto;
  margin: .6rem 0;
  font-size: 15px;     /* keep code compact; don't inherit the larger prose body size */
  line-height: 1.5;    /* and not the airy prose line-height */
}
.code-prose pre code { background: none; padding: 0; }
/* Highlighted example blocks: code-playground.js tags the <pre> with cm-s-exercise
   and fills the <code> with cm-* token spans via CodeMirror.runMode, reusing the
   editor palette below. This sets the base (untokenized) text to the editor's. */
.code-prose pre.cm-s-exercise code { color: #e2e8f0; }

.code-task-prompt code {
  background: rgba(148, 163, 184, .16);
  padding: .08em .35em;
  border-radius: .3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- Editor (CodeMirror 5 replaces the textarea) ---- */
.code-editor { display: none; }
.code-task .CodeMirror {
  margin-top: .85rem;   /* CodeMirror replaces the <textarea> and drops its mt-3, so add the gap here */
  height: auto;
  min-height: 5.5rem;
  border-radius: .6rem;
  border: 1px solid rgba(148, 163, 184, .18);
  font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.code-task .CodeMirror-scroll { min-height: 5.5rem; }

/* ---- Editor theme "exercise": calm dark, matched to the site (replaces Dracula) ---- */
/* codemirror.css defaults to a WHITE editor + #f7f7f7 gutter — the wrapper and gutter
   backgrounds MUST be set here, or dropping Dracula would render the editor bright. */
.cm-s-exercise.CodeMirror { background: #0b1020; color: #e2e8f0; }
.cm-s-exercise .CodeMirror-gutters { background: #0b1020; border: none; }
.cm-s-exercise .CodeMirror-linenumber { color: #4b5872; }
.cm-s-exercise .CodeMirror-cursor { border-left: 1px solid #67e8f9; }
.cm-s-exercise .CodeMirror-selected { background: rgba(99, 102, 241, .3); }
.cm-s-exercise.CodeMirror-focused .CodeMirror-selected { background: rgba(99, 102, 241, .3); }
.cm-s-exercise .CodeMirror-line::selection,
.cm-s-exercise .CodeMirror-line > span::selection,
.cm-s-exercise .CodeMirror-line > span > span::selection { background: rgba(99, 102, 241, .35); }
.cm-s-exercise .CodeMirror-activeline-background { background: rgba(255, 255, 255, .025); }
.cm-s-exercise .CodeMirror-matchingbracket { color: #67e8f9 !important; text-decoration: underline; }
.cm-s-exercise .cm-comment { color: #76859f; font-style: italic; }
.cm-s-exercise .cm-keyword { color: #c4b5fd; }
.cm-s-exercise .cm-builtin { color: #7dd3fc; }
.cm-s-exercise .cm-def { color: #67e8f9; }
.cm-s-exercise .cm-variable { color: #e2e8f0; }
.cm-s-exercise .cm-variable-2 { color: #cbd5e1; }
.cm-s-exercise .cm-variable-3, .cm-s-exercise .cm-type { color: #7dd3fc; }
.cm-s-exercise .cm-property { color: #93c5fd; }
.cm-s-exercise .cm-operator { color: #94a3b8; }
.cm-s-exercise .cm-string { color: #86efac; }
.cm-s-exercise .cm-string-2 { color: #86efac; }
.cm-s-exercise .cm-number { color: #fcd34d; }
.cm-s-exercise .cm-atom { color: #c4b5fd; }
.cm-s-exercise .cm-meta { color: #94a3b8; }
.cm-s-exercise .cm-bracket { color: #94a3b8; }
.cm-s-exercise .cm-error { color: #fca5a5; }

/* ---- Toolbar buttons ---- */
.code-btn {
  border-radius: 9999px;
  padding: .35rem .9rem;
  font-size: .8rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  cursor: pointer;
  transition: background .15s, color .15s, opacity .15s;
}
.code-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .12); color: #fff; }
.code-btn:disabled { opacity: .4; cursor: not-allowed; }
/* Keyboard focus ring — matches .code-continue / .code-example-run so every
   control in the playground shares one focus style (these pills otherwise fell
   back to the UA default outline). */
.code-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(34, 211, 238, .6); }
.code-btn-primary { background: rgba(34, 211, 238, .16); color: #67e8f9; border-color: rgba(34, 211, 238, .3); }
.code-btn-primary:hover:not(:disabled) { background: rgba(34, 211, 238, .26); color: #a5f3fc; }
.code-btn-check { background: rgba(99, 102, 241, .16); color: #c7d2fe; border-color: rgba(99, 102, 241, .3); }
.code-btn-check:hover:not(:disabled) { background: rgba(99, 102, 241, .26); color: #e0e7ff; }
.code-btn-hint { background: rgba(251, 191, 36, .16); color: #fcd34d; border-color: rgba(251, 191, 36, .32); }
.code-btn-hint:hover:not(:disabled) { background: rgba(251, 191, 36, .26); color: #fde68a; }

/* Icon-only run/stop/reset buttons — the symbol replaces the text label; the
   localized word lives in title/aria-label. Same vertical height as the text
   Check button keeps the toolbar row aligned. */
.code-run, .code-stop, .code-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .35rem .55rem;
}
.code-run svg, .code-stop svg, .code-reset svg { width: 17px; height: 17px; display: block; }

/* Hint is icon-only (lightbulb → spinner while loading); Check keeps its text but
   gains a leading checkmark, so both use inline-flex with a small leading icon. */
.code-hint { display: inline-flex; align-items: center; justify-content: center; padding: .35rem .55rem; }
.code-check { display: inline-flex; align-items: center; gap: .35rem; }
.code-hint svg, .code-check svg { width: 17px; height: 17px; display: block; }
.code-hint .icon-spinner { display: none; }
.code-hint.is-loading .icon-hint { display: none; }
.code-hint.is-loading .icon-spinner { display: block; animation: code-spin .7s linear infinite; }
@keyframes code-spin { to { transform: rotate(1turn); } }

/* ---- Console ---- */
.code-console {
  background: #05070f;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: .6rem;
  padding: .6rem .8rem;
  min-height: 2.5rem;
  max-height: 16rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-console-empty { color: #475569; font-style: italic; }
/* Output is appended as inline spans whose text carries its own newlines; the
   console <pre> (white-space: pre-wrap) renders the breaks. The inline input is
   appended after the last span, so a newline-less prompt keeps it on the same
   line — like a local terminal. */
.code-out  { color: #cbd5e1; }
.code-err  { color: #fca5a5; }
.code-sys  { color: #64748b; font-style: italic; }
.code-echo { color: #67e8f9; }
.code-console-input {
  display: inline;
  width: 24ch;
  max-width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #e2e8f0;
  font: inherit;
  caret-color: #22d3ee;
}

/* ---- Check result ---- */
.code-result { border-radius: .6rem; padding: .55rem .8rem; font-size: .82rem; }
.code-result-pending { color: #94a3b8; }
.code-result-pass { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .35); color: #86efac; }
.code-result-fail { background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .3); color: #fca5a5; }
.code-result-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: #e2e8f0; margin-top: .25rem; white-space: pre-wrap; }
.code-result-label { color: #94a3b8; }
/* Multi-line SQL result grid in the check result box (expected vs got). */
.code-result-grid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: #e2e8f0; white-space: pre; overflow-x: auto; margin: .15rem 0 .4rem; padding: .35rem .55rem; background: rgba(2, 6, 23, .5); border-radius: .35rem; }
/* First-difference highlight in a stdout "expected vs got" line: the run of
   characters from where the two strings diverge. The underline makes a
   highlighted *space* visible too (so a comma-vs-space difference is obvious). */
.code-diff-hl {
  border-radius: .15rem;
  padding: 0 .05rem;
  background: rgba(248, 113, 113, .3);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, .45);
  text-decoration: underline;
  text-decoration-color: rgba(254, 202, 202, .85);
  text-underline-offset: 2px;
}
/* dom (HTML/CSS) check result: a ✓/✗ requirements checklist — a friendly to-do
   list shown on pass AND fail, so the beginner sees partial progress, not a diff. */
.code-check-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.code-check-item { display: flex; align-items: flex-start; gap: .45rem; font-size: .9rem; line-height: 1.45; margin-top: .28rem; color: #cbd5e1; }
.code-check-mark { flex: none; width: 1.05rem; text-align: center; font-weight: 700; }
.code-check-item.is-ok .code-check-mark { color: #86efac; }
.code-check-item.is-no .code-check-mark { color: #fca5a5; }
.code-check-item.is-no { color: #fecdd3; }

/* ---- Hint panel (AI-generated, sits below the result box) ---- */
.code-hint-panel { border-radius: .6rem; padding: .55rem .8rem; font-size: .85rem; line-height: 1.5; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .22); color: #fde9b8; }
.code-hint-panel.code-hint-pending { background: none; border-color: transparent; color: #94a3b8; }
.code-hint-panel.code-hint-fail { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); color: #fca5a5; }
.code-hint-panel p { margin: 0 0 .45rem; }
.code-hint-panel p:last-child { margin-bottom: 0; }
.code-hint-panel ul, .code-hint-panel ol { margin: .1rem 0 .45rem; padding-left: 1.2rem; }
.code-hint-panel li { margin: .12rem 0; }
.code-hint-panel code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; background: rgba(2, 6, 23, .45); padding: .05rem .3rem; border-radius: .25rem; }
.code-hint-panel strong { color: #fef3c7; }

/* ---- Completed task ---- */
.code-task.code-done { border-color: rgba(34, 197, 94, .35); }

/* ---- Modern-browser guard ---- */
.code-runtime-warning {
  border-radius: .6rem;
  padding: .7rem .9rem;
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .3);
  color: #fca5a5;
  font-size: .85rem;
}

/* ---- Runnable examples in lesson prose (```python blocks) ---- */
/* Prefixed with .code-prose so these win over the generic .code-prose pre rules. */
.code-prose .code-example { position: relative; margin: .6rem 0; }
.code-prose .code-example > pre { margin: 0; }

.code-example-run {
  position: absolute;
  bottom: .6rem;   /* ≈ centered on the last code line (sits just above the bottom padding) */
  right: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9999px;
  background: rgba(11, 16, 32, .82);   /* near the code-block bg, opaque enough to sit over code */
  color: #67e8f9;
  border: 1px solid rgba(148, 163, 184, .22);
  cursor: pointer;
  opacity: .85;
  transition: opacity .15s, background .15s, color .15s, border-color .15s;
}
.code-example-run:hover:not(:disabled) { opacity: 1; background: rgba(34, 211, 238, .28); color: #a5f3fc; border-color: rgba(34, 211, 238, .4); }
.code-example-run:disabled { opacity: .3; cursor: not-allowed; }
.code-example-run:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(34, 211, 238, .6); }
.code-example-run .icon-play, .code-example-run .icon-stop { width: 15px; height: 15px; display: block; }
.code-example-run .icon-stop { display: none; }
.code-example-run.is-running { background: rgba(11, 16, 32, .82); color: #fca5a5; border-color: rgba(248, 113, 113, .45); }
.code-example-run.is-running .icon-play { display: none; }
.code-example-run.is-running .icon-stop { display: block; }

.code-prose .code-example-output {
  margin: -.1rem 0 .8rem;
  background: #070b16;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: .6rem;
  padding: .5rem .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
  overflow: auto;
}
.code-prose .code-example-output::before {
  content: attr(data-label);
  display: block;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #475569;
  margin-bottom: .3rem;
}

/* ---- HTML/CSS live preview (iframe) ----
   The task preview (replaces the console on html lessons) and the auto-rendered
   preview under each prose ```html example. White canvas (a rendered page expects
   light); code-html.js auto-sizes the height to the content after each render, so
   the heights below are just the pre-render default. */
.code-preview {
  display: block;
  width: 100%;
  height: 9rem;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: .6rem;
  background: #ffffff;
}

/* LaTeX compiled-PDF preview pane (code-latex.js paints into it). */
.code-pdf {
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: .6rem;
  background: #0b0f1a;
  padding: .55rem;
  max-height: 32rem;
  overflow: auto;
}
.code-pdf-empty, .code-pdf-pending {
  display: block;
  padding: 1.4rem .8rem;
  text-align: center;
  color: #64748b;
  font-size: .85rem;
}
.code-pdf-pending { color: #94a3b8; }
.code-pdf-bar { display: flex; justify-content: flex-end; margin-bottom: .5rem; }
.code-pdf-download {           /* lesson page has no [data-course] accent — use a fixed sky */
  font-size: .78rem;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: .4rem;
  padding: .2rem .6rem;
  transition: background .15s ease;
}
.code-pdf-download:hover { background: rgba(56, 189, 248, .14); }
.code-pdf-pages { display: flex; flex-direction: column; gap: .55rem; align-items: center; }
.code-pdf-page {            /* a server-rasterized page PNG */
  display: block;
  width: 100%;
  height: auto;
  border-radius: .25rem;
  box-shadow: 0 2px 14px -4px rgba(0, 0, 0, .7);
}
.code-pdf-error {
  margin: 0;
  padding: .6rem .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #fda4af;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-prose .code-example-preview {
  display: block;
  width: 100%;
  height: 8rem;
  margin: -.1rem 0 .8rem;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: .6rem;
  background: #ffffff;
}

/* ---- Lesson layout + step-through (progressive disclosure) ---- */
/* Narrow, centered reading column so lines stay short (ESL readability). */
.code-lesson { max-width: 42rem; margin-inline: auto; }
.code-step { scroll-margin-top: 5rem; }     /* auto-scroll clears the sticky header */
.code-step:focus { outline: none; }          /* programmatic focus on reveal — no ring on the section */
.code-step + .code-step { margin-top: 1.5rem; }

.code-continue-wrap { display: flex; align-items: center; justify-content: space-between; margin-top: 1.5rem; }
.code-continue {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border-radius: 9999px;
  padding: .5rem 1.15rem;
  font-size: .95rem;
  font-weight: 600;
  color: #67e8f9;
  background: rgba(34, 211, 238, .16);
  border: 1px solid rgba(34, 211, 238, .35);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.code-continue:hover { background: rgba(34, 211, 238, .26); color: #a5f3fc; border-color: rgba(34, 211, 238, .5); }
.code-continue:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(34, 211, 238, .6); }
.code-continue svg { width: 15px; height: 15px; }

/* Back — a subtle ghost button (no fill, no border) so Continue is the only CTA. */
.code-back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .5rem .35rem;
  font-size: .9rem;
  font-weight: 500;
  color: #94a3b8;           /* slate-400 — muted, matches the lesson-nav links */
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color .15s;
}
.code-back:hover { color: #e2e8f0; }
.code-back:focus-visible { outline: none; border-radius: 6px; box-shadow: 0 0 0 2px rgba(148, 163, 184, .5); }
.code-back svg { width: 14px; height: 14px; }
/* The reveal engine toggles the [hidden] attribute on these to hide Back on the
   first step and Continue on the last. The display rules above have the same
   specificity as [hidden]{display:none} but come later, so they'd win and leave a
   dead button on screen — re-assert [hidden] with a higher-specificity guard. */
.code-continue[hidden], .code-back[hidden] { display: none; }

/* ---- Landing index: per-course accent lesson cards ----
   Mirrors the .practice-card system in 06-landing.css: one --accent-rgb var per
   course (set on the [data-course] wrapper so the section label inherits it too)
   drives the badge, label, hover border/gradient, chevron, and focus ring. The
   neutral glass base stays on the card via Tailwind utilities; only accent-driven
   bits + the glass/gloss polish live here. */
/* Cool palette (cyan→blue→indigo→violet→sky, matching the hero gradient and the
   site's space theme) — warm/green accents clashed with the dark-blue background. */
[data-course]                 { --accent-rgb: 34, 211, 238; }   /* default cyan */
[data-course="python-basics"] { --accent-rgb: 34, 211, 238; }   /* cyan */
[data-course="a-level-cs"]    { --accent-rgb: 96, 165, 250; }   /* blue */
[data-course="ap-csp"]        { --accent-rgb: 129, 140, 248; }  /* indigo */
[data-course="ap-csa"]        { --accent-rgb: 167, 139, 250; }  /* violet */
[data-course="c-basics"]      { --accent-rgb: 56, 189, 248; }   /* sky */
[data-course="sql-databases"] { --accent-rgb: 45, 212, 191; }   /* teal */
[data-course="web-basics"]    { --accent-rgb: 192, 132, 252; }  /* purple — HTML/CSS (cool, nebula-like; orange would clash with the dark-blue bg) */
[data-course="latex"]         { --accent-rgb: 52, 211, 153; }   /* emerald — LaTeX / typesetting (Overleaf-ish green) */
[data-course="linux"]         { --accent-rgb: 251, 191, 36; }   /* amber — Linux / the terminal */
[data-course="cyber-security"]{ --accent-rgb: 244, 63, 94; }    /* rose — security */
[data-course="practice-python"] { --accent-rgb: 34, 211, 238; }   /* cyan — Python */
[data-course="practice-java"]   { --accent-rgb: 167, 139, 250; }  /* violet — Java (matches ap-csa) */
[data-course="practice-c"]      { --accent-rgb: 56, 189, 248; }   /* sky — C (matches c-basics) */

/* Course icon tile in the card header — accent-tinted (mirrors .practice-card-icon-bg, which
   isn't loaded on /code). The header cascades --accent-rgb from [data-course]. */
.code-course-icon { background-color: rgba(var(--accent-rgb), .12); color: rgb(var(--accent-rgb)); }

/* Glossy frosted glass, tinted + glowing in each course's accent. Layers:
   1. a top-lit ACCENT gradient FILL — brightest top-left, fading down: the
      gloss/sheen, now carrying the course colour at rest (a flat fill looks matte).
   2. backdrop-filter blur + saturate — the page (starfield + gradient) frosts
      through, so the card is genuinely see-through, not a flat dark panel.
   3. an inset 1px top highlight — the bright specular edge that reads as glass.
   4. an outer accent GLOW (the 0 0 …-blur shadow) — soft at rest, bright on hover.
   5. a soft drop shadow — lifts the card off the background for depth.
   The `background` shorthand intentionally clears Tailwind's gradient; the
   `backdrop-filter` overrides Tailwind's backdrop-blur-sm (this stylesheet loads
   after the bundle). */
.code-card {
  background: linear-gradient(155deg, rgba(var(--accent-rgb), .12) 0%, rgba(var(--accent-rgb), .05) 46%, rgba(255, 255, 255, .025) 100%);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-color: rgba(var(--accent-rgb), .26);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .22), 0 0 16px -4px rgba(var(--accent-rgb), .34), 0 10px 26px -16px rgba(0, 0, 0, .7);
  transition: border-color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.code-card:hover {
  border-color: rgba(var(--accent-rgb), .62);
  background: linear-gradient(155deg, rgba(var(--accent-rgb), .26) 0%, rgba(var(--accent-rgb), .11) 50%, rgba(255, 255, 255, .035) 100%);
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .3), 0 0 30px -2px rgba(var(--accent-rgb), .6), 0 18px 38px -14px rgba(var(--accent-rgb), .5);
}
.code-card:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: 1px; }

/* Number square — a glossy, glowing accent glass chip: top-lit accent gradient
   fill, a bright inset top edge + accent ring, an outer accent glow, and a faint
   text-glow on the number. Glows harder with the card on hover. */
.code-card-badge {
  background: linear-gradient(150deg, rgba(var(--accent-rgb), .44) 0%, rgba(var(--accent-rgb), .16) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgb(var(--accent-rgb));
  text-shadow: 0 0 10px rgba(var(--accent-rgb), .45);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .35), inset 0 0 0 1px rgba(var(--accent-rgb), .42), 0 0 12px -2px rgba(var(--accent-rgb), .5);
  transition: background .18s ease, box-shadow .18s ease;
}
.code-card:hover .code-card-badge {
  background: linear-gradient(150deg, rgba(var(--accent-rgb), .58) 0%, rgba(var(--accent-rgb), .24) 100%);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .45), inset 0 0 0 1px rgba(var(--accent-rgb), .6), 0 0 18px 0 rgba(var(--accent-rgb), .7);
}
.code-card-sub { color: #94a3b8; }   /* slate-400 — lifted from slate-500 for readability */
.code-card-chevron { color: rgba(var(--accent-rgb), .55); transition: color .18s ease, transform .18s ease; }
.code-card:hover .code-card-chevron { color: rgb(var(--accent-rgb)); transform: translateX(2px); }

.code-course-label { color: rgb(var(--accent-rgb)); }   /* section label, colored to its block */

/* ---- Landing index: collapsible course accordion ----
   Each course is a <details> styled as a SUBTLE glass card — a faint neutral
   fill + a low-alpha accent border — so the header reads as a card without
   competing with the inner .code-card lesson tiles (avoid glass-on-glass). The
   accent (per [data-course]) colours the title, the lesson-count pill, and the
   chevron. No backdrop-filter here: the closed list is small and the subtle fill
   is enough; the frosted glass stays reserved for the lesson tiles. */
.code-course {
  background: linear-gradient(180deg, rgba(255, 255, 255, .05) 0%, rgba(255, 255, 255, .02) 100%);
  border-color: rgba(var(--accent-rgb), .2);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .04), 0 8px 24px -18px rgba(0, 0, 0, .8);
  transition: border-color .18s ease, background .18s ease;
}
/* Brighten the (rounded) card on header hover via :has, so the fill follows the
   border radius — a summary:hover background would square off the top corners
   since the <details> is intentionally not overflow-hidden. */
.code-course:has(> summary:hover) {
  border-color: rgba(var(--accent-rgb), .34);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .08) 0%, rgba(var(--accent-rgb), .03) 100%);
}
.code-course[open] { border-color: rgba(var(--accent-rgb), .3); }

.code-course-count {
  color: rgb(var(--accent-rgb));
  background: rgba(var(--accent-rgb), .12);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .24);
}
.code-course-chevron { color: rgba(var(--accent-rgb), .6); }
.code-course[open] .code-course-chevron,
.code-course:has(> summary:hover) .code-course-chevron { color: rgb(var(--accent-rgb)); }

/* ---- Landing index: Resources button + overlay ----
   The button sits in the header row, left of the lesson-count pill, and appears
   only once the course is unfolded. It carries the course accent (it's inside
   [data-course]); the <dialog> does too (it's a DOM child of <details data-course>,
   so --accent-rgb cascades even though showModal() promotes it to the top layer). */
.code-course-resources-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .55rem;
  border-radius: .375rem;
  font-size: .75rem;
  font-weight: 600;
  color: rgb(var(--accent-rgb));
  background: rgba(var(--accent-rgb), .12);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .24);
  transition: background .15s ease, box-shadow .15s ease;
}
.code-course-resources-btn:hover {
  background: rgba(var(--accent-rgb), .2);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .4);
}
.code-course-resources-btn:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: 1px; }
.code-course-resources-btn svg { width: .9rem; height: .9rem; }
/* "Appears when one unfolds the course" — hidden while collapsed. */
.code-course:not([open]) .code-course-resources-btn { display: none; }
@media (max-width: 480px) { .code-course-resources-label { display: none; } }

/* The unfolded content area is the positioning context for the Resources panel,
   so the panel overlays the lesson grid (not the whole viewport). */
.code-course-body { position: relative; }
.code-resources-pop {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 30;
  width: min(23rem, calc(100% - 1rem));
  max-height: min(70vh, 30rem);
  overflow-y: auto;
  padding: 1.1rem 1.15rem 1.2rem;
  border-radius: .9rem;
  color: #e2e8f0;
  /* Accent-tinted glass — the page/cards frost through behind it. */
  background: linear-gradient(162deg, rgba(var(--accent-rgb), .16) 0%, rgba(13, 21, 40, .9) 58%);
  backdrop-filter: blur(22px) saturate(155%);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
  border: 1px solid rgba(var(--accent-rgb), .34);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, .08),
              0 22px 48px -18px rgba(0, 0, 0, .8),
              0 0 36px -12px rgba(var(--accent-rgb), .4);
  /* Closed → unfolds from the button (top-right) on .is-open. */
  transform-origin: top right;
  transform: translateY(-8px) scale(.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.2, .8, .2, 1), visibility .2s;
}
.code-resources-pop.is-open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .code-resources-pop { transition: opacity .12s ease, visibility .12s; transform: none; }
}
.code-resources-close {
  position: absolute;
  top: .7rem;
  right: .7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: .5rem;
  color: rgba(148, 163, 184, .85);
  transition: background .12s ease, color .12s ease;
}
.code-resources-close:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.code-resources-close svg { width: 1rem; height: 1rem; }
.code-resources-title {
  font-family: "Sora", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0 1.75rem .9rem 0;     /* right margin clears the ✕ */
}
.code-resources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.code-resources-link {
  display: block;
  padding: .6rem .7rem;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  text-decoration: none;
  transition: background .14s ease, box-shadow .14s ease, transform .14s ease;
}
.code-resources-link:hover {
  background: rgba(var(--accent-rgb), .1);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .4);
  transform: translateY(-1px);
}
.code-resources-link:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: 1px; }
.code-resources-link-title {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  font-weight: 600;
  color: #e2e8f0;
}
.code-resources-link:hover .code-resources-link-title { color: #fff; }
.code-resources-ext { width: .8rem; height: .8rem; flex-shrink: 0; color: rgb(var(--accent-rgb)); }
.code-resources-note { display: block; margin-top: .15rem; font-size: .78rem; color: #94a3b8; }
.code-resources-seeall {
  display: inline-block;
  margin-top: 1rem;
  font-size: .82rem;
  font-weight: 600;
  color: rgb(var(--accent-rgb));
  text-decoration: none;
}
.code-resources-seeall:hover { filter: brightness(1.15); text-decoration: underline; text-underline-offset: 2px; }

/* ---- Landing index: Practice tracks (fixed button row + unfolding bodies) ----
   Three language buttons stay on one line in .code-practice-row; clicking one
   (aria-expanded) reveals its challenges full-width in .code-practice-bodies BELOW
   the row, independently — the other buttons never move. The buttons reuse the
   .code-course card surface; data-course carries the per-language --accent-rgb. */
.code-practice { margin-top: 2.5rem; }
.code-practice-head { margin-bottom: 1rem; max-width: 48rem; }
.code-practice-head h2 {
  font-family: "Sora", system-ui, sans-serif;
  font-size: 1.5rem; line-height: 2rem; font-weight: 600;
  letter-spacing: -0.015em; color: #fff;
}
.code-practice-head p { margin-top: .25rem; font-size: .875rem; line-height: 1.4rem; color: #94a3b8; }

/* Three buttons on one line, always (stack only on phones). */
.code-practice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  align-items: start;
}
@media (max-width: 640px) { .code-practice-row { grid-template-columns: 1fr; } }

/* The <button> reuses .code-course's card surface; these add the button reset plus
   the hover/open states .code-course normally gets from summary:hover and [open]
   (neither applies to a <button>). */
.code-practice-card {
  width: 100%; text-align: left; font: inherit; color: inherit;
  -webkit-appearance: none; appearance: none;
}
.code-practice-card:hover {
  border-color: rgba(var(--accent-rgb), .34);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .08) 0%, rgba(var(--accent-rgb), .03) 100%);
}
.code-practice-card[aria-expanded="true"] { border-color: rgba(var(--accent-rgb), .3); }
.code-practice-card[aria-expanded="true"] .code-course-chevron {
  transform: rotate(90deg); color: rgb(var(--accent-rgb));
}

/* Bodies unfold full-width below the row; only open ones show. Bespoke class (not
   Tailwind .hidden — see the layer gotcha); multiple may be open and stack here. */
.code-practice-bodies { margin-top: .75rem; display: flex; flex-direction: column; gap: .75rem; }
.code-practice-body { display: none; }
.code-practice-body.is-open { display: block; }

.code-practice-stars {
  margin-top: .15rem; font-size: .8rem; letter-spacing: .08em;
  color: #fbbf24;   /* amber-400 — difficulty stars read consistently across tracks */
  white-space: nowrap;
}

/* ---- Reference overlay ------------------------------------------------------
   The header "Reference" button opens this modal <dialog> in place (see
   code-playground.js). Mirrors the practice page's knowledge-base overlay
   (.handout-dialog* in eXam/practice_take.html) so the two read the same; the
   body wrapper .learn-content-body comes from the conditionally-loaded
   06-landing.css. Panel bg == .learn-content-body bg (rgb(3,9,26)) so the
   rendered handout has no visible edge inside the frame. */
.code-reference-dialog {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0; color: inherit;
  width: min(880px, 94vw); max-width: 94vw; max-height: 86vh; overflow-y: auto; scrollbar-gutter: stable;
  border-radius: 1.25rem;
  background: rgb(3, 9, 26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 70px -24px rgba(0, 0, 0, 0.72),
    0 0 100px -30px rgba(34, 211, 238, 0.15);
}
.code-reference-dialog::backdrop {
  background: rgba(1, 4, 14, 0.74);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  animation: code-ref-fade 0.2s ease;
}
.code-reference-dialog[open] { margin: auto; animation: code-ref-pop 0.24s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes code-ref-pop  { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes code-ref-fade { from { opacity: 0; } to { opacity: 1; } }
.code-reference-dialog-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.95rem 2rem 0.95rem 3rem; border-radius: 1.25rem 1.25rem 0 0;
  background: linear-gradient(to bottom, rgb(8, 16, 36), rgb(3, 9, 26));
}
.code-reference-dialog-head::after {
  content: ""; position: absolute; left: 3rem; right: 2rem; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12) 18%, rgba(255, 255, 255, 0.12) 82%, transparent);
}
.code-reference-dialog-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 1.65rem; height: 1.65rem; border-radius: 0.55rem;
  color: rgb(165, 243, 252); background: rgba(34, 211, 238, 0.10);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.22);
}
.code-reference-dialog-title { flex: 1 1 auto; }
.code-reference-dialog-body { padding: 1.15rem 2rem 1.75rem 3rem; }
.code-reference-dialog-close {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 1.85rem; height: 1.85rem; border-radius: 0.6rem;
  color: rgba(148, 163, 184, 0.85);
  background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}
.code-reference-dialog-close:hover { background: rgba(255, 255, 255, 0.09); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.code-reference-dialog-close:focus-visible { outline: 2px solid rgba(34, 211, 238, 0.6); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .code-reference-dialog[open], .code-reference-dialog::backdrop { animation: none; }
}
