/* ---------------------------------------------------------------------------
   Interactive class player.

   A lecture surface, not a document: one idea per screen, generous type, the
   slide always taller than it is wordy. Chrome sits at the edges so the slide
   itself keeps the middle.
   --------------------------------------------------------------------------- */

.class-host { min-height: 100vh; background: var(--bg); }

.class-loading {
  min-height: 60vh; display: grid; place-items: center; gap: 14px;
  color: var(--muted); font-size: 13px;
}
.class-loading span {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: class-spin .8s linear infinite;
}
@keyframes class-spin { to { transform: rotate(360deg); } }

.class-player {
  min-height: 100vh; display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  background: var(--bg); position: relative;
}

/* ---- top bar ---- */
.player-top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.player-exit, .player-tools button {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.player-exit svg { transform: rotate(90deg); }
.player-exit:hover, .player-tools button:hover { color: var(--ink); border-color: var(--brand); }
.player-tools { display: flex; gap: 8px; }
.player-identity { text-align: center; min-width: 0; }
.player-identity strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.player-identity span { font-size: 11px; color: var(--muted); }
.test-counter { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---- progress ---- */
.player-progress { height: 4px; background: var(--surface-soft); }
.player-progress > span {
  display: block; height: 100%; background: var(--brand);
  transition: width .28s cubic-bezier(.4, 0, .2, 1);
}

/* ---- section rail ---- */
.player-sections {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line); background: var(--surface);
  scrollbar-width: thin;
}
.player-sections button {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 7px 12px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.player-sections button svg { width: 14px; height: 14px; }
.player-sections button:hover:not(:disabled) { color: var(--ink); background: var(--surface-soft); }
.player-sections button.active { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }
.player-sections button:disabled { opacity: .35; cursor: not-allowed; }

/* ---- the slide ---- */
.player-stage {
  display: grid; place-items: center; padding: clamp(20px, 4vw, 48px);
  overflow-y: auto;
}
.slide {
  width: min(1000px, 100%); padding: clamp(26px, 4vw, 52px);
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow);
  outline: none;
}
.slide:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 3px; }
.slide-head { margin-bottom: 26px; }
.slide-section {
  margin: 0 0 8px; font-size: 10px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--brand);
}
.slide h1 {
  margin: 0; font-size: clamp(24px, 3.4vw, 38px); line-height: 1.15; letter-spacing: -.03em;
}
.slide-subtitle { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

.slide-content { display: grid; gap: 24px; }
.slide-content.has-visual { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .slide-content.has-visual { grid-template-columns: 1.05fr .95fr; align-items: start; }
}

.slide-statement { margin: 0; font-size: clamp(17px, 2vw, 21px); line-height: 1.6; }
.slide-step {
  display: inline-block; margin: 0 0 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
}
.slide-explanation, .slide-mechanism, .slide-significance {
  margin: 14px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65;
}
.slide-significance { padding-left: 14px; border-left: 3px solid var(--brand); }

.slide-bullets { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 11px; }
.slide-bullets li {
  position: relative; padding-left: 26px; font-size: 16px; line-height: 1.55;
}
.slide-bullets li::before {
  content: ""; position: absolute; left: 6px; top: .62em;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
}

/* Mechanism chain: numbered steps that read as one causal line. */
.slide-chain { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; }
.slide-chain li {
  position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 14px;
  align-items: start; padding: 0 0 22px;
}
.slide-chain li:not(:last-child)::after {
  content: ""; position: absolute; left: 17px; top: 30px; bottom: 4px;
  width: 2px; background: linear-gradient(var(--brand), var(--line));
}
.chain-step {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 800;
}
.slide-chain p { margin: 5px 0 0; font-size: 16px; line-height: 1.55; }

/* Summary flow: cause -> mechanism -> presentation -> diagnosis -> treatment */
.slide-flow { display: grid; gap: 10px; }
@media (min-width: 780px) { .slide-flow { grid-auto-flow: column; grid-auto-columns: 1fr; } }
.slide-flow article {
  position: relative; padding: 15px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface-soft);
}
.slide-flow article span {
  display: block; margin-bottom: 6px; font-size: 10px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--brand);
}
.slide-flow article p { margin: 0; font-size: 13px; line-height: 1.5; }

.slide-roadmap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.slide-roadmap span {
  padding: 9px 15px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-soft); font-size: 13px; font-weight: 700;
}
.slide-roadmap span.here { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.slide-table-wrap { overflow-x: auto; }
.slide-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.slide-table th, .slide-table td {
  padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
.slide-table thead th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.slide-table tbody th { width: 30%; color: var(--brand); font-weight: 800; }

.slide-meta-card {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;
}
.slide-meta-card span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-soft); font-size: 11px; color: var(--muted);
}

/* Images always carry their attribution. */
.slide-visual { margin: 0; }
.slide-visual img {
  width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft);
}
.slide-visual figcaption { margin-top: 9px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.slide-visual figcaption small { display: block; margin-top: 4px; font-size: 10px; color: var(--faint); }

/* An unwritten slot states its purpose rather than pretending to teach. */
.slide-unwritten { border-style: dashed; background: var(--surface-soft); }
.slide-gap { display: grid; gap: 12px; justify-items: start; }
.gap-mark {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px;
  background: var(--surface); color: var(--muted);
}
.slide-gap h3 { margin: 0; font-size: 18px; }
.gap-purpose { margin: 0; font-size: 15px; }
.gap-needs { margin: 0; color: var(--muted); font-size: 14px; }
.gap-why {
  margin: 6px 0 0; padding: 13px 15px; border-left: 3px solid var(--brand);
  border-radius: 0 9px 9px 0; background: var(--surface);
  color: var(--muted); font-size: 13px; line-height: 1.6;
}

.slide-foot { margin-top: 26px; padding-top: 15px; border-top: 1px solid var(--line); }
.prov { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--faint); }
.prov svg { width: 13px; height: 13px; }
.prov.authored { color: var(--brand); }

/* ---- cases and quiz ---- */
.slide-case, .slide-quiz { display: grid; gap: 20px; }
.case-stem {
  padding: 18px 20px; border-left: 3px solid var(--brand);
  border-radius: 0 12px 12px 0; background: var(--surface-soft);
}
.case-stem p:last-child { margin: 0; font-size: 16px; line-height: 1.65; }
.case-prompt { margin: 0; font-size: 17px; font-weight: 700; }
.case-options { display: grid; gap: 10px; }
.case-option {
  display: grid; grid-template-columns: 34px 1fr; gap: 13px; align-items: center;
  width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: inherit; font: inherit; font-size: 15px;
  text-align: left; cursor: pointer; transition: border-color .15s, background .15s;
}
.case-option:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.case-option:disabled { cursor: default; }
.case-option b {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-soft); font-size: 13px;
}
.case-option.correct { border-color: #2a9a70; background: #e6f8f0; }
.case-option.correct b { background: #2a9a70; color: #fff; }
.case-option.incorrect { border-color: #d76169; background: #fff0f1; }
.case-option.incorrect b { background: #d76169; color: #fff; }
.case-option.chosen { box-shadow: 0 0 0 2px var(--brand-soft); }

.case-feedback[hidden] { display: none; }
.feedback { padding: 18px 20px; border-radius: 13px; border: 1px solid var(--line); }
.feedback.right { border-color: #2a9a70; background: #e6f8f0; }
.feedback.wrong { border-color: #d76169; background: #fff0f1; }
.feedback-verdict { margin: 0 0 9px; font-size: 17px; font-weight: 800; }
.feedback p { margin: 0 0 8px; font-size: 15px; line-height: 1.6; }
.feedback-explanation { color: #33403c; }
.feedback-explanation.muted { color: #6b7a75; font-style: italic; }
.case-source { margin: 0; font-size: 11px; color: var(--faint); }

/* ---- bottom bar ---- */
.player-bar {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 13px clamp(16px, 3vw, 32px); border-top: 1px solid var(--line);
  background: var(--surface);
}
.player-bar button {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 17px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.player-bar button:disabled { opacity: .4; cursor: not-allowed; }
.player-bar button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.player-bar #class-prev svg { transform: rotate(180deg); }
.player-state { display: flex; gap: 8px; }
.player-state button { font-size: 12px; padding: 9px 13px; color: var(--muted); }
.player-state button svg { width: 14px; height: 14px; }
.player-state button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.player-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.player-count strong { font-size: 15px; color: var(--ink); }

/* ---- contents drawer ---- */
.player-toc {
  position: absolute; inset: 0 0 0 auto; width: min(420px, 100%); z-index: 20;
  padding: 20px; overflow-y: auto;
  border-left: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.player-toc[hidden] { display: none; }
.player-toc > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.player-toc h2 { margin: 0; font-size: 19px; }
.player-toc > header button {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 19px; cursor: pointer;
}
.toc-coverage {
  margin-bottom: 16px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-soft); font-size: 12px; line-height: 1.6; color: var(--muted);
}
.toc-coverage p { margin: 0; }
.player-toc section { margin-bottom: 18px; }
.player-toc h3 {
  margin: 0 0 8px; font-size: 10px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--brand);
}
.player-toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.player-toc ol button {
  display: grid; grid-template-columns: 30px 1fr auto auto; gap: 8px; align-items: center;
  width: 100%; padding: 8px 9px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: inherit; font: inherit; font-size: 13px;
  text-align: left; cursor: pointer;
}
.player-toc ol button:hover { background: var(--surface-soft); }
.player-toc ol button.here { border-color: var(--brand); background: var(--brand-soft); }
.player-toc ol button.gap .toc-title { color: var(--faint); font-style: italic; }
.toc-num { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.toc-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-ok svg, .toc-mark svg { width: 13px; height: 13px; }
.toc-ok { color: var(--brand); }
.toc-mark { color: var(--warning, #c07c22); }

/* ---- result ---- */
.slide-result { display: grid; gap: 26px; }
.result-score { text-align: center; }
.result-score h1 { font-size: clamp(30px, 5vw, 48px); }
.result-score p { margin: 8px 0 0; color: var(--muted); }
.result-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.result-grid article {
  padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft);
}
.result-grid h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.result-grid p { margin: 0; font-size: 17px; font-weight: 700; }
.result-review h3 { margin: 0 0 10px; font-size: 15px; }
.review-target {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  width: 100%; margin-bottom: 8px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.review-target:hover { border-color: var(--brand); background: var(--brand-soft); }
.review-target span { font-weight: 700; }
.review-target small { color: var(--muted); font-size: 12px; }
.result-clear { color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.mistake-review { margin-top: 22px; display: grid; gap: 14px; }
.mistake-review h3 { margin: 0; font-size: 16px; }
.mistake-review article {
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft);
}
.mistake-stem { font-size: 15px; line-height: 1.6; }
.mistake-explanation { color: var(--muted); font-size: 14px; line-height: 1.6; }
.mistake-review small { color: var(--faint); font-size: 11px; }
.loading-line { color: var(--muted); font-size: 13px; }

/* ---- presentation mode ---- */
.class-player:fullscreen { background: var(--bg); }
.class-player:fullscreen .player-sections,
.class-player:fullscreen .player-top .player-exit { display: none; }
.class-player:fullscreen .slide { width: min(1180px, 100%); }
.class-player:fullscreen .slide h1 { font-size: clamp(30px, 4.2vw, 52px); }
.class-player:fullscreen .slide-statement { font-size: clamp(19px, 2.4vw, 26px); }
.class-player:fullscreen .slide-bullets li { font-size: 19px; }

/* ---- dark ---- */
html[data-theme="dark"] .case-option.correct { border-color: #3f9c78; background: #16302a; }
html[data-theme="dark"] .case-option.incorrect { border-color: #c76a72; background: #33201f; }
html[data-theme="dark"] .feedback.right { border-color: #3f9c78; background: #16302a; }
html[data-theme="dark"] .feedback.wrong { border-color: #c76a72; background: #33201f; }
html[data-theme="dark"] .feedback-explanation { color: var(--ink); }
html[data-theme="dark"] .feedback-explanation.muted { color: var(--muted); }
html[data-theme="dark"] .player-bar button.primary { color: #0d1513; }

/* ---- narrow screens ---- */
@media (max-width: 720px) {
  .player-top { grid-template-columns: auto 1fr auto; gap: 10px; }
  .player-identity span { display: none; }
  .player-exit span, .player-tools button span { display: none; }
  .player-bar { grid-template-columns: auto 1fr auto; row-gap: 10px; }
  .player-state { grid-column: 1 / -1; order: 3; justify-content: center; }
  .player-count { order: 2; }
  .result-grid { grid-template-columns: 1fr; }

  /* Hiding the labels above collapsed these to their 28x18px icons, which is well under what a
     thumb can reliably hit. The icon stays the only visible part; the button around it does not. */
  .player-exit, .player-tools button {
    min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  /* Section jump targets sat at 30px. Wrapping is fine; being too short to tap is not. */
  .player-sections button { min-height: 40px; }
}

/* ---- owner: class authoring review ---- */
.block-review {
  margin-bottom: 14px; padding: 18px 20px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft);
}
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.block-head h3 { margin: 4px 0 0; font-size: 16px; line-height: 1.45; }
.block-explanation, .block-significance { margin: 11px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.block-bullets { margin: 11px 0 0; padding-left: 20px; display: grid; gap: 5px; font-size: 14px; }
.block-source { margin: 12px 0 0; font-size: 11px; color: var(--faint); }
.block-note { display: grid; gap: 6px; margin: 13px 0 0; font-size: 11px; font-weight: 700; color: var(--muted); }
.block-note textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: inherit; font: inherit; font-size: 13px; font-weight: 400;
}
.block-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* AI-verified blocks are served, but a student must be able to see that no clinician has signed
   the dose in front of them. The label is amber, not green, and says so in words. */
.prov.ai-verified { color: var(--warning); font-weight: 700; }
