/* style.css — Korean Level Test */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #1a56db;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --accent: #0ea5e9;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f0f4ff;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f4ff 40%, #e0f2fe 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--accent));
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(26,86,219,0.3);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.header-logo svg {
  width: 32px;
  height: 32px;
}

.lang-selector {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 4px;
}

.lang-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.lang-btn.active, .lang-btn:hover {
  background: rgba(255,255,255,0.25);
  color: white;
}

/* ===== Progress Bar ===== */
.progress-container {
  background: rgba(255,255,255,0.2);
  height: 6px;
  position: relative;
  display: none;
}

.progress-container.visible {
  display: block;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #10b981);
  transition: width 0.5s ease;
  border-radius: 0 3px 3px 0;
}

.progress-text {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  font-weight: 600;
}

/* ===== Main Container ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.4s ease; }

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

/* ===== Landing / Hero ===== */
.hero {
  text-align: center;
  padding: 48px 16px 32px;
}

.hero-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(26,86,219,0.3);
}

.hero-icon svg {
  width: 56px;
  height: 56px;
  fill: white;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero .subtitle {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.hero .desc {
  font-size: 14px;
  color: var(--text-light);
  max-width: 480px;
  margin: 0 auto 32px;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 16px 48px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(26,86,219,0.35);
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(26,86,219,0.45);
}

.start-btn svg { width: 20px; height: 20px; }

/* ===== Section Selection ===== */
.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.section-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

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

.section-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.section-card:hover::before { opacity: 1; }

.section-card.completed {
  border-color: var(--success);
}

.section-card.completed::before {
  background: var(--success);
  opacity: 1;
}

.section-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-icon svg { width: 28px; height: 28px; fill: white; }

.section-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.section-card p {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.section-card .level-badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: #f0fdf4;
  color: var(--success);
  font-weight: 600;
}

.section-card .start-label {
  display: inline-block;
  font-size: 13px;
  padding: 6px 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 500;
}

/* ===== Question Card ===== */
.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
}

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

.question-type-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-reading { background: #eff6ff; color: #2563eb; }
.type-listening { background: #f0fdf4; color: #16a34a; }
.type-speaking { background: #fef3c7; color: #d97706; }
.type-writing { background: #fdf2f8; color: #db2777; }

.question-text {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 16px;
  line-height: 1.7;
  white-space: pre-line;
}

.passage-box {
  background: #f8fafc;
  border-left: 4px solid var(--primary-light);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 20px;
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-line;
}

/* ===== Visual (그림) ===== */
.visual-box {
  text-align: center;
  margin-bottom: 20px;
}
.visual-image {
  font-size: 80px;
  line-height: 1.2;
  margin-bottom: 12px;
  padding: 20px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: var(--radius-md);
  border: 2px solid #bae6fd;
}
.visual-scene {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}
.type-visual { background: #06b6d4; }

/* Level banner */
.level-banner {
  text-align: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  border: 1px solid #bfdbfe;
  animation: bannerSlide 0.4s ease;
}
.level-banner.start {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border-color: #fbbf24;
  font-weight: 600;
}
@keyframes bannerSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Level change indicator */
.level-change {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  animation: levelPop 0.5s ease;
}
.level-change.up {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #166534;
}
.level-change.down {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
}
.level-change.same {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  color: #1e40af;
}
@keyframes levelPop {
  0% { opacity: 0; transform: scale(0.8); }
  60% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* Mic pulse animation */
.mic-pulse {
  display: inline-block;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  animation: micPulse 0.8s ease-in-out infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes micPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
}

/* ===== Choices ===== */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
  line-height: 1.5;
}

.choice-btn:hover {
  border-color: var(--primary-light);
  background: #eff6ff;
}

.choice-btn.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.choice-btn.correct {
  border-color: var(--success);
  background: #f0fdf4;
  animation: correctPulse 0.5s ease;
}

.choice-btn.incorrect {
  border-color: var(--danger);
  background: #fef2f2;
  animation: shake 0.4s ease;
}

.choice-btn .choice-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  flex-shrink: 0;
  transition: var(--transition);
}

.choice-btn.selected .choice-marker {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.choice-btn.correct .choice-marker {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.choice-btn.incorrect .choice-marker {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ===== Feedback ===== */
.feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  display: none;
  align-items: center;
  gap: 8px;
}

.feedback.visible { display: flex; }
.feedback.correct { background: #f0fdf4; color: var(--success); }
.feedback.incorrect { background: #fef2f2; color: var(--danger); }

.feedback svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ===== Audio / Speaking / Writing Controls ===== */
.audio-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.audio-btn, .record-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 50px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.audio-btn {
  background: linear-gradient(135deg, #16a34a, #059669);
  color: white;
  box-shadow: 0 3px 12px rgba(16,163,97,0.3);
}

.audio-btn:hover { transform: translateY(-1px); }
.audio-btn svg { width: 18px; height: 18px; }

.record-btn {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: white;
  box-shadow: 0 3px 12px rgba(239,68,68,0.3);
}

.record-btn.recording {
  animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

.record-btn svg { width: 18px; height: 18px; }

/* Speaking prompt */
.speak-prompt {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fbbf24;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.speak-prompt .prompt-text {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
}

/* Writing area */
.write-area {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.7;
  resize: vertical;
  transition: var(--transition);
}

.write-area:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.hint-box {
  margin-top: 8px;
  padding: 10px 14px;
  background: #fffbeb;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #92400e;
}

.hint-box strong {
  font-weight: 600;
}

/* ===== Action Buttons ===== */
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 28px;
  border-radius: 50px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 3px 12px rgba(26,86,219,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(26,86,219,0.4);
}

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

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

.btn-ghost:hover {
  background: #f8fafc;
}

/* ===== Result Screen ===== */
.result-header {
  text-align: center;
  padding: 24px 0 32px;
}

.result-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.result-level-big {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  padding: 16px 32px;
  border-radius: var(--radius);
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(26,86,219,0.3);
  margin: 16px 0;
}

/* Radar Chart */
.chart-container {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.chart-container canvas {
  max-width: 320px;
  max-height: 320px;
  margin: 0 auto;
  display: block;
}

/* Result Details */
.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.result-detail-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}

.result-detail-card .label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
  font-weight: 500;
}

.result-detail-card .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* Section result bars */
.section-results-list {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.section-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.section-result-item:last-child { border-bottom: none; }

.section-result-item .sr-label {
  width: 60px;
  font-weight: 600;
  font-size: 14px;
}

.section-result-item .sr-bar-bg {
  flex: 1;
  height: 12px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.section-result-item .sr-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 1s ease;
}

.sr-bar.level-0 { background: #94a3b8; width: 20%; }
.sr-bar.level-1 { background: #60a5fa; width: 40%; }
.sr-bar.level-2 { background: #34d399; width: 60%; }
.sr-bar.level-3 { background: #fbbf24; width: 80%; }
.sr-bar.level-4 { background: #f97316; width: 100%; }

.section-result-item .sr-level {
  width: 80px;
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
}

/* Result actions */
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  box-shadow: 0 3px 12px rgba(16,163,97,0.3);
}

.btn-success:hover { transform: translateY(-1px); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

/* ===== Speech result ===== */
.speech-result {
  margin-top: 16px;
  padding: 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.speech-result .recognized {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.speech-result .score-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.speech-result .score-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.speech-result .score-text {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header { padding: 12px 16px; }
  .header-logo { font-size: 16px; }
  .lang-btn { padding: 5px 7px; font-size: 11px; }
  .container { padding: 16px 12px 48px; }
  .hero h1 { font-size: 24px; }
  .hero-icon { width: 80px; height: 80px; }
  .hero-icon svg { width: 44px; height: 44px; }
  .section-grid { grid-template-columns: 1fr; }
  .question-card { padding: 20px 16px; }
  .question-text { font-size: 15px; }
  .passage-box { padding: 12px 14px; font-size: 14px; }
  .choice-btn { padding: 12px 14px; font-size: 14px; }
  .result-details { grid-template-columns: 1fr; }
  .result-level-big { font-size: 22px; padding: 12px 24px; }
  .speak-prompt .prompt-text { font-size: 20px; }
  .action-row { flex-direction: column; }
  .action-row .btn { width: 100%; justify-content: center; }
}

/* ===== Loading spinner ===== */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

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

/* Section complete overlay within card */
.section-done {
  text-align: center;
  padding: 32px 16px;
}

.section-done .check-icon {
  width: 64px;
  height: 64px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.section-done .check-icon svg { width: 32px; height: 32px; fill: white; }
.section-done h3 { font-size: 20px; margin-bottom: 8px; }
.section-done p { color: var(--text-light); font-size: 14px; }
