/* Historical Friction - Modern Stylesheet */

:root {
  --bg: #0d0d0d;
  --bg-panel: #1a1a1a;
  --bg-card: #222;
  --bg-card-hover: #2a2a2a;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --text-dim: #555;
  --accent: #c9a84c;
  --accent-dim: rgba(201, 168, 76, 0.2);
  --need-image: #5c2a2a;
  --active-glow: rgba(201, 168, 76, 0.4);
  --danger: #b04040;
  --success: #408050;
  --font-body: 'Georgia', 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Layout ─────────────────────────────────────────── */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  padding: 2rem 0 1rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: normal;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

header .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

header .tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 1rem;
  line-height: 1.7;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Status bar ─────────────────────────────────────── */

#status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
}

#status-bar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

#status-bar .dot.active {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

#status-bar .dot.error {
  background: var(--danger);
}

#status-bar .dot.loading {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ── Moonshine / Voice status ───────────────────────── */

#voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

#voice-status.listening {
  color: var(--accent);
}

#voice-status .mic-icon {
  font-size: 1rem;
}

#moonshine-loading {
  text-align: center;
  padding: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

#moonshine-loading progress {
  width: 200px;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  display: block;
  margin: 0.3rem auto 0;
}

#moonshine-loading progress::-webkit-progress-bar {
  background: var(--bg-panel);
  border-radius: 2px;
}

#moonshine-loading progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 2px;
}

/* ── Mode switcher ──────────────────────────────────── */

#mode-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

#mode-switcher button {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.6rem 0.25rem;
  background: var(--bg-panel);
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#mode-switcher button:last-child {
  border-right: none;
}

#mode-switcher button:hover {
  background: var(--bg-card);
  color: var(--text);
}

#mode-switcher button.active {
  background: var(--accent-dim);
  color: var(--accent);
}

#mode-switcher button .mode-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

#mode-switcher button .mode-desc {
  display: block;
  font-size: 0.65rem;
  opacity: 0.6;
}

/* ── Controls row ───────────────────────────────────── */

#controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}

#controls label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#controls input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

#controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

#play-pause {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#play-pause:hover {
  background: var(--accent);
  color: var(--bg);
}

#mic-toggle {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#mic-toggle:hover {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

#mic-toggle.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Article list ───────────────────────────────────── */

#results {
  list-style: none;
}

#results li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  transition: background 0.3s, border-color 0.3s, opacity 0.3s;
  display: none; /* revealed via JS */
  cursor: pointer;
}

#results li:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-dim);
}

#results li.sounding {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--active-glow);
}

#results li.need-image {
  border-left: 3px solid var(--danger);
}

#results li .article-title {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

#results li .article-title:hover {
  color: var(--accent);
}

#results li .article-meta {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

#results li .article-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Transcript display ─────────────────────────────── */

#transcript {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 1.2em;
  padding: 0.3rem;
  margin-bottom: 0.5rem;
  transition: color 0.3s;
}

#transcript.active {
  color: var(--accent);
}

/* ── Footer ─────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.8;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  #mode-switcher button .mode-desc {
    display: none;
  }

  #mode-switcher button {
    padding: 0.5rem 0.2rem;
    font-size: 0.75rem;
  }

  #controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ── Utility ────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
