/* ================================================================
   Agile Quiz — 课堂小测在线系统
   设计方向: Anthropic 官方风格 — 克制、安静、专业的排版驱动设计
   ================================================================ */

/* ---- CSS Variables ---- */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e8e6e3;
  --border-hover: #d4d1cc;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-muted: #9c9690;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-bg: #fffbeb;
  --correct: #15803d;
  --correct-bg: #f0fdf4;
  --incorrect: #b91c1c;
  --incorrect-bg: #fef2f2;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max-width: 720px;
  --header-h: 56px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Typography ---- */
h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
p  { color: var(--text-secondary); line-height: 1.65; }

/* ---- Layout ---- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ---- Header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.site-header .logo {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-header .logo:hover { color: var(--accent); }
.site-header .back-link {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color .15s;
}
.site-header .back-link:hover { color: var(--text); }

/* ---- Main ---- */
.main-content { padding: 40px 0 80px; min-height: calc(100vh - var(--header-h)); }

/* ================================================================
   HOME PAGE
   ================================================================ */

.home-intro {
  margin-bottom: 36px;
}
.home-intro h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.home-intro p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.6;
}

/* Section grouping */
.home-section {
  margin-bottom: 32px;
}
.home-section-header {
  margin-bottom: 12px;
}
.home-section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.home-section-header span {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* Home footer */
.home-footer {
  margin-top: 40px;
  text-align: center;
}
.home-footer a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.home-footer a:hover {
  color: var(--text-secondary);
}

.subject-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--border);
}

.subject-card {
  background: var(--surface);
  padding: 20px 24px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background .12s;
  gap: 16px;
}
.subject-card:hover { background: #fafaf9; }
.subject-card:active { background: #f5f4f2; }

.subject-card .info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.subject-card .info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.subject-card .caret {
  color: var(--text-muted);
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform .15s;
}
.subject-card:hover .caret { transform: translateX(2px); color: var(--text-secondary); }

/* ================================================================
   QUIZ PAGE
   ================================================================ */

.quiz-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 680px) {
  .quiz-layout {
    grid-template-columns: 1fr 160px;
    gap: 28px;
  }
}

/* Sidebar dots */
.progress-sidebar { display: none; }
@media (min-width: 680px) {
  .progress-sidebar {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 28px);
    align-self: start;
  }
  .progress-sidebar .inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
  }
  .progress-sidebar .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
  }
  .question-dots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }
  .question-dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
  }
  .question-dot:hover { border-color: var(--border-hover); }
  .question-dot.answered { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
  .question-dot.current { background: var(--accent); color: #fff; border-color: var(--accent); }
}

/* Quiz card */
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.quiz-progress-bar {
  height: 3px;
  background: var(--border);
}
.quiz-progress-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width .35s ease;
}

.quiz-body { padding: 32px 28px 24px; }

/* Question meta */
.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.question-number {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.question-type-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Stem */
.question-stem {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.68;
  margin-bottom: 28px;
  color: var(--text);
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .12s;
  position: relative;
}
.option-item:hover { border-color: var(--border-hover); background: #fafaf9; }
.option-item.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all .12s;
  position: relative;
}
.option-item input[type="checkbox"] { border-radius: 3px; }
.option-item.selected input[type="radio"],
.option-item.selected input[type="checkbox"] {
  border-color: var(--accent);
  background: var(--accent);
}
.option-item.selected input[type="radio"]::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}
.option-item.selected input[type="checkbox"]::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.option-letter {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 20px;
  flex-shrink: 0;
}
.option-item.selected .option-letter { color: var(--accent); }

.option-text { font-size: 0.92rem; line-height: 1.5; color: var(--text); }

/* ---- Instant Feedback States ---- */

.option-item.locked {
  cursor: default;
}
.option-item.locked:hover {
  border-color: var(--border);
  background: transparent;
}

.option-item.correct-choice {
  border-color: var(--correct) !important;
  background: var(--correct-bg) !important;
}
.option-item.correct-choice .option-letter { color: var(--correct) !important; }
.option-item.correct-choice input { border-color: var(--correct) !important; background: var(--correct) !important; }

.option-item.incorrect-choice {
  border-color: var(--incorrect) !important;
  background: var(--incorrect-bg) !important;
}
.option-item.incorrect-choice .option-letter { color: var(--incorrect) !important; }
.option-item.incorrect-choice input { border-color: var(--incorrect) !important; background: var(--incorrect) !important; }

.option-item.reveal-correct {
  border-color: var(--correct) !important;
  background: var(--correct-bg) !important;
}
.option-item.reveal-correct .option-letter { color: var(--correct) !important; }

/* Feedback toast */
.feedback-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 18px;
}
.feedback-toast.correct {
  background: var(--correct-bg);
  color: var(--correct);
  border: 1px solid rgba(21,128,61,.15);
}
.feedback-toast.incorrect {
  background: var(--incorrect-bg);
  color: var(--incorrect);
  border: 1px solid rgba(185,28,28,.12);
}

/* Explanation block */
.explanation-block {
  margin-top: 14px;
  padding: 14px 16px;
  background: #fafaf9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.explanation-block .exp-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.explanation-block .source-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}
.explanation-block a.source-link {
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.explanation-block a.source-link:hover {
  border-bottom-color: var(--accent);
}
.explanation-block span.source-link {
  color: var(--text-muted);
  cursor: default;
}
.explanation-block .ai-notice {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
}

/* Quiz footer */
.quiz-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafaf9;
}
.quiz-footer .footer-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Mobile dots */
.mobile-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 16px 0 0;
}
@media (min-width: 680px) { .mobile-dots { display: none; } }
.mobile-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: all .12s;
}
.mobile-dot.answered { background: var(--accent); }
.mobile-dot.current { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
  line-height: 1.4;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
}
.btn:hover:not(:disabled) { border-color: var(--border-hover); background: #fafaf9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: var(--incorrect);
  color: #fff;
  border-color: var(--incorrect);
}
.btn-danger:hover:not(:disabled) { background: #991b1b; border-color: #991b1b; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background: #fafaf9; border-color: var(--border-hover); }

.btn-lg { padding: 12px 24px; font-size: 0.9rem; border-radius: var(--radius); }

/* ================================================================
   CONFIRM DIALOG
   ================================================================ */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .12s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dialog-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,.1);
}
.dialog-box h3 { margin-bottom: 6px; }
.dialog-box p { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 22px; line-height: 1.55; }
.dialog-box .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ================================================================
   RESULT PAGE
   ================================================================ */

.result-header {
  text-align: center;
  padding: 36px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.result-score {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.result-score.great { color: var(--correct); }
.result-score.good  { color: var(--accent); }
.result-score.ok    { color: #b45309; }
.result-score.poor  { color: var(--incorrect); }

.result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.result-stats b { font-weight: 600; color: var(--text); }

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* Review list */
.review-list { display: flex; flex-direction: column; gap: 10px; }

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.review-item.incorrect {
  border-left: 3px solid var(--incorrect);
  background: var(--incorrect-bg);
}
.review-item.correct {
  border-left: 3px solid var(--correct);
}

.review-item .review-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.review-item .review-number {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.review-item .review-status {
  font-weight: 600;
  font-size: 0.8rem;
}
.review-item.correct .review-status { color: var(--correct); }
.review-item.incorrect .review-status { color: var(--incorrect); }

.review-item .review-stem {
  font-weight: 500;
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 0.92rem;
}
.review-item .review-answers {
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--text-secondary);
}
.review-item .review-answers b { font-weight: 600; }
.review-item .your-answer { color: var(--incorrect); }
.review-item .correct-answer { color: var(--correct); }
.review-item.correct .your-answer { color: var(--correct); }

/* ================================================================
   EMPTY / LOADING
   ================================================================ */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 8px; font-size: 0.9rem; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 500px) {
  .container { padding: 0 16px; }
  .main-content { padding: 28px 0 64px; }
  .home-intro h1 { font-size: 1.3rem; }
  .quiz-body { padding: 22px 18px; }
  .quiz-footer { padding: 12px 18px; flex-wrap: wrap; gap: 8px; }
  .quiz-footer .btn { flex: 1; }
  .option-item { padding: 12px 14px; }
  .result-score { font-size: 2.8rem; }
  .result-stats { gap: 14px; }
}

/* ================================================================
   UTILITY
   ================================================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
