@font-face {
  font-family: "Literata";
  src: url("./fonts/Literata-Variable.ttf") format("truetype");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("./fonts/Literata-VariableItalic.ttf") format("truetype");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Basier Circle";
  src: url("./fonts/BasierCircle-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Basier Circle";
  src: url("./fonts/BasierCircle-SemiBold.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Basier Circle";
  src: url("./fonts/BasierCircle-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/AtkinsonHyperlegible-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/AtkinsonHyperlegible-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --tqa-ember: #d54a2f;
  --tqa-ember-deep: #8a2a1c;
  --tqa-sunrise: #e5a402;
  --tqa-sunrise-soft: #f5c84b;
  --tqa-ink: #2b2b52;
  --tqa-ink-deep: #1a1a3a;
  --tqa-paper: #f5f0d3;
  --tqa-paper-soft: #faf6e1;
  --tqa-charcoal: #1e1e1e;
  --neutral-200: #e8e1be;
  --neutral-500: #8a8572;
  --neutral-700: #4a4638;
  --sidebar-bg: #f7f3df;
  --sidebar-width: 340px;
  --header-height: 52px;
  --font-display: "Literata", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-sans: "Basier Circle", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reading: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--tqa-paper);
  color: var(--neutral-700);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input {
  font: inherit;
}

a {
  color: var(--tqa-ember);
}

/* Top brand bar — Thinkific header equivalent */
.topbar {
  height: var(--header-height);
  background: var(--tqa-ember);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right { justify-content: flex-end; }

.topbar-brand {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 16px;
}

.topbar a,
.topbar button.linkish {
  color: #fff;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
}

.topbar a:hover,
.topbar button.linkish:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Course shell */
.course-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--neutral-200);
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
  padding: 20px 16px 40px;
}

.sidebar-course-title {
  margin: 0 0 10px;
  color: var(--tqa-charcoal);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.progress-block {
  margin-bottom: 14px;
}

.progress-label {
  margin: 0 0 8px;
  color: var(--neutral-500);
  font-size: 13px;
  font-weight: 600;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(43, 43, 82, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--tqa-ember);
  border-radius: inherit;
}

.lesson-search {
  width: 100%;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--neutral-200);
  border-radius: 4px;
  background: var(--tqa-paper-soft);
  color: var(--tqa-charcoal);
}

.lesson-search::placeholder {
  color: var(--neutral-500);
}

.chapter {
  border-bottom: 1px solid rgba(232, 225, 190, 0.9);
}

.chapter-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr auto 16px;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 6px;
  cursor: pointer;
  color: var(--tqa-charcoal);
}

.chapter-toggle:hover {
  background: rgba(213, 74, 47, 0.06);
}

.chapter-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(43, 43, 82, 0.25);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chapter.is-complete .chapter-check {
  background: var(--tqa-ember);
  border-color: var(--tqa-ember);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.chapter-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.chapter-count {
  color: var(--neutral-500);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chapter-chevron {
  color: var(--neutral-500);
  transition: transform 160ms ease;
}

.chapter.is-open .chapter-chevron {
  transform: rotate(180deg);
}

.chapter-lessons {
  display: none;
  padding: 0 0 10px;
}

.chapter.is-open .chapter-lessons {
  display: block;
}

.lesson-link {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 8px 10px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--neutral-700);
  position: relative;
}

.lesson-link:hover {
  background: rgba(43, 43, 82, 0.05);
}

.lesson-link.is-active {
  background: rgba(213, 74, 47, 0.1);
}

.lesson-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--tqa-ember);
}

.lesson-check {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid rgba(43, 43, 82, 0.22);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.lesson-link.is-complete .lesson-check {
  background: var(--tqa-ember);
  border-color: var(--tqa-ember);
}

.lesson-title {
  display: block;
  font-family: var(--font-reading);
  font-size: 14px;
  line-height: 1.35;
  color: var(--tqa-charcoal);
}

.lesson-meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neutral-500);
}

.chapter-pending-note {
  padding: 4px 8px 12px 34px;
  color: var(--neutral-500);
  font-size: 12px;
}

/* Main stage */
.stage {
  background: var(--tqa-paper-soft);
  min-width: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

.stage-inner {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.content-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--tqa-charcoal);
}

.content-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 6px;
}

.btn {
  appearance: none;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(43, 43, 82, 0.28);
  color: var(--tqa-ink);
}

.btn-ghost:hover {
  background: rgba(43, 43, 82, 0.05);
}

.btn-primary {
  background: var(--tqa-ember);
  color: #fff;
}

.btn-primary:hover {
  background: var(--tqa-ember-deep);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.video-shell {
  background: #111;
  border: 1px solid rgba(43, 43, 82, 0.16);
  border-radius: 4px;
  overflow: hidden;
}

.video-shell video,
.video-shell iframe {
  width: 100%;
  display: block;
  max-height: min(68vh, 620px);
  background: #000;
}

.video-shell:fullscreen,
.video-shell:-webkit-full-screen {
  background: #000;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.video-shell--embed {
  aspect-ratio: 16 / 9;
}

.video-shell--embed iframe {
  border: 0;
  width: 100%;
  height: 100%;
  min-height: 280px;
}

.video-shell:fullscreen video,
.video-shell:-webkit-full-screen video,
.video-shell:fullscreen iframe,
.video-shell:-webkit-full-screen iframe {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.footer-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.pdf-shell {
  background: var(--tqa-paper);
  border: 1px solid var(--neutral-200);
  border-radius: 4px;
  overflow: hidden;
  min-height: 70vh;
}

.pdf-shell iframe {
  width: 100%;
  height: 75vh;
  border: 0;
  display: block;
  background: #fff;
}

.pdf-fallback {
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--neutral-200);
}

.lesson-copy {
  font-family: var(--font-reading);
  font-size: 17px;
  line-height: 1.72;
  color: var(--neutral-700);
  max-width: 760px;
}

.lesson-copy img {
  max-width: 100%;
  height: auto;
}

.lesson-copy a {
  color: var(--tqa-ember);
  font-weight: 700;
}

.transcript {
  margin-top: 28px;
  border-top: 1px solid var(--neutral-200);
  padding-top: 18px;
}

.transcript summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--tqa-charcoal);
  margin-bottom: 10px;
}

.transcript summary::-webkit-details-marker { display: none; }

.transcript summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--tqa-ember);
  transition: transform 160ms ease;
}

.transcript[open] summary::before {
  transform: rotate(90deg);
}

.transcript-body {
  font-family: var(--font-reading);
  font-size: 17px;
  line-height: 1.72;
  color: var(--neutral-700);
}

.transcript-body p {
  margin: 0 0 16px;
}

.empty-stage {
  min-height: 50vh;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--neutral-500);
  padding: 40px 20px;
}

.empty-stage h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  color: var(--tqa-charcoal);
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.topbar button.linkish.mobile-nav-toggle {
  display: none;
}

@media (max-width: 900px) {
  .course-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: 30;
    max-height: none;
    width: min(100%, 420px);
    box-shadow: 0 20px 50px rgba(30, 30, 30, 0.25);
  }

  body.sidebar-open .sidebar {
    display: block;
  }

  .topbar button.linkish.mobile-nav-toggle {
    display: inline-flex;
  }

  .stage-inner {
    padding: 20px 16px 40px;
  }

  .content-header {
    flex-direction: column;
  }
}
