/* BitSize Python Foundations — the "stunning" layer over lesson.html's own styles.
   · Playground: your scratchpad, docked beside the lesson (🧪 in the top bar; ↗ on an example sends its code).
   · Tabs colour-coded: Learn blue · Pitfalls coral · Quiz violet · Predict teal.
   · Code boxes with depth, a glowing Run, an output that reads at a glance. */
:root { --pg: #059669; --pg-2: #34D399; }

/* ── Code boxes: clean and compact, like the Patterns app ──
   No window chrome. Editor with line numbers → ONE control row (Run row, which becomes the stepper
   while stepping) → a height-capped console (output, with the variables beside it while stepping). */
.py-runbox { --rb-bg: #1D2226; --rb-line: #2B3237; --rb-bar: #171B1E; --rb-gut: 40px;
  margin-bottom: 14px; border: 1px solid var(--rb-line); border-radius: 12px; overflow: hidden; background: var(--rb-bg);
  box-shadow: 0 12px 28px -24px rgba(10, 15, 20, .7); transition: box-shadow .2s; }
.py-runbox:focus-within { box-shadow: 0 0 0 2px rgba(255, 212, 59, .35), 0 12px 28px -24px rgba(10, 15, 20, .7); }
.py-runbox__cap { margin: 0 0 6px; font-size: 12.5px; font-style: italic; color: var(--py-ink-30, #8a8a8a); }
.py-runbox__editor-wrap { background: var(--rb-bg); }
.py-runbox__highlight code { font-family: inherit !important; }
.py-runbox__editor-wrap:focus-within { box-shadow: none; }
.py-runbox__code, .py-runbox__highlight { padding: 12px 14px 12px calc(var(--rb-gut) + 12px) !important; font-family: var(--py-mono2, var(--mono)) !important; }
.py-runbox__gutter { position: absolute; top: 0; left: 0; bottom: 0; width: var(--rb-gut); padding: 12px 8px 12px 0; box-sizing: border-box;
  border-right: 1px solid var(--rb-line); text-align: right; white-space: pre; pointer-events: none; user-select: none;
  font-family: var(--py-mono2, var(--mono)); font-size: 12.5px; line-height: 1.65; color: #4F5A60; }
.py-runbox__linemark { border-left-width: 0; background: rgba(255, 212, 59, .13); box-shadow: inset 3px 0 0 #FFD43B; }

/* the single control row */
.py-runbox__bar { background: var(--rb-bar); border-top: 1px solid var(--rb-line); }
.py-runbox__actions, .py-stepper { min-height: 42px; padding: 6px 8px 6px 10px; gap: 6px; background: transparent; border: 0; flex-wrap: nowrap; }
.py-runbox.is-stepping .py-runbox__actions { display: none; }
.py-runbox.is-stepping .py-stepper { display: flex; animation: none; }
.py-runbox__run { padding: 6px 14px; border-radius: 999px; background: #FFD43B; color: #1A1A1A; box-shadow: none; font-size: 12.5px; }
.py-runbox__run:hover:not(:disabled) { background: #FFE066; transform: none; }
.py-runbox__step { padding: 6px 12px; border-radius: 999px !important; border: 1px solid #3A434A; background: transparent; color: #C9D1D6; font-size: 12.5px; }
.py-runbox__step:hover:not(:disabled) { background: #262C31; color: #fff; }
.py-runbox__tool { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: #8C979D; font-size: 14px; cursor: pointer; transition: background .15s, color .15s; }
.py-runbox__tool:hover { background: #262C31; color: #fff; }
.py-runbox__send:hover { background: var(--pg); color: #fff; }
.py-kbdhint { margin-left: auto; padding-right: 4px; font: 500 11px var(--py-mono2, var(--mono)); color: #6B767C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.py-kbdhint kbd { padding: 0 4px; border-radius: 4px; border: 1px solid #3A434A; font: inherit; color: #9AA5AB; }
.py-runlock-note { font-size: 11.5px; color: #8C979D; }
.py-stepper__nav { border-radius: 999px; border-color: #3A434A; background: transparent; color: #C9D1D6; padding: 5px 11px; }
.py-stepper__next { background: #FFD43B; color: #1A1A1A; border-color: transparent; min-width: 74px; }
.py-stepper__count { flex: none; color: #FFD43B; }
.py-stepper__line { flex: 1 1 auto; color: #7E898F; }
.py-stepper .py-kbdhint { margin-left: 0; flex: 0 1 auto; }
.py-stepper__exit { flex: none; width: 28px; height: 28px; border-radius: 8px; color: #8C979D; font-size: 13px; }
.py-stepper__exit:hover { background: #262C31; color: #fff; }

/* the console: output, plus the variables beside it while stepping — capped so the box stays short */
.py-runbox__console { display: flex; align-items: stretch; border-top: 1px solid var(--rb-line); }
.py-runbox__console:not(:has(.show)) { display: none; }
.py-runbox__output { flex: 1 1 0; min-width: 0; max-height: 220px; margin: 0; border-top: 0; background: #14181B; padding: 10px 14px 10px 18px; }
.py-runbox__output::before { background: #22C55E; width: 3px; }
.py-vars { flex: 0 0 min(44%, 360px); max-height: 220px; overflow-y: auto; border-top: 0; border-left: 1px solid var(--rb-line); background: #191E21; padding: 9px 12px; }
.py-vars__title { margin-bottom: 5px; }
.py-var { grid-template-columns: minmax(56px, auto) 1fr; padding: 2px 6px; }
.py-var__type { display: none; }
/* the box sizes its own row: drop the line caption (the band already marks the line), then the hints */
.py-runbox { container-type: inline-size; }
@container (max-width: 760px) { .py-stepper__line { display: none; } .py-stepper .py-kbdhint { margin-left: auto; } }
@container (max-width: 480px) { .py-kbdhint { display: none !important; } .py-stepper__exit { margin-left: auto; } }
@media (max-width: 640px) {
  .py-runbox__console { flex-direction: column; }
  .py-runbox__output { flex: 0 1 auto; }
  .py-runbox__output, .py-vars { max-height: 170px; }
  .py-vars { flex-basis: auto; border-left: 0; border-top: 1px solid var(--rb-line); }
  .py-kbdhint { display: none; }
  .py-stepper__line { display: none; }
  .py-stepper__exit { margin-left: auto; }
}

/* ── Tabs, colour-coded ── */
.py-tabs { background: rgba(0, 0, 0, .04); padding: 4px; border-radius: 12px; }
.py-tab { border-radius: 9px; }
.py-tab[data-tab="learn"]    { --tc: #2563EB; }
.py-tab[data-tab="pitfalls"] { --tc: #E8590C; }
.py-tab[data-tab="mcq"]      { --tc: #7C3AED; }
.py-tab[data-tab="predict"]  { --tc: #0D9488; }
.py-tab.active { color: var(--tc); box-shadow: 0 1px 0 #fff inset, 0 6px 14px -8px var(--tc), 0 0 0 1.5px color-mix(in srgb, var(--tc) 35%, transparent); }
.py-tab:not(.locked):hover { color: var(--tc); }

/* ── Lesson sections ── */
.py-block, .py-pitfall { transition: box-shadow .25s, transform .25s, border-color .25s; }
.py-block:hover, .py-pitfall:hover { box-shadow: 0 14px 30px -24px rgba(20, 20, 40, .55); }
.py-block.open { border-color: rgba(37, 99, 235, .25); box-shadow: 0 16px 34px -26px rgba(37, 99, 235, .7); }
.py-block__num { background: linear-gradient(180deg, #EFF4FF, #DBE6FF); color: #1D4ED8; }

/* ══ Playground: one dark editor, docked beside the lesson ══ */
/* the top-bar button (matches the shared ⛶ Focus pill beside it) */
.py-topbar__tool { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; flex: none;
  border-radius: 999px; border: 1px solid rgba(0, 0, 0, .12); background: #fff; color: var(--py-ink, #1a1a1a);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, color .15s; }
.py-topbar__tool:hover { border-color: var(--pg); color: var(--pg); }
.py-topbar__tool.is-on { background: var(--pg); border-color: var(--pg); color: #fff; }
@media (max-width: 640px) { .py-topbar__tool-t { display: none; } .py-topbar__tool { padding: 0 10px; } }

.pg-panel { --pg-fs: 14px; --pg-bg: #1D2226; --pg-bar: #171B1E; --pg-line: #2B3237; background: var(--pg-bg); border-left: 1px solid #0F1214;
  box-shadow: -18px 0 48px -12px rgba(0, 0, 0, .35); }
.pg-panel.pg-panel--wide { width: min(62vw, 980px); }
body.pg-open.pg-wide { padding-right: min(62vw, 980px); }
.pg-panel--got { animation: pgGot .7s ease; }
@keyframes pgGot { 30% { box-shadow: -18px 0 48px -12px rgba(0, 0, 0, .35), inset 0 0 0 2px var(--pg-2); } }
.pg-panel__topbar { gap: 10px; padding: 10px 12px 10px 16px; background: var(--pg-bar); border-bottom: 1px solid var(--pg-line); }
.pg-panel__title { flex: none; font-size: 13.5px; font-weight: 750; letter-spacing: -.01em; color: #F1F5F4; }
.pg-panel__meta { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 500 11.5px var(--py-mono2, monospace); color: #6B767C; transition: color .2s; }
.pg-panel__meta.is-flash { color: var(--pg-2); }
.pg-panel__close { border: 0; background: transparent; color: #8C979D; width: 28px; height: 28px; border-radius: 8px; }
.pg-panel__close:hover { background: #262C31; color: #fff; }
.pg-panel__topbar .pgf-tools { margin-left: 0; }
.pg-panel__topbar .pgf-b { border-color: #3A434A; background: transparent; color: #C9D1D6; font-weight: 600; }
.pg-panel__topbar .pgf-b:hover { background: #262C31; }
.pg-panel__resizer:hover::after, body.pg-resizing .pg-panel__resizer::after { background: var(--pg-2); }

/* the tool row */
.pg-tools { display: flex; align-items: center; gap: 4px; flex: none; padding: 6px 10px; background: var(--pg-bar); border-bottom: 1px solid var(--pg-line); }
.pg-tools__gap { flex: 1; }
.pg-tool { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 28px; padding: 0 10px; border: 0; border-radius: 8px;
  background: transparent; color: #AEB8BD; font: 600 12.5px var(--py-sans, system-ui); cursor: pointer; transition: background .15s, color .15s; }
.pg-tool:hover { background: #262C31; color: #fff; }
.pg-tool[hidden] { display: none; }
.pg-tool--icon { width: 30px; padding: 0; }
.pg-tool small { font-size: 10px; margin-left: 1px; }
.pg-tool--undo { color: var(--pg-2); }
.pg-tool[aria-pressed="true"] { background: rgba(52, 211, 153, .14); color: var(--pg-2); }
.pg-font { display: inline-flex; align-items: center; margin-right: 4px; padding: 0 2px; border-radius: 9px; border: 1px solid var(--pg-line); }
.pg-font .pg-tool { height: 26px; width: 26px; }
.pg-font__val { min-width: 20px; text-align: center; font: 600 11.5px var(--py-mono2, monospace); color: #8C979D; }

/* the editor fills the panel: no card, no margin — just code, the run row and the console */
.pg-panel__body { padding: 0; background: var(--pg-bg); display: flex; flex-direction: column; }
.pg-panel .py-runbox { flex: 1 0 auto; display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.pg-panel .py-runbox:focus-within { box-shadow: none; }
.pg-panel .py-runbox__editor-wrap { flex: 1 0 auto; min-height: 180px; }
.pg-panel .py-runbox__code, .pg-panel .py-runbox__highlight { font-size: var(--pg-fs); line-height: 1.7; padding-top: 14px !important; padding-bottom: 14px !important; }
.pg-panel .py-runbox__highlight code { font-size: var(--pg-fs) !important; line-height: 1.7 !important; }
.pg-panel .py-runbox__gutter { font-size: var(--pg-fs); line-height: 1.7; padding-top: 14px; }
.pg-panel .py-runbox { --rb-gut: 44px; }
.pg-panel .py-runbox__bar { position: sticky; bottom: 0; z-index: 2; }
.pg-panel .py-runbox__console { flex-direction: column; }
.pg-panel .py-runbox__output { flex: 0 1 auto; max-height: 36vh; font-size: calc(var(--pg-fs) - 1px); }
.pg-panel .py-vars { flex-basis: auto; max-height: 30vh; border-left: 0; border-top: 1px solid var(--rb-line); }
.pg-panel .py-runbox__actions .py-kbdhint { display: none; }          /* the keys line under the panel says it */
.pg-keys { flex: none; margin: 0; padding: 7px 14px; background: var(--pg-bar); border-top: 1px solid var(--pg-line);
  font: 500 11px var(--py-mono2, monospace); color: #6B767C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-keys kbd { padding: 0 4px; border-radius: 4px; border: 1px solid #3A434A; font: inherit; color: #9AA5AB; }
@media (max-width: 900px) { .pg-panel.pg-panel--wide { width: 100%; } body.pg-open.pg-wide { padding-right: 0; } .pg-tool--wide { display: none; } }
@media (max-width: 640px) { .pg-keys { display: none; } }
@media (prefers-reduced-motion: reduce) { .pg-panel, .pg-panel--got { transition: none; animation: none; } .py-runbox__output.show { animation: none; } }

/* ══ Module list ══ */
/* live step-through demo in the hero */
.fd-demo { margin-top: 22px; max-width: 540px; border-radius: 16px; overflow: hidden; background: #14152A; border: 1px solid #262845;
  box-shadow: 0 26px 50px -30px rgba(10, 10, 30, .8); }
.fd-demo__bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: linear-gradient(90deg, #2A1F06, #6B4C07); }
.fd-demo__bar i { width: 10px; height: 10px; border-radius: 50%; background: #FF5F57; }
.fd-demo__bar i:nth-child(2) { background: #FEBC2E; } .fd-demo__bar i:nth-child(3) { background: #28C840; }
.fd-demo__bar span { margin-left: 8px; font: 600 11.5px 'JetBrains Mono', monospace; color: rgba(255, 255, 255, .6); }
.fd-demo__bar b { margin-left: auto; font: 700 11px 'JetBrains Mono', monospace; color: #FFD43B; }
.fd-demo__body { display: grid; grid-template-columns: minmax(0, 1fr) 150px; }
.fd-demo__code { position: relative; margin: 0; padding: 14px 16px; font: 14px/1.8 'JetBrains Mono', monospace; color: #E5E7EB; }
.fd-demo__code code { position: relative; z-index: 1; }
.fd-demo__code .k { color: #93C5FD; } .fd-demo__code .n { color: #FCA5A5; } .fd-demo__code .s { color: #BEF264; } .fd-demo__code .f { color: #C4B5FD; }
.fd-band { position: absolute; left: 0; right: 0; height: 1.8em; top: calc(14px + var(--line, 0) * 1.8em); background: rgba(255, 212, 59, .14);
  border-left: 3px solid #FFD43B; transition: top .45s cubic-bezier(.2, .8, .2, 1); }
.fd-demo__vars { display: grid; align-content: start; gap: 6px; padding: 14px 12px; border-left: 1px solid rgba(255, 255, 255, .07); background: #101122; }
.fd-var { display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px; border-radius: 7px; background: rgba(147, 197, 253, .08);
  font: 600 12.5px 'JetBrains Mono', monospace; color: #FDE68A; }
.fd-var em { font-style: normal; color: #93C5FD; }
.fd-var.is-new { animation: fdIn .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes fdIn { from { opacity: 0; transform: translateX(10px) scale(.92); background: rgba(255, 212, 59, .35); } to { opacity: 1; transform: none; } }
.fd-demo__out { padding: 8px 16px 12px; min-height: 22px; font: 700 13.5px 'JetBrains Mono', monospace; color: #86EFAC; border-top: 1px solid rgba(255, 255, 255, .06);
  opacity: .25; transition: opacity .3s; }
.fd-demo__out.is-on { opacity: 1; }
/* module cards: a colour band per ten modules */
.py-card { --mc: #C98200; position: relative; overflow: hidden; transition: transform .2s, box-shadow .25s, border-color .2s; }
.py-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--mc); }
/* each module has its own colour (views.module_color): a faint wash + left edge so neighbours are told apart at a glance */
.py-grid > .py-card { background: linear-gradient(180deg, color-mix(in srgb, var(--mc) 10%, #fff), #fff 60%); border-left: 3px solid color-mix(in srgb, var(--mc) 55%, #fff); }
a.py-card:hover { transform: translateY(-3px); border-color: var(--mc); box-shadow: 0 20px 40px -24px var(--mc); }
.py-card__icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--mc) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--mc) 22%, #fff); transition: transform .25s; }
a.py-card:hover .py-card__icon { transform: rotate(-8deg) scale(1.1); }
.py-card__num { color: var(--mc) !important; }
.py-card--done::before { background: linear-gradient(90deg, #16A34A, #86EFAC); }
.py-card--current { border-color: var(--mc) !important; animation: fdGlow 2.4s ease-in-out infinite; }
@keyframes fdGlow { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mc) 35%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@media (max-width: 600px) { .fd-demo__body { grid-template-columns: 1fr; } .fd-demo__vars { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .07); grid-auto-flow: column; overflow-x: auto; } .fd-demo { max-width: none; } }
@media (prefers-reduced-motion: reduce) { .fd-band { transition: none; } .fd-var.is-new, .py-card--current { animation: none; } a.py-card:hover .py-card__icon { transform: none; } }
/* In the shared app hero's visual card ({% lp_hero %}, learning/hero.py): the step-through fills the card. */
.ah__visual > .fd-demo { width: 100%; max-width: none; margin: 0; }
