/* ==========================================================================
   PROMPTR — design tokens
   Palette: deep charcoal-navy console, amber dashboard glow, red tally light.
   ========================================================================== */

:root {
  --ink: #10141a;
  --panel: #171c23;
  --panel-raised: #1e252e;
  --line: #2a323d;
  --paper: #eceff3;
  --dust: #838d9c;
  --dust-dim: #545e6b;
  --amber: #e8a33d;
  --amber-dim: rgba(232, 163, 61, 0.16);
  --tally: #e5473f;
  --tally-glow: rgba(229, 71, 63, 0.45);

  --font-display: 'Space Grotesk', sans-serif;
  --font-ui: 'Inter', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;

  --shadow-panel: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ==========================================================================
   CONSOLE VIEW
   ========================================================================== */

.console {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 2px var(--amber-dim);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 15px;
}

.script-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

#script-select {
  background: var(--panel-raised);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  max-width: 220px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--paper);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-ghost:hover { border-color: var(--dust-dim); }

.btn-danger { color: var(--tally); }
.btn-danger:hover { border-color: var(--tally); }

.btn-live {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--amber);
  color: #1a1204;
  border: none;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.btn-live:hover { filter: brightness(1.08); }

.tally-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1204;
  display: inline-block;
}

.console-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1px;
  background: var(--line);
}

.editor-pane, .console-panel {
  background: var(--ink);
  padding: 24px;
}

.editor-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.title-input {
  background: transparent;
  border: none;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  flex: 1;
  min-width: 0;
}
.title-input:hover, .title-input:focus { border-bottom-color: var(--line); }

.editor-stats {
  font-size: 12px;
  color: var(--dust);
  white-space: nowrap;
}
.stat-sep { margin: 0 6px; opacity: 0.5; }

.script-textarea {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 320px;
  resize: vertical;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--paper);
  font-size: 17px;
  line-height: 1.7;
  padding: 20px;
  font-family: var(--font-ui);
}
.script-textarea::placeholder { color: var(--dust-dim); }

.console-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dust);
  margin: 0 0 20px;
}

.control-group { margin-bottom: 22px; }

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--paper);
  margin-bottom: 10px;
}

.control-value {
  font-family: var(--font-display);
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-hint {
  font-size: 11px;
  color: var(--dust-dim);
  text-align: right;
}

.select-control {
  width: 100%;
  background: var(--panel-raised);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
}

/* --- Fader-style range slider: tick marks like a physical console --- */
.fader {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background:
    repeating-linear-gradient(
      to right,
      var(--dust-dim) 0, var(--dust-dim) 1px,
      transparent 1px, transparent calc(100% / 20)
    ),
    var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.fader::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 24px;
  border-radius: 2px;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-dim);
  border: none;
  cursor: grab;
}
.fader::-moz-range-thumb {
  width: 8px;
  height: 24px;
  border-radius: 2px;
  background: var(--amber);
  border: none;
  cursor: grab;
}
.fader::-moz-range-track {
  height: 24px;
  background: transparent;
}

/* --- Toggle switch --- */
.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
}
.switch-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
  width: 34px;
  height: 20px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--dust);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch-label input:checked + .switch { background: var(--amber-dim); border-color: var(--amber); }
.switch-label input:checked + .switch::after { transform: translateX(14px); background: var(--amber); }

/* --- Theme swatches --- */
.theme-swatches {
  display: flex;
  gap: 10px;
}
.swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  padding: 0;
}
.swatch.active { border-color: var(--amber); }
.swatch-classic { background: #000; }
.swatch-console { background: #10141a; box-shadow: inset 0 0 0 8px transparent; position: relative; }
.swatch-console::after { content:''; position:absolute; inset:10px; background: var(--amber); border-radius: 2px; }
.swatch-paper { background: #fff; }
.swatch-dim { background: #23262b; }

.console-footer {
  padding: 12px 24px;
  font-size: 11px;
  color: var(--dust-dim);
  border-top: 1px solid var(--line);
  text-align: center;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.btn-small {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  text-align: center;
}
.block-hint {
  display: block;
  text-align: left;
  line-height: 1.5;
  margin-top: 4px;
}

kbd {
  display: inline-block;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-display);
  font-size: 11px;
}
.console-footer kbd { margin: 0 2px; }

/* ==========================================================================
   PROMPTER (FULLSCREEN) VIEW
   ========================================================================== */

.prompter {
  position: fixed;
  inset: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
  z-index: 100;
  cursor: none;
}
.prompter.show-cursor { cursor: default; }

.prompter.theme-classic { background: #000; }
.prompter.theme-console { background: #0b0e13; }
.prompter.theme-paper   { background: #ffffff; }
.prompter.theme-dim     { background: #1c1e22; }

/* Mirroring is applied to the scroll container, not .prompter-text — the
   scroll engine drives .prompter-text's transform every frame via JS, and
   an inline style always wins over a class rule, so mirroring the same
   element JS animates would silently get overwritten. Keeping them on
   separate elements means both can be set independently. */
.prompter.mirrored .prompter-scroll { transform: scaleX(-1); }
.prompter.mirrored-v .prompter-scroll { transform: scaleY(-1); }
.prompter.mirrored.mirrored-v .prompter-scroll { transform: scale(-1, -1); }

.progress-rail {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,0.08);
  z-index: 3;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-dim);
  transition: width 0.1s linear;
}

.reading-guide {
  position: absolute;
  left: 0; right: 0;
  top: 40%;
  height: 1px;
  background: linear-gradient(to right, transparent 4%, rgba(232,163,61,0.35) 50%, transparent 96%);
  z-index: 2;
  pointer-events: none;
}

.prompter-scroll {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Soft fade at top/bottom so the reading-guide line reads as the focal
   point, without hard-clipping the text like a mask would. */
.vignette {
  position: absolute;
  left: 0; right: 0;
  height: 22vh;
  z-index: 2;
  pointer-events: none;
}
.vignette-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}
.vignette-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
}
.theme-paper .vignette-top { background: linear-gradient(to bottom, rgba(255,255,255,0.7), transparent); }
.theme-paper .vignette-bottom { background: linear-gradient(to top, rgba(255,255,255,0.7), transparent); }

.shortcuts-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.shortcuts-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  min-width: 280px;
  box-shadow: var(--shadow-panel);
}
.shortcuts-card h3 {
  font-family: var(--font-display);
  margin: 0 0 16px;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dust);
}
.shortcuts-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.shortcuts-card li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--paper);
  border-bottom: 1px solid var(--line);
}
.shortcuts-card li:last-child { border-bottom: none; }
.shortcuts-close-hint {
  display: block;
  margin-top: 16px;
  font-size: 11px;
  color: var(--dust-dim);
  text-align: center;
}

.prompter-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  padding-top: 100vh;
  padding-bottom: 100vh;
  font-size: 56px;
  line-height: 1.5;
  font-weight: 600;
  white-space: pre-wrap;
  will-change: transform;
}
.theme-paper .prompter-text { color: #0a0a0a; }
.theme-console .prompter-text { color: var(--amber); }

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 10;
}
.countdown-number {
  font-family: var(--font-display);
  font-size: 30vh;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 60px var(--amber-dim);
}

.prompter-hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  z-index: 5;
  font-family: var(--font-display);
  font-size: 13px;
  transition: opacity 0.3s ease, transform 0.3s ease;
  cursor: default;
}
.prompter-hud.hud-hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-sep { opacity: 0.4; }

.hud-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.hud-btn:hover { background: rgba(255,255,255,0.18); }

.hud-btn-main {
  width: 52px;
  height: 52px;
  background: var(--amber);
  color: #1a1204;
  border: none;
  font-size: 18px;
}
.hud-btn-main:hover { filter: brightness(1.1); }

.hud-btn-exit {
  width: auto;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 12px;
  gap: 6px;
}

.tally-dot-lg {
  width: 10px;
  height: 10px;
  background: var(--dust-dim);
}
.tally-dot-lg.live {
  background: var(--tally);
  box-shadow: 0 0 10px 2px var(--tally-glow);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 860px) {
  .console-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .script-textarea { height: 42vh; }
  .topbar { flex-wrap: wrap; }
  .script-switcher { order: 3; width: 100%; }
  .prompter-hud { flex-wrap: wrap; gap: 10px; }
  .prompter-text { width: 90%; font-size: 40px !important; }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
