/* File: /english-study/style.css */
/* ============================================================
   CSS CUSTOM PROPERTIES — THEME SYSTEM
   ============================================================ */
:root {
  --bg-primary: #FAFAF8;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-accent: #F0EFEB;
  --bg-correct: #E8F5E9;
  --bg-wrong: #FFEBEE;
  --bg-highlight: #FFF8E1;
  --text-primary: #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-muted: #9A9A9A;
  --text-correct: #2E7D32;
  --text-wrong: #C62828;
  --border: #E8E8E4;
  --border-focus: #1A1A1A;
  --accent: #1A1A1A;
  --accent-soft: #E8E8E4;
  --accent-hover: #333333;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --correct-border: #66BB6A;
  --wrong-border: #EF5350;
  --progress-fill: #1A1A1A;
  --tag-bg: #F5F5F0;
  --tag-text: #5A5A5A;
  --streak-bg: linear-gradient(135deg, #FFF8E1, #FFF3CD);
  --streak-border: #FFD54F;
  --input-bg: #FFFFFF;
}

[data-theme="dark"] {
  --bg-primary: #0F0F0F;
  --bg-secondary: #1A1A1A;
  --bg-card: #1E1E1E;
  --bg-accent: #2A2A2A;
  --bg-correct: #1B3A1E;
  --bg-wrong: #3A1B1B;
  --bg-highlight: #3A3520;
  --text-primary: #EAEAEA;
  --text-secondary: #AAAAAA;
  --text-muted: #666666;
  --text-correct: #81C784;
  --text-wrong: #EF9A9A;
  --border: #2E2E2E;
  --border-focus: #EAEAEA;
  --accent: #EAEAEA;
  --accent-soft: #2E2E2E;
  --accent-hover: #CCCCCC;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --correct-border: #388E3C;
  --wrong-border: #D32F2F;
  --progress-fill: #EAEAEA;
  --tag-bg: #2A2A2A;
  --tag-text: #AAAAAA;
  --streak-bg: linear-gradient(135deg, #3A3520, #332E1A);
  --streak-border: #FFD54F;
  --input-bg: #252525;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::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-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-container {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px 100px;
  position: relative;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 100;
  transition: background var(--transition);
}

.app-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   ICON BUTTONS (THEME / RESET)
   ============================================================ */
.theme-toggle,
.reset-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
}

.theme-toggle:hover { border-color: var(--border-focus); }

.reset-btn {
  color: var(--text-secondary);
  font-size: 1rem;
}
.reset-btn:hover {
  border-color: var(--wrong-border);
  color: var(--text-wrong);
}

/* ============================================================
   PROGRESS OVERVIEW
   ============================================================ */
.progress-overview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.progress-bar-container {
  height: 6px;
  background: var(--bg-accent);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.stat-item { text-align: center; flex: 1; }

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-value.correct { color: var(--text-correct); }
.stat-value.wrong { color: var(--text-wrong); }

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================================
   STREAK INDICATOR
   ============================================================ */
.streak-bar {
  background: var(--streak-bg);
  border: 1px solid var(--streak-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-8px);
  transition: all var(--transition);
  pointer-events: none;
}
.streak-bar.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.streak-fire { font-size: 1.1rem; }

/* ============================================================
   CATEGORY CARDS — HOME SCREEN
   ============================================================ */
.screen { display: none; }
.screen.active { display: block; }

.category-grid { display: grid; gap: 12px; }

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.category-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.category-card:active { transform: translateY(0); }

.category-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.category-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}
.category-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cat-bar {
  flex: 1; height: 4px;
  background: var(--bg-accent);
  border-radius: 2px;
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  background: var(--text-correct);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.cat-pct {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

.start-all-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.start-all-btn:hover { background: var(--accent-hover); }

/* ============================================================
   QUIZ HEADER
   ============================================================ */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.back-btn:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.quiz-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================
   QUESTION CARD
   ============================================================ */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
  animation: fadeIn 0.3s ease;
}

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

.question-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.question-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

.question-instruction {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
  font-style: italic;
}

/* ============================================================
   ANSWER OPTIONS
   ============================================================ */
.options-list { display: grid; gap: 10px; }

.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.option-btn:hover:not(.disabled) { border-color: var(--border-focus); }
.option-btn.selected {
  border-color: var(--accent);
  background: var(--bg-accent);
}
.option-btn.correct {
  border-color: var(--correct-border);
  background: var(--bg-correct);
  color: var(--text-correct);
}
.option-btn.wrong {
  border-color: var(--wrong-border);
  background: var(--bg-wrong);
  color: var(--text-wrong);
}
.option-btn.disabled { pointer-events: none; }
.option-btn.show-correct {
  border-color: var(--correct-border);
  background: var(--bg-correct);
  color: var(--text-correct);
}

/* ============================================================
   EXPLANATION BOX
   ============================================================ */
.explanation {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-highlight);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--streak-border);
  animation: fadeIn 0.3s ease;
}
.explanation-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.explanation-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-primary);
}
.explanation-text strong { font-weight: 600; }

/* ============================================================
   NEXT BUTTON
   ============================================================ */
.next-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.next-btn:hover { background: var(--accent-hover); }

/* ============================================================
   RESULTS SCREEN
   ============================================================ */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.results-emoji { font-size: 3rem; margin-bottom: 12px; }
.results-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 8px;
}
.results-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  line-height: 1.5;
}
.results-score {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.results-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 24px;
}
.results-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.breakdown-item {
  background: var(--bg-accent);
  padding: 14px;
  border-radius: var(--radius-md);
}
.breakdown-value {
  font-size: 1.3rem;
  font-weight: 700;
}
.breakdown-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 2px;
}
.results-actions { display: grid; gap: 10px; }
.results-actions button {
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.retry-weak-btn {
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
}
.go-home-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 8px;
}
.modal-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-cancel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.modal-confirm {
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--text-wrong);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 600px) {
  .app-container { padding: 0 24px 100px; }
  .question-card { padding: 32px 28px; }
}
