/* Dialogic Slide Player — Dark cinematic presentation theme */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --d-bg: #0f0f14;
  --d-surface: #1a1a24;
  --d-surface-2: #22223a;
  --d-border: #2e2e44;
  --d-text: #e8e8f0;
  --d-text-muted: #8888a0;
  --d-text-dim: #5a5a72;
  --d-accent: #667eea;
  --d-accent-light: #8b9cf7;
  --d-accent-glow: rgba(102, 126, 234, 0.15);
  --d-gradient-1: #667eea;
  --d-gradient-2: #764ba2;
  --d-gold: #f5c542;
  --d-green: #34d399;
  --d-red: #f87171;
  --d-question-bg: rgba(245, 197, 66, 0.08);
  --d-question-border: #f5c542;
  --d-font-display: 'Playfair Display', Georgia, serif;
  --d-font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --d-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--d-bg);
  color: var(--d-text);
}

/* ── Header ── */

.dialogic-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(180deg, rgba(15, 15, 20, 0.98) 0%, rgba(15, 15, 20, 0.92) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--d-border);
  font-family: var(--d-font-body);
  z-index: 1000;
}

.dialogic-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--d-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 35%;
  letter-spacing: 0.02em;
}

/* ── Reveal overrides ── */

.reveal {
  flex: 1;
  min-height: 0;
  font-family: var(--d-font-body);
}

.reveal .backgrounds { background: var(--d-bg); }

.reveal .slides {
  text-align: left;
}

.reveal .slides section {
  text-align: left;
  padding: 2.5rem 3rem 2rem;
}

.reveal .slide-content {
  width: 100%;
  height: 100%;
  color: var(--d-text);
  line-height: 1.55;
  font-size: 0.82em;
  font-weight: 400;
  padding-bottom: 8rem;
  padding-right: 1rem;
  overflow-y: auto;
}

.reveal .slide-content p {
  margin: 0.5em 0 0.9em;
  color: var(--d-text);
}

.reveal .slide-content ul,
.reveal .slide-content ol {
  margin: 0.4em 0 1em;
  padding-left: 1.3em;
  font-size: 0.92em;
  overflow: hidden;
}

.reveal .slide-content li {
  margin: 0.35em 0;
  color: var(--d-text);
  line-height: 1.5;
}

.reveal .slide-content li::marker {
  color: var(--d-accent);
}

/* Headings */
.reveal h1, .reveal h2, .reveal h3 {
  text-transform: none;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.reveal .slide-content h1 {
  font-family: var(--d-font-display);
  font-size: 1.65em;
  font-weight: 700;
  background: linear-gradient(135deg, var(--d-gradient-1), var(--d-gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4em;
  line-height: 1.2;
}

.reveal .slide-content h2 {
  font-family: var(--d-font-display);
  font-size: 1.2em;
  color: var(--d-text-muted);
  font-weight: 500;
  margin: 0.15em 0 0.5em;
  font-style: italic;
}

.reveal .slide-content h3 {
  font-size: 0.95em;
  color: var(--d-accent-light);
  font-weight: 600;
  margin: 0 0 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78em;
}

.reveal .slide-content strong {
  color: #fff;
  font-weight: 600;
}

.reveal .slide-content em {
  color: var(--d-text-muted);
  font-style: italic;
}

.reveal .slide-content a {
  color: var(--d-accent-light);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 156, 247, 0.3);
  transition: border-color 0.2s;
}

.reveal .slide-content a:hover {
  border-bottom-color: var(--d-accent-light);
}

.reveal .slide-content code {
  font-family: var(--d-font-mono);
  font-size: 0.88em;
  background: var(--d-surface-2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--d-accent-light);
}

/* Tables */
.reveal .slide-content table {
  margin: 0.85rem 0;
  font-size: 0.78em;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--d-border);
}

.reveal .slide-content th,
.reveal .slide-content td {
  padding: 0.55em 0.8em;
  text-align: left;
  border-bottom: 1px solid var(--d-border);
}

.reveal .slide-content th {
  background: var(--d-surface-2);
  color: var(--d-accent-light);
  font-weight: 600;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reveal .slide-content td {
  background: var(--d-surface);
}

.reveal .slide-content tr:last-child td { border-bottom: none; }
.reveal .slide-content tr:hover td { background: var(--d-surface-2); }

/* ── Slide number ── */
.slide-number {
  font-size: 0.8rem;
  color: var(--d-text-dim);
  font-variant-numeric: tabular-nums;
  font-family: var(--d-font-mono);
}

/* ── Captions ── */

.dialogic-captions {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 72%;
  width: auto;
  padding: 0.35rem 1rem;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.35;
  z-index: 1000;
  text-align: center;
  transition: opacity 0.25s ease;
  font-family: var(--d-font-body);
  border-radius: 4px;
  letter-spacing: 0.01em;
  max-height: 3.1em;
  overflow: hidden;
}

.dialogic-captions:empty { opacity: 0; pointer-events: none; }
.dialogic-captions:not(:empty) { opacity: 1; }

/* ── Controls ── */

.dialogic-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-family: var(--d-font-body);
  flex-shrink: 0;
}

.dialogic-controls button {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  border: 1px solid var(--d-border);
  border-radius: 6px;
  background: var(--d-surface);
  color: var(--d-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dialogic-controls button:hover {
  background: var(--d-surface-2);
  border-color: var(--d-accent);
  color: var(--d-accent-light);
}

.dialogic-controls button.active {
  background: var(--d-accent);
  color: #fff;
  border-color: var(--d-accent);
}

.captions-toggle {
  font-size: 0.8rem;
  color: var(--d-text-dim);
  cursor: pointer;
  user-select: none;
}

.captions-toggle input { margin-right: 0.3em; }

/* Progress */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 10rem;
  flex: 1;
  max-width: 260px;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.time-display {
  font-size: 0.75rem;
  color: var(--d-text-dim);
  font-variant-numeric: tabular-nums;
  font-family: var(--d-font-mono);
}

.btn-start-over {
  flex-shrink: 0;
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  border: 1px solid var(--d-border);
  border-radius: 4px;
  background: var(--d-surface);
  color: var(--d-text-dim);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.btn-start-over:hover {
  background: var(--d-surface-2);
  border-color: var(--d-accent);
  color: var(--d-accent-light);
}

.progress-track {
  height: 4px;
  background: var(--d-border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.progress-track:hover { background: var(--d-surface-2); }

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--d-gradient-1), var(--d-gradient-2));
  border-radius: 2px;
  width: 0%;
  transition: width 0.15s ease;
  pointer-events: none;
}

.dialogic-controls #btn-raise-hand.active {
  background: var(--d-question-bg);
  border-color: var(--d-question-border);
  color: var(--d-gold);
}

/* ── Q&A Panel (student asks professor) ── */

.dialogic-question-panel {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 420px);
  max-height: 40vh;
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  font-family: var(--d-font-body);
}

.dialogic-question-panel[hidden] { display: none !important; }

.question-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--d-border);
  background: var(--d-surface-2);
  border-radius: 12px 12px 0 0;
}

.question-panel-title { font-weight: 600; color: var(--d-text); }

.question-panel-header button {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--d-text-dim);
  cursor: pointer;
  padding: 0 0.3rem;
}

.question-panel-header button:hover { color: var(--d-text); }

.question-panel-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-history {
  max-height: 300px;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-item {
  padding: 0.75rem;
  background: var(--d-accent-glow);
  border-radius: 6px;
  border-left: 3px solid var(--d-accent);
  color: var(--d-text);
  font-weight: 500;
}

.answer-item {
  padding: 0.75rem;
  background: var(--d-surface-2);
  border-radius: 6px;
  border-left: 3px solid var(--d-text-dim);
  color: var(--d-text);
  line-height: 1.5;
}

.answer-item.loading {
  color: var(--d-text-dim);
  font-style: italic;
  position: relative;
  padding-left: 2.5rem;
}

.answer-item.loading::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--d-accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: dialogic-spin 0.8s linear infinite;
}

@keyframes dialogic-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.question-panel-body textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--d-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 4rem;
  background: var(--d-bg);
  color: var(--d-text);
}

.question-panel-body textarea:focus {
  outline: none;
  border-color: var(--d-accent);
}

.question-panel-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.question-panel-actions button {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  border: 1px solid var(--d-border);
  border-radius: 6px;
  background: var(--d-surface);
  color: var(--d-text);
  cursor: pointer;
  font-family: inherit;
}

.question-panel-actions button:hover {
  background: var(--d-surface-2);
  border-color: var(--d-accent);
  color: var(--d-accent-light);
}

.question-panel-actions #question-submit {
  background: var(--d-accent);
  color: #fff;
  border-color: var(--d-accent);
}

.question-panel-actions #question-submit:hover {
  background: var(--d-accent-light);
  border-color: var(--d-accent-light);
}

.question-stt-icon { font-size: 1em; }
.question-stt.recording { background: rgba(248, 113, 113, 0.1); border-color: var(--d-red); color: var(--d-red); }

/* ── Student Question Panel (professor asks student) ── */

.dialogic-student-question-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90%, 500px);
  background: var(--d-surface);
  border: 1px solid var(--d-accent);
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(102, 126, 234, 0.15), 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1002;
  font-family: var(--d-font-body);
  animation: dialogic-slide-in 0.3s ease;
}

.dialogic-student-question-panel[hidden] { display: none !important; }

@keyframes dialogic-slide-in {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.student-question-content {
  padding: 2rem;
}

.student-question-prompt {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--d-text);
  margin: 0 0 1.5rem;
  line-height: 1.4;
}

.student-question-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.student-question-choices .choice-btn {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--d-border);
  border-radius: 8px;
  background: var(--d-surface-2);
  color: var(--d-text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  font-family: inherit;
}

.student-question-choices .choice-btn:hover {
  border-color: var(--d-accent);
  background: var(--d-accent-glow);
  color: var(--d-accent-light);
}

.student-question-content textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--d-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 3rem;
  margin-bottom: 1rem;
  background: var(--d-bg);
  color: var(--d-text);
}

.student-question-content textarea:focus {
  outline: none;
  border-color: var(--d-accent);
}

.student-question-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.student-question-actions button {
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  border: 1px solid var(--d-border);
  border-radius: 8px;
  background: var(--d-surface);
  color: var(--d-text);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

.student-question-actions #student-answer-submit {
  background: var(--d-accent);
  color: #fff;
  border-color: var(--d-accent);
}

.student-question-actions #student-answer-submit:hover {
  background: var(--d-accent-light);
}

.student-question-actions #student-question-skip:hover {
  border-color: var(--d-text-muted);
}

.student-question-feedback {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.student-question-feedback.correct {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid var(--d-green);
  color: var(--d-green);
}

.student-question-feedback.incorrect {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--d-red);
  color: var(--d-red);
}

/* ── In-slide question block ── */

.dialogic-question {
  margin: 1.25rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--d-question-bg);
  border: 1px solid rgba(245, 197, 66, 0.25);
  border-left: 3px solid var(--d-question-border);
  border-radius: 10px;
}

.dialogic-question .question-prompt {
  font-size: 0.95em;
  margin: 0 0 0.5rem;
  color: var(--d-text);
}

.dialogic-question .question-prompt strong {
  color: var(--d-gold);
}

.dialogic-question .question-choices {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.dialogic-question .question-choices li {
  padding: 0.3rem 0;
  font-size: 0.9em;
  color: var(--d-text-muted);
}

.dialogic-question .question-explanation {
  font-size: 0.85em;
  color: var(--d-text-dim);
  font-style: italic;
  margin: 0.5rem 0 0;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .dialogic-header {
    flex-wrap: wrap;
    padding: 0.4rem 0.75rem;
  }
  .dialogic-title {
    font-size: 0.85rem;
    max-width: 100%;
    order: -1;
    width: 100%;
  }
  .dialogic-controls {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .dialogic-controls button {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
  }
  .reveal .slides section {
    padding: 1.5rem 1.5rem 1rem;
  }
  .reveal .slide-content h1 {
    font-size: 1.3em;
  }
  .progress-wrap { min-width: 6rem; max-width: none; }
  .progress-header { flex-wrap: wrap; }
  .btn-start-over { font-size: 0.65rem; padding: 0.12rem 0.35rem; }
  .time-display { font-size: 0.7rem; width: 100%; order: 10; }
  .progress-track { height: 3px; }
  .dialogic-captions {
    max-width: 95%;
    font-size: 1rem;
    bottom: 1rem;
    padding: 0.3rem 0.8rem;
  }
  .dialogic-question-panel { width: calc(100% - 2rem); bottom: 4rem; }
  .dialogic-student-question-panel { width: calc(100% - 2rem); }
}
