/* ══════════════════════════════════════════
   RSVP Reader — Dark Theme
   ══════════════════════════════════════════ */

:root {
  --bg-app:      #0d0d1a;
  --bg-panel:    #13132a;
  --bg-display:  #08081a;
  --bg-input:    #1a1a32;
  --border:      #2a2a50;
  --text:        #dcdcf5;
  --text-muted:  #6060a0;
  --orp:         #FF9900;
  --orp-glow:    rgba(255, 153, 0, 0.25);
  --accent:      #4a90e2;
  --btn-bg:      #1c1c3c;
  --btn-hover:   #26266e;
  --btn-active:  #30308a;
  --play-bg:     #1a3a6e;
  --play-hover:  #2248a0;
  --play-active: #2a55b8;

  /* ORP display metrics — keep in sync with JS */
  --left-width:  5ch;
  --right-width: 13ch;
  --font-display: 72px;
  --font-family:  'Consolas', 'Courier New', monospace;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text);
  user-select: none;
}

/* ── App shell ───────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ══ UPPER PANEL ════════════════════════════ */
.panel-input {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border);
  padding: 14px 18px 16px;
}

/* Textarea */
#textInput {
  width: 100%;
  height: 150px;
  background: var(--bg-input);
  border: 2px solid #3a3a6a;
  border-radius: 6px;
  color: var(--text);
  font-family: 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  padding: 10px 13px;
  resize: vertical;
  outline: none;
  cursor: text;
  transition: border-color 0.18s, box-shadow 0.18s;
  user-select: text;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}
#textInput:hover {
  border-color: #5a5aaa;
}
#textInput:focus {
  border-color: var(--accent);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(74, 144, 226, 0.18);
}
#textInput::placeholder { color: var(--text-muted); }

/* Controls bar — WPM | divider | transport | counter */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Thin vertical separator between WPM and transport */
.ctrl-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

/* WPM control cluster */
.wpm-control {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.wpm-btn {
  width: 38px;
  height: 46px;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.13s;
}
.wpm-btn:hover  { background: var(--btn-hover); }
.wpm-btn:active { background: var(--btn-active); }

#wpmInput {
  width: 80px;
  height: 46px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 4px 6px;
  outline: none;
  transition: border-color 0.18s;
}
#wpmInput:focus { border-color: var(--accent); }
#wpmInput::-webkit-outer-spin-button,
#wpmInput::-webkit-inner-spin-button { -webkit-appearance: none; }

.wpm-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ctrl-btn {
  width: 58px;
  height: 46px;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}
.ctrl-btn:hover  { background: var(--btn-hover); }
.ctrl-btn:active { background: var(--btn-active); }

.ctrl-play {
  width: 72px;
  background: var(--play-bg);
  border-color: #2a5090;
  font-size: 22px;
}
.ctrl-play:hover  { background: var(--play-hover); }
.ctrl-play:active { background: var(--play-active); }

/* Mode toggle: Fixed | Ramp */
.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-btn {
  padding: 0 16px;
  height: 46px;
  background: var(--btn-bg);
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  letter-spacing: 0.04em;
}
.mode-btn + .mode-btn {
  border-left: 1px solid var(--border);
}
.mode-btn:hover { background: var(--btn-hover); color: var(--text); }
.mode-btn.is-active {
  background: var(--play-bg);
  color: var(--text);
}

/* Dim WPM control when ramp mode is active */
.wpm-control.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.progress-info {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

/* ══ LOWER PANEL — RSVP display ═════════════ */
.panel-display {
  flex: 1;
  background: var(--bg-display);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Pivot tick marks above / below ORP — positioned by JS */
.pivot {
  width: 3px;
  height: 14px;
  background: var(--orp);
  border-radius: 2px;
  opacity: 0.7;
  position: absolute;
  pointer-events: none;
}

/* Word row: left | ORP | right
   font-size is set here so that ch units in the transform resolve against
   the 72px display font (not the inherited body font).
   The translateX shifts the row right by (right-width - left-width) / 2
   so the ORP character lands exactly on the panel's horizontal centre
   at any window width. */
.word-row {
  display: flex;
  align-items: baseline;
  font-size: var(--font-display);
  transform: translateX(calc((var(--right-width) - var(--left-width)) / 2));
}

.word-left,
.word-orp,
.word-right {
  font-family: var(--font-family);
  font-size:   var(--font-display);
  line-height: 1.1;
}

.word-left {
  display: inline-block;
  width: var(--left-width);
  text-align: right;
  color: var(--text);
}

.word-orp {
  display: inline-block;
  color: var(--orp);
  font-weight: bold;
  text-shadow: 0 0 18px var(--orp-glow);
}

.word-right {
  display: inline-block;
  width: var(--right-width);
  text-align: left;
  color: var(--text);
}

/* Current speed indicator — upper-right of display panel */
.speed-badge {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: calc(var(--font-display) / 2);
  font-weight: 700;
  font-family: var(--font-family);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}
.speed-badge.is-ramp { color: var(--orp); }

/* Hint text shown when idle */
.hint {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s;
}
.hint.hidden { opacity: 0; }

/* ── Seekbar ─────────────────────────────── */
.seekbar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(transparent, rgba(8, 8, 26, 0.92) 45%);
}

/* Track — tall for easy clicking, visually slim via ::before */
.seekbar-track {
  flex: 1;
  position: relative;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.seekbar-track::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.seekbar-track:hover::before {
  background: rgba(255, 255, 255, 0.18);
}

.seekbar-fill {
  position: absolute;
  left: 0;
  height: 5px;
  width: 0%;
  background: var(--orp);
  border-radius: 3px;
  pointer-events: none;
}

.seekbar-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--orp);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 8px var(--orp-glow);
}

.seekbar-time {
  flex-shrink: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 110px;
  text-align: right;
}
