/* ============================================================
   Persuade — Voice Coaching App
   Glassmorphism + Gradient + Microphone-centric UI
   ============================================================ */

/* --- Tokens --- */
:root {
  --bg-gradient: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 40%, #0a1628 100%);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.07);
  --surface: rgba(15, 15, 35, 0.6);
  --primary: #7c6aff;
  --primary-glow: rgba(124, 106, 255, 0.3);
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.2);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --text: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
}

/* Animated background orbs */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 600px; height: 600px;
  background: var(--primary);
  top: -200px; right: -200px;
  animation: float-orb 20s ease-in-out infinite;
}
body::after {
  width: 500px; height: 500px;
  background: var(--accent);
  bottom: -150px; left: -150px;
  animation: float-orb 25s ease-in-out infinite reverse;
}

@keyframes float-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Layout --- */
#app {
  max-width: 520px;
  width: 100%;
  padding: 2rem 1.25rem 4rem;
  position: relative;
  z-index: 1;
}

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

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.375rem;
  font-weight: 400;
}

/* --- Glass Card --- */
.card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  transition: transform var(--transition), opacity var(--transition);
  animation: card-in 0.5s ease-out both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- Persona Selector --- */
.persona-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.persona-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 1rem 0.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-family: var(--font);
}

.persona-btn:hover {
  background: var(--glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text);
}

.persona-btn.selected {
  background: rgba(124, 106, 255, 0.12);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 20px rgba(124, 106, 255, 0.15);
}

.persona-emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.persona-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.persona-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.persona-btn.selected .persona-desc {
  color: var(--text-secondary);
}

/* --- Prompt Card --- */
#prompt-card {
  position: relative;
  overflow: hidden;
}

#prompt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius) var(--radius) 0 0;
}

.prompt {
  white-space: pre-line;
  line-height: 1.75;
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 400;
}

/* --- Recorder Card --- */
.recorder-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Mic button */
.mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #5b4cd4);
  box-shadow: 0 0 0 0 var(--primary-glow);
  transition: all var(--transition);
  color: #fff;
}

.mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--primary-glow);
}

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

.mic-btn.recording {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4);
  animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  70% { box-shadow: 0 0 0 20px rgba(248, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

.mic-btn svg {
  width: 32px;
  height: 32px;
  transition: transform var(--transition);
}

.mic-btn.recording svg {
  animation: mic-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes mic-bounce {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

/* Waveform visualization */
.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  opacity: 0;
  transition: opacity var(--transition);
}

.waveform.active {
  opacity: 1;
}

.waveform-bar {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave 0.8s ease-in-out infinite alternate;
}

.waveform-bar:nth-child(1) { animation-delay: 0s; }
.waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.waveform-bar:nth-child(4) { animation-delay: 0.3s; }
.waveform-bar:nth-child(5) { animation-delay: 0.4s; }
.waveform-bar:nth-child(6) { animation-delay: 0.3s; }
.waveform-bar:nth-child(7) { animation-delay: 0.2s; }
.waveform-bar:nth-child(8) { animation-delay: 0.1s; }
.waveform-bar:nth-child(9) { animation-delay: 0s; }

@keyframes wave {
  from { height: 6px; opacity: 0.4; }
  to { height: 32px; opacity: 1; }
}

.recorder-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2em;
}

.timer {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Playback */
.playback-row {
  width: 100%;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.playback-row audio {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-xs);
}

/* Action buttons */
.action-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.btn {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  flex: 1;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #5b4cd4);
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px var(--primary-glow);
}

.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--glass-hover);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Loading --- */
#loading {
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.25rem;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
}

.loading-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.loading-step {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Result --- */
#result .card {
  animation-delay: 0.1s;
}

.result-section {
  margin-bottom: 1.5rem;
}

.result-section:last-of-type {
  margin-bottom: 0;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Overall score — big ring */
.score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
}

.score-ring-circle {
  width: 120px;
  height: 120px;
  position: relative;
}

.score-ring-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 6;
}

.score-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-out, stroke 0.5s;
}

.score-ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.score-ring-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Detail scores */
.scores-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.score-item {
  display: grid;
  grid-template-columns: 90px 1fr 28px;
  align-items: center;
  gap: 0.75rem;
}

.score-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.score-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease-out;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.score-value {
  font-size: 0.8rem;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Transcript */
.transcript {
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  font-style: italic;
}

/* Feedback lists */
.feedback-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.feedback-list li {
  padding: 0.625rem 0.875rem 0.625rem 2rem;
  position: relative;
  line-height: 1.6;
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-xs);
}

.feedback-list li::before {
  content: '';
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.strengths li::before { background: var(--success); box-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
.gaps li::before { background: var(--warning); box-shadow: 0 0 8px rgba(251, 191, 36, 0.3); }

/* Rewrite */
.rewrite {
  background: rgba(52, 211, 153, 0.06);
  border-left: 2px solid var(--success);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  line-height: 1.7;
  font-size: 0.9rem;
}

/* Diagnosis summary (v2) */
.diagnosis-card {
  position: relative;
  overflow: hidden;
}

.diagnosis-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.diagnosis-summary {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  font-weight: 500;
  text-align: center;
  padding: 0.5rem 0;
}

/* Priority fix (v2) */
.priority-fix-card {
  border-color: rgba(251, 191, 36, 0.2) !important;
}

.priority-fix {
  background: rgba(251, 191, 36, 0.06);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--warning);
  line-height: 1.7;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Listener reaction (v2) */
.listener-reaction {
  background: rgba(124, 106, 255, 0.06);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--primary);
  line-height: 1.7;
  font-size: 0.9rem;
  font-style: italic;
}

/* Opening / Closing (v2) */
.opening-closing {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.oc-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.oc-quote {
  background: rgba(52, 211, 153, 0.06);
  border-left: 2px solid var(--success);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  line-height: 1.7;
  font-size: 0.9rem;
}

/* Immediate drill (v2) */
.drill-card {
  border-color: rgba(0, 212, 255, 0.2) !important;
}

.immediate-drill {
  background: rgba(0, 212, 255, 0.06);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--accent);
  line-height: 1.7;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Quality issues */
.quality-card {
  border-color: rgba(251, 191, 36, 0.25) !important;
  background: rgba(251, 191, 36, 0.04) !important;
}

.quality-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.quality-issues-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quality-issues-list li {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  line-height: 1.5;
}

.quality-warning {
  background: rgba(251, 191, 36, 0.08);
  border-left: 2px solid var(--warning);
  color: var(--warning);
}

.quality-error {
  background: rgba(248, 113, 113, 0.08);
  border-left: 2px solid var(--danger);
  color: var(--danger);
}

/* Next question */
.next-question {
  background: rgba(0, 212, 255, 0.06);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--accent);
  line-height: 1.7;
  font-size: 0.9rem;
}

/* Result actions */
.result-actions {
  margin-top: 1.75rem;
  display: flex;
  gap: 0.75rem;
}

/* --- Error --- */
.error-card {
  border-color: rgba(248, 113, 113, 0.3) !important;
}

.error-card h2 {
  color: var(--danger) !important;
}

.error-card p {
  margin-bottom: 1rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

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

/* --- Responsive --- */
@media (max-width: 480px) {
  #app { padding: 1.5rem 1rem 3rem; }
  .card { padding: 1.25rem; border-radius: 16px; }
  .logo { font-size: 1.75rem; }
  .mic-btn { width: 76px; height: 76px; }
  .mic-btn svg { width: 28px; height: 28px; }
  .timer { font-size: 2rem; }
  .score-ring-circle { width: 100px; height: 100px; }
  .score-ring-value { font-size: 1.75rem; }
}
