/* ========================================
   福建高校教师岗前培训 · 全局样式
   Tufte-inspired typography + Component styles
   ======================================== */

:root {
  /* Colors */
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1d4ed8;
  --color-correct: #16a34a;
  --color-correct-bg: #f0fdf4;
  --color-incorrect: #dc2626;
  --color-incorrect-bg: #fef2f2;
  --color-warning: #f59e0b;

  /* Light mode */
  --bg: #fefefe;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
  --font-size-base: 1.125rem;
  --line-height: 1.75;
  --max-width: 52rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --color-correct-bg: #052e16;
    --color-incorrect-bg: #2d0a0a;
  }
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1.5rem;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---- Typography ---- */
h1, h2, h3, h4 { line-height: 1.3; color: var(--text); margin-top: 2.5rem; }
h1 { font-size: 2rem; font-weight: 700; margin-top: 0; }
h2 { font-size: 1.5rem; font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 1rem 0; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg-secondary); padding: 0.15em 0.4em; border-radius: 3px; }
strong { font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ---- Chapter Navigation ---- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin: 2rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 0.95rem;
  transition: background 0.2s;
}
.chapter-nav a:hover { background: var(--border); text-decoration: none; }

/* ---- Progress Bar ---- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress-bar .fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---- Quiz Container ---- */
.quiz-container {
  margin: 2rem 0;
}
.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.quiz-question .q-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.quiz-question .q-number {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 0.9rem;
  white-space: nowrap;
}
.quiz-question .q-type {
  font-size: 0.75rem;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.quiz-question .q-text {
  font-weight: 500;
  margin-bottom: 1rem;
}

/* Options */
.quiz-options { list-style: none; padding: 0; margin: 0; }
.quiz-options li {
  padding: 0.75rem 1rem;
  margin: 0.4rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.quiz-options li:hover { background: var(--bg-secondary); }
.quiz-options li.selected { border-color: var(--color-primary); background: rgba(37,99,235,0.05); }
.quiz-options li.correct { border-color: var(--color-correct); background: var(--color-correct-bg); }
.quiz-options li.incorrect { border-color: var(--color-incorrect); background: var(--color-incorrect-bg); }
.quiz-options li .opt-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 1.5em;
}

/* Explanation */
.quiz-explanation {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-primary);
  background: var(--bg-secondary);
  border-radius: 0 6px 6px 0;
  font-size: 0.95rem;
  display: none;
}
.quiz-explanation.show { display: block; }

/* Quiz Stats */
.quiz-stats {
  display: flex;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.quiz-stats .stat { font-size: 0.95rem; }
.quiz-stats .stat strong { color: var(--color-primary); }
.quiz-stats .btn { margin-left: auto; }

/* ---- Flashcard ---- */
.flashcard-container {
  margin: 2rem 0;
  text-align: center;
}
.flashcard-deck {
  perspective: 1000px;
  margin: 1.5rem auto;
  max-width: 36rem;
}
.flashcard {
  position: relative;
  width: 100%;
  min-height: 14rem;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard .card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 1.1rem;
}
.flashcard .card-front {
  background: var(--bg-card);
}
.flashcard .card-back {
  background: var(--bg-secondary);
  transform: rotateY(180deg);
}
.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.flashcard-progress {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 1rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-success { background: var(--color-correct); color: #fff; }
.btn-danger { background: var(--color-incorrect); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-secondary); }

/* ---- Dashboard Cards ---- */
.day-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.day-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.day-card .day-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  letter-spacing: 0.05em;
}
.day-card h3 { margin: 0.4rem 0 0.6rem; font-size: 1.15rem; }
.day-card .day-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.day-card .day-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.day-card .day-links a {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  background: var(--bg-secondary);
  border-radius: 4px;
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  body { padding: 1rem; font-size: 1rem; }
  h1 { font-size: 1.6rem; }
  .day-cards { grid-template-columns: 1fr; }
  .quiz-stats { flex-direction: column; gap: 0.5rem; }
  .quiz-stats .btn { margin-left: 0; }
  .flashcard .card-face { padding: 1.25rem; font-size: 1rem; }
}

/* ---- Print ---- */
@media print {
  body { font-size: 11pt; color: #000; background: #fff; padding: 0; }
  .chapter-nav, .btn, .flashcard-controls, .quiz-stats .btn { display: none; }
  .quiz-question { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  .quiz-explanation { display: block !important; border-left-color: #666; }
  a { color: #000; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}
