/* ============================================================================
   AI-Docent — UI v3  ·  Presentation Theater
   ============================================================================ */

:root {
  --bg:           #f0f0f5;
  --panel:        #ffffff;
  --ink:          #18181b;
  --ink-soft:     #3f3f46;
  --ink-mute:     #71717a;
  --ink-faint:    #a1a1aa;
  --line:         #e4e4e7;
  --line-soft:    #f4f4f5;

  /* Accent */
  --accent:       #4338ca;
  --accent-hover: #3730a3;
  --accent-soft:  #eef2ff;
  --accent-text:  #ffffff;

  /* Slide theater */
  --theater:      #0c0c14;
  --theater-mid:  #141420;
  --glass-bg:     rgba(255,255,255,0.08);
  --glass-border: rgba(255,255,255,0.13);
  --glass-text:   rgba(255,255,255,0.90);
  --glass-mute:   rgba(255,255,255,0.45);

  /* Chat */
  --user-bubble:  #eef2ff;
  --user-text:    #1e1b4b;
  --ai-bubble:    #f9f9fc;
  --ai-text:      #18181b;

  /* Schaduwen */
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:    0 8px 24px rgba(0,0,0,0.10);
  --slide-glow:   0 16px 64px rgba(0,0,0,0.65);

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;

  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.55;
}

/* ── TOPBAR ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  height: 54px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #4338ca, #6366f1);
  color: white;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(67,56,202,0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small {
  color: var(--ink-mute);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.slide-indicator {
  color: var(--ink-mute);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 5px 10px;
  background: var(--line-soft);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.progress-track {
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: transparent;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  flex: 1;
  min-height: 0;
}

/* ── SLIDE THEATER ───────────────────────────────────────────────────────── */
.slides-panel {
  display: flex;
  flex-direction: column;
  background: var(--theater);
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Subtiele gradient-vignette boven in theater */
.slides-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(67,56,202,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.slide-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 36px 16px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  min-height: 0;
}

/* Titel is ingebakken in de slide-afbeelding — verbergen */
#slide-title { display: none; }

.slide-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

/* Slide afbeelding — vult de stage */
.slide-figure {
  margin: 0;
  width: 100%;
  text-align: center;
}
.slide-figure img {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  height: auto;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--slide-glow);
  border: none;
}
.slide-figure figcaption { display: none; }
.img-row { display: none; }

/* ── SLIDE CONTROLS (theater) ────────────────────────────────────────────── */
.slide-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.narration-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.narration-status {
  font-size: 11.5px;
  color: var(--glass-mute);
  min-height: 16px;
}
.voice-label {
  font-size: 10.5px;
  color: rgba(255,255,255,0.25);
  margin-top: 2px;
}

/* ── BUTTONS (theater variant — glass) ────────────────────────────────────── */
.btn-primary, .btn-secondary {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
}

/* In theater — primary = accent glow */
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 0 0 rgba(67,56,202,0);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 16px rgba(99,102,241,0.4);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled {
  background: rgba(255,255,255,0.1);
  border-color: transparent;
  color: rgba(255,255,255,0.25);
  cursor: not-allowed;
}

/* In theater — secondary = glass */
.btn-secondary {
  background: var(--glass-bg);
  color: var(--glass-text);
  border-color: var(--glass-border);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.22);
}
.btn-secondary:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary:disabled {
  color: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.03);
  cursor: not-allowed;
}

/* Download log knop in topbar — lichte variant */
#download-log {
  background: var(--panel);
  color: var(--ink-soft);
  border-color: var(--line);
  backdrop-filter: none;
}
#download-log:hover:not(:disabled) {
  background: var(--line-soft);
  color: var(--ink);
}

/* ── CHAT PANEEL ─────────────────────────────────────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.chat-header {
  padding: 15px 20px 13px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
}
.chat-header-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #4338ca, #6366f1);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(67,56,202,0.3);
}
.chat-header-text {
  display: flex; flex-direction: column;
  line-height: 1.25; min-width: 0;
}
.chat-header-text strong { font-size: 14px; color: var(--ink); }
.chat-sub { font-size: 11.5px; color: var(--ink-mute); margin-top: 1px; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  background: #fbfbfe;
}

.msg-wrap {
  display: flex; gap: 9px;
  align-items: flex-start; max-width: 100%;
}
.msg-wrap.user { flex-direction: row-reverse; }
.msg-wrap.ai   { flex-direction: row; }

.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.avatar.ai {
  background: linear-gradient(135deg, #4338ca, #6366f1);
  color: white;
}
.avatar.user { background: var(--line); color: var(--ink-soft); }

.msg {
  padding: 9px 13px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: calc(100% - 36px);
}
.msg.user {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.msg.ai {
  background: var(--ai-bubble);
  color: var(--ai-text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--ink-mute);
  font-size: 11.5px;
  font-style: italic;
  text-align: center;
  max-width: 90%;
  padding: 4px 12px;
}
.msg-meta {
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 5px;
}

.chat-form {
  display: flex; gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  align-items: flex-end;
  background: var(--panel);
}
#chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: none; outline: none;
  min-height: 40px; max-height: 130px;
  background: #f9f9fc;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#chat-input:focus {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#chat-input::placeholder { color: var(--ink-faint); }

/* Chat send button — color variant voor buiten theater */
.chat-form .btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.chat-form .btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(67,56,202,0.3);
}

.chat-status {
  padding: 0 14px 9px;
  font-size: 11px;
  color: var(--ink-mute);
  min-height: 14px;
}

/* ── SCROLLBARS ──────────────────────────────────────────────────────────── */
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.chat-log::-webkit-scrollbar-thumb:hover { background: #d4d4d8; }
.chat-log::-webkit-scrollbar-track { background: transparent; }

/* ── SLIDE FADE ANIMATIE ─────────────────────────────────────────────────── */
@keyframes slideFadeIn {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}
.slide-fade-in .slide-content { animation: slideFadeIn 0.3s cubic-bezier(0.4,0,0.2,1); }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 60% 40%; }
  .chat-panel { border-left: none; border-top: 1px solid var(--line); }
  .slide-stage { padding: 16px 16px 8px; }
  .slide-figure img { max-height: 45vh; }
  .topbar { padding: 0 16px; }
  .brand-text small { display: none; }
}
@media (max-width: 600px) {
  .topbar { height: 48px; }
  .slide-indicator { font-size: 12px; padding: 4px 8px; }
  .slide-figure img { border-radius: 6px; }
}

/* ============================================================================
   V2 — Meadows-iteratie
   - Intake-scherm (drie grote keuze-kaarten)
   - Topbar auto-play toggle
   - Countdown-indicator
   - Denkvraag-overlay
   - Eind-scherm met "wat blijft je bij?"
   - Ken Burns afbeelding-animatie
   - Bullet fade-in op slide-render
   - Bron-tonen knop
   ============================================================================ */

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── INTAKE-SCHERM ───────────────────────────────────────────────────────── */
.intake-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0c0c14 0%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
  animation: fadeIn 0.4s ease;
}
.intake-card {
  width: 100%;
  max-width: 880px;
  text-align: center;
  color: white;
}
.intake-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: rgba(255,255,255,0.96);
}
.intake-sub {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  margin: 0 0 40px;
  font-weight: 400;
}
.intake-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 40px;
}
.intake-option {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 14px;
  padding: 28px 22px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: inherit;
  color: white;
  backdrop-filter: blur(8px);
}
.intake-option:hover {
  background: rgba(67,56,202,0.18);
  border-color: rgba(99,102,241,0.55);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(67,56,202,0.25);
}
.intake-option:active { transform: translateY(0); }
.intake-option-label {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.intake-option-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  font-weight: 400;
}
.intake-footnote {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  margin: 0;
  letter-spacing: 0.02em;
}

/* ── TOPBAR AUTO-TOGGLE ──────────────────────────────────────────────────── */
.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.btn-toggle:hover { background: #dbeafe; }
.btn-toggle[aria-pressed="false"] {
  background: var(--line-soft);
  color: var(--ink-mute);
  border-color: var(--line);
}
.toggle-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.btn-toggle[aria-pressed="false"] .toggle-dot {
  background: var(--ink-faint);
}

/* ── COUNTDOWN ───────────────────────────────────────────────────────────── */
.countdown {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  background: rgba(67,56,202,0.55);
  border: 1px solid rgba(99,102,241,0.55);
  padding: 4px 12px;
  border-radius: 14px;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  animation: countdownPulse 1s ease-in-out infinite;
}
.countdown span {
  font-weight: 700;
  font-size: 14px;
  padding: 0 2px;
}
@keyframes countdownPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(99,102,241,0); }
}

/* ── DENKVRAAG-OVERLAY ──────────────────────────────────────────────────── */
.thinking-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12,12,20,0.92);
  backdrop-filter: blur(6px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
  animation: fadeIn 0.3s ease;
}
.thinking-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  padding: 36px 40px;
  max-width: 640px;
  text-align: center;
  color: white;
}
.thinking-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a5b4fc;
  background: rgba(99,102,241,0.18);
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 18px;
}
.thinking-question {
  font-size: 22px;
  line-height: 1.45;
  font-weight: 500;
  color: rgba(255,255,255,0.95);
  margin: 0 0 28px;
}
.thinking-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.thinking-hint {
  font-size: 12.5px;
  color: rgba(255,255,255,0.45);
  font-style: italic;
}

/* ── EIND-SCHERM ─────────────────────────────────────────────────────────── */
.end-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0c0c14 0%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
  animation: fadeIn 0.4s ease;
}
.end-card {
  width: 100%;
  max-width: 560px;
  text-align: center;
  color: white;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 16px;
  padding: 44px 40px;
}
.end-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.end-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  margin: 0 0 32px;
}
.end-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  color: rgba(255,255,255,0.85);
  text-align: left;
}
.end-word {
  width: 100%;
  font-family: inherit;
  font-size: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: white;
  outline: none;
  margin-bottom: 20px;
  transition: all 0.15s ease;
}
.end-word:focus {
  border-color: rgba(99,102,241,0.7);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}
.end-word::placeholder { color: rgba(255,255,255,0.35); }
.end-submit { width: 100%; padding: 12px 18px; font-size: 14px; }
.end-thanks {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  font-size: 14.5px;
  line-height: 1.55;
}
.end-thanks p { margin: 0 0 18px; }
.end-thanks strong { color: white; }
.end-footnote {
  margin-top: 22px;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

/* ── KEN BURNS — afbeelding-animatie op slide ───────────────────────────── */
@keyframes kenBurns {
  0%   { transform: scale(1.00) translate(0, 0); }
  100% { transform: scale(1.06) translate(-1.5%, -1%); }
}
.slide-figure img {
  animation: kenBurns 18s ease-out forwards;
  transform-origin: center center;
}
/* Wanneer slide opnieuw rendert, animatie herstart via .slide-fade-in restart */
.slide-fade-in .slide-figure img {
  animation: kenBurns 18s ease-out forwards;
}

/* ── BULLET FADE-IN ──────────────────────────────────────────────────────── */
.slide-fade-in .slide-content li {
  animation: bulletFadeIn 0.5s cubic-bezier(0.4,0,0.2,1) forwards;
  opacity: 0;
}
.slide-fade-in .slide-content li:nth-child(1) { animation-delay: 0.1s; }
.slide-fade-in .slide-content li:nth-child(2) { animation-delay: 0.5s; }
.slide-fade-in .slide-content li:nth-child(3) { animation-delay: 0.9s; }
.slide-fade-in .slide-content li:nth-child(4) { animation-delay: 1.3s; }
.slide-fade-in .slide-content li:nth-child(5) { animation-delay: 1.7s; }
.slide-fade-in .slide-content li:nth-child(6) { animation-delay: 2.1s; }
@keyframes bulletFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── BRON-TONEN KNOP ─────────────────────────────────────────────────────── */
.source-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0 0;
  margin-top: 5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(67,56,202,0.4);
}
.source-toggle:hover { color: var(--accent-hover); }
.source-excerpt {
  margin-top: 8px;
  padding: 9px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  font-style: italic;
}

/* ── FADE-IN UTILITY ─────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── INTAKE & END RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 760px) {
  .intake-title { font-size: 26px; }
  .intake-options { grid-template-columns: 1fr; gap: 12px; }
  .intake-option { padding: 18px 18px; }
  .intake-option-label { font-size: 18px; }
  .end-card { padding: 32px 24px; }
  .end-title { font-size: 24px; }
  .thinking-question { font-size: 18px; }
  .thinking-card { padding: 26px 24px; }
}
