/* FCE Practice - Global Styles (Mobile First) */

:root {
  --primary: #1E40AF;
  --primary-light: #3B82F6;
  --p1-color: #2563EB;
  --p2-color: #7C3AED;
  --p3-color: #059669;
  --p4-color: #D97706;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --success-border: #86EFAC;
  --error: #DC2626;
  --error-bg: #FEE2E2;
  --error-border: #FCA5A5;
  --neutral-bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-dark: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --transition: 150ms ease;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--neutral-bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── App Header ── */
.app-header {
  background: var(--primary);
  color: white;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header .header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header .back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
  text-decoration: none;
}
.app-header .back-btn:hover { background: rgba(255,255,255,0.25); }

.app-header .header-text { flex: 1; min-width: 0; }
.app-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}
.app-header .subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-top: 1px;
}

.app-header .header-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Main Content ── */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Home Page ── */
.home-hero {
  text-align: center;
  padding: 24px 0 8px;
}
.home-hero .hero-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 12px;
}
.home-hero h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.home-hero p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 24px 0 10px;
}

.part-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* ── Part Card ── */
.part-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: block;
  position: relative;
  overflow: hidden;
}
.part-card:active { transform: scale(0.97); }
.part-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
}

.part-card .card-icon {
  font-size: 1.75rem;
  margin-bottom: 10px;
  display: block;
}
.part-card .card-name {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--card-color, var(--primary));
  margin-bottom: 2px;
}
.part-card .card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 10px;
}
.part-card .card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.card-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-progress .progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--card-color, var(--primary));
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Practice Page ── */
.practice-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.ctrl-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background var(--transition), border-color var(--transition);
}
.ctrl-btn:hover {
  background: var(--neutral-bg);
  border-color: var(--border-dark);
}
.ctrl-btn.active {
  background: #EFF6FF;
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Exercise Card ── */
.exercise-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.exercise-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.exercise-header .ex-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--part-color, var(--primary));
  margin-bottom: 2px;
}
.exercise-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}
.exercise-body { padding: 16px; }

/* ── Submit & Navigation Buttons ── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--part-color, var(--primary));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 16px;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: var(--part-color, var(--primary));
  border: 2px solid var(--part-color, var(--primary));
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition);
  margin-top: 10px;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--neutral-bg); }

/* ── Score / Feedback Summary ── */
.score-banner {
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 8px;
}
.score-banner.great { background: var(--success-bg); color: var(--success); }
.score-banner.ok { background: #FEF9C3; color: #854D0E; }
.score-banner.poor { background: var(--error-bg); color: var(--error); }
.score-banner .score-emoji { font-size: 2rem; display: block; margin-bottom: 4px; }
.score-banner .score-text { font-size: 1.25rem; font-weight: 800; }
.score-banner .score-sub { font-size: 0.875rem; margin-top: 2px; opacity: 0.85; }

/* ── Explanation Box ── */
.explanation-box {
  background: #F0F9FF;
  border-left: 3px solid #38BDF8;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 10px;
  font-size: 0.8125rem;
  color: #0C4A6E;
  line-height: 1.45;
  margin-top: 8px;
}

/* ── Navigation Row ── */
.nav-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.nav-row .btn-primary, .nav-row .btn-secondary {
  margin-top: 0;
  flex: 1;
}

/* ── Empty States ── */
.all-done {
  text-align: center;
  padding: 48px 16px;
}
.all-done .done-icon { font-size: 3.5rem; margin-bottom: 12px; }
.all-done h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.all-done p { color: var(--text-muted); margin-bottom: 20px; }

/* ── Utility ── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ── All-done / completion screen ── */
.all-done-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 20px;
  text-align: center;
  gap: 14px;
}
.all-done-trophy {
  font-size: 3.5rem;
  line-height: 1;
}
.all-done-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}
.all-done-stats-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 4px;
}
.all-done-stat {
  background: var(--neutral-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
}
.stat-val {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text);
}
.stat-lbl {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.all-done-perfect {
  font-size: 0.9375rem;
  color: var(--success);
  font-weight: 600;
  padding: 10px 16px;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--success-border);
  width: 100%;
}
.all-done-btn {
  width: 100%;
  max-width: 340px;
  justify-content: center;
}
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition);
}
.btn-ghost:hover { color: var(--text); }

/* ── Single-question progress (Part 3 & 4) ── */
.sq-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.sq-counter {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.sq-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.sq-progress-fill {
  height: 100%;
  background: var(--part-color, var(--primary));
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* ── Desktop Enhancement ── */
@media (min-width: 640px) {
  .main-content { padding: 24px 16px; }
  .part-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .home-hero { padding: 32px 0 12px; }
  .home-hero h2 { font-size: 1.875rem; }
  .exercise-header { padding: 20px 20px 16px; }
  .exercise-body { padding: 20px; }
  .app-header h1 { font-size: 1.25rem; }
}

@media (min-width: 768px) {
  .part-grid { grid-template-columns: repeat(4, 1fr); }
}
