/* Python Playground: self-contained. Inherit root tokens, define the rest. */
@import url("../styles.css");

:root { --accent: #6f7a30; }
.mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 7px; color: #fff; background: linear-gradient(135deg, #6f7a30, #4f7d39); }

/* concept prev/next navigation */
.study-nav { display: flex; align-items: stretch; justify-content: space-between; gap: 12px; margin: 22px 0 2px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.snav { display: flex; flex-direction: column; gap: 3px; min-height: 54px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: transform .08s, border-color .12s, box-shadow .12s; max-width: 46%; }
.snav:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 4px 14px rgba(111,122,48,.16); }
.snav.next { text-align: right; align-items: flex-end; border-color: var(--accent); }
.snav-k { font-size: .72rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.snav-n { font-weight: 800; font-size: .93rem; line-height: 1.2; color: var(--ink); }
.snav-pos { align-self: center; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.snav-spacer { max-width: 46%; display: flex; align-items: center; color: var(--muted); font-weight: 700; font-size: .9rem; }
@media (max-width: 560px) { .snav, .snav-spacer { max-width: none; flex: 1 1 100%; } .snav.next { text-align: left; align-items: flex-start; } .snav-pos { order: -1; flex: 1 1 100%; text-align: center; } }
button { cursor: pointer; font: inherit; }
.hl { color: var(--accent); }
.eyebrow { margin: 0 0 12px; color: var(--rose); font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); gap: clamp(24px, 5vw, 60px); align-items: center; padding: clamp(44px, 7vw, 84px) clamp(18px, 4vw, 56px); min-height: 540px; background: radial-gradient(900px 420px at 12% -10%, #e4ecd9, transparent 60%), var(--paper); }
.hero h1 { margin: 0; font-size: clamp(2rem, 4.6vw, 3.7rem); line-height: 1.05; }
.lead { color: var(--muted); line-height: 1.7; font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 60ch; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.hero-badges span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff; font-weight: 800; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 850; transition: transform .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.hero-stage { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.hero-stage canvas { display: block; width: 100%; height: auto; }

/* bands */
.band, .studio, .next { padding: clamp(40px, 6vw, 80px) clamp(18px, 4vw, 56px); border-top: 1px solid var(--line); }
.band { background: #e7eddc; } .band.alt { background: #e7ede0; }
.section-title { max-width: 820px; margin: 0 auto 22px; text-align: center; }
.section-title h2 { margin: 6px 0 10px; font-size: clamp(1.7rem, 3.4vw, 2.8rem); }
.section-title .lead { margin-inline: auto; }

/* category bar */
.cat-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 900px; margin: 0 auto 20px; }
.cat { border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; background: #fff; font-weight: 800; }
.cat:hover { border-color: var(--c, var(--accent)); }
.cat.on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: #fff; }

/* concept grid */
.concept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; max-width: 1200px; margin: 0 auto; }
.concept-card { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px 14px; border: 1px solid var(--line); border-top: 3px solid var(--c, var(--accent)); border-radius: 12px; background: #fff; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.concept-card:hover { transform: translateY(-3px); box-shadow: 0 20px 44px rgba(24, 35, 49, .16); }
.concept-card.sel { outline: 3px solid var(--c, var(--accent)); outline-offset: 1px; }
.cc-emoji { font-size: 1.5rem; }
.cc-cat { font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; color: var(--c, var(--accent)); }
.concept-card strong { font-size: 1rem; color: var(--ink); }
.cc-blurb { color: var(--muted); font-size: .82rem; line-height: 1.4; }

/* concept view */
.concept-head { display: flex; align-items: center; gap: 16px; max-width: 1100px; margin: 0 auto 18px; padding: 16px 18px; border: 1px solid var(--line); border-left: 6px solid var(--c, var(--accent)); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.concept-head .ch-emoji { font-size: 2.4rem; }
.concept-head h2 { margin: 2px 0; font-size: clamp(1.4rem, 3vw, 2.1rem); color: var(--c, var(--accent)); }
.concept-head .ch-blurb { margin: 0; color: var(--muted); font-weight: 600; }
.concept-view { max-width: 1100px; margin: 0 auto; }
.card { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); padding: clamp(16px, 2.4vw, 26px); }
.idea { line-height: 1.7; color: var(--ink); } .idea p { margin: 0 0 10px; } .idea code { background: #e7eddc; padding: 1px 5px; border-radius: 5px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }
.lbl { margin: 22px 0 8px; font-size: .72rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lbl.warn { color: var(--rose); }
.keys, .gotchas { margin: 0; padding-left: 18px; color: var(--ink); line-height: 1.7; }
.gotchas { list-style: none; padding-left: 0; } .gotchas li { margin-bottom: 6px; color: var(--ink); }

/* examples + code */
.example { margin: 14px 0 18px; }
.ex-note { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.code-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; background: #0f1722; color: #cfe0c5; font-weight: 800; font-size: .8rem; }
.runbtn { border: 1px solid #2f4a3a; background: #1b6; background: #1f8f5a; color: #fff; border-radius: 6px; padding: 3px 12px; font-weight: 800; font-size: .78rem; }
.code-block { margin: 0; max-height: 360px; overflow: auto; background: #0f1722; padding: 10px 0; }
.code-block code { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.6; }
.cline { display: block; padding: 0 14px; white-space: pre; color: #d7e6f7; border-left: 3px solid transparent; }
.cline.hot { background: rgba(255, 211, 78, .16); border-left-color: #ffd34e; }
.c-kw { color: #ff9d6f; } .c-str { color: #9ff0c0; } .c-com { color: #6f8296; font-style: italic; }
.out { margin-top: 8px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.out-label { display: block; padding: 5px 12px; background: #e7eddc; color: var(--muted); font-weight: 800; font-size: .74rem; }
.out pre { margin: 0; background: #10261c; color: #b6f5cf; padding: 10px 14px; }

/* tracer */
.tracer { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fafdff; }
.tracer .code-wrap { margin-bottom: 0; }
.tr-right { display: grid; gap: 10px; margin-top: 10px; }
.console { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #10261c; min-height: 70px; }
.con-label { padding: 4px 12px; background: #16351f; color: #9ff0c0; font-weight: 800; font-size: .72rem; }
#trOut { padding: 8px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; color: #b6f5cf; font-size: .85rem; line-height: 1.5; min-height: 40px; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.var { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; background: #fff; font-size: .82rem; }
.var .vk { font-weight: 900; color: var(--accent); } .var .vv { font-family: ui-monospace, Menlo, Consolas, monospace; }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.player-btn { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 800; }
.player-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-counter { margin-left: auto; font-weight: 800; color: var(--muted); font-size: .85rem; }
.step-desc { min-height: 2.2em; margin: 10px 0 0; padding: 10px 12px; border-radius: 9px; background: #e7eddc; color: var(--ink); line-height: 1.5; font-weight: 600; }

/* slicer */
.slicer { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fafdff; }
.sl-seq { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sl-cell { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid var(--line); border-radius: 8px; background: #fff; font-weight: 800; }
.sl-cell small { position: absolute; bottom: -16px; color: var(--muted); font-weight: 700; }
.sl-cell.on { border-color: var(--accent); background: #e4ecd9; }
.sl-ctrls { display: grid; gap: 8px; max-width: 360px; }
.sl-ctrls label { display: grid; gap: 4px; font-weight: 800; font-size: .85rem; color: var(--muted); }
.sl-expr, .sl-res { margin: 8px 0 0; font-size: 1.05rem; } .sl-res { color: var(--accent); font-weight: 800; }
.sl-expr code, .sl-res code { background: #0f1722; color: #e9f4ff; padding: 2px 8px; border-radius: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* idioms + quiz */
.idiom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; max-width: 1100px; margin: 0 auto; }
.idiom { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff; box-shadow: var(--shadow); }
.idiom strong { display: block; margin-bottom: 8px; }
.idiom pre { margin: 0 0 8px; background: #0f1722; color: #e9f4ff; border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.idiom p { margin: 0; color: var(--muted); line-height: 1.5; }
.panel-head { max-width: 1000px; margin: 0 auto 12px; text-align: right; }
.panel-head strong { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; background: #fff; font-weight: 900; }
.quiz-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; max-width: 1000px; margin: 0 auto; }
.quiz-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff; box-shadow: var(--shadow); }
.quiz-card strong { display: block; margin-bottom: 10px; line-height: 1.4; }
.q-opts { display: grid; gap: 8px; }
.q-opts button { text-align: left; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700; }
.q-opts button:hover:not(:disabled) { border-color: var(--accent); }
.q-opts button.correct { background: var(--green); border-color: var(--green); color: #fff; }
.q-opts button.wrong { background: var(--rose); border-color: var(--rose); color: #fff; }

.next { text-align: center; background: linear-gradient(180deg, #f1eed8, var(--paper)); }
.next .actions { justify-content: center; }

/* ---------- games ---------- */
.code-block.mini { max-height: 220px; }
.game { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: linear-gradient(180deg, #fff8ee, #fff); }
.game-prompt { margin: 0 0 10px; font-weight: 800; }
.game-opts { display: grid; gap: 8px; }
.gopt, .cbtn, .cqo, .ochip, .order-check, .order-reset, .oremove { font: inherit; cursor: pointer; }
.gopt { text-align: left; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; }
.gopt:hover:not(:disabled) { border-color: var(--accent); }
.gopt.correct, .cbtn.correct, .cqo.correct { background: var(--green); border-color: var(--green); color: #fff; }
.gopt.wrong, .cbtn.wrong, .cqo.wrong { background: var(--rose); border-color: var(--rose); color: #fff; }
.game-fb { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: #e7eddc; line-height: 1.5; }
.classify-items { display: grid; gap: 8px; }
.citem { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.citem code { font-weight: 800; }
.cbtns { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.cbtn { min-height: 36px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-weight: 700; }
.cbtn:hover:not(:disabled) { border-color: var(--accent); }
.game-score { margin: 10px 0 0; font-weight: 800; color: var(--accent); }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ochip { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.ochip:hover { border-color: var(--accent); }
.order-slots { display: grid; gap: 6px; margin: 0 0 10px; padding-left: 26px; min-height: 12px; }
.oslot { background: #0f1722; color: #d7e6f7; border-radius: 8px; padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.oremove { border: none; background: transparent; color: #ff9d6f; font-weight: 900; }
.order-ctrls { display: flex; gap: 8px; }
.order-check, .order-reset { min-height: 38px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 800; }
.order-check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- per-concept quiz ---------- */
.cq-score { font-weight: 900; color: var(--accent); margin-left: 8px; }
.cquiz { display: grid; gap: 12px; }
.cq { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.cq strong { display: block; margin-bottom: 8px; line-height: 1.4; }
.cq-opts { display: grid; gap: 8px; }
.cqo { text-align: left; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700; }
.cqo:hover:not(:disabled) { border-color: var(--accent); }
.cq-fb { margin: 10px 0 0; padding: 9px 12px; border-radius: 8px; background: #e7eddc; line-height: 1.5; color: var(--ink); }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 920px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
}
@media (max-width: 560px) { .actions .button { flex: 1 1 100%; justify-content: center; } .step-counter { margin-left: 0; width: 100%; } }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } .concept-card:hover { transform: none; } html { scroll-behavior: auto; } }

/* ---------- ✦ Beautiful math callout ---------- */
.beauty-note {
  margin: 16px 0 4px;
  padding: 12px 16px;
  background: #eef3e3;
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  line-height: 1.55;
}
.beauty-note .bn-label {
  margin: 0 0 6px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.beauty-note p { margin: 0 0 8px; }
.beauty-note p:last-child { margin-bottom: 0; }
.beauty-note .katex-display { margin: 10px 0; }
.beauty-note .katex { color: var(--ink); }

/* ---------- aliasing / names-to-heap visual ---------- */
.aliaser { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fafdff; }
.aliaser canvas { display: block; width: 100%; height: auto; }

/* ============================================================
   POLISH LAYER  (additive, appended last, overrides safely)
   Accessibility, gentle micro-interactions, responsive hardening.
   All motion is disabled under prefers-reduced-motion below.
   ============================================================ */

/* --- Keyboard focus: visible sage ring on every interactive control.
       Uses :focus-visible so mouse clicks stay clean. --- */
.cat:focus-visible,
.button:focus-visible,
.runbtn:focus-visible,
.player-btn:focus-visible,
.snav:focus-visible,
.q-opts button:focus-visible,
.gopt:focus-visible,
.cbtn:focus-visible,
.cqo:focus-visible,
.ochip:focus-visible,
.order-check:focus-visible,
.order-reset:focus-visible,
.oremove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.concept-card:focus-visible {
  outline: 3px solid var(--c, var(--accent));
  outline-offset: 1px;
}

/* --- Gentle, consistent transitions on controls that currently
       only swap colour on hover. Tasteful 1px lift, no layout shift. --- */
.cat,
.runbtn,
.player-btn,
.gopt,
.cbtn,
.cqo,
.ochip,
.q-opts button,
.order-check,
.order-reset {
  transition: transform .12s ease, border-color .12s ease,
              background-color .12s ease, box-shadow .12s ease;
}
.cat:hover { transform: translateY(-1px); }
.runbtn:hover { filter: brightness(1.08); }
.ochip:hover,
.gopt:hover:not(:disabled),
.cbtn:hover:not(:disabled),
.cqo:hover:not(:disabled),
.q-opts button:hover:not(:disabled) {
  box-shadow: 0 3px 10px rgba(111, 122, 48, .12);
}
.player-btn:hover { transform: translateY(-1px); border-color: var(--accent); }

/* Disabled answer buttons read as settled, not clickable. */
.gopt:disabled,
.cbtn:disabled,
.cqo:disabled,
.q-opts button:disabled { cursor: default; }

/* --- Sage-tinted scrollbars for the dark code/console panels so the
       default grey bars don't clash with the palette (WebKit/Blink). --- */
.code-block,
.idiom pre,
.idiom-grid,
.concept-grid { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
.code-block::-webkit-scrollbar,
.idiom pre::-webkit-scrollbar { width: 9px; height: 9px; }
.code-block::-webkit-scrollbar-thumb,
.idiom pre::-webkit-scrollbar-thumb {
  background: rgba(111, 122, 48, .55);
  border-radius: 8px;
}
.code-block::-webkit-scrollbar-track,
.idiom pre::-webkit-scrollbar-track { background: transparent; }

/* --- Typographic rhythm: keep the last paragraph of an explanation
       from adding a trailing gap, and soften long-line wrapping. --- */
.idea p:last-child { margin-bottom: 0; }
.cc-blurb,
.ch-blurb,
.idiom p,
.step-desc { overflow-wrap: anywhere; }
.step-desc,
.game-fb,
.cq-fb { transition: background-color .15s ease; }

/* Smooth in-page anchor jumps from the topbar nav. */
html { scroll-behavior: smooth; }

/* --- Responsive hardening for wide media on small screens.
       Prevents the tracer code, slicer track and idiom pre blocks
       from forcing horizontal page scroll. No effect at rest on desktop. --- */
@media (max-width: 560px) {
  .code-block code,
  .cline { font-size: .8rem; }
  .sl-cell { width: 38px; height: 38px; }
  .sl-ctrls { max-width: 100%; }
  .order-ctrls { flex-wrap: wrap; }
  .concept-head { gap: 12px; padding: 14px; }
  .concept-head .ch-emoji { font-size: 2rem; }
}

/* Honour reduced-motion: strip every transition/animation added above. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cat, .runbtn, .player-btn, .gopt, .cbtn, .cqo, .ochip,
  .q-opts button, .order-check, .order-reset,
  .step-desc, .game-fb, .cq-fb {
    transition: none;
  }
  .cat:hover, .player-btn:hover, .runbtn:hover { transform: none; filter: none; }
}
