/* ==========================================================================
   THE PSYCHO-THERAPIST: PROTOCOL 50 — CINEMATIC STYLING
   Aesthetic: Dark Brutalist Subterranean, Haute Couture Chiaroscuro
   ========================================================================== */

:root {
  --bg-deep: #050608;
  --bg-panel: rgba(14, 17, 22, 0.88);
  --border-zinc: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(0, 229, 255, 0.6);
  --text-primary: #ededed;
  --text-muted: #8b929a;
  --accent-cyan: #00e5ff;
  --accent-amber: #e6a15c;
  --accent-red: #ff334b;
  --font-serif: "Cinzel", "Playfair Display", "Didot", "Bodoni MT", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
}

/* --- Cinema Container & Aspect Ratio Framing --- */
#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #000;
  overflow: hidden;
}

/* Background Image Layer (Dr. Valeria Thorne seated in chair) */
.therapist-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
}

#therapist-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: contrast(1.15) brightness(0.85) grayscale(0.18);
  transform: scale(1.02);
  animation: subtleDrift 30s infinite ease-in-out alternate;
  will-change: transform;
}

/* Segmented vault backdrop (muted loop, cued per question by MediaDirector).
   Sits ABOVE the therapist still via `screen` blending so the dark plate adds
   drifting vault light without ever hiding the subject portrait. */
.backdrop-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.05) brightness(0.6) saturate(0.6);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.6s ease;
  pointer-events: none;
  z-index: 2;
}

.backdrop-video.playing {
  opacity: 0.4;
}

/* Scrim keeps HUD text legible over the moving plate */
#backdrop-scrim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.8) 70%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.2) 22%, rgba(0, 0, 0, 0.25) 75%, rgba(0, 0, 0, 0.92) 100%);
}

@keyframes subtleDrift {
  0% {
    transform: scale(1.02) translate(0, 0);
  }
  50% {
    transform: scale(1.06) translate(-0.8%, -0.4%);
  }
  100% {
    transform: scale(1.03) translate(0.5%, 0.2%);
  }
}

/* Dark Cinematic Vignette & Rain Overlay */
#cinematic-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, rgba(0, 0, 0, 0.15) 0%, rgba(5, 7, 10, 0.75) 68%, rgba(2, 3, 5, 0.98) 100%);
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.9);
}

#light-flicker-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  background: rgba(255, 255, 255, 0);
  transition: background 0.05s ease;
}

#light-flicker-overlay.flicker {
  animation: halogenDip 0.4s ease forwards;
}

@keyframes halogenDip {
  0% { background: rgba(0, 0, 0, 0.85); }
  25% { background: rgba(255, 255, 255, 0.15); }
  50% { background: rgba(0, 0, 0, 0.95); }
  75% { background: rgba(255, 255, 255, 0.08); }
  100% { background: rgba(0, 0, 0, 0); }
}

/* Film Grain Texture */
.film-grain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* --- HUD Header & Footer Bars (Anamorphic Letterbox) --- */
.cinema-bar {
  position: relative;
  z-index: 10;
  height: 64px;
  background: linear-gradient(180deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 70%, rgba(0,0,0,0) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.cinema-bar-bottom {
  height: 48px;
  background: linear-gradient(0deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 70%, rgba(0,0,0,0) 100%);
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  align-items: center;
  gap: 20px;
}

.rec-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-red);
  font-weight: 700;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.hud-bpm-indicator {
  color: var(--accent-cyan);
  font-weight: 600;
  transition: color 0.3s;
}

.hud-bpm-indicator.spike {
  color: var(--accent-red);
  text-shadow: 0 0 8px var(--accent-red);
}

.btn-hud {
  background: transparent;
  border: 1px solid var(--border-zinc);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-hud:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* --- Main Screen Viewport Layer --- */
.screen-layer {
  position: absolute;
  top: 64px;
  bottom: 48px;
  left: 0;
  right: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  padding: 32px 64px 48px 64px;
}

.screen-layer.active {
  display: flex;
}

/* --- Screen 1: Intro Dossier / Registration --- */
#screen-intro {
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.75);
}

.intro-panel {
  max-width: 620px;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-zinc);
  backdrop-filter: blur(16px);
  padding: 44px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}

.cinema-title {
  font-family: var(--font-serif);
  font-size: 28px;
  letter-spacing: 6px;
  font-weight: 400;
  color: #fff;
  margin-bottom: 8px;
}

.cinema-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent-amber);
  margin-bottom: 24px;
}

.intro-desc {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 28px;
  text-align: justify;
}

.intro-input-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.cinema-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-zinc);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 16px;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.3s;
}

.cinema-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.returning-badge {
  background: rgba(0, 229, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #ddd;
  text-align: left;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* --- Screen 2: Interactive Session & Zinc Table Interface --- */
.zinc-interface {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  background: rgba(10, 13, 18, 0.88);
  border: 1px solid var(--border-zinc);
  backdrop-filter: blur(12px);
  padding: 28px 36px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.85);
  transition: all 0.3s ease;
}

.dialogue-box {
  margin-bottom: 20px;
  min-height: 80px;
}

.dialogue-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent-amber);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.dialogue-text {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.6;
  color: #f5f5f5;
  letter-spacing: 0.5px;
}

.question-container {
  display: none;
  flex-direction: column;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-zinc);
}

.question-container.visible {
  display: flex;
}

.question-prompt {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--accent-cyan);
  font-style: italic;
}

.input-area {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn-cinema {
  position: relative;
  background: rgba(18, 22, 28, 0.9);
  border: 1px solid var(--border-zinc);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 14px 28px;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}

.btn-cinema:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
  color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.08);
}

.btn-choice {
  min-width: 160px;
  font-size: 14px;
  font-weight: 600;
}

/* Sliders & Allocations */
.slider-input-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-display {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.slider-display strong {
  color: var(--accent-cyan);
  font-size: 14px;
}

.cinema-slider {
  width: 100%;
  height: 6px;
  background: #222;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.cinema-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.cinema-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-zinc);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  outline: none;
  resize: vertical;
}

/* --- Screen 3: Forensic Diagnostic Verdict --- */
#screen-evaluation {
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  overflow-y: auto;
}

.evaluation-panel {
  max-width: 860px;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-zinc);
  padding: 40px;
  margin: auto 0;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.95);
}

.eval-header {
  border-bottom: 1px solid var(--border-zinc);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.eval-archetype {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--accent-red);
  letter-spacing: 2px;
  margin: 12px 0 6px 0;
}

.eval-verdict-box {
  background: rgba(0, 0, 0, 0.4);
  border-left: 3px solid var(--accent-amber);
  padding: 16px 20px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: #e2e2e2;
  margin-bottom: 24px;
}

.eval-delta-box {
  background: rgba(0, 229, 255, 0.05);
  border-left: 3px solid var(--accent-cyan);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: #bbb;
  white-space: pre-line;
  margin-bottom: 28px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-zinc);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.metric-bar-bg {
  width: 100%;
  height: 6px;
  background: #1a1a1a;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background: var(--accent-cyan);
  transition: width 0.8s ease;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-align: right;
}

.eval-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* --- Dossier Modal --- */
.modal-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.modal-layer.active {
  display: flex;
}

.modal-card {
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-zinc);
  padding: 36px;
  overflow-y: auto;
  font-family: var(--font-sans);
}

.dossier-entry {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-zinc);
  padding: 18px;
  margin-bottom: 20px;
}

.dossier-entry h4 {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-amber);
  margin-bottom: 8px;
}

.dossier-scores {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  margin: 10px 0;
}

.dossier-pre {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #aaa;
  white-space: pre-wrap;
}

/* --- Question Metadata Chips & Validation --- */
.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.06);
  padding: 4px 9px;
  text-transform: uppercase;
}

.meta-chip-dim {
  color: var(--text-muted);
  border-color: var(--border-zinc);
  background: rgba(255, 255, 255, 0.03);
}

.validation-error {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--accent-red);
  border-left: 3px solid var(--accent-red);
  background: rgba(255, 51, 75, 0.08);
  padding: 10px 14px;
  margin-top: 14px;
  display: none;
}

.validation-error.visible {
  display: block;
  animation: errorJitter 0.32s ease;
}

@keyframes errorJitter {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* --- Validated numeric entry (slider + typed field, two-way bound) --- */
.numeric-entry {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
}

.numeric-input {
  width: 120px;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: center;
  padding: 10px;
}

.numeric-input::-webkit-outer-spin-button,
.numeric-input::-webkit-inner-spin-button {
  opacity: 0.4;
}

.numeric-entry .cinema-slider {
  flex: 1 1 auto;
}

.schema-hint {
  color: var(--text-muted);
  font-style: normal;
  font-size: 10px;
}

.cinema-divider {
  border: none;
  border-top: 1px solid var(--border-zinc);
  margin: 16px 0;
}
