/* ============================================================
   LESSON PAGE TEMPLATE — STYLESHEET
   freeCodeCamp-style 3-column lesson layout (sidebar / content / TOC)
   All colors, sizes and spacing are exposed as CSS variables in
   :root so this template can be re-skinned for any course/content
   without touching the rules below.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');
@import url('https://cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css');

:root {
  /* ── Brand tokens (swap these to re-theme the whole page) ── */
  --navy:        #0a0a23;
  --navy-80:     #1b1b32;
  --navy-70:     #2a2a40;
  --navy-60:     #3b3b4f;
  --navbar-background: #3b3b4f;
  --white:       #ffffff;
  --off-white:   #f5f6f7;
  --gray-10:     #dfdfe2;
  --gray-20:     #d0d0d5;

  /* Semantic accent colours */
  --purple-light:#dbb8ff;
  --purple-dark: #5a01a7;
  --yellow-light:#f1be32;
  --yellow-dark: #4d3800;
  --blue-light:  #99c9ff;
  --blue-dark:   #002ead;
  --green-light: #acd157;
  --green-dark:  #00471b;
  --red:         #d92d20;
  --red-bg:      #fdecea;

  /* ── Callout tokens ── */
  --new-concept-bg:       var(--blue-dark);
  --repeating-concept-bg: var(--blue-light);
  --repeating-concept-label: #1d5fa5;
  --repeating-concept-text:  #163f73;
  --caution-bg:           var(--yellow-dark);
  --best-practice-bg:     var(--green-dark);
  --common-error-bg:      var(--yellow-light);
  --try-it-bg:            var(--green-light);
  --deep-dive-bg:         var(--purple-light);
  --critical-bg:          var(--purple-dark);

  /* ── Layout ── */
  --sidebar-w:   260px;
  --toc-w:       240px;
  --header-h:    56px;
  --topbar-h:    100px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow-sm:   0 1px 3px rgba(10,10,35,.08);
  --shadow-md:   0 4px 16px rgba(10,10,35,.10);
  --transition:  .2s ease;

  /* ── Type ── */
  --font-body: 'Lato', sans-serif;
  --font-mono: 'Hack', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.78;
  color: var(--navy);
  background: var(--off-white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── TOP BAR (outer brand strip) ── */
.topbar {
  height: var(--topbar-h);
  text-align: center;
  display: block;
  margin: auto;
  padding: 28px;
  z-index: 1000;
  background: var(--navy);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--white); font-weight: 700; font-size: 20px; letter-spacing: .5px;
  text-decoration: none; font-family: var(--font-mono);
}
.topbar-brand img { height: 44px; width: auto; display: block; }

/* ── NAV BAR (course-level nav) ── */
.navbar {
  z-index: 1000;
  height: var(--header-h);
  background: var(--navbar-background);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--white); font-weight: 700; font-size: 16px; letter-spacing: -.3px;
  text-decoration: none;
}
.navbar-badge {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--purple-light), var(--blue-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--navy);
}
.navbar-links { display: flex; align-items: center; gap: 6px; }
.navbar-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8); font-size: 13px; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.navbar-btn:hover { background: rgba(255,255,255,.1); color: var(--white); }
a.navbar-btn { text-decoration: none; }
.navbar-btn:focus-visible { outline: 2px solid var(--purple-light); outline-offset: 2px; }
.navbar-btn.primary { background: var(--purple-dark); border-color: var(--purple-dark); color: var(--white); }
.navbar-btn.primary:hover { background: #7000d0; }
.navbar-search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm); padding: 6px 12px;
  color: rgba(255,255,255,.5); font-size: 13px; cursor: text;
  transition: var(--transition);
}
.navbar-search:hover { background: rgba(255,255,255,.15); }
.navbar-search:focus-visible { outline: 2px solid var(--purple-light); outline-offset: 2px; }
.navbar-search { cursor: pointer; }
.search-icon { font-size: 14px; }
.navbar-search kbd {
  margin-left: auto; font-size: 10px; opacity: .5;
  background: rgba(255,255,255,.1); padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono);
}

  /* allow the topbar to grow for the extra button line, without touching styles.css */
  .topbar { height: auto !important; padding-bottom: 18px !important; }

  .disclaimer-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 16px;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.75);
    font-family: 'Lato', sans-serif;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: .2s ease;
  }
  .disclaimer-btn:hover {
    background: rgba(255,255,255,.16);
    color: #fff;
  }

  .disclaimer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,10,35,.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .disclaimer-overlay.open { display: flex; }

  .disclaimer-modal {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    max-width: 480px;
    width: 100%;
    padding: 32px 28px 28px;
    box-shadow: 0 12px 40px rgba(10,10,35,.35);
  }
  .disclaimer-title {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5a01a7;
    margin-bottom: 14px;
  }
  .disclaimer-text {
    font-family: 'Lato', sans-serif;
    font-size: 13.5px;
    line-height: 1.8;
    color: #3b3b4f;
    margin-bottom: 12px;
  }
  .disclaimer-text:last-of-type { margin-bottom: 0; }
  .disclaimer-text strong { color: #0a0a23; font-weight: 700; }

  .disclaimer-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f5f6f7;
    color: #3b3b4f;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s ease;
  }
  .disclaimer-close:hover { background: #dfdfe2; color: #0a0a23; }

/* ── MAIN 3-COLUMN LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  grid-template-rows: auto;
  min-height: calc(100vh - var(--header-h));
}

/* ── LEFT SIDEBAR — LESSON NAVIGATOR ── */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--white);
  border-right: 1px solid var(--gray-10);
  scrollbar-width: thin; scrollbar-color: var(--gray-10) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-10); border-radius: 4px; }

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--gray-10);
  position: sticky; top: 0; background: var(--white); z-index: 10;
}
.sidebar-title {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--navy-60);
}
.progress-bar-wrap {
  margin-top: 8px; height: 4px; background: var(--gray-10);
  border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--purple-dark), var(--blue-dark));
  border-radius: 4px;
  transition: width 1s ease;
}
.progress-label { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--navy-60); }

.lesson-group { padding: 8px 0; }
.lesson-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--navy-60); padding: 6px 16px 2px;
}
.lesson-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition); text-decoration: none;
  color: inherit; position: relative;
}
.lesson-item:hover { background: var(--off-white); }
.lesson-item.active { background: #f0eaff; border-left-color: var(--purple-dark); }
.lesson-item.done .lesson-num { background: var(--green-dark); color: var(--white); }
.lesson-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-10); color: var(--navy-60);
  font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  margin-top: 1px; transition: var(--transition);
}
.lesson-item.active .lesson-num { background: var(--purple-dark); color: var(--white); }
.lesson-info { flex: 1; min-width: 0; }
.lesson-name { font-size: 13px; font-weight: 500; color: var(--navy); line-height: 1.3; }
.lesson-item.active .lesson-name { color: var(--purple-dark); }
.lesson-meta { font-size: 11px; color: var(--navy-60); margin-top: 1px; }
.lesson-badge { font-size: 10px; padding: 1px 7px; border-radius: 20px; font-weight: 500; flex-shrink: 0; margin-top: 2px; }
.badge-new { background: #eef1ff; color: var(--blue-dark); }
.badge-lab { background: #f3fbea; color: var(--green-dark); }

/* ── SIDEBAR PARTS ACCORDION ──
   Built by engine.js from CONFIG.parts. If no parts are configured,
   none of these classes are used and the flat list above applies. */
.parts-controls { display: flex; justify-content: flex-end; margin-top: 6px; }
.parts-toggle-all {
  background: none; border: none; padding: 2px 0; cursor: pointer;
  font-family: var(--font-body); font-size: 11px; font-weight: 700; line-height: 1.4;
  color: var(--purple-dark); border-radius: 3px;
}
.parts-toggle-all:hover { text-decoration: underline; text-underline-offset: 2px; }
.parts-toggle-all:focus-visible { outline: 2px solid var(--purple-dark); outline-offset: 2px; }

.parts-accordion { padding: 0 0 24px; }
.part { border-bottom: 1px solid var(--gray-10); }
.part-heading { margin: 0; font: inherit; }

.part-toggle {
  width: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px 12px;
  background: var(--white); color: var(--navy);
  border: none; cursor: pointer; text-align: left;
  font-family: var(--font-body); line-height: 1.35;
  transition: background var(--transition);
}
.part-toggle:hover { background: var(--off-white); }
.part-toggle:focus-visible { outline: 2px solid var(--purple-dark); outline-offset: -2px; }
.part.open .part-toggle { background: var(--off-white); }

.part-chevron {
  flex-shrink: 0; width: 22px; height: 22px; margin-top: 3px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--gray-10); color: var(--navy-60);
  transition: transform .25s ease, background var(--transition), color var(--transition);
}
.part.open .part-chevron { transform: rotate(90deg); }
.part.has-active .part-chevron { background: var(--purple-dark); color: var(--white); }

.part-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.part-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--navy-60);
}
.part.has-active .part-label { color: var(--purple-dark); }
.part-title { font-size: 13.5px; font-weight: 700; color: var(--navy); }

.part-count {
  flex-shrink: 0; margin-top: 3px;
  font-size: 11px; font-weight: 700; line-height: 1.6;
  padding: 0 8px; border-radius: 20px;
  background: var(--white); color: var(--navy-60);
  border: 1px solid var(--gray-10);
  font-variant-numeric: tabular-nums;
}
.part.complete .part-count { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); }

/* Collapse animation: 0fr → 1fr grid rows (no fixed heights needed) */
.part-panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .28s ease;
}
.part.open .part-panel { grid-template-rows: 1fr; }
.part-panel-inner { overflow: hidden; min-height: 0; }
.part-panel-body { padding: 2px 0 10px; }

.part-empty {
  font-size: 12px; line-height: 1.5; color: var(--navy-60); font-style: italic;
  padding: 4px 16px 6px 48px;
}
.part .lesson-item { padding-left: 26px; }

.parts-accordion.no-anim .part-panel,
.parts-accordion.no-anim .part-chevron { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .part-panel, .part-chevron { transition: none; }
}

/* ── SEARCH MODAL ── */
body.search-open { overflow: hidden; }
.search-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 2300;
  background: rgba(10,10,35,.6);
  align-items: flex-start; justify-content: center;
  padding: 12vh 20px 20px;
}
.search-modal-overlay.open { display: flex; }
.search-modal {
  width: min(620px, 100%);
  max-height: 72vh;
  display: flex; flex-direction: column;
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(10,10,35,.4);
  font-family: var(--font-body);
}
.search-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--gray-10);
}
.search-modal-icon { font-size: 16px; line-height: 1; opacity: .7; }
.search-modal-input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-family: var(--font-body); font-size: 17px; line-height: 1.5; color: var(--navy);
  padding: 6px 0;
}
.search-modal-input::placeholder { color: var(--navy-60); opacity: .7; }
.search-modal-input::-webkit-search-cancel-button { display: none; }
.search-modal-close {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--off-white); color: var(--navy-60);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.search-modal-close:hover { background: var(--gray-10); color: var(--navy); }
.search-modal-close:focus-visible { outline: 2px solid var(--purple-dark); outline-offset: 2px; }

.search-modal-results { overflow-y: auto; padding: 8px; scrollbar-width: thin; }
.search-modal-result {
  display: block; width: 100%;
  text-align: left; cursor: pointer;
  padding: 10px 14px; margin-bottom: 2px;
  border: none; border-left: 3px solid transparent; border-radius: var(--radius-sm);
  background: transparent; font-family: var(--font-body); color: var(--navy);
  line-height: 1.4;
}
.search-modal-result.active { background: #f0eaff; border-left-color: var(--purple-dark); }
.search-modal-result-title { font-size: 14.5px; font-weight: 700; }
.search-modal-result.active .search-modal-result-title { color: var(--purple-dark); }
.search-modal-result-meta { font-size: 12.5px; color: var(--navy-60); margin-top: 2px; }
.search-modal-result-part {
  font-size: 11px; color: var(--navy-60); margin-top: 3px;
  opacity: .85;
}
.search-modal-result mark {
  background: var(--yellow-light); color: var(--navy);
  border-radius: 2px; padding: 0 1px;
}
.search-modal-current {
  display: inline-block; vertical-align: 1px; margin-left: 6px;
  font-size: 10px; font-weight: 700; padding: 0 7px; border-radius: 20px;
  background: var(--purple-dark); color: var(--white); line-height: 1.7;
}
.search-modal-empty {
  padding: 28px 18px; text-align: center;
  font-size: 14px; color: var(--navy-60); line-height: 1.6;
}
.search-modal-footer {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 9px 18px;
  border-top: 1px solid var(--gray-10); background: var(--off-white);
  font-size: 11.5px; color: var(--navy-60); line-height: 1.6;
}
.search-modal-footer kbd {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--white); border: 1px solid var(--gray-20); border-radius: 4px;
  padding: 0 5px; margin-right: 3px;
}
@media (max-width: 720px) {
  .search-modal-overlay { padding: 16px 12px; }
  .search-modal { max-height: calc(100vh - 32px); }
  .search-modal-footer { display: none; }
}

/* READ PAPER AND COLAB NOTEBOOK RESOURCES */

/* ── ACTION LINKS & BADGES ── */
.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.action-badge img { height: 26px; display: block; }
.action-badge:hover { opacity: .85; }
.action-badge.github { background: #24292e; }

/* ── PDF MODAL ── */
.pdf-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,35,.7);
  z-index: 2100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pdf-modal-overlay.open { display: flex; }
.pdf-modal {
  position: relative;
  width: min(900px, 100%);
  height: min(90vh, 1100px);
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(10,10,35,.4);
  display: flex;
  flex-direction: column;
}
.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--navy);
  color: var(--white);
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.pdf-modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: var(--white);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.pdf-modal-close:hover { background: rgba(255,255,255,.25); }
.pdf-modal-frame { flex: 1; border: none; width: 100%; }


/* ── content images are clickable to zoom ── */
.content-body img {
  cursor: zoom-in;
  transition: opacity var(--transition);
}
.content-body img:hover { opacity: .92; }

/* ── IMAGE LIGHTBOX ── */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,35,.7);
  z-index: 2200;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
  cursor: zoom-out;
}
.lightbox-close {
  position: fixed;
  top: 24px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── VIDEO EMBEDS ── */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0 8px;
  background: var(--navy-80);
}
.video-wrap iframe,
.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
/* ── VIDEO CENTRE PLAY BUTTON ── */
.video-play-overlay {
  position: absolute; top: 50%; left: 50%; z-index: 2;
  width: 84px; height: 84px; margin: -42px 0 0 -42px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.85);
  background: rgba(10,10,35,.62); color: var(--white);
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(10,10,35,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity .2s ease, transform .2s ease, background var(--transition);
}
.video-play-overlay svg { width: 44px; height: 44px; display: block; }
.video-play-overlay:hover { background: var(--purple-dark); transform: scale(1.06); }
.video-play-overlay:focus-visible { outline: 3px solid var(--purple-light); outline-offset: 4px; }
.video-play-overlay.is-hidden { opacity: 0; transform: scale(.85); pointer-events: none; }
@media (max-width: 720px) {
  .video-play-overlay { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
  .video-play-overlay svg { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .video-play-overlay { transition: none; }
}

.video-caption {
  font-size: 13px;
  color: var(--navy-60);
  margin: 0 0 24px;
  text-align: center;
}

.video-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--purple-dark);
  margin: 24px 0 10px;
}

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
}
.content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-family: 'Lato', sans-serif;
}
.content-table caption {
  caption-side: top;
  text-align: left;
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--purple-dark);
  background: var(--off-white);
  border-bottom: 1px solid var(--gray-10);
}
.content-table thead th {
  background: var(--navy);
  color: var(--white);
  text-align: left;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .03em;
  white-space: nowrap;
}
.content-table tbody td {
  padding: 12px 18px;
  border-top: 1px solid var(--gray-10);
  color: #2c2c45;
  vertical-align: top;
  font-size: 18px;
}
.content-table tbody tr:nth-child(even) { background: var(--off-white); }
.content-table tbody tr:hover { background: #f0eaff; }
.content-table td strong { color: var(--navy); }

/* ── MAIN CONTENT AREA ── */
.main { min-width: 0; background: var(--white); }

.lesson-header {
  background: var(--navy);
  padding: 32px 48px 28px;
  position: relative; overflow: hidden;
}
.lesson-header::before {
  content: '';
  position: absolute; top: -60px; right: -60px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(219,184,255,.12) 0%, transparent 70%);
}
.lesson-breadcrumb {
  font-size: 12px; color: rgba(255,255,255,.5); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.lesson-breadcrumb a { color: rgba(255,255,255,.5); text-decoration: none; }
.lesson-breadcrumb a:hover { color: var(--purple-light); }
.lesson-breadcrumb span.sep { opacity: .4; }
.lesson-main-title {
  font-size: 28px; font-weight: 900; color: var(--white); letter-spacing: -.3px;
  line-height: 1.2; margin-bottom: 10px; font-family: var(--font-body);
}
.lesson-subtitle { font-size: 15px; color: rgba(255,255,255,.65); max-width: 540px; font-weight: 300; line-height: 1.7; }
.lesson-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.lesson-tag {
  font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 500;
  border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.07);
}
.lesson-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.action-btn {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 7px; border: none;
}
a.action-btn { text-decoration: none; }
.action-btn.outline { background: rgba(255,255,255,.1); color: var(--white); border: 1px solid rgba(255,255,255,.2); }
.action-btn.outline:hover { background: rgba(255,255,255,.18); }
.action-btn.accent { background: var(--purple-dark); color: var(--white); }
.action-btn.accent:hover { background: #7000d0; }

.content-body { padding: 40px 48px 80px;  } /* max-width: 780px; */

/* ── CONTENT TYPOGRAPHY ── */
.content-body h2 {
  font-size: 22px; font-weight: 700; color: var(--navy);
  margin: 40px 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-10);
  letter-spacing: -.2px; font-family: var(--font-body);
}
.content-body h2:first-child { margin-top: 0; }
.content-body h3 { font-size: 18px; font-weight: 700; color: var(--navy); margin: 28px 0 10px; font-family: var(--font-body); }
.content-body p { margin-bottom: 16px; color: #2c2c45; line-height: 1.85; font-weight: 400; }
.content-body a { color: var(--purple-dark); text-decoration: underline; text-underline-offset: 3px; }
.content-body strong { font-weight: 700; color: var(--navy); }
.content-body ul, .content-body ol { margin: 0 0 16px 20px; }
.content-body li { margin-bottom: 6px; color: #2c2c45; font-weight: 400; }
.content-body img { max-width: 100%; border-radius: var(--radius); margin: 8px 0 24px; display: block; }

/* ── ALERT CALLOUT CARDS ── */
.callout {
  border-radius: var(--radius); padding: 16px 20px;
  margin: 24px 0; border-left: 4px solid;
  display: flex; gap: 14px; align-items: flex-start;
}
.callout-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; }
.callout-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.callout-text { font-size: 14px; line-height: 1.6; }

/* one modifier class per callout "type" — add more by following the same pattern */
.callout-new       { background: var(--new-concept-bg); border-color: var(--new-concept-bg); }
.callout-new .callout-label, .callout-new .callout-text { color: var(--white); }

.callout-caution    { background: var(--caution-bg); border-color: var(--caution-bg); }
.callout-caution .callout-label, .callout-caution .callout-text { color: var(--white); }

.callout-best       { background: var(--best-practice-bg); border-color: var(--try-it-bg); }
.callout-best .callout-label, .callout-best .callout-text { color: var(--white); }

.callout-error      { background: var(--common-error-bg); border-color: var(--caution-bg); }
.callout-error .callout-label, .callout-error .callout-text { color: var(--navy); }

/* ── CODE BLOCK ── */
.code-block { background: var(--navy-80); border-radius: var(--radius); padding: 20px 24px; margin: 24px 0; overflow-x: auto; position: relative; }
.code-lang {
  position: absolute; top: 10px; right: 14px;
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.3); font-family: var(--font-mono);
}
.code-block pre { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.75; color: #c8d3f5; white-space: pre; tab-size: 2; }
.code-block .kw { color: #c099ff; }
.code-block .fn { color: #82aaff; }
.code-block .str { color: #c3e88d; }
.code-block .cm { color: rgba(200,211,245,.4); font-style: italic; }
.code-block .num { color: #f78c6c; }
.copy-btn {
  position: absolute; top: 10px; right: 60px;
  padding: 4px 10px; border-radius: 4px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.5); font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,.2); color: var(--white); }

/* ── MATH BLOCK (KaTeX) ── */
.math-block {
  background: var(--off-white);
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
  overflow-x: auto;
  text-align: center;
}
.math-block .katex-display { margin: 0; }
.math-block .katex { font-size: 1.15em; }

/* ── KEY TERM CHIPS ── */
.term-chip {
  display: inline-block; padding: 1px 9px; border-radius: 20px;
  font-size: 12.5px; font-weight: 400; font-family: var(--font-mono);
  background: #f0eaff; color: var(--purple-dark);
  border: 1px solid rgba(90,1,167,.15);
  white-space: nowrap;
}
.inline-code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--off-white); padding: 2px 6px; border-radius: 4px;
}

/* ── QUIZ MINI-WIDGET ── */
.quiz-card { background: var(--off-white); border: 1px solid var(--gray-10); border-radius: var(--radius); padding: 24px; margin: 32px 0; }
.quiz-header { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--purple-dark); margin-bottom: 12px; }
.quiz-question { font-size: 15px; font-weight: 500; color: var(--navy); margin-bottom: 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-size: 15px; cursor: pointer; transition: var(--transition);
  text-align: left; font-family: var(--font-body); font-weight: 400; color: var(--navy);
}
.quiz-option:hover { border-color: var(--purple-light); background: #faf7ff; }
.quiz-option:disabled { cursor: default; }
.quiz-option.correct { border-color: var(--try-it-bg); background: var(--best-practice-bg); color: var(--white); }
.quiz-option.wrong { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.quiz-feedback { margin-top: 12px; font-size: 13px; display: none; }
.quiz-feedback.show { display: block; }


/* NEW QUIZ STYLE */

/* ── QUIZ SET (multi-question, graded on submit) ── */
.quizset-card {
  background: var(--off-white);
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
  padding: 24px;
  margin: 32px 0;
}
.quizset-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--purple-dark); margin-bottom: 20px;
}
.quizset-question-block { margin-bottom: 26px; }
.quizset-question-block:last-of-type { margin-bottom: 22px; }
.quizset-question-num {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--navy-60); margin-bottom: 6px;
}
.quizset-question-text { font-size: 15px; font-weight: 500; color: var(--navy); margin-bottom: 12px; }
.quizset-options { display: flex; flex-direction: column; gap: 8px; }
.quizset-option {
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-size: 14.5px; cursor: pointer; transition: var(--transition);
  text-align: left; font-family: 'Lato', sans-serif; font-weight: 400; color: var(--navy);
}
.quizset-option:hover { border-color: var(--purple-light); background: #faf7ff; }
.quizset-option.selected { border-color: var(--purple-dark); background: #f0eaff; }
.quizset-option.correct { border-color: var(--try-it-bg); background: var(--best-practice-bg); color: var(--white); }
.quizset-option.wrong { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.quizset-option:disabled { cursor: default; }
.quizset-explanation {
  margin-top: 8px; font-size: 13px; color: var(--navy-60);
  display: none; padding-left: 2px;
}
.quizset-explanation.show { display: block; }
.quizset-submit-btn {
  padding: 10px 22px; border-radius: var(--radius-sm); border: none;
  background: var(--purple-dark); color: var(--white);
  font-family: 'Lato', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.quizset-submit-btn:hover { background: #7000d0; }
.quizset-submit-btn:disabled { opacity: .5; cursor: default; }
.quizset-score-banner {
  display: none;
  padding: 14px 18px; border-radius: var(--radius-sm);
  margin-bottom: 20px; font-family: 'Lato', sans-serif;
  font-size: 14px; font-weight: 700;
}
.quizset-score-banner.show { display: block; }
.quizset-score-banner.pass { background: var(--best-practice-bg); color: var(--white); }
.quizset-score-banner.fail { background: var(--common-error-bg); color: var(--navy); }

/* ── SECTION DIVIDER ── */
.section-divider { height: 1px; background: var(--gray-10); margin: 40px 0; }

/* ── LESSON NAVIGATION FOOTER ── */
.lesson-nav-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 48px; border-top: 1px solid var(--gray-10);
  background: var(--white);
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-family: var(--font-body); font-size: 14px; cursor: pointer;
  transition: var(--transition); color: var(--navy); text-decoration: none;
}
.nav-btn:hover { border-color: var(--purple-dark); color: var(--purple-dark); background: #faf7ff; }
.nav-btn-label { font-size: 11px; color: var(--navy-60); display: block; margin-bottom: 2px; }
.nav-btn-title { font-weight: 600; }
.nav-btn.next { flex-direction: row-reverse; text-align: right; }
.nav-btn.next .nav-arrow { transform: rotate(180deg); }
.nav-btn.disabled { opacity: .4; pointer-events: none; }

/* ── RIGHT TOC — SECTION NAVIGATOR ── */
.toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--off-white);
  border-left: 1px solid var(--gray-10);
  scrollbar-width: thin; scrollbar-color: var(--gray-10) transparent;
}
.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb { background: var(--gray-10); border-radius: 4px; }
.toc-inner { padding: 20px 16px; }
.toc-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--navy-60); margin-bottom: 12px; }
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc-item a {
  display: block; padding: 5px 10px;
  font-size: 13px; color: var(--navy-60); text-decoration: none;
  border-radius: var(--radius-sm); border-left: 2px solid transparent;
  transition: var(--transition); line-height: 1.4;
}
.toc-item a:hover { color: var(--navy); background: var(--gray-10); }
.toc-item.active a { color: var(--purple-dark); font-weight: 600; border-left-color: var(--purple-dark); background: #f0eaff; }
.toc-item.sub a { padding-left: 22px; font-size: 12px; }

.toc-meta { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--gray-10); }
.toc-meta-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy-60); margin-bottom: 8px; }
.toc-meta-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.legend { margin-top: 24px; }
.legend-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-60); margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy-60); margin-bottom: 7px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ── MOBILE TOGGLE ── */
.mob-toggle {
  display: none; position: fixed; bottom: 20px; right: 20px; z-index: 900;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--purple-dark); color: var(--white);
  border: none; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(90,1,167,.4);
  align-items: center; justify-content: center;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .toc { display: none; }
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
}
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -280px; top: var(--header-h); width: 280px; z-index: 800;
    transition: left .3s ease;
    height: calc(100vh - var(--header-h));
    box-shadow: none;
  }
  .sidebar.open { left: 0; box-shadow: var(--shadow-md); }
  .mob-toggle { display: flex; }
  .content-body { padding: 24px 20px 60px; }
  .lesson-header { padding: 24px 20px 20px; }
  .lesson-main-title { font-size: 20px; }
  .lesson-nav-footer { padding: 16px 20px; }
  .navbar-links .navbar-btn:not(.primary) { display: none; }
  .navbar-search { display: none; }
}
@media (max-width: 480px) {
  .lesson-nav-footer { flex-direction: column; gap: 10px; }
  .nav-btn { width: 100%; justify-content: center; }
  .nav-btn.next { flex-direction: row; text-align: left; }
}


 .site-footer {
    background: var(--navy);
    padding: 40px 48px 28px;
    margin-top: 0;
  }
  .site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    /* display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 28px; */
        margin: auto;
  }
  .site-footer-brand {
    font-family: 'Hack', 'Courier New', monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 6px;
  }
  .site-footer-tagline {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,.5);
    max-width: 360px;
    line-height: 1.7;
    text-align: center;
    margin: auto;
  }
  .site-footer-container {
      margin: auto;
      text-align: center;
    }
  .site-footer-links {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
  }
  .site-footer-links a,
  .site-footer-links button {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
  }
  .site-footer-links a:hover,
  .site-footer-links button:hover { color: var(--purple-light); }
  .site-footer-bottom {
    max-width: 1100px;
    margin: 24px auto 0;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    color: rgba(255,255,255,.35);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  @media (max-width: 720px) {
    .site-footer { padding: 32px 20px 24px; }
    .site-footer-inner { flex-direction: column; }
  }