/* MITRA course site
   White paper, ink, and one institutional navy. Light only — no dark theme. */

:root {
  --paper:      #FFFFFF;
  --paper-2:    #FFFFFF;
  --inset:      #F4F6F9;
  --inset-2:    #EDF0F5;
  --rule:       #E2E6EC;
  --rule-firm:  #C8CFDA;

  --ink:        #0F1826;
  --ink-soft:   #4A5566;
  --ink-faint:  #78849A;

  --line:       #16386E;   /* institutional navy — links, marks, the fitted line */
  --line-deep:  #0D2450;
  --line-soft:  rgba(22, 56, 110, 0.07);
  --line-edge:  rgba(22, 56, 110, 0.26);
  --point:      #64728A;   /* the data: quiet graphite */
  --done:       #17694A;
  --done-soft:  rgba(23, 105, 74, 0.10);

  --r:     8px;
  --r-sm:  5px;
  --sidebar: 300px;
  --header:  62px;

  --lift: 0 1px 2px rgba(15, 24, 38, .04), 0 8px 24px -14px rgba(15, 24, 38, .14);
  --sans:  "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--line); text-decoration-color: var(--line-edge); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

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

.skip {
  position: fixed; top: 8px; left: 8px; z-index: 90;
  padding: 8px 14px; background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--rule-firm); border-radius: var(--r-sm);
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

.loading { color: var(--ink-faint); font-family: var(--mono); font-size: 13px; }

/* ─── Header ──────────────────────────────────────────────────────────── */

header {
  position: fixed; inset: 0 0 auto 0; height: var(--header); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--line); flex: none; }
.brand-name { color: var(--ink); }
.brand-name {
  font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: -0.015em;
}

.header-spacer { flex: 1; }

.header-links { display: flex; gap: 20px; }
.header-links a {
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 450;
}
.header-links a:hover { color: var(--ink); }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); color: var(--ink-soft); text-decoration: none;
}
.icon-btn:hover { background: var(--inset); color: var(--ink); }

/* The menu button is the rail's handle — only needed once the rail is off-canvas. */
.nav-only { display: none; }

/* ─── Sidebar ─────────────────────────────────────────────────────────── */

#sidebar {
  position: fixed; top: var(--header); bottom: 0; left: 0; width: var(--sidebar);
  display: flex; flex-direction: column; z-index: 30;
  background: var(--paper); border-right: 1px solid var(--rule);
}

.sidebar-top { padding: 16px 16px 12px; border-bottom: 1px solid var(--rule); }

.overall {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--ink-soft); margin-bottom: 8px;
}
#overall-pct { font-family: var(--mono); color: var(--ink); font-size: 12.5px; }

.bar { height: 3px; background: var(--inset); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--line); transition: width .35s ease; }

.search-wrap { position: relative; margin-top: 14px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
#search {
  width: 100%; padding: 8px 10px 8px 31px; font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--inset);
  border: 1px solid transparent; border-radius: var(--r-sm);
}
#search:focus { border-color: var(--rule-firm); background: var(--paper-2); outline: none; }
#search::placeholder { color: var(--ink-faint); }

#toc { flex: 1; overflow-y: auto; padding: 10px 10px 40px; }

.mod { margin-bottom: 4px; }
.mod-head {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 8px; border-radius: var(--r-sm); color: var(--ink);
}
.mod-head:hover { background: var(--inset); }
.mod-num {
  display: grid; place-items: center; flex: none; width: 22px; height: 22px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  background: var(--inset); border-radius: 5px;
}
.mod.complete .mod-num { background: var(--done-soft); color: var(--done); }
.mod-meta { flex: 1; min-width: 0; }
.mod-title { display: block; font-size: 14px; font-weight: 550; line-height: 1.35; }
.mod-count { display: block; font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }
.mod-head > svg:last-child { color: var(--ink-faint); transition: transform .2s ease; }
.mod.open .mod-head > svg:last-child { transform: rotate(90deg); }

.lessons { display: none; padding: 2px 0 6px 16px; margin-left: 18px; border-left: 1px solid var(--rule); }
.mod.open .lessons { display: block; }

.lesson {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 8px; border-radius: var(--r-sm); color: var(--ink-soft); font-size: 13.5px;
}
.lesson:hover { background: var(--inset); color: var(--ink); }
.lesson.active { background: var(--line-soft); color: var(--line); font-weight: 600; }
.lesson .tick { flex: none; width: 14px; color: transparent; }
.lesson.done .tick { color: var(--done); }
.lesson.done .lesson-name { color: var(--ink-faint); }
.lesson-name { flex: 1; min-width: 0; }
.lesson-dur { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }
.lesson-dur.pending { color: var(--line); opacity: .8; }

#backdrop {
  position: fixed; inset: var(--header) 0 0 0; z-index: 25;
  background: rgba(10,14,20,.42); opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.nav-open #backdrop { opacity: 1; pointer-events: auto; }

/* ─── Main ────────────────────────────────────────────────────────────── */

#main {
  position: fixed; inset: var(--header) 0 0 0; overflow-y: auto;
  scroll-behavior: smooth;
}
#main { left: var(--sidebar); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 28px 100px; }

/* ─── Hero ────────────────────────────────────────────────────────────── */

.hero {
  display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 46px; align-items: center; padding: 54px 0 52px;
}

.hero-eyebrow {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-faint);
  margin: 0 0 20px;
}

.hero h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(34px, 3.6vw, 52px); line-height: 1.04; letter-spacing: -0.028em;
  margin: 0 0 22px; text-wrap: balance;
}

.hero-lede {
  font-size: 17px; line-height: 1.62; color: var(--ink-soft);
  max-width: 44ch; margin: 0 0 30px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ─── The live fit ────────────────────────────────────────────────────── */

.fit-wrap { margin: 0; min-width: 0; }

.fit {
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  background: var(--paper-2); box-shadow: var(--lift); overflow: hidden;
}
.fit-plot { display: block; width: 100%; height: auto; }

.fit-readout {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--rule);
  background: var(--inset); font-family: var(--mono); font-size: 12.5px;
}
.fit-readout dl { display: flex; gap: 7px; margin: 0; align-items: baseline; }
.fit-readout dt { color: var(--ink-faint); }
.fit-readout dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.fit-readout .loss dd { color: var(--line); font-weight: 600; }
.fit-replay { margin-left: auto; color: var(--ink-soft); font-size: 12.5px; font-family: var(--mono); }
.fit-replay:hover { color: var(--line); }

.fit-caption {
  margin: 12px 2px 0; font-size: 13px; color: var(--ink-faint); line-height: 1.55;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 17px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 550; text-decoration: none;
  border: 1px solid transparent; transition: background .16s, border-color .16s;
}
.btn-primary { background: var(--line); color: #fff; border-color: var(--line); }
.btn-primary:hover { background: var(--line-deep); border-color: var(--line-deep); }
.btn-ghost { color: var(--ink); border-color: var(--rule-firm); background: var(--paper-2); }
.btn-ghost:hover { background: var(--inset); }
.btn-done { background: var(--done); color: #fff; border-color: var(--done); }
.btn-done:hover { background: #12563B; border-color: #12563B; }

/* ─── Sections ────────────────────────────────────────────────────────── */

.band { border-top: 1px solid var(--rule); padding: 46px 0; }

.band > h2 {
  font-family: var(--serif); font-weight: 600; font-size: 25px;
  letter-spacing: -0.02em; margin: 0 0 6px;
}
.band > .band-sub { color: var(--ink-soft); margin: 0 0 26px; max-width: 62ch; }

/* Outcomes: a checklist, because that is what it is */
.outcomes { list-style: none; margin: 0; padding: 0; max-width: 72ch; }
.outcomes li {
  display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--rule);
  font-size: 15.5px;
}
.outcomes li:last-child { border-bottom: 0; }
.outcomes svg { flex: none; margin-top: 4px; color: var(--done); }

/* The four pieces: a spec table, matching how the notes present it */
.pieces { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.pieces th {
  text-align: left; font-weight: 550; font-size: 12.5px; color: var(--ink-faint);
  padding: 0 14px 9px 0; border-bottom: 1px solid var(--rule-firm);
}
.pieces td { padding: 13px 14px 13px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.pieces tr:last-child td { border-bottom: 0; }
.pieces .what { font-weight: 550; white-space: nowrap; }
.pieces code {
  font-family: var(--mono); font-size: 13px; color: var(--line);
  background: var(--line-soft); padding: 2px 6px; border-radius: 4px;
}

/* Project brief */
.brief {
  border: 1px solid var(--rule-firm); border-left: 3px solid var(--line);
  border-radius: var(--r); padding: 24px 26px; background: var(--paper-2);
  max-width: 78ch;
}
.brief h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0 0 8px; }
.brief p { margin: 0 0 18px; color: var(--ink-soft); }
.brief p:last-child { margin-bottom: 0; }

/* ─── Lesson view ─────────────────────────────────────────────────────
   Video first, the way a course platform does it: the player owns the top of
   the screen, everything else is tabbed underneath. */

.stage {
  background: var(--inset); border-bottom: 1px solid var(--rule);
  padding: 24px 28px;
}
.stage .player { max-width: 1000px; margin: 0 auto; }

.player {
  position: relative; aspect-ratio: 16 / 9;
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  background: #000; overflow: hidden;
}
.player iframe, .player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* No video yet: a slim note, not a reserved cinema slot. The notes carry the lesson. */
.player.is-pending {
  aspect-ratio: auto; background: var(--paper-2);
  border-style: dashed; border-color: var(--rule-firm);
}
.player-pending {
  display: grid; gap: 8px; padding: 24px 26px; justify-items: start; text-align: left;
}
.player-pending .big { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.player-pending .small { font-size: 14px; color: var(--ink-soft); max-width: 62ch; line-height: 1.6; }
.player-pending code { font-family: var(--mono); font-size: 12.5px; color: var(--line); }

.lesson-bar {
  display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap;
  padding: 30px 0 22px;
}
.lesson-bar-text { flex: 1; min-width: 260px; }

.crumb { margin: 0; font-size: 12.5px; color: var(--ink-faint); font-family: var(--mono); }
.crumb a { color: var(--ink-soft); text-decoration: none; }
.crumb a:hover { color: var(--line); }

.lesson-bar h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(26px, 3vw, 35px); line-height: 1.12; letter-spacing: -0.024em;
  margin: 9px 0 9px; text-wrap: balance; max-width: 24ch;
}

.lesson-meta {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin: 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-faint);
}
.lesson-meta span { display: inline-flex; align-items: center; gap: 6px; }
.lesson-meta .is-done { color: var(--done); }

/* ─── Tabs ────────────────────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--rule); margin-bottom: 8px;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 11px 15px; font-size: 14.5px; font-weight: 500; white-space: nowrap;
  color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--line); border-bottom-color: var(--line); font-weight: 600; }

.panel { display: none; padding-top: 18px; }
.panel.active { display: block; }

/* ─── Files (the Run it tab) ──────────────────────────────────────────── */

.files { display: grid; gap: 10px; max-width: 72ch; }
.file {
  display: flex; align-items: center; gap: 15px; padding: 16px 18px;
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  background: var(--paper-2); color: var(--ink); text-decoration: none;
}
.file:hover { border-color: var(--line-edge); }
.file-mark { flex: none; color: var(--line); display: grid; place-items: center; }
.file-text { min-width: 0; }
.file-text b { display: block; font-family: var(--mono); font-size: 14px; font-weight: 600; }
.file-text span { font-size: 13.5px; color: var(--ink-soft); }

.run-steps { max-width: 72ch; margin-top: 26px; }
.run-steps p { margin: 0 0 12px; color: var(--ink-soft); }
.run-steps pre {
  margin: 0 0 16px; padding: 15px 17px; overflow-x: auto;
  background: var(--inset); border: 1px solid var(--rule); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.65;
}

/* ─── Notes (rendered Markdown) ───────────────────────────────────────── */

.notes { max-width: 72ch; padding-top: 12px; }
.notes > :first-child { margin-top: 0; }
.notes h1 {
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: -0.022em; margin: 46px 0 14px;
}
.notes h2 {
  font-family: var(--serif); font-size: 23px; font-weight: 600;
  letter-spacing: -0.018em; margin: 42px 0 12px;
  padding-top: 20px; border-top: 1px solid var(--rule);
}
.notes h3 { font-size: 17px; font-weight: 600; margin: 30px 0 8px; }
.notes p { margin: 0 0 17px; }
.notes ul, .notes ol { margin: 0 0 17px; padding-left: 22px; }
.notes li { margin-bottom: 7px; }
.notes li::marker { color: var(--ink-faint); }

.notes code {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--inset); padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--rule);
}
.notes pre {
  margin: 0 0 20px; padding: 16px 18px; overflow-x: auto;
  background: var(--inset); border: 1px solid var(--rule); border-radius: var(--r-sm);
  line-height: 1.6;
}
.notes pre code { background: none; border: 0; padding: 0; font-size: 13.5px; }

.notes blockquote {
  margin: 0 0 20px; padding: 2px 0 2px 18px;
  border-left: 2px solid var(--line-edge); color: var(--ink-soft);
}
.notes blockquote p:last-child { margin-bottom: 0; }

.notes table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 14.5px; }
.notes th {
  text-align: left; font-weight: 550; font-size: 12.5px; color: var(--ink-faint);
  padding: 0 14px 9px 0; border-bottom: 1px solid var(--rule-firm);
}
.notes td { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }

.notes hr { border: 0; border-top: 1px solid var(--rule); margin: 36px 0; }
.notes a { font-weight: 500; }

/* ─── Resources ───────────────────────────────────────────────────────── */

.resources { list-style: none; margin: 0; padding: 0; max-width: 72ch; }
.resources li { border-bottom: 1px solid var(--rule); }
.resources li:last-child { border-bottom: 0; }
.resources a {
  display: flex; align-items: center; gap: 11px; padding: 13px 4px;
  color: var(--ink); text-decoration: none; font-size: 14.5px;
}
.resources a:hover { color: var(--line); }
.resources svg { flex: none; color: var(--ink-faint); }
.resources a:hover svg { color: var(--line); }

/* ─── Pager ───────────────────────────────────────────────────────────── */

.pager {
  display: flex; gap: 14px; margin-top: 52px; padding-top: 26px;
  border-top: 1px solid var(--rule);
}
.pager a {
  flex: 1; padding: 15px 18px; border: 1px solid var(--rule-firm); border-radius: var(--r);
  text-decoration: none; color: var(--ink); background: var(--paper-2);
}
.pager a:hover { border-color: var(--line-edge); }
.pager .next { text-align: right; }
.pager .spacer { flex: 1; }
.pager .dir { display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.pager .what { display: block; font-size: 14.5px; font-weight: 550; margin-top: 3px; }

/* ─── Toast ───────────────────────────────────────────────────────────── */

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 18px);
  padding: 10px 18px; border-radius: 100px; z-index: 80;
  background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 500;
  box-shadow: var(--lift); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.no-results { padding: 24px 12px; color: var(--ink-faint); font-size: 13.5px; }

/* ─── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1240px) {
  .hero { grid-template-columns: 1fr; gap: 38px; padding: 46px 0 44px; }
  .hero-lede { max-width: 58ch; }
}

@media (max-width: 860px) {
  #main { left: 0; }
  .nav-only { display: grid; }
  #sidebar { transform: translateX(-100%); transition: transform .24s ease; box-shadow: var(--lift); }
  body.nav-open #sidebar { transform: none; }
  .header-links { display: none; }
  .wrap { padding: 0 20px 80px; }
  .pager { flex-direction: column; }
  .pager .next { text-align: left; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px 70px; }
  .stage { padding: 0; border-bottom: 0; }
  .stage .player { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
  .hero { padding: 34px 0 34px; }
  .fit-readout { gap: 14px; font-size: 11.5px; }
  .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  #main { scroll-behavior: auto; }
}
