/* CSS Variables - shadcn dark theme */
:root {
  --background: 0 0% 4%;
  --foreground: 60 9% 94%;
  --card: 0 0% 6%;
  --card-foreground: 60 9% 94%;
  --popover: 0 0% 6%;
  --popover-foreground: 60 9% 94%;
  --primary: 0 72% 44%;
  --primary-foreground: 60 9% 94%;
  --secondary: 0 0% 12%;
  --secondary-foreground: 60 9% 94%;
  --muted: 0 0% 12%;
  --muted-foreground: 0 0% 45%;
  --accent: 0 0% 12%;
  --accent-foreground: 60 9% 94%;
  --destructive: 0 62% 30%;
  --destructive-foreground: 60 9% 94%;
  --border: 0 0% 14%;
  --input: 0 0% 14%;
  --ring: 0 72% 44%;
  --radius: 0.5rem;
  --orp-color: #c41e1e;
  --text-size: 80px;
  --reading-font: 'Lora', serif;
}

/* Light theme */
[data-theme="light"] {
  --background: 0 0% 100%;
  --foreground: 0 0% 9%;
  --card: 0 0% 98%;
  --card-foreground: 0 0% 9%;
  --popover: 0 0% 98%;
  --popover-foreground: 0 0% 9%;
  --primary: 0 72% 44%;
  --primary-foreground: 60 9% 94%;
  --secondary: 0 0% 94%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 94%;
  --muted-foreground: 0 0% 45%;
  --accent: 0 0% 94%;
  --accent-foreground: 0 0% 9%;
  --border: 0 0% 88%;
  --input: 0 0% 88%;
}

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

body {
  font-family: 'Geist', sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
}

/* Input View */
#input-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

#input-view.hidden {
  display: none;
}

.input-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* URL Row */
.url-row {
  display: flex;
  gap: 0.5rem;
}

/* Input styles - shadcn */
input[type="url"],
input[type="text"] {
  flex: 1;
  height: 2.5rem;
  padding: 0 0.75rem;
  font-family: 'Geist', sans-serif;
  font-size: 0.875rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="url"]:focus,
input[type="text"]:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsla(var(--ring), 0.2);
}

input[type="url"]::placeholder,
input[type="text"]::placeholder {
  color: hsl(var(--muted-foreground));
}

/* Textarea - shadcn */
textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  font-family: 'Geist', sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsla(var(--ring), 0.2);
}

textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

/* Checkbox - shadcn style */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.checkbox-box svg {
  width: 0.75rem;
  height: 0.75rem;
  color: hsl(var(--primary-foreground));
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.checkbox-row input[type="checkbox"]:checked + .checkbox-box {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.checkbox-row input[type="checkbox"]:checked + .checkbox-box svg {
  opacity: 1;
  transform: scale(1);
}

.checkbox-row input[type="checkbox"]:focus-visible + .checkbox-box {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.checkbox-row:hover .checkbox-box {
  border-color: hsl(var(--ring));
}

.checkbox-label {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

/* Button base - shadcn */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  outline: none;
}

button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Secondary button (Fetch, Exit) */
.btn-secondary {
  height: 2.5rem;
  padding: 0 1rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
  background: hsl(var(--accent));
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary button (Start Reading) */
.btn-primary {
  height: 2.75rem;
  padding: 0 1.5rem;
  background: hsl(var(--primary));
  border: none;
  color: hsl(var(--primary-foreground));
  font-size: 0.9375rem;
}

.btn-primary:hover:not(:disabled) {
  background: hsl(0 72% 38%);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* WPM Slider Row */
.wpm-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wpm-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.wpm-row .wpm-value {
  min-width: 3rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}

/* Range slider - shadcn style */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 0.5rem;
  background: hsl(var(--secondary));
  border-radius: 9999px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  background: hsl(var(--foreground));
  border: 2px solid hsl(var(--background));
  border-radius: 9999px;
  cursor: pointer;
  transition: transform 0.1s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  background: hsl(var(--foreground));
  border: 2px solid hsl(var(--background));
  border-radius: 9999px;
  cursor: pointer;
  transition: transform 0.1s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* Reading View */
#reading-view {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: hsl(var(--background));
}

#reading-view.active {
  display: block;
}

.crosshair-v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: hsl(var(--border));
}

.crosshair-h {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: hsl(var(--border));
}

.word-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--reading-font);
  font-size: var(--text-size);
  font-weight: 400;
  white-space: nowrap;
  user-select: none;
  color: hsl(var(--foreground));
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
}

.word-container .orp {
  color: var(--orp-color);
}

/* Keyboard hint */
.keyboard-hint {
  position: absolute;
  bottom: 7.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.keyboard-hint.visible {
  opacity: 1;
}

.keyboard-hint span {
  margin-right: 0.75rem;
}

.keyboard-hint span:last-of-type {
  margin-right: 0;
}

kbd.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.375rem;
  font-family: 'Geist', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem;
  box-shadow: 0 1px 0 1px hsl(var(--background)), 0 2px 0 1px hsl(var(--border));
}

/* Reading Controls - card style */
.reading-controls {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.875rem 1.25rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  transition: opacity 0.2s ease;
}

.reading-controls.faded {
  opacity: 0.3;
}

.reading-controls:hover {
  opacity: 1;
}

.reading-controls label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.reading-controls input[type="range"] {
  width: 120px;
}

.reading-controls .wpm-value {
  min-width: 2.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}

.pause-indicator {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
}

/* Ghost button for reading controls */
.btn-ghost {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
}

.btn-ghost:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

/* Progress indicator */
.progress-indicator {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.progress-indicator.visible {
  opacity: 1;
}

/* Settings Button */
.settings-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.2s ease;
  z-index: 10;
}

.settings-btn:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.settings-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

#settings-btn-reading {
  opacity: 0;
  pointer-events: none;
}

#settings-btn-reading.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: var(--radius);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.modal-close svg {
  width: 1rem;
  height: 1rem;
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Setting Groups */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.setting-value {
  min-width: 3.5rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
  text-align: right;
}

/* Theme Buttons */
.theme-btn {
  flex: 1;
  height: 2.25rem;
  font-family: 'Geist', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-btn:hover {
  color: hsl(var(--foreground));
}

.theme-btn.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Color Buttons */
.color-options {
  gap: 0.5rem;
}

.color-btn {
  width: 2rem;
  height: 2rem;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: hsl(var(--foreground));
}

/* Select */
.setting-select {
  flex: 1;
  height: 2.25rem;
  padding: 0 0.75rem;
  font-family: 'Geist', sans-serif;
  font-size: 0.8125rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  cursor: pointer;
  outline: none;
}

.setting-select:focus {
  border-color: hsl(var(--ring));
}
