/*
 * Qadah · Session player layout (Phase 5 → polished in Phase 10 Fix 7)
 *
 * UX rules:
 *   - Slide is the focus, fills the viewport.
 *   - Sara floats bottom-end as a small draggable tile.
 *   - Mic button is centered + primary; slide nav is secondary (smaller, ghost).
 *   - Transcript opens as a bottom drawer that PUSHES the slide up — never a modal.
 *   - Text input is hidden by default; one click toggles it as a strip above the bottom bar.
 *   - "Avatar offline" lives only INSIDE the Sara tile, never as a corner toast.
 *   - Phase 1.5 tokens — no blue, no gradients, no glassmorphism, no resting shadows
 *     (the only shadow lives inside an animation @keyframes).
 */

body.session-mode {
  background: var(--c-bg);
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ───────── Top bar ───────── */
.session-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-bottom: var(--bw) solid var(--c-border);
  background: var(--c-surface);
}
.session-top-left  { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.session-top-right { display: flex; align-items: center; gap: var(--s-3); }
.session-top h3    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }

/* ───────── Slide stage ───────── */
.slide-stage {
  position: relative;
  overflow: hidden;
  background: var(--c-surface-2);
}
#slide-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--c-bg);
}

/* ───────── Floating Sara tile (pinned bottom-right) ───────── */
.sara-tile {
  position: absolute;
  inset-inline-end: var(--s-5);
  bottom: var(--s-5);
  width: 220px;
  background: var(--c-surface);
  border: var(--bw) solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10;
  user-select: none;
}
.sara-tile.dragging { /* legacy class — drag disabled, no-op */ }
.sara-tile.speaking {
  outline: 1.5px solid var(--c-coral);
  outline-offset: -1.5px;
  animation: sara-pulse-ring 2.2s ease-in-out infinite;
}
@keyframes sara-pulse-ring {
  0%, 100% { outline-color: var(--c-coral); }
  50%      { outline-color: var(--c-coral-soft); }
}

.sara-tile-header {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 6px 10px;
  font-size: 12px; color: var(--c-ink-2);
  border-bottom: var(--bw) solid var(--c-border);
  background: var(--c-surface);
}
.sara-tile-header .dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--c-ink-3);
}
.sara-tile-header .dot[data-state="speaking"]   { background: var(--c-coral); }
.sara-tile-header .dot[data-state="listening"]  { background: #4a8a59; }
.sara-tile-header .dot[data-state="connecting"] { background: var(--c-warning); }
.sara-tile-header .dot[data-state="error"]      { background: var(--c-danger); }

#sara-video {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #1a1a1a;
  object-fit: cover;
  display: block;
}

/* Avatar-offline fallback — lives ONLY inside the tile, never as a corner toast. */
.sara-fallback {
  padding: var(--s-3);
  background: var(--c-surface-2);
  text-align: center;
}
.sara-fallback h3 { font-size: 13px; margin: 0 0 6px; font-family: var(--f-display); font-weight: 500; }
.sara-fallback p  { margin: 0; font-size: 11px; color: var(--c-ink-2); line-height: 1.45; }
.sara-fallback .last-response {
  margin-top: 10px;
  padding-top: 10px;
  border-top: var(--bw) solid var(--c-border);
  font-size: 12px;
  color: var(--c-ink);
  text-align: start;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

/* ───────── Transcript drawer (slides up from bottom — does NOT block slide) ───────── */
.transcript-drawer {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  bottom: 0;
  height: 30%;
  max-height: 280px;
  background: var(--c-surface);
  border-top: var(--bw) solid var(--c-border);
  transform: translateY(100%);
  transition: transform var(--t-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 8;
}
.transcript-drawer.open { transform: translateY(0); }
.transcript-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px var(--s-4);
  border-bottom: var(--bw) solid var(--c-border);
  font-size: 12px;
  color: var(--c-ink-2);
}
.transcript-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-4);
}
.msg-row {
  display: flex; gap: var(--s-3);
  padding: 8px 0;
  border-top: var(--bw) solid var(--c-border);
}
.msg-row:first-child { border-top: 0; }
.msg-row .who {
  font-size: 11px;
  color: var(--c-ink-3);
  width: 60px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 1px;
}
.msg-row .body { font-size: 14px; color: var(--c-ink); line-height: 1.55; flex: 1; }

/* ───────── Bottom controls — voice-first ───────── */
.session-bottom {
  display: flex; align-items: center; justify-content: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-top: var(--bw) solid var(--c-border);
  background: var(--c-surface);
  position: relative;
  min-height: 88px;
}
.session-bottom .secondary-action {
  appearance: none;
  border: var(--bw) solid var(--c-border-2);
  background: var(--c-surface);
  color: var(--c-ink-2);
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.session-bottom .secondary-action:hover:not(:disabled) {
  background: var(--c-surface-3);
  color: var(--c-ink);
}
.session-bottom .secondary-action:disabled { opacity: 0.4; cursor: not-allowed; }
.session-bottom .secondary-action.active {
  background: var(--c-coral-soft);
  color: var(--c-coral-text);
  border-color: var(--c-coral);
}

/* Always-on mic indicator. Not a button — purely informational.
   Three visual states driven by data-state on #mic-indicator:
     listening   → green dot, gentle pulse, "listening" copy
     speaking    → coral, no pulse, "Sara is speaking" copy
     connecting  → grey, no pulse, "connecting" copy */
.mic-indicator {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 14px;
  border: var(--bw) solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  cursor: default;
  user-select: none;
  position: relative;
}
.mic-indicator-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-surface-3);
  color: var(--c-ink-3);
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.mic-indicator-label {
  display: flex; flex-direction: column; line-height: 1.15;
}
#mic-state-text {
  font-size: 13px; color: var(--c-ink); font-weight: 500;
}
.mic-indicator-hint {
  font-size: 11px; color: var(--c-ink-3);
}
.mic-indicator[data-state="listening"] .mic-indicator-icon {
  background: rgba(74, 138, 89, 0.14);
  color: #4a8a59;
  animation: mic-listen-pulse 2.2s ease-in-out infinite;
}
.mic-indicator[data-state="speaking"] .mic-indicator-icon {
  background: var(--c-coral-soft);
  color: var(--c-coral-text);
}
.mic-indicator[data-state="error"] .mic-indicator-icon {
  background: rgba(180, 60, 50, 0.12);
  color: var(--c-danger);
}
@keyframes mic-listen-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 138, 89, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(74, 138, 89, 0.18); }
}

#next-btn[data-pulse="true"] {
  border-color: var(--c-coral);
  color: var(--c-coral);
  animation: nextPulse 1.6s ease-in-out infinite;
}
@keyframes nextPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* Text input — appears as a strip above the bottom bar when toggled */
.text-input-bar {
  display: none;
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  bottom: 88px;
  background: var(--c-surface);
  border-top: var(--bw) solid var(--c-border);
  padding: var(--s-3) var(--s-5);
  z-index: 9;
  gap: var(--s-2);
  align-items: center;
}
.text-input-bar.visible { display: flex; }
.text-input-bar input {
  flex: 1;
  padding: 9px 12px;
  border: var(--bw) solid var(--c-border-2);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 14px;
  background: var(--c-surface);
  color: var(--c-ink);
}

/* Mobile */
@media (max-width: 768px) {
  .sara-tile { width: 130px; inset-inline-end: 12px; bottom: 12px; }
  .session-bottom { padding: var(--s-3); gap: var(--s-3); }
  .mic-btn { width: 56px; height: 56px; }
  .session-bottom .secondary-action { width: 36px; height: 36px; }
}
