/* Archivo (SIL OFL), variable weight 100–900 and width 62–125%. */
@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0b0c0b;
  --bg-2: #131413;
  --bg-3: #1a1c1a;
  --line: #222422;
  --line-2: #33362f;
  --text: #f2f2ec;
  --soft: #d6d7d0;
  --muted: #8d9089;
  --faint: #5c5f59;
  --green: #3cf28f;
  --font: 'Archivo', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --topbar: 64px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Hollow letters, like "MAGIC" in the logo. */
.outline-text {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--text);
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-fill {
  fill: currentColor;
  stroke: none;
}
.icon-check {
  stroke-width: 2.4;
}

/* --- Top bar ----------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar);
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 40px;
}
.lesson-body-page .topbar-inner {
  max-width: none;
  padding: 0 32px;
}
.brand img {
  height: 40px;
  width: auto;
}
.crumb {
  padding-left: 20px;
  border-left: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb:hover {
  color: var(--text);
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  font-size: 14px;
}
.topbar-nav form {
  margin: 0;
}
.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  border: 1px solid var(--line-2);
  border-radius: 99px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.progress-pill:hover {
  border-color: var(--muted);
}
.progress-ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line-2) 0);
  -webkit-mask: radial-gradient(circle, transparent 4.5px, #000 5px);
  mask: radial-gradient(circle, transparent 4.5px, #000 5px);
}
.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.link-button:hover {
  color: var(--text);
}

/* --- Buttons & forms ------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 600 15px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.button.primary {
  background: var(--text);
  color: var(--bg);
}
.button.primary:hover {
  background: #fff;
}
.button.secondary {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
.button.secondary:hover {
  border-color: var(--muted);
}
.button.secondary .icon {
  color: var(--faint);
}
.button.done {
  background: rgb(60 242 143 / 0.08);
  border-color: rgb(60 242 143 / 0.35);
  color: var(--green);
}
.button.done:hover {
  background: transparent;
}
.button.wide {
  width: 100%;
}

.stack {
  display: grid;
  gap: 14px;
}
.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: 16px var(--font);
}
.field input:focus {
  outline: none;
  border-color: var(--text);
}

/* --- Sign-in pages --------------------------------------------------------------------- */

.auth {
  display: grid;
  place-items: center;
  padding: 72px 16px 96px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-card h1 {
  margin: 0 0 12px;
  font-size: 34px;
  font-weight: 800;
  font-stretch: 118%;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 17px;
}
.lede strong {
  color: var(--text);
  font-weight: 600;
}
.notice {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-left: 2px solid #f2c14e;
  background: rgb(242 193 78 / 0.07);
  color: #f5d98e;
  font-size: 15px;
}
.fine {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.fine a,
.tips a {
  color: var(--text);
}
.tips {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 15px;
}

/* --- Course page ----------------------------------------------------------------------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 40px 120px;
}

.hero {
  position: relative;
  display: grid;
  min-height: 480px;
  margin-bottom: 80px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #000;
}
.hero-media {
  position: absolute;
  inset: 0 0 0 32%;
}
.hero-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* The encoded "black" is #050505; a little contrast makes it true black so there's no seam. */
  filter: contrast(1.12);
  -webkit-mask: linear-gradient(90deg, transparent 0, #000 40%);
  mask: linear-gradient(90deg, transparent 0, #000 40%);
}
.hero-content {
  position: relative;
  z-index: 1;
  align-self: center;
  max-width: 600px;
  padding: 56px;
}
.hero-hello {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}
.hero-kicker {
  margin: 28px 0 0;
  color: var(--soft);
  font-size: 15px;
}
.hero-title {
  margin: 10px 0 32px;
  font-size: clamp(34px, 3.8vw, 52px);
  font-weight: 800;
  font-stretch: 118%;
  line-height: 1;
  letter-spacing: -0.02em;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}
.button.large {
  min-height: 52px;
  padding: 0 26px;
  font-size: 16px;
}
.button.large .icon {
  width: 16px;
  height: 16px;
}
.hero-len {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.hero-progress {
  display: grid;
  gap: 8px;
  max-width: 340px;
  margin-top: 44px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.bar {
  display: block;
  height: 3px;
  border-radius: 3px;
  background: var(--line-2);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.sections-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 8px;
}
.sections-head h2 {
  font-size: 22px;
  font-weight: 700;
  font-stretch: 112%;
}
.sections-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sections {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.section {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 48px;
  padding: 44px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--topbar) + 16px);
}
.section-cover {
  align-self: start;
  aspect-ratio: 640 / 325;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
}
.section-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.section-cover:hover img {
  transform: scale(1.04);
}
.section-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}
.section-num {
  min-width: 2.2ch;
  font-size: 56px;
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.9;
  -webkit-text-stroke: 1.25px var(--faint);
}
.section.is-complete .section-num {
  -webkit-text-stroke-color: var(--green);
}
.section-head h2 {
  font-size: 26px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}
.section-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.section-go {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.section-go:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* --- Lesson rows (course page + sidebar) ---------------------------------------------- */

.lesson-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.lesson-row {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 18px;
  gap: 12px;
  align-items: center;
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  text-decoration: none;
}
.lesson-row:hover {
  background: var(--bg-2);
}
.lesson-num {
  display: flex;
  color: var(--faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.lesson-num .icon {
  width: 16px;
  height: 16px;
}
.lesson-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.lesson-meta {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.lesson-check {
  display: flex;
  color: var(--green);
}
.lesson-check .icon {
  width: 16px;
  height: 16px;
}
.lesson-row.is-done .lesson-title {
  color: var(--muted);
}
.lesson-row.is-current {
  background: var(--bg-3);
}
.lesson-row.is-current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--green);
}
.lesson-row.is-current .lesson-title {
  color: var(--text);
  font-weight: 600;
}
.tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--green);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
}

/* --- Lesson page ----------------------------------------------------------------------- */

.theatre {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: calc(100vh - var(--topbar) - 1px);
}
.theatre-main {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 40px 96px;
}
.stage {
  /* Keep the whole player on screen on wide but short displays. */
  max-width: calc((100vh - var(--topbar) - 200px) * 16 / 9);
  min-width: min(100%, 640px);
  margin: 0 auto 28px;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}
.player {
  margin: 0;
  aspect-ratio: 16 / 9;
  background: #000;
}
.player video {
  display: block;
  width: 100%;
  height: 100%;
}
.lesson-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
/* Video-only lessons: no notes below, so no divider before the pager. */
.lesson-head:has(+ .lesson-pager) {
  margin-bottom: 0;
  border-bottom: 0;
}
.lesson-head + .lesson-pager {
  margin-top: 16px;
}
.lesson-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}
.lesson-head h1 {
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 750;
  font-stretch: 112%;
  letter-spacing: -0.015em;
}
.lesson-actions {
  display: flex;
  gap: 10px;
}
.lesson-actions form {
  margin: 0;
}

.prose {
  max-width: 68ch;
  color: var(--soft);
  font-size: 17px;
  line-height: 1.7;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1em;
}
.prose ul,
.prose ol {
  padding-left: 1.2em;
}
.prose li + li {
  margin-top: 0.35em;
}
.prose h2,
.prose h3 {
  margin: 1.8em 0 0.5em;
  color: var(--text);
  font-size: 21px;
  font-weight: 700;
  font-stretch: 110%;
}
.prose h3 {
  font-size: 18px;
}
.prose strong {
  color: var(--text);
  font-weight: 600;
}
.prose a {
  color: var(--text);
  text-decoration-color: rgb(60 242 143 / 0.6);
  text-underline-offset: 3px;
}
.prose a:hover {
  text-decoration-color: var(--green);
}
.prose .player {
  margin: 0 0 1.5em;
  border-radius: 10px;
  overflow: hidden;
}

.file-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  max-width: 560px;
  margin: 0 0 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}
.prose .file-card {
  text-decoration: none;
}
.file-card:hover {
  border-color: var(--muted);
}
.file-card > .icon {
  width: 26px;
  height: 26px;
}
.file-info {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}
.file-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-info small {
  color: var(--muted);
  font-size: 13px;
}
.file-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.lesson-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
}
.lesson-pager a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s;
}
.lesson-pager a:hover {
  border-color: var(--muted);
}
.lesson-pager small {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.lesson-pager .pager-next {
  justify-content: flex-end;
  grid-column: 2;
  text-align: right;
}
.lesson-pager .icon {
  color: var(--muted);
}

.theatre-side {
  position: sticky;
  top: calc(var(--topbar) + 1px);
  height: calc(100vh - var(--topbar) - 1px);
  overflow-y: auto;
  padding: 18px 16px 48px;
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.side-head {
  display: grid;
  gap: 10px;
  margin: 0 0 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--line);
}
.side-head p {
  display: flex;
  justify-content: space-between;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.side-head p span:first-child {
  color: var(--text);
  font-weight: 600;
}

.outline-section summary {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto 16px;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  list-style: none;
  cursor: pointer;
  transition: background 0.15s;
}
.outline-section summary::-webkit-details-marker {
  display: none;
}
.outline-section summary:hover {
  background: var(--bg-2);
}
.outline-thumb {
  width: 64px;
  height: 32px;
  border-radius: 5px;
  object-fit: cover;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.outline-section summary:hover .outline-thumb,
.outline-section[open] .outline-thumb {
  opacity: 1;
}
.outline-label {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}
.outline-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.outline-section summary:hover .outline-name,
.outline-section[open] .outline-name {
  color: var(--text);
}
.outline-section.is-current .outline-name {
  font-weight: 650;
}
.outline-sub {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.icon-chevron {
  width: 16px;
  height: 16px;
  color: var(--faint);
  transition: transform 0.2s;
}
.outline-section[open] .icon-chevron {
  transform: rotate(90deg);
}
/* Lessons hang off a guide line under the section thumbnail. */
.outline-section .lesson-list {
  margin: 2px 0 12px 40px;
  padding-left: 6px;
  border-left: 1px solid var(--line-2);
}
.theatre-side .lesson-row {
  grid-template-columns: 24px minmax(0, 1fr) auto 16px;
  gap: 8px;
  margin: 0;
  padding: 7px 8px;
  color: var(--soft);
  font-size: 14px;
}
.theatre-side .lesson-row.is-current::before {
  left: -7px;
  top: 4px;
  bottom: 4px;
}
.theatre-side .lesson-num {
  font-size: 12px;
}
.theatre-side .lesson-meta {
  font-size: 12px;
}

/* --- Smaller screens ------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .theatre {
    grid-template-columns: minmax(0, 1fr);
  }
  .theatre-side {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 24px 24px 64px;
  }
}

@media (max-width: 900px) {
  .hero {
    min-height: 0;
    margin-bottom: 56px;
  }
  .hero-media {
    position: relative;
    inset: auto;
    aspect-ratio: 16 / 9;
  }
  .hero-media video {
    -webkit-mask: linear-gradient(180deg, #000 60%, transparent 100%);
    mask: linear-gradient(180deg, #000 60%, transparent 100%);
  }
  .hero-content {
    max-width: none;
    margin-top: -64px;
    padding: 0 28px 32px;
  }
  .section {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .lesson-body-page .topbar-inner {
    gap: 12px;
    padding: 0 16px;
  }
  .brand img {
    height: 34px;
  }
  .crumb {
    display: none;
  }
  .topbar-nav {
    gap: 14px;
  }
  .page {
    padding: 40px 16px 80px;
  }
  .hero-content {
    padding: 0 20px 28px;
  }
  .hero-kicker {
    margin-top: 16px;
  }
  .section {
    padding: 32px 0;
  }
  .section-num {
    font-size: 40px;
  }
  .section-head h2 {
    font-size: 21px;
  }
  .theatre-main {
    padding: 0 0 48px;
  }
  .stage {
    min-width: 0;
    border-radius: 0;
  }
  .lesson-head,
  .prose,
  .lesson-pager {
    margin-left: 16px;
    margin-right: 16px;
  }
  .lesson-head {
    padding-top: 4px;
  }
  .lesson-actions {
    width: 100%;
  }
  .lesson-actions > * {
    flex: 1;
  }
  .lesson-actions .button {
    width: 100%;
  }
  .lesson-pager {
    grid-template-columns: minmax(0, 1fr);
  }
  .lesson-pager .pager-next {
    grid-column: 1;
  }
  .theatre-side {
    padding: 20px 8px 48px;
  }
  .file-card {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .file-action {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
