/* Causality: shared bar and footer. Uses each lesson's own tokens. */
.course-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: -36px -20px 28px;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--muted);
}
.course-bar a {
  color: var(--ink);
  text-decoration: none;
}
.course-bar a:hover {
  text-decoration: underline;
}
.course-home {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.course-nav {
  display: flex;
  gap: 14px;
}
.course-nav .dim {
  opacity: 0.4;
}
.course-foot {
  margin: 56px 0 0;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
}
.course-foot-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
}
.course-foot-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
}
.course-foot-sub {
  font-size: 13.5px;
  color: var(--muted);
}
.course-foot-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.course-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.course-btn.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

/* Recap card */
.recap {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal, #1c8c8c);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 30px;
}
.recap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.recap-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.recap-skip {
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.recap-q {
  padding: 8px 0;
  border-top: 1px solid var(--grid);
}
.recap-qt {
  font-size: 14px;
  margin-bottom: 6px;
}
.recap-opts,
.predict-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.recap-opt,
.predict-opt {
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.recap-opt:disabled,
.predict-opt:disabled {
  cursor: default;
  opacity: 0.75;
}
.recap-opt.right,
.predict-opt.right {
  border-color: var(--green);
  color: var(--green);
  opacity: 1;
}
.recap-opt.chosen:not(.right),
.predict-opt.chosen:not(.right) {
  border-color: var(--red);
  color: var(--red);
  opacity: 1;
}
.recap-res,
.predict-result {
  font-size: 13px;
  margin-top: 6px;
}
.recap-res.ok,
.predict-result.ok {
  color: var(--green);
}
.recap-res.no,
.predict-result.no {
  color: var(--red);
}
.recap-foot {
  padding-top: 10px;
}

/* Predict card (placed just above a scene) */
.predict {
  background: var(--soft, var(--paper));
  border: 1px dashed var(--purple);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0 12px;
  max-width: 68ch;
}
.predict-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 3px;
}
.predict-q {
  font-size: 14.5px;
  margin-bottom: 8px;
}

/* Compute-it-yourself inputs */
.cy {
  display: grid;
  grid-template-columns: auto repeat(4, minmax(0, 1fr));
  gap: 6px 10px;
  align-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  margin: 12px 0;
}
.cy .h {
  color: var(--muted);
  font-size: 11.5px;
}
.cy input {
  font: inherit;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
}
.cy input.ok {
  border-color: var(--green);
}
.cy input.no {
  border-color: var(--red);
}
.cy-check {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  margin-top: 8px;
}
.cy-check.ok {
  color: var(--green);
}
.cy-check.no {
  color: var(--red);
}

/* Unit meta, recap strip, scene index, dots, requirements */
.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  margin: -22px 0 18px;
}
.recap-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal, #1c8c8c);
  border-radius: 8px;
  padding: 9px 14px;
  margin: 0 0 16px;
  max-width: 68ch;
}
.course-btn.small {
  font-size: 12.5px;
  padding: 5px 11px;
}
.scene-index {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  margin: 0 0 26px;
  max-width: 68ch;
}
.scene-index a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--rule);
}
.scene-index a:hover {
  color: var(--ink);
}
.scene-index-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.course-dots {
  display: inline-flex;
  gap: 5px;
  vertical-align: middle;
  margin-left: 6px;
}
.course-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--grid);
  border: 1px solid var(--rule);
  display: inline-block;
}
.course-dots .dot.seen {
  background: var(--muted);
}
.course-dots .dot.now {
  background: var(--purple);
  border-color: var(--purple);
}
.course-req {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.course-req li {
  margin: 2px 0;
}
.course-req li.ok {
  color: var(--green);
}
.course-foot-sub a {
  color: var(--muted);
}
@media (max-width: 820px) {
  .course-bar {
    margin: -36px -20px 24px;
  }
  .course-where {
    order: 3;
    width: 100%;
    font-size: 11.5px;
  }
  .recap-opt,
  .predict-opt,
  .course-btn {
    padding: 9px 13px;
    font-size: 14px;
  }
  .recap-skip {
    padding: 7px 12px;
  }
}
/* Shared accessibility and study layer. Legacy lesson palettes remain aliases. */
.course-bar {
  background: var(--paper, var(--panel));
  position: relative;
  margin-top: -36px;
  line-height: 1.5;
}
.course-nav {
  flex-wrap: wrap;
}
.course-settings {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px;
}
.course-settings label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 20px;
}
.course-settings p {
  font-size: 13px;
}
.roadmap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  margin: 20px 0;
}
.roadmap [aria-current] {
  color: var(--ink);
  font-weight: bold;
  border-bottom: 3px solid var(--purple);
}
.contract-reminder,
.notation-key {
  font-size: 14px;
  margin: 12px 0 20px;
  max-width: 72ch;
}
.contract-reminder p,
.notation-key p {
  margin: 10px 0;
}
.practice {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 22px;
  margin: 44px 0;
  background: var(--paper, var(--panel));
}
.practice h2 {
  margin: 0 0 18px;
}
.practice label {
  display: grid;
  gap: 8px;
  margin: 15px 0;
}
.practice input {
  max-width: 200px;
}
.practice input,
.practice textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 10px;
}
.practice .feedback {
  min-height: 1.8em;
}
.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.skip-link {
  position: absolute;
  left: 10px;
  top: -100px;
  z-index: 99;
  padding: 10px;
  background: var(--paper);
  color: var(--ink);
}
.skip-link:focus {
  top: 8px;
}
.figure-viewport {
  overflow: auto;
  max-width: 100%;
  overscroll-behavior-x: contain;
}
.figure-transcript {
  font-size: 14px;
  margin: 12px 0;
}
.figure-transcript ul {
  columns: 2;
  padding-left: 22px;
  line-height: 1.6;
}
.figure-scroll-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}
.scene,
.act,
.paper,
.stage,
.wrap {
  min-width: 0;
}
.scene-index a {
  padding: 8px 3px;
}
.scene-index {
  margin-top: 16px;
}
.eq {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.readout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow-wrap: anywhere;
}
button,
input,
select,
textarea {
  max-width: 100%;
}
input[type="range"] {
  min-height: 28px;
}
summary {
  cursor: pointer;
  padding: 6px 0;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}
button {
  min-height: 40px;
}
.fp-wrap {
  max-width: 100%;
}
.course-foot-sub {
  max-width: 60ch;
}
.course-foot {
  padding-bottom: 24px;
}
.course-btn.primary {
  background: var(--ink);
  color: var(--paper);
}
@media (max-width: 600px) {
  .course-bar {
    gap: 8px;
    padding: 10px 16px;
    font-size: 12px;
  }
  .course-nav {
    gap: 12px;
  }
  .practice {
    padding: 16px;
  }
  .figure-transcript ul {
    columns: 1;
  }
  .course-settings label {
    display: flex;
    flex-wrap: wrap;
  }
  .unit-meta {
    margin: 16px 0;
  }
}
select {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.course-settings select {
  width: auto;
  max-width: 100%;
}
.legacy-step[hidden] {
  display: none;
}
.step-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 20px 0;
}
.step-nav button {
  text-align: left;
  font-size: 13px;
}
.step-nav button[aria-current="step"] {
  border: 2px solid var(--purple);
}
.legacy-step {
  scroll-margin-top: 16px;
}

/* Stage colour: set on <body> by course.js from the unit's roadmap stage. */
.course-bar {
  border-bottom: 2px solid var(--stage, var(--rule));
}
.course-stage {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stage, var(--muted));
  margin-right: 8px;
}
.roadmap [aria-current] {
  border-bottom-color: var(--stage, var(--purple));
  color: var(--stage, var(--ink));
}
.step-nav button[aria-current="step"],
.scene-index a[aria-current] {
  border-color: var(--stage, var(--purple));
}
.recap,
.recap-strip {
  border-left-color: var(--stage, var(--teal));
}

/* Single navigation. Guided mode keeps one strip of numbered step pills; the current pill shows
   its title. The scene index and the legacy table of contents only appear in Explore mode. */
.step-nav {
  align-items: center;
}
.step-nav button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.step-nav .sn {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}
.step-nav .sn::after {
  content: ".";
}
body[data-mode="guided"] .step-nav {
  gap: 6px;
}
body[data-mode="guided"] .step-nav button {
  min-width: 34px;
  min-height: 34px;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 17px;
}
body[data-mode="guided"] .step-nav .sn::after {
  content: "";
}
body[data-mode="guided"] .step-nav button:not([aria-current="step"]) .st {
  display: none;
}
body[data-mode="guided"] .step-nav button[aria-current="step"] {
  background: var(--stage, var(--purple));
  border-color: var(--stage, var(--purple));
  color: #fff;
}
body[data-mode="guided"] .scene-index,
body[data-mode="guided"] .toc,
body[data-mode="guided"] .legacy-step > .eyebrow {
  display: none;
}
body[data-mode="explore"] .wrap:has(.toc) .scene-index {
  display: none;
}
@media (max-width: 600px) {
  body[data-mode="guided"] .step-nav button[aria-current="step"] .st {
    display: none;
  }
  .roadmap {
    display: none;
  }
}

/* Beats: guided steps reveal one small idea at a time (see CausalBeats in course.js). */
.beat {
  display: block;
}
.beat:focus,
.beat:focus-visible {
  outline: none;
}
.beat[hidden] {
  display: none !important;
}
body[data-mode="guided"] .legacy-step > .beat > .eyebrow {
  display: none;
}
@keyframes beat-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.beat.beat-enter {
  animation: beat-rise 350ms cubic-bezier(0.45, 0, 0.55, 1) both;
}
@media (prefers-reduced-motion: reduce) {
  .beat.beat-enter {
    animation: none;
  }
}
.step-btns {
  align-items: center;
}
.step-btns .step-next {
  margin-left: auto;
  min-height: 44px;
  min-width: 120px;
}
.beat-dots {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-left: auto;
  max-width: 50%;
}
.beat-dots:not([hidden]) + .step-next {
  margin-left: 0;
}
.beat-dots[hidden] {
  display: none;
}
.beat-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--stage, var(--purple));
  box-sizing: border-box;
}
.beat-dots i.on {
  background: var(--stage, var(--purple));
}
.course-settings .course-check input {
  width: auto;
  margin: 0;
}

/* World card: names the teaching world a figure uses when it is not the course's 100-patient cohort.
   <aside class="world-card"><b>This lesson's world</b> 1,000 simulated registry patients · outcome: ... · truth: ...</aside> */
.world-card {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  margin: 10px 0 14px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--stage, var(--teal));
  border-radius: 8px;
  background: var(--paper);
  font-size: 14px;
  color: var(--muted);
}
.world-card b {
  color: var(--ink);
  font-weight: 600;
}

/* Beat controls (CausalBeats in course.js): show-rest and skip are quiet text buttons, the
   keyboard hint only shows where there is a keyboard, and a gated Continue looks disabled
   while staying focusable. */
.step-btns .beat-rest,
.step-btns .beat-skip {
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 6px;
  min-height: 44px;
  cursor: pointer;
}
.step-btns .beat-rest:hover,
.step-btns .beat-skip:hover {
  color: var(--ink);
}
.beat-rest[hidden],
.beat-skip[hidden],
.beat-key[hidden] {
  display: none;
}
.beat-key {
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
}
@media (hover: none), (pointer: coarse), (max-width: 700px) {
  .beat-key {
    display: none;
  }
}
.beat-dots:not([hidden]) ~ .step-next {
  margin-left: 0;
}
.step-btns .step-next.beat-gated {
  opacity: 0.55;
  cursor: not-allowed;
}
@media (max-width: 520px) {
  .step-btns .beat-rest {
    order: 10;
    flex-basis: 100%;
    text-align: right;
    padding-top: 0;
    min-height: 36px;
  }
}

/* "Go deeper" and "Preview" boxes: optional detail kept out of the main path. */
details.go-deeper {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0 14px;
  margin: 14px 0;
  background: var(--paper);
}
details.go-deeper > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
}
details.go-deeper[open] > summary {
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}
details.go-deeper.preview > summary {
  color: var(--stage, var(--purple));
}

/* Callback: a short pointer from a lesson to a related lesson or tool. */
p.callback {
  border-left: 3px solid var(--stage, var(--purple));
  padding: 6px 0 6px 12px;
  margin: 22px 0;
}
