/* css/styles.css — Word to Sleep dark theme */

*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:            #0a0a0f;
  --surface:       #12121a;
  --surface-hover: #1a1a25;
  --text-primary:  #9999bb;
  --text-secondary:#7b7b99;
  --text-dim:      #7a7a92;
  --accent:        #4a5568;
  --accent-active: #667788;
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* Screen transitions */
.screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity var(--transition), transform var(--transition);
  overflow-y: auto;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  visibility: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}

/* App header (home screen) */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}
.app-title {
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.header-nav {
  display: flex;
  gap: 4px;
}
.nav-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.nav-btn:hover { color: var(--text-primary); background: var(--surface); }

/* Home content */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding-bottom: 80px;
}
.instruction-text {
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Play button */
.play-btn {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--accent-active);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.play-btn:hover:not(:disabled) {
  border-color: var(--accent-active);
  background: var(--surface-hover);
  transform: scale(1.05);
}
.play-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.play-btn.active {
  border-color: var(--accent-active);
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(102, 119, 136, 0.2); }
  50% { box-shadow: 0 0 0 20px rgba(102, 119, 136, 0); }
}
.play-btn svg {
  width: 40px; height: 40px;
  fill: currentColor;
}

/* Settings summary */
.settings-summary {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Voice download status */
.voice-status { text-align: center; width: 100%; max-width: 280px; }
.voice-status-text { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }
.progress-bar {
  height: 3px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-active);
  width: 0%;
  transition: width 0.3s ease;
}

/* Screen headers (settings, about) */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
.back-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
}
.screen-header h2 {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-primary);
}

/* Settings groups */
.settings-content { padding: 8px 0; display: flex; flex-direction: column; gap: 32px; }
.setting-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.setting-value {
  color: var(--accent-active);
  font-variant-numeric: tabular-nums;
}

/* Range inputs */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-active);
  cursor: pointer;
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-active);
  cursor: pointer;
  border: none;
}

/* Duration chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { background: var(--surface); }
.chip.selected {
  background: var(--accent);
  color: var(--text-primary);
  border-color: var(--accent-active);
}

/* Voice list */
.voice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.voice-item.selected {
  border-color: var(--accent-active);
}
.voice-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.voice-item-name { font-size: 0.95rem; }
.voice-item-meta { font-size: 0.75rem; color: var(--text-dim); }
.voice-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.voice-item-preview {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.voice-item-preview:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--surface-hover);
}
.voice-item-preview:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.voice-item-preview.previewing {
  color: var(--accent-active);
  animation: pulse-preview 1s ease-in-out infinite;
}
@keyframes pulse-preview {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.voice-item-action {
  background: none; border: 1px solid var(--accent); border-radius: var(--radius-sm);
  color: var(--text-secondary); padding: 6px 12px; font-size: 0.8rem; cursor: pointer;
  transition: all var(--transition);
}
.voice-item-action:hover:not(:disabled) {
  border-color: var(--accent-active);
  color: var(--text-primary);
}
.voice-item-action.downloading {
  pointer-events: none; opacity: 0.5;
}
.voice-item-action:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Model download card */
.model-download-card {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  text-align: center;
  margin-bottom: 12px;
}
.model-download-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.model-download-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition);
}
.model-download-btn:hover { background: var(--accent-active); }
.model-download-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* About content */
.about-content { padding: 8px 0; line-height: 1.7; }
.about-content h3 { font-size: 1rem; font-weight: 500; margin: 24px 0 8px; color: var(--text-primary); }
.about-content h3:first-child { margin-top: 0; }
.about-content p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; }
.about-content a { color: var(--accent-active); text-decoration: none; }
.about-content a:hover { text-decoration: underline; }
.links-list { list-style: none; padding: 0; }
.links-list li { margin-bottom: 8px; font-size: 0.85rem; }
.credits { font-size: 0.8rem; color: var(--text-dim); }
.legal-links { font-size: 0.75rem; text-align: center; margin-top: 32px; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 0.75rem;
  text-decoration: underline; text-underline-offset: 2px;
  font-family: inherit;
}
.link-btn:hover { color: var(--text-secondary); }
.version-text { font-size: 0.75rem; color: var(--text-dim); margin-top: 12px; text-align: center; }

/* Legal content */
.legal-content { padding: 8px 0 32px; line-height: 1.7; }
.legal-content h3 { font-size: 1rem; font-weight: 500; margin: 24px 0 8px; color: var(--text-primary); }
.legal-content h3:first-child { margin-top: 0; }
.legal-content p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; }
.legal-content a { color: var(--accent-active); text-decoration: none; }
.legal-content a:hover { text-decoration: underline; }
.legal-detail { font-size: 0.8rem; color: var(--text-dim); }
.license-item {
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.license-item strong { font-size: 0.9rem; color: var(--text-primary); }
.license-item p { font-size: 0.8rem; color: var(--text-dim); margin: 6px 0 0; }
.license-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-hover);
  color: var(--accent-active);
  margin-left: 8px;
  vertical-align: middle;
}

/* Focus-visible for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--accent-active);
  outline-offset: 2px;
}
.play-btn:focus-visible,
.voice-item-preview:focus-visible {
  outline-offset: 4px;
}
input[type="range"]:focus-visible {
  outline-offset: 4px;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
*::-webkit-scrollbar { width: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--accent-active); }

/* Utility */
.hidden { display: none !important; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive */
@media (max-height: 600px) {
  .home-content { gap: 20px; }
  .play-btn { width: 100px; height: 100px; }
}
