/* ============================================
   Mena — Real-Time Speech to Text
   Style Sheet
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-elevated: #1a1a26;
  --bg-surface: #22222e;
  --text-primary: #e8e6e3;
  --text-secondary: #8a8a9a;
  --text-muted: #55556a;
  --accent: #c9a84c;
  --accent-glow: #d4af37;
  --accent-dim: rgba(201, 168, 76, 0.15);
  --danger: #e05555;
  --danger-dim: rgba(224, 85, 85, 0.15);
  --border: rgba(255, 255, 255, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* --- App Layout --- */
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1;
}

.tagline {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-top: 0.5rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* --- Unsupported --- */
.unsupported {
  max-width: 420px;
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 3rem;
}

.unsupported-icon {
  color: var(--danger);
  margin-bottom: 1.25rem;
}

.unsupported h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.unsupported p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.unsupported strong {
  color: var(--text-primary);
}

/* --- Main Content --- */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 720px;
  flex: 1;
}

/* --- Visualizer --- */
.visualizer-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visualizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity var(--transition);
}

.visualizer.active {
  opacity: 1;
}

.orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, var(--bg-surface), var(--bg-secondary));
  border: 1px solid var(--border);
  transition: all var(--transition);
  position: relative;
  z-index: 1;
}

.orb.listening {
  background: radial-gradient(circle at 40% 40%, #2a2535, #1a1525);
  border-color: rgba(201, 168, 76, 0.3);
  box-shadow:
    0 0 30px rgba(201, 168, 76, 0.1),
    0 0 60px rgba(201, 168, 76, 0.05);
  animation: orbPulse 2s ease-in-out infinite;
}

@keyframes orbPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 30px rgba(201, 168, 76, 0.1),
      0 0 60px rgba(201, 168, 76, 0.05);
  }
  50% {
    transform: scale(1.06);
    box-shadow:
      0 0 40px rgba(201, 168, 76, 0.2),
      0 0 80px rgba(201, 168, 76, 0.1);
  }
}

/* --- Mic Button --- */
.mic-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.mic-btn:hover {
  border-color: rgba(201, 168, 76, 0.4);
  background: var(--bg-surface);
  transform: scale(1.05);
}

.mic-btn:active {
  transform: scale(0.97);
}

.mic-btn.recording {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.08);
  box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.1);
  animation: micPulse 2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(201, 168, 76, 0.05);
  }
}

.mic-btn.recording .mic-icon {
  color: var(--accent);
}

.mic-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.06em;
  transition: color var(--transition);
}

/* --- Stats --- */
.stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  margin-bottom: 1.5rem;
  transition: opacity var(--transition), transform var(--transition);
}

.stats.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
}

.stats:not(.hidden) {
  animation: fadeSlideIn 0.4s ease forwards;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* --- Transcript --- */
.transcript-container {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  padding: 1.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  scroll-behavior: smooth;
  transition: opacity var(--transition), transform var(--transition);
}

.transcript-container.hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  max-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.transcript-container:not(.hidden) {
  animation: fadeSlideIn 0.5s ease forwards;
}

/* Scrollbar */
.transcript-container::-webkit-scrollbar {
  width: 4px;
}

.transcript-container::-webkit-scrollbar-track {
  background: transparent;
}

.transcript-container::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: 4px;
}

.transcript {
  font-size: 1.1rem;
  line-height: 1.85;
  color: var(--text-primary);
  font-weight: 300;
  word-spacing: 0.02em;
}

.transcript .word {
  display: inline;
  opacity: 0;
  animation: wordFadeIn 0.35s ease forwards;
}

.transcript .interim {
  color: var(--text-muted);
  font-style: italic;
}

/* Filler word glow */
.transcript .filler {
  color: var(--accent-glow);
  font-weight: 500;
  position: relative;
  animation: wordFadeIn 0.35s ease forwards, fillerGlow 2.5s ease-in-out infinite;
  text-shadow:
    0 0 6px rgba(212, 175, 55, 0.4),
    0 0 14px rgba(212, 175, 55, 0.2);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 1px;
}

@keyframes fillerGlow {
  0%, 100% {
    text-shadow:
      0 0 6px rgba(212, 175, 55, 0.4),
      0 0 14px rgba(212, 175, 55, 0.2);
  }
  50% {
    text-shadow:
      0 0 10px rgba(212, 175, 55, 0.6),
      0 0 24px rgba(212, 175, 55, 0.35),
      0 0 40px rgba(212, 175, 55, 0.15);
  }
}

@keyframes wordFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Action Buttons --- */
.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2rem;
  transition: opacity var(--transition), transform var(--transition);
}

.actions.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
}

.actions:not(.hidden) {
  animation: fadeSlideIn 0.4s ease forwards;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

.action-btn--danger:hover {
  color: var(--danger);
  border-color: rgba(224, 85, 85, 0.25);
  background: var(--danger-dim);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.65rem 1.4rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Footer --- */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
}

.footer p {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

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

/*
 * Transition-based hiding for elements that animate in/out.
 * These override the generic .hidden to use opacity + position
 * instead of display:none so transitions work smoothly.
 */
.stats.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.actions.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.transcript-container.hidden {
  display: block !important;
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  visibility: hidden;
}

/* Toast uses its own show/hide via .show class */
.toast.hidden {
  display: block !important;
  visibility: hidden;
}

/* --- Animations --- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .app {
    padding: 1.5rem 1rem;
  }

  .logo {
    font-size: 2.2rem;
  }

  .visualizer-container {
    width: 120px;
    height: 120px;
  }

  .orb {
    width: 60px;
    height: 60px;
  }

  .mic-btn {
    width: 64px;
    height: 64px;
  }

  .transcript-container {
    padding: 1.25rem;
    max-height: 45vh;
  }

  .transcript {
    font-size: 1rem;
    line-height: 1.75;
  }

  .stats {
    gap: 1rem;
    padding: 0.6rem 1.2rem;
  }

  .action-btn {
    padding: 0.55rem 0.9rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 380px) {
  .logo {
    font-size: 1.9rem;
  }

  .tagline {
    font-size: 0.75rem;
  }

  .actions {
    gap: 0.4rem;
  }
}

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