/* Course story player (course-kit/story.js). The player is dark in both themes, like a video. */
.cs-story {
  scroll-margin-top: 90px;
  margin: 28px 0 36px;
  padding: 22px;
  border: 1px solid rgba(78, 205, 196, 0.28);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(78, 205, 196, 0.08), rgba(130, 170, 255, 0.05) 60%, transparent);
}
.cs-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 14px; }
.cs-head h2 { margin: 0; font-size: clamp(1.25rem, 2.6vw, 1.6rem); }
.cs-head p { margin: 0; flex-basis: 100%; opacity: 0.8; }
.cs-kicker {
  font: 700 0.72rem/1 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4ecdc4;
}
.cs-watched { display: none; font: 600 0.8rem 'DM Sans', system-ui, sans-serif; color: #4ecdc4; }
.cs-story.is-watched .cs-watched { display: inline; }

.cs-player {
  container-type: inline-size;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #060a12;
  color: #e6edf5;
  font-family: 'DM Sans', system-ui, sans-serif;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  outline: none;
}
.cs-player:focus-visible { box-shadow: 0 0 0 3px #4ecdc4; }
.cs-player.is-failed { padding: 24px; color: #e6edf5; }
.cs-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #12202c, #060a12 70%);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.cs-player:fullscreen { display: flex; flex-direction: column; border-radius: 0; }
.cs-player:fullscreen .cs-stage { aspect-ratio: auto; flex: 1; }
.cs-layer {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity 0.7s ease;
  will-change: transform, opacity;
  pointer-events: none;
}
.cs-layer.is-front { opacity: 1; }
.cs-pins { position: absolute; inset: 0; }

/* Pins */
.cs-pin {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  padding: 0;
  background: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.cs-pin.is-on { opacity: 1; }
.cs-pin-dot {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #4ecdc4;
  color: #04121a;
  font: 700 14px/28px 'DM Sans', system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 0 0 3px rgba(6, 10, 18, 0.75), 0 0 18px rgba(78, 205, 196, 0.55);
  transform: scale(0.6);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.cs-pin.is-on .cs-pin-dot { transform: scale(1); }
.cs-pin.is-new .cs-pin-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #4ecdc4;
  animation: cs-ping 1.6s ease-out infinite;
}
@keyframes cs-ping { from { transform: scale(1); opacity: 0.9; } to { transform: scale(2.4); opacity: 0; } }
.cs-callout {
  position: absolute;
  left: 22px;
  top: -16px;
  width: max-content;
  max-width: min(46cqi, 300px);
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(6, 10, 18, 0.86);
  border: 1px solid rgba(78, 205, 196, 0.55);
  font: 600 clamp(11px, 2.1cqi, 15px)/1.3 'DM Sans', system-ui, sans-serif;
  color: #f3f7fb;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(4px);
}
.cs-pin.is-new .cs-callout { opacity: 1; transform: none; }
.cs-pin.is-flip .cs-callout { left: auto; right: 22px; transform: translateX(6px); }
.cs-pin.is-flip.is-new .cs-callout { transform: none; }
.cs-pin.is-low .cs-callout { top: auto; bottom: -16px; }

/* Tap challenge: every marker becomes a button. */
button.cs-pin { pointer-events: auto; cursor: pointer; width: 40px; height: 40px; margin: -20px 0 0 -20px; }
button.cs-pin .cs-pin-dot { width: 34px; height: 34px; left: 3px; top: 3px; line-height: 34px; font-size: 15px; }
button.cs-pin:hover .cs-pin-dot, button.cs-pin:focus-visible .cs-pin-dot { box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(78, 205, 196, 0.8); outline: none; }
button.cs-pin:focus-visible { outline: none; }
button.cs-pin .cs-pin-dot { animation: cs-bob 1.8s ease-in-out infinite; }
button.cs-pin:disabled { cursor: default; }
button.cs-pin:disabled .cs-pin-dot { animation: none; opacity: 0.5; }
button.cs-pin.is-right .cs-pin-dot { background: #7ee787; opacity: 1; transform: scale(1.2); }
button.cs-pin.is-wrong .cs-pin-dot { background: #ff8a7a; animation: cs-shake 0.4s ease; opacity: 1; }
@keyframes cs-bob { 50% { transform: scale(1.12); } }
@keyframes cs-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Specimens: eyepiece views of what the narrator names, popping in on the word. */
.cs-specs {
  position: absolute;
  top: 5%;
  right: 3%;
  display: flex;
  gap: clamp(8px, 1.6cqi, 16px);
  pointer-events: none;
}
.cs-spec {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: clamp(70px, 16cqi, 150px);
  text-align: center;
  opacity: 0;
  transform: scale(0.6) translateY(-8px);
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.cs-spec.is-on { opacity: 0.82; transform: scale(0.92); }
.cs-spec.is-new { opacity: 1; transform: none; }
.cs-spec svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(6, 10, 18, 0.8), 0 10px 28px rgba(0, 0, 0, 0.55);
  transition: box-shadow 0.35s ease;
}
.cs-spec.is-new svg { box-shadow: 0 0 0 3px #4ecdc4, 0 0 26px rgba(78, 205, 196, 0.55), 0 10px 28px rgba(0, 0, 0, 0.55); }
.cs-spec-label {
  margin-top: 7px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(6, 10, 18, 0.82);
  display: flex;
  flex-direction: column;
  font: 500 clamp(10px, 1.7cqi, 13px)/1.25 'DM Sans', system-ui, sans-serif;
  color: #c9d4df;
}
.cs-spec-label strong { font-size: 1.12em; color: #f3f7fb; white-space: nowrap; }
.cs-spec.is-new .cs-spec-label strong { color: #4ecdc4; }
.cs-layer.is-front { transition: opacity 0.7s ease, filter 0.5s ease; }
.cs-stage.has-specs .cs-layer.is-front { filter: brightness(0.55) saturate(0.8); }
/* While specimens are up they are the subject: markers and their labels step back. */
.cs-stage.has-specs .cs-pin { opacity: 0 !important; }

/* Title and note cards */
.cs-title {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 6%;
  padding: 3% 4%;
  /* A soft dark pool behind the words, so a title stays legible over a white autoclave. */
  background: radial-gradient(ellipse 62% 70% at 50% 50%, rgba(6, 10, 18, 0.78), rgba(6, 10, 18, 0.45) 55%, transparent 78%);
  text-align: center;
  font: 700 clamp(22px, 6cqi, 54px)/1.1 'DM Sans', system-ui, sans-serif;
  letter-spacing: -0.01em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}
.cs-title.is-on { opacity: 1; transform: none; }
.cs-title em, .cs-start-meta em, .cs-end-title em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-style: italic;
  background: linear-gradient(90deg, #4ecdc4, #82aaff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}
.cs-note {
  position: absolute;
  left: 3.5%;
  top: 6%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 48%;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.84);
  border-left: 3px solid #edbe77;
  font: 500 clamp(11px, 2.2cqi, 16px)/1.35 'DM Sans', system-ui, sans-serif;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.cs-note strong { color: #edbe77; }
.cs-note span:last-child:not(:first-child) { opacity: 0.7; font-size: 0.85em; }
.cs-note.is-on { opacity: 1; transform: none; }

/* Captions */
.cs-cap {
  position: absolute;
  left: 50%;
  bottom: 5%;
  width: max-content;
  max-width: 88%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.cs-cap.is-on { opacity: 1; }
.cs-cap-line {
  display: inline;
  padding: 0.18em 0.45em;
  border-radius: 8px;
  background: rgba(6, 10, 18, 0.78);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  font: 600 clamp(12px, 2.9cqi, 24px)/1.55 'DM Sans', system-ui, sans-serif;
}
.cs-cap-line span { color: rgba(230, 237, 245, 0.55); transition: color 0.12s linear; }
.cs-cap-line span.is-said { color: #fff; }

.cs-capdock { display: none; background: #0b131d; padding: 8px 12px; min-height: calc(2 * 1.5em + 16px); font-size: 13px; }
.cs-capdock.is-on { display: block; }
.cs-capdock .cs-cap { position: static; transform: none; width: auto; max-width: none; text-align: left; }
.cs-capdock .cs-cap-line { background: none; padding: 0; font-size: 13px; line-height: 1.5; }

/* Start and end cards */
.cs-start, .cs-end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
  background: linear-gradient(180deg, rgba(6, 10, 18, 0.2), rgba(6, 10, 18, 0.78));
}
.cs-start[hidden] { display: none; }
.cs-bigplay {
  width: clamp(58px, 14cqi, 96px);
  height: clamp(58px, 14cqi, 96px);
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ecdc4, #82aaff);
  color: #04121a;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(78, 205, 196, 0.5);
  transition: transform 0.2s ease;
}
.cs-bigplay:hover, .cs-bigplay:focus-visible { transform: scale(1.08); }
.cs-bigplay svg { width: 46%; height: 46%; margin-left: 8%; fill: currentColor; }
.cs-start-meta { display: flex; flex-direction: column; gap: 6px; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9); }
.cs-start-meta strong { font: 700 clamp(18px, 4.4cqi, 36px)/1.15 'DM Sans', system-ui, sans-serif; }
.cs-start-meta span { font-size: clamp(12px, 2.2cqi, 15px); opacity: 0.85; }
.cs-end { display: none; background: rgba(6, 10, 18, 0.86); backdrop-filter: blur(3px); }
.cs-end.is-on { display: flex; animation: cs-fade 0.5s ease; }
@keyframes cs-fade { from { opacity: 0; } }
.cs-end-kicker { color: #4ecdc4; font: 700 clamp(10px, 1.8cqi, 13px)/1 'DM Sans', system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; }
.cs-end-title { font: 700 clamp(20px, 5cqi, 44px)/1.1 'DM Sans', system-ui, sans-serif; }
.cs-stars { display: flex; gap: 6px; font-size: clamp(22px, 5cqi, 40px); color: rgba(255, 255, 255, 0.18); }
.cs-stars .is-on { color: #edbe77; text-shadow: 0 0 18px rgba(237, 190, 119, 0.6); animation: cs-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.cs-stars .is-on:nth-child(2) { animation-delay: 0.15s; }
.cs-stars .is-on:nth-child(3) { animation-delay: 0.3s; }
@keyframes cs-pop { from { transform: scale(0); } }
.cs-end-score { font-size: clamp(12px, 2.2cqi, 15px); opacity: 0.8; }
.cs-end-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.cs-continue, .cs-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 0;
  font: 700 clamp(13px, 2.2cqi, 15px)/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
}
.cs-continue { background: #4ecdc4; color: #04121a; }
.cs-ghost { background: transparent; color: #e6edf5; box-shadow: inset 0 0 0 1.5px rgba(230, 237, 245, 0.45); }
.cs-continue svg, .cs-ghost svg { width: 16px; height: 16px; fill: currentColor; }
.cs-continue:focus-visible, .cs-ghost:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Challenge card */
.cs-check {
  position: absolute;
  display: none;
  flex-direction: column;
  gap: 10px;
  cursor: default;
}
.cs-check.is-on { display: flex; animation: cs-fade 0.35s ease; }
.cs-check.is-docked.is-choice { background: #101b27; backdrop-filter: none; padding: 12px 14px; }
.cs-check.is-docked.is-choice .cs-check-head { text-align: left; align-self: stretch; }
.cs-check.is-docked.is-choice { position: static; inset: auto; border-top: 2px solid #edbe77; align-items: stretch; }
.cs-check.is-docked.is-choice .cs-options { width: 100%; }
.cs-check.is-tap {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 14px;
  background: #101b27;
  border-top: 2px solid #edbe77;
}
.cs-check.is-tap .cs-check-head { flex: 1 1 260px; max-width: none; padding: 0; border: 0; background: none; }
.cs-check.is-choice {
  inset: 0;
  justify-content: center;
  align-items: center;
  padding: 4% 6%;
  background: rgba(6, 10, 18, 0.82);
  backdrop-filter: blur(3px);
}
.cs-check-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 640px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.88);
  border: 1px solid rgba(237, 190, 119, 0.6);
}
.cs-check.is-choice .cs-check-head { background: none; border: 0; padding: 0; text-align: center; }
.cs-check-kicker { color: #edbe77; font: 700 clamp(10px, 1.8cqi, 12px)/1 'DM Sans', system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; }
.cs-check-head strong { font: 700 clamp(14px, 3cqi, 22px)/1.25 'DM Sans', system-ui, sans-serif; }
.cs-check-hint { font-size: clamp(11px, 1.9cqi, 13px); opacity: 0.7; }
.cs-options { display: grid; gap: 8px; width: min(100%, 560px); }
.cs-option {
  padding: clamp(8px, 1.8cqi, 13px) 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(230, 237, 245, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: #e6edf5;
  font: 600 clamp(12px, 2.4cqi, 16px)/1.3 'DM Sans', system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.cs-option:hover:not(:disabled), .cs-option:focus-visible { border-color: #4ecdc4; background: rgba(78, 205, 196, 0.12); outline: none; }
.cs-option:disabled { cursor: default; opacity: 0.55; }
.cs-option.is-right { border-color: #7ee787; background: rgba(126, 231, 135, 0.16); opacity: 1; }
.cs-option.is-wrong { border-color: #ff8a7a; background: rgba(255, 138, 122, 0.12); opacity: 1; animation: cs-shake 0.4s ease; }
.cs-feedback {
  margin: 0;
  max-width: 640px;
  padding: 0;
  font: 500 clamp(12px, 2.3cqi, 16px)/1.4 'DM Sans', system-ui, sans-serif;
}
.cs-feedback:empty { display: none; }
.cs-check.is-tap .cs-feedback { flex: 1 1 100%; }
.cs-feedback.is-good { color: #9ff0a6; }
.cs-feedback.is-bad { color: #ffb2a6; }

/* Confetti burst on a right answer */
.cs-toast { position: absolute; left: 50%; top: 50%; pointer-events: none; }
.cs-toast i {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #4ecdc4;
  opacity: 0;
}
.cs-toast i:nth-child(3n) { background: #edbe77; }
.cs-toast i:nth-child(3n + 1) { background: #82aaff; }
.cs-toast.is-on i { animation: cs-burst 0.9s ease-out forwards; }
@keyframes cs-burst {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(220deg); }
}

/* Control bar */
.cs-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  padding: 8px 10px;
  background: #0b131d;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.cs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e6edf5;
  cursor: pointer;
}
.cs-btn svg { width: 20px; height: 20px; fill: currentColor; }
.cs-btn:hover, .cs-btn:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.cs-btn[aria-pressed='false'] { opacity: 0.45; }
.cs-rate span { font: 700 13px/1 'JetBrains Mono', ui-monospace, monospace; }
.cs-time { font: 500 12px/1 'JetBrains Mono', ui-monospace, monospace; opacity: 0.8; white-space: nowrap; }
.cs-track { position: relative; flex: 1 1 160px; min-width: 0; height: 36px; display: flex; align-items: center; }
.cs-range {
  width: 100%;
  margin: 0;
  height: 6px;
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, #4ecdc4 var(--pct, 0%), rgba(255, 255, 255, 0.16) var(--pct, 0%));
  cursor: pointer;
}
.cs-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.cs-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.cs-range:focus-visible { outline: 2px solid #4ecdc4; outline-offset: 4px; }
.cs-ticks { position: absolute; left: 0; right: 0; top: 50%; pointer-events: none; z-index: 1; }
.cs-tick { position: absolute; width: 3px; height: 10px; margin: -5px 0 0 -1px; background: rgba(255, 255, 255, 0.4); border-radius: 2px; }
.cs-tick.is-check { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #edbe77; box-shadow: 0 0 0 2px #0b131d; }

/* Transcript */
.cs-transcript { margin-top: 14px; }
.cs-transcript summary { cursor: pointer; font-weight: 600; }
.cs-transcript p { margin: 10px 0 0; line-height: 1.6; }

@container (max-width: 560px) {
  .cs-stage { aspect-ratio: 4 / 3; }
  button.cs-pin { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
  button.cs-pin .cs-pin-dot { width: 26px; height: 26px; left: 3px; top: 3px; line-height: 26px; font-size: 13px; }
  .cs-note { font-size: 11px; gap: 2px; }
  .cs-note span:last-child:not(:first-child) { display: none; }
  .cs-cap-line { font-size: 13px; }
  .cs-pin-dot { width: 22px; height: 22px; left: -11px; top: -11px; font-size: 12px; line-height: 22px; }
  .cs-callout { left: 16px; top: -13px; padding: 4px 8px; }
  .cs-pin.is-flip .cs-callout { right: 16px; }
  .cs-pin.is-low .cs-callout { bottom: -13px; }
  .cs-note { max-width: 62%; padding: 7px 10px; }
  .cs-cap { bottom: 3%; max-width: 94%; }
  .cs-specs { left: 3%; right: 3%; top: 4%; justify-content: center; gap: 24px; }
  .cs-spec { width: min(24cqi, 86px); }
  .cs-spec-label { margin-top: 4px; padding: 2px 6px; font-size: 11px; }
  .cs-spec-label span { display: none; }
}
@media (max-width: 560px) {
  .cs-story { padding: 14px; }
  .cs-time { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-layer, .cs-title, .cs-note, .cs-callout, .cs-spec, .cs-layer.is-front { transition: none; }
  .cs-pin.is-new .cs-pin-dot::after, button.cs-pin .cs-pin-dot { animation: none; }
}
