/* ------------------------------------------------------------------------ *
 * Lesson player + Hour of Code page styles (apps.learn).
 * Loaded after site.css (page-scoped, does not touch shared tokens). Palette
 * mirrors the marketing pages: purple #6c4aee, teal #12c2b8.
 * ------------------------------------------------------------------------ */

/* --- Minimal app chrome (learn_base.html) ------------------------------ */
/* The lesson player runs a slim app bar, NOT the marketing nav/footer. */
:root {
  /* base-reset.css reads this into scroll-padding-top: in-page anchors land
     below the 56px sticky .learn-appbar instead of under it. */
  --anchor-offset: 72px;
}
.learn-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: #f6f7fb;
  font-family: "Open Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
}
.learn-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid #e6e6ef;
  position: sticky;
  top: 0;
  z-index: 20;
}
.learn-appbar__brand img { height: 26px; width: auto; display: block; }
.learn-appbar__actions { display: flex; align-items: center; gap: 18px; }
.learn-appbar__link {
  color: #4a3fb0;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
@media (hover: hover) and (pointer: fine) {
  .learn-appbar__link:hover { text-decoration: underline; }
}
.learn-appmain { display: block; }

.learn {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* --- Guest / signup banner --------------------------------------------- */
.learn-banner {
  background: #f4f0ff;
  border: 1px solid #d9cffa;
  color: #3d2a8c;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.learn-banner a { color: #6c4aee; font-weight: 600; }
.learn-banner--inline { margin: 24px 0 0; }
/* Staff preview banner — amber so authors can't miss that this isn't the
   real student experience and no progress is being saved. */
.learn-banner--preview {
  background: #fffbeb;
  border-color: #fbbf24;
  color: #78350f;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.learn-banner--preview a { color: #b45309; font-weight: 600; }

/* --- Header ------------------------------------------------------------- */
.learn-head { margin-bottom: 20px; }
.learn-crumb { font-size: 0.9rem; color: #6b7280; margin: 0 0 4px; }
.learn-crumb a { color: #6c4aee; text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .learn-crumb a:hover { text-decoration: underline; }
}
.learn-title { font-size: 1.6rem; margin: 0; color: #1f2937; }

/* --- Two-column layout: rail + main ------------------------------------- */
.learn-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 760px) {
  .learn-grid { grid-template-columns: 1fr; }
}

/* --- Activity rail ------------------------------------------------------ */
.learn-rail {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  position: sticky;
  top: 16px;
}
.learn-rail__list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.learn-rail__item { margin: 2px 0; }
.learn-rail__link {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-areas: "badge name" "badge type";
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: #374151;
}
@media (hover: hover) and (pointer: fine) {
  .learn-rail__link:hover { background: #f6f5fb; }
}
.learn-rail__badge {
  grid-area: badge;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 0.85rem;
  background: #eef2f7; color: #6b7280;
}
.learn-rail__name { grid-area: name; font-weight: 600; font-size: 0.95rem; }
.learn-rail__type { grid-area: type; font-size: 0.78rem; color: #9ca3af; }

.learn-rail__item--done .learn-rail__badge { background: #12c2b8; color: #fff; }
.learn-rail__item--current .learn-rail__badge { background: #6c4aee; color: #fff; }
.learn-rail__item.is-selected .learn-rail__link { background: #f0ecff; box-shadow: inset 0 0 0 1px #d9cffa; }
.learn-rail__link--locked { color: #b0b6bf; cursor: not-allowed; }
.learn-rail__empty { padding: 12px; color: #9ca3af; font-size: 0.9rem; }

/* --- Main pane ---------------------------------------------------------- */
.learn-main { min-width: 0; }
.learn-pane {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
}
.learn-pane h2 { margin: 8px 0 12px; font-size: 1.35rem; color: #1f2937; }
.learn-pane__body { color: #374151; line-height: 1.55; }
.learn-pane--empty, .learn-pane--locked { text-align: center; color: #6b7280; }
.learn-pane--locked { border-color: #d9cffa; background: #faf9ff; }

.learn-pill {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #6c4aee; background: #f0ecff;
  padding: 3px 10px; border-radius: 999px;
}

/* --- Buttons ------------------------------------------------------------ */
.learn-btn {
  display: inline-block;
  border: 1px solid #d1d5db;
  background: #fff; color: #374151;
  border-radius: 9px;
  padding: 10px 18px;
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-decoration: none;
  margin-top: 16px;
}
@media (hover: hover) and (pointer: fine) {
  .learn-btn:hover { border-color: #6c4aee; color: #6c4aee; }
}
.learn-btn--primary {
  background: #6c4aee; border-color: #6c4aee; color: #fff;
}
@media (hover: hover) and (pointer: fine) {
  .learn-btn--primary:hover { background: #5a3ad6; color: #fff; }
}
.learn-complete-form { margin-top: 8px; }

/* --- Video pane --------------------------------------------------------- */
.learn-video { margin: 8px 0 4px; }
.learn-video video { width: 100%; border-radius: 10px; background: #000; }
.learn-video__placeholder {
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background: #111827; color: #fff; font-size: 3rem;
  border-radius: 10px;
}
/* Responsive 16:9 wrapper for embedded (YouTube/Vimeo) video iframes. */
.learn-video__frame { position: relative; aspect-ratio: 16 / 9; }
.learn-video__frame iframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; border-radius: 10px; background: #000;
}
.learn-video__hint { color: #6b7280; font-size: 0.9rem; margin: 8px 0 6px; }

/* --- Quiz pane ---------------------------------------------------------- */
.learn-quiz__q {
  border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 14px 16px; margin: 0 0 14px;
}
.learn-quiz__q legend { font-weight: 700; padding: 0 6px; color: #1f2937; }
.learn-quiz__choice {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: 8px; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .learn-quiz__choice:hover { background: #f6f5fb; }
}
/* Rendered block-JSON spans from render_quiz_text — same pill treatment the
   IDE quiz page (apps/ide/templates/ide/quiz.html) gives .quiz-block. */
.learn-quiz .quiz-block {
  display: inline-block; background: #4a6cd4; color: #fff;
  padding: 2px 8px; border-radius: 10px; font-size: 13px;
}

/* --- Lesson complete ---------------------------------------------------- */
.learn--complete { text-align: center; }
.learn-done {
  max-width: 560px; margin: 40px auto;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 16px;
  padding: 40px 28px;
}
.learn-done__badge { font-size: 3rem; display: block; margin-bottom: 8px; }
.learn-done__meta { color: #6b7280; margin: 10px 0; }
.learn-done__links { margin-top: 20px; font-size: 0.9rem; }
.learn-done__links a { color: #6c4aee; text-decoration: none; }

/* Course progress rollup (CURR-035) on the lesson-complete page. */
.learn-rollup { max-width: 420px; margin: 8px auto 18px; }
.learn-rollup__bar {
  height: 10px; background: #ede9fe; border-radius: 999px; overflow: hidden;
}
.learn-rollup__fill {
  display: block; height: 100%; background: #6c4aee; border-radius: 999px;
}
.learn-rollup__label { color: #6b7280; font-size: 0.9rem; margin: 8px 0 0; }

/* --- Hour of Code landing ---------------------------------------------- */
.hoc-hero { text-align: center; max-width: 640px; margin: 24px auto 32px; }
.hoc-hero h1 { font-size: 2rem; margin: 12px 0 8px; color: #1f2937; }
.hoc-hero__lede { color: #4b5563; line-height: 1.55; }
.hoc-hero__note { color: #9ca3af; font-size: 0.9rem; }
.hoc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.hoc-card {
  display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 20px; text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
@media (hover: hover) and (pointer: fine) {
  .hoc-card:hover { box-shadow: 0 6px 20px rgba(108,74,238,0.15); transform: translateY(-2px); }
}
.hoc-card__eyebrow { font-size: 0.78rem; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; }
.hoc-card__title { font-weight: 700; font-size: 1.05rem; color: #1f2937; }
.hoc-card__cta { color: #6c4aee; font-weight: 600; margin-top: 4px; }

/* Teacher-only "Answer Key" sidebar item (CURR-066). */
.learn-rail__answerkey {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding: 10px 12px;
  border: 1px dashed #c4b5fd; border-radius: 10px;
  color: #6c4aee; text-decoration: none; font-weight: 600;
}
@media (hover: hover) and (pointer: fine) {
  .learn-rail__answerkey:hover { background: #f5f3ff; }
}

/* ---------------------------------------------------------------------- */
/* Notebook lesson cells (GitHub #504/#505) — imported Markdown/MDX body    */
/* with an in-browser Skulpt code-run widget. Styling mirrors the legacy    */
/* notebook player's light "content + code cell" look.                      */
/* ---------------------------------------------------------------------- */
.nb-lesson { margin: 4px 0 8px; }
.nb-cell { margin: 0 0 18px; }
.nb-cell--md { color: #1f2937; line-height: 1.6; }
.nb-cell--md h1, .nb-cell--md h2, .nb-cell--md h3 { color: #111827; margin: 18px 0 8px; }
.nb-cell--md h1 { font-size: 1.5rem; }
.nb-cell--md h2 { font-size: 1.25rem; }
.nb-cell--md h3 { font-size: 1.08rem; }
.nb-cell--md p { margin: 8px 0; }
.nb-cell--md ul, .nb-cell--md ol { margin: 8px 0 8px 22px; }
.nb-cell--md img { max-width: 100%; height: auto; }
.nb-cell--md code { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: 0.92em; }
.nb-cell--md table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.nb-cell--md th, .nb-cell--md td { border: 1px solid #e5e7eb; padding: 6px 10px; text-align: left; }
.nb-cell--md th { background: #f9fafb; }

/* Code cell */
.nb-cell--code {
  border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden;
  background: #1e1e2e; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nb-code__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: #2a2a3c; color: #cbd5e1; font-size: 0.8rem;
}
.nb-code__lang { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.nb-code__run {
  background: #22c55e; color: #04210f; border: 0; border-radius: 6px;
  padding: 4px 14px; font-weight: 700; cursor: pointer; font-size: 0.85rem;
}
@media (hover: hover) and (pointer: fine) {
  .nb-code__run:hover { background: #16a34a; }
}
.nb-code__run:disabled { opacity: 0.6; cursor: default; }
.nb-code__badge { color: #fbbf24; font-weight: 600; }
.nb-code__input {
  width: 100%; box-sizing: border-box; border: 0; resize: vertical;
  padding: 12px 14px; background: #1e1e2e; color: #e5e7eb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem; line-height: 1.5;
}
.nb-code__input:focus { outline: 2px solid #6c4aee; outline-offset: -2px; }
.nb-code__output {
  margin: 0; padding: 10px 14px; background: #11111b; color: #a7f3d0;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.88rem;
  white-space: pre-wrap; border-top: 1px solid #2a2a3c;
}
.nb-code__output.is-error { color: #fca5a5; }
.nb-code__note {
  margin: 0; padding: 8px 14px; background: #11111b; color: #94a3b8;
  font-size: 0.82rem; border-top: 1px solid #2a2a3c;
}

/* Ported notebook quiz widget (#504). */
.nb-cell--quiz {
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px 18px;
  background: #fbfbfe;
}
.nb-q { margin: 0 0 18px; }
.nb-q:last-child { margin-bottom: 0; }
.nb-q__title { font-weight: 600; color: #111827; margin: 0 0 10px; line-height: 1.5; }
.nb-q__title .nb-q__code, .nb-q__label .nb-q__code {
  display: block; background: #0d1117; color: #e6edf3; border-radius: 6px;
  padding: 8px 12px; margin: 6px 0; font-size: 0.85rem; white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.nb-q__title img, .nb-q__label img { max-width: 100%; height: auto; vertical-align: middle; }
.nb-q__choices { list-style: none; margin: 0; padding: 0; }
.nb-q__choice { margin: 6px 0; }
.nb-q__choice label {
  display: flex; align-items: flex-start; gap: 8px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px;
}
@media (hover: hover) and (pointer: fine) {
  .nb-q__choice label:hover { background: #f1f0fb; }
}
.nb-q__choice input { margin-top: 3px; }
.nb-q__actions { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.nb-q__check {
  background: #6c4aee; color: #fff; border: 0; border-radius: 6px;
  padding: 6px 14px; font-weight: 600; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .nb-q__check:hover { background: #5a3ad6; }
}
.nb-q__result { font-weight: 600; font-size: 0.9rem; }
.nb-q__result.is-correct { color: #16a34a; }
.nb-q__result.is-wrong { color: #dc2626; }
.nb-q__result.is-hint { color: #6b7280; }
.nb-q__free {
  width: 100%; box-sizing: border-box; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 8px 10px; font-family: inherit; font-size: 0.9rem;
  /* Grow with the answer; min-height keeps the rows="4" starting height,
     which field-sizing: content would otherwise collapse to one line. */
  field-sizing: content;
  min-height: calc(4lh + 18px);
}

/* --- Accessibility ------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 2000;
  padding: 0.6rem 1rem;
  background: #6c4aee;
  color: #fff;
  font-weight: 700;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.15s ease-out;
}
.skip-link:focus { top: 8px; color: #fff; }

:focus-visible {
  outline: 3px solid #6c4aee;
  outline-offset: 2px;
}

/* Skip-link target: suppress the ring on the programmatically focused main. */
main[tabindex="-1"]:focus {
  outline: none;
}
