/* ── MWT Training Course — Design System ───────────────────────────────── */
:root {
  --bg:          #161310;
  --bg-surface:  #1e1a16;
  --bg-elevated: #27221c;
  --bg-card:     #2e2820;
  --border:      rgba(200,182,160,0.1);
  --border-warm: rgba(200,182,160,0.2);
  --text:        #c5c1b9;
  --text-muted:  #8a8278;
  --text-light:  #dcdad5;
  --text-white:  #f0ede8;
  --accent:      #575ECF;
  --accent-dim:  rgba(87,94,207,0.15);
  --accent-hover:#6b72e0;
  --warm:        #c4845a;
  --warm-dim:    rgba(196,132,90,0.15);
  --warm-hover:  #d4946a;
  --success:     #4a9a6f;
  --success-dim: rgba(74,154,111,0.15);
  --error:       #c4614a;
  --error-dim:   rgba(196,97,74,0.15);
  --warn:        #b89050;
  --radius:      12px;
  --radius-sm:   7px;
  --sidebar-w:   280px;
  --header-h:    60px;
  --bar-h:       72px;
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: "CameraPlainVariable", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--bar-h);
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main"
    "controls controls";
}

/* ── SCROLLBAR ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-warm); border-radius: 99px; }

/* ── HEADER ───────────────────────────────────────────────────────────── */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
#header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.01em;
}
#header .logo-mark {
  width: 32px;
  height: 32px;
  background: var(--warm-dim);
  border: 1px solid rgba(196,132,90,0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}
#progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
#progress-bar-wrap {
  width: 160px;
  height: 4px;
  background: var(--bg-card);
  border-radius: 99px;
  overflow: hidden;
}
#progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warm), var(--accent));
  border-radius: 99px;
  transition: width 0.5s ease;
}
#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  font-size: 1.2rem;
}

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.module-group { padding: 4px 0; }
.module-label {
  padding: 8px 16px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-label .mod-icon {
  width: 20px;
  height: 20px;
  background: var(--bg-card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-style: normal;
}
.module-label.complete .mod-icon { background: var(--success-dim); color: var(--success); }
.module-label.active .mod-icon   { background: var(--warm-dim);    color: var(--warm); }
.module-label.quiz-label .mod-icon { background: rgba(87,94,207,0.15); color: var(--accent); }

.slide-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 28px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  position: relative;
}
.slide-nav-item:hover { background: var(--bg-card); color: var(--text); }
.slide-nav-item.active {
  background: var(--warm-dim);
  color: var(--warm);
}
.slide-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--warm);
  border-radius: 0 2px 2px 0;
}
.slide-nav-item.completed { color: var(--success); }
.slide-nav-item.completed .snav-dot { background: var(--success); }
.slide-nav-item.locked { opacity: 0.4; cursor: not-allowed; }
.snav-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}
.slide-nav-item.active .snav-dot { background: var(--warm); }
.snav-label { flex: 1; line-height: 1.3; }

/* ── MAIN CONTENT ────────────────────────────────────────────────────── */
#main {
  grid-area: main;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 32px 20px;
}

/* ── WAVEFORM VISUALIZER ─────────────────────────────────────────────── */
.waveform-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  height: 56px;
}
#waveform-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 56px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
#waveform-wrap.playing {
  border-color: rgba(196,132,90,0.4);
  box-shadow: 0 0 18px rgba(196,132,90,0.1);
}
.wf-bar {
  width: 3px;
  height: 6px;
  border-radius: 99px;
  background: var(--warm);
  opacity: 0.25;
  transition: height 0.08s ease, opacity 0.08s ease;
  /* CSS fallback animation when no Web Audio */
  animation: wfIdle 1.4s ease-in-out infinite;
}
#waveform-wrap.playing .wf-bar {
  animation: none; /* JS takes over */
}
/* Stagger the idle animation */
.wf-bar:nth-child(2)  { animation-delay: 0.1s; }
.wf-bar:nth-child(3)  { animation-delay: 0.2s; }
.wf-bar:nth-child(4)  { animation-delay: 0.3s; }
.wf-bar:nth-child(5)  { animation-delay: 0.15s; }
.wf-bar:nth-child(6)  { animation-delay: 0.05s; }
.wf-bar:nth-child(7)  { animation-delay: 0.25s; }
.wf-bar:nth-child(8)  { animation-delay: 0.35s; }
.wf-bar:nth-child(9)  { animation-delay: 0.1s; }
.wf-bar:nth-child(10) { animation-delay: 0.2s; }
.wf-bar:nth-child(11) { animation-delay: 0.0s; }
.wf-bar:nth-child(12) { animation-delay: 0.3s; }
@keyframes wfIdle {
  0%, 100% { height: 4px;  opacity: 0.18; }
  50%       { height: 10px; opacity: 0.32; }
}
.waveform-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 0.3s;
}
#waveform-wrap.playing + .waveform-label {
  color: var(--warm);
}

.slide-content-col { min-width: 0; }

/* Slide wrapper (non-avatar slides) */
.slide {
  width: 100%;
  max-width: 760px;
  animation: slideIn 0.35s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Module intro badge */
.module-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--warm-dim);
  border: 1px solid rgba(196,132,90,0.35);
  color: var(--warm);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 16px;
}

.slide-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.25;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

/* Narrator text */
.narrator-text {
  font-size: 1.02rem;
  line-height: 1.82;
  color: var(--text);
  margin-bottom: 20px;
}
.narrator-text .word {
  display: inline;
  transition: color 0.08s;
  border-radius: 3px;
}
.narrator-text .word.spoken {
  color: var(--text-light);
}
.narrator-text .word.current {
  background: var(--warm-dim);
  color: var(--warm);
  padding: 0 2px;
  border-radius: 3px;
}

/* Highlight box */
.highlight-box {
  background: var(--warm-dim);
  border-left: 3px solid var(--warm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--text-light);
  font-style: italic;
}

/* ── REVEAL CARDS ────────────────────────────────────────────────────── */
.reveal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.reveal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  height: 130px;
  position: relative;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  perspective: 600px;
}
.reveal-card:hover {
  border-color: var(--warm);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(196,132,90,0.12);
}
.reveal-card.flipped { border-color: var(--border-warm); }
.reveal-card.flipped .card-front { opacity: 0; transform: rotateY(-90deg); }
.reveal-card.flipped .card-back  { opacity: 1; transform: rotateY(0); }
.card-front, .card-back {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: var(--radius);
  transition: opacity 0.25s, transform 0.25s;
}
.card-front {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--warm);
  flex-direction: column;
  gap: 8px;
}
.card-front::after {
  content: 'tap to reveal';
  font-size: 0.63rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.card-back {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-elevated);
  opacity: 0;
  transform: rotateY(90deg);
}
.reveal-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ── REFLECTION ──────────────────────────────────────────────────────── */
.reflection-wrap { margin-top: 20px; }
.reflection-prompt {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warm);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 18px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-light);
  margin-bottom: 14px;
}
.reflection-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  line-height: 1.65;
  padding: 14px 16px;
  resize: vertical;
  min-height: 120px;
  transition: border-color var(--transition);
}
.reflection-textarea:focus {
  outline: none;
  border-color: var(--warm);
}
.reflection-textarea::placeholder { color: var(--text-muted); }
.reflection-note { font-size: 0.76rem; color: var(--text-muted); margin-top: 8px; }

/* ── WOVEN QUESTION ──────────────────────────────────────────────────── */
.woven-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
}
.woven-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warm);
  margin-bottom: 10px;
}
.woven-prompt {
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--text-light);
  margin-bottom: 14px;
}

/* ── QUIZ ────────────────────────────────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.quiz-progress-dots { display: flex; gap: 6px; }
.qdot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: background var(--transition);
}
.qdot.correct { background: var(--success); border-color: var(--success); }
.qdot.wrong   { background: var(--error);   border-color: var(--error); }
.qdot.current { background: var(--warm);    border-color: var(--warm); }

.quiz-counter { font-size: 0.8rem; color: var(--text-muted); }

.question-text {
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--text-white);
  margin-bottom: 18px;
  font-weight: 500;
}
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  font-size: 0.91rem;
  line-height: 1.5;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.option-btn:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--warm);
  color: var(--text-light);
}
.option-btn.selected { border-color: var(--warm); background: var(--warm-dim); color: var(--text-light); }
.option-btn.correct  { border-color: var(--success); background: var(--success-dim); color: #7bcca0; }
.option-btn.wrong    { border-color: var(--error);   background: var(--error-dim);   color: #e08070; }
.option-btn:disabled { cursor: default; }
.option-letter {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-muted);
}
.option-btn.correct .option-letter { background: var(--success); color: #fff; }
.option-btn.wrong   .option-letter { background: var(--error);   color: #fff; }
.option-btn.selected .option-letter { background: var(--warm);   color: #fff; }

.rationale-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 14px;
  animation: fadeIn 0.3s ease;
}
.rationale-box.wrong { border-left-color: var(--error); }

.quiz-result {
  text-align: center;
  padding: 28px 20px;
  animation: fadeIn 0.4s ease;
}
.result-score {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 8px;
}
.result-score span { color: var(--text-muted); font-size: 2rem; }
.result-message {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
}
.result-message.pass { color: var(--success); }
.result-message.fail { color: var(--error); }
.retry-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 10px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.retry-btn:hover { background: var(--bg-elevated); border-color: var(--warm); }

/* ── CONTROLS BAR ────────────────────────────────────────────────────── */
#controls {
  grid-area: controls;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}
.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.83rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.ctrl-btn:hover { background: var(--bg-card); color: var(--text-light); border-color: var(--border-warm); }
.ctrl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ctrl-btn.primary {
  background: var(--warm);
  border-color: var(--warm);
  color: #1a1008;
  font-weight: 700;
  padding: 9px 22px;
}
.ctrl-btn.primary:hover { background: var(--warm-hover); border-color: var(--warm-hover); }
.ctrl-btn.primary:disabled { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); font-weight: 400; }

#tts-btn { font-size: 1rem; padding: 9px 12px; }
#tts-btn.playing { border-color: var(--warm); color: var(--warm); background: var(--warm-dim); }
.tts-time { font-size: 0.75rem; color: var(--text-muted); min-width: 40px; }

#speed-slider {
  -webkit-appearance: none;
  width: 80px; height: 3px;
  background: var(--bg-card);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--warm);
  border-radius: 50%;
}
.speed-label { font-size: 0.75rem; color: var(--text-muted); min-width: 32px; }

/* ── COMPLETION SCREEN ──────────────────────────────────────────────── */
#completion-screen {
  display: none;
  grid-area: main;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  flex-direction: column;
  gap: 20px;
}
#completion-screen.show { display: flex; }
.completion-badge {
  width: 80px; height: 80px;
  background: var(--warm-dim);
  border: 2px solid var(--warm);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto;
}
.completion-title { font-size: 2rem; font-weight: 700; color: var(--text-white); }
.completion-body {
  font-size: 0.97rem; line-height: 1.75;
  color: var(--text);
  max-width: 520px;
}
.completion-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.print-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.print-btn:hover { background: var(--bg-elevated); border-color: var(--warm); color: var(--warm); }

/* ── ANIMATIONS ──────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── TOAST ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-warm);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error   { border-color: var(--error);   color: var(--error); }

/* ── LOGIN PAGE ──────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: auto;
  background: radial-gradient(ellipse at 30% 40%, rgba(196,132,90,0.08) 0%, transparent 60%),
              var(--bg);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-warm);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--warm-dim);
  border: 1px solid rgba(196,132,90,0.4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 20px;
}
.login-title { font-size: 1.4rem; font-weight: 700; color: var(--text-white); margin-bottom: 6px; }
.login-sub   { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 32px; line-height: 1.5; }
.login-field { margin-bottom: 16px; text-align: left; }
.login-field label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.login-field input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.login-field input:focus { outline: none; border-color: var(--warm); }
.login-submit {
  width: 100%;
  background: var(--warm);
  border: none;
  color: #1a1008;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--transition);
}
.login-submit:hover { background: var(--warm-hover); }
.login-error {
  background: var(--error-dim);
  border: 1px solid var(--error);
  color: #e08070;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  margin-bottom: 16px;
}
.login-footer { font-size: 0.75rem; color: var(--text-muted); margin-top: 24px; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #waveform-wrap { padding: 6px 8px; }
}

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "controls";
  }
  #sidebar {
    position: fixed;
    top: var(--header-h); left: 0; bottom: var(--bar-h);
    width: var(--sidebar-w);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
  #sidebar-toggle { display: flex; }
  #main { padding: 20px 16px 16px; }
  .slide-title { font-size: 1.3rem; }
  .reveal-grid { grid-template-columns: 1fr 1fr; }
  #speed-slider, .speed-label, .tts-time { display: none; }
}

@media (max-width: 480px) {
  .reveal-grid { grid-template-columns: 1fr; }
  .ctrl-btn span { display: none; }
  #controls { padding: 0 12px; gap: 8px; }
}
