/* Storycraft runtime — minimal, WCAG-friendly, no external deps. */

:root {
  --bg: #0f1115;
  --panel: #181a21;
  --ink: #e8eaf0;
  --ink-dim: #a5acba;
  --accent: #6ea8ff;
  --accent-deep: #4b86d9;
  --ok: #5bd28b;
  --err: #ff7a7a;
  --line: #262a33;
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafbfc;
    --panel: #ffffff;
    --ink: #15171b;
    --ink-dim: #545a66;
    --accent: #1f6feb;
    --accent-deep: #0a4cb0;
    --ok: #1f883d;
    --err: #cf222e;
    --line: #d8dde3;
    --shadow: 0 8px 24px rgba(0,0,0,0.08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}

header {
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

#course-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

#progress-bar {
  height: 6px;
  width: 100%;
  background: var(--line);
  position: sticky;
  top: 48px;
  z-index: 9;
}

#progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width 220ms ease-out;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.slide {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 32px 28px;
  box-shadow: var(--shadow);
  animation: fadeIn 200ms ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide h2 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.25;
  outline: none;
}

.slide h2:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.slide-image {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin-bottom: 20px;
  display: block;
}

.narration {
  color: var(--ink-dim);
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.body {
  margin: 0 0 22px;
}

.body p { margin: 0 0 12px; }
.body ul, .body ol { padding-left: 22px; margin: 0 0 12px; }

.question, .prompt {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 8px 0 16px;
}

.choices, .branches {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice, .btn.branch {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 140ms ease;
}

.choice:hover:not(:disabled),
.btn.branch:hover {
  border-color: var(--accent);
  background: rgba(110, 168, 255, 0.06);
}

.choice:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice.right { border-color: var(--ok); background: rgba(91,210,139,0.10); }
.choice.wrong { border-color: var(--err); background: rgba(255,122,122,0.10); }
.choice.answer:not(.right) { border-style: dashed; border-color: var(--ok); }

.feedback {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 4px 0 18px;
  font-size: 0.95rem;
}
.feedback.ok { background: rgba(91,210,139,0.10); color: var(--ok); }
.feedback.err { background: rgba(255,122,122,0.10); color: var(--err); }

.nav {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
}

.btn {
  font: inherit;
  border-radius: 8px;
  padding: 10px 22px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 140ms ease;
}

.btn.primary {
  background: var(--accent);
  color: white;
}
.btn.primary:hover { background: var(--accent-deep); }

.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.secondary:hover { border-color: var(--accent); }

.slide-end {
  text-align: center;
}
.score-line {
  font-size: 1.3rem;
  margin: 24px 0;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

footer {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.78rem;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 640px) {
  main { padding: 20px 14px 60px; }
  .slide { padding: 24px 20px; border-radius: 10px; }
  .slide h2 { font-size: 1.35rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
