/* ============================================================
   CCAF Study Site — Shared Styles
   ============================================================ */

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --sidebar-bg: #0d1117;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #8b949e;
  --accent: #da7756;
  --accent-hover: #c4614a;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;

  --d1: #e67e22;
  --d1-light: #fef3e2;
  --d2: #3498db;
  --d2-light: #e8f4fd;
  --d3: #27ae60;
  --d3-light: #e8f8ef;
  --d4: #9b59b6;
  --d4-light: #f5eef8;
  --d5: #e74c3c;
  --d5-light: #fdf2f1;

  --correct: #27ae60;
  --correct-light: #e8f8ef;
  --incorrect: #e74c3c;
  --incorrect-light: #fdf2f1;
  --neutral-light: #f1f5f9;

  --radius: 8px;
  --radius-lg: 12px;
  --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);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── TOP NAV ── */
.topnav {
  background: var(--sidebar-bg);
  border-bottom: 1px solid #21262d;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav-logo {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topnav-logo span { color: var(--accent); }

.topnav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex: 1;
}

.topnav-links a {
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.topnav-links a:hover { color: var(--sidebar-text); background: rgba(255,255,255,0.06); }
.topnav-links a.active { color: #fff; background: rgba(255,255,255,0.1); }

/* ── LAYOUT: SIDEBAR + CONTENT ── */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid #21262d;
  padding: 1.5rem 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 0.75rem;
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.375rem;
}

.sidebar-link {
  display: block;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1.4;
}

.sidebar-link:hover { color: var(--sidebar-text); background: rgba(255,255,255,0.06); }
.sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); }

.sidebar-domain-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  margin-bottom: 0.125rem;
}

.sidebar-domain-label:hover { background: rgba(255,255,255,0.06); }

.domain-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.d1 .domain-dot, .dot-d1 { background: var(--d1); }
.d2 .domain-dot, .dot-d2 { background: var(--d2); }
.d3 .domain-dot, .dot-d3 { background: var(--d3); }
.d4 .domain-dot, .dot-d4 { background: var(--d4); }
.d5 .domain-dot, .dot-d5 { background: var(--d5); }

/* ── MAIN CONTENT ── */
.main-content {
  padding: 2rem 2.5rem;
  max-width: 900px;
}

/* ── DOMAIN SECTIONS ── */
.domain-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.domain-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  white-space: nowrap;
}

.d1-badge { background: var(--d1-light); color: #a85e14; }
.d2-badge { background: var(--d2-light); color: #1a6fa3; }
.d3-badge { background: var(--d3-light); color: #1a7a45; }
.d4-badge { background: var(--d4-light); color: #6b3285; }
.d5-badge { background: var(--d5-light); color: #b02a1e; }

.domain-weight {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 2.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; color: var(--text); }
h4 { font-size: 0.875rem; font-weight: 600; margin-top: 1rem; margin-bottom: 0.375rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

p { margin-bottom: 0.875rem; font-size: 0.9rem; }

/* ── TASK STATEMENT BOX ── */
.task-statement {
  background: var(--neutral-light);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  margin-top: 2rem;
}

/* ── CONCEPT CARD ── */
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.concept-card h3 { margin-top: 0; }
.concept-card p:last-child { margin-bottom: 0; }

/* ── INFO BOXES ── */
.box {
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.box-key {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-left: 4px solid #f59e0b;
}

.box-warn {
  background: var(--incorrect-light);
  border: 1px solid #fca5a5;
  border-left: 4px solid var(--incorrect);
}

.box-tip {
  background: var(--correct-light);
  border: 1px solid #86efac;
  border-left: 4px solid var(--correct);
}

.box-edge {
  background: #faf5ff;
  border: 1px solid #d8b4fe;
  border-left: 4px solid #9333ea;
}

.box-title {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.box-key .box-title { color: #92400e; }
.box-warn .box-title { color: #991b1b; }
.box-tip .box-title { color: #14532d; }
.box-edge .box-title { color: #6b21a8; }
.box p:last-child { margin-bottom: 0; }

/* ── CODE ── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.82em;
  background: #f1f5f9;
  color: #c026d3;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

/* ── COMPARISON TABLE ── */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.compare-table th {
  background: var(--neutral-light);
  text-align: left;
  padding: 0.625rem 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.compare-table td {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.compare-table tr:nth-child(even) td { background: #fafbfc; }

/* ── EXTERNAL DOC LINKS ── */
.doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--d2);
  text-decoration: none;
  background: var(--d2-light);
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  transition: opacity 0.15s;
}

.doc-link:hover { opacity: 0.8; text-decoration: underline; }
.doc-link::before { content: '↗'; }

/* ── EXAM PAGE ── */
.exam-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.exam-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.exam-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.exam-controls label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.exam-controls select {
  font-size: 0.85rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

.progress-bar-wrap {
  flex: 1;
  min-width: 150px;
  background: var(--border);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 20px;
  transition: width 0.3s ease;
}

.score-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── QUESTION CARD ── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.q-num { font-weight: 700; color: var(--text-muted); }

.scenario-tag {
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-style: italic;
}

.question-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

/* ── OPTIONS ── */
.options { display: flex; flex-direction: column; gap: 0.625rem; }

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  text-align: left;
  font-size: 0.875rem;
  line-height: 1.55;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  font-family: inherit;
  color: var(--text);
}

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

.option-btn:disabled { cursor: default; }

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--border);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background 0.15s, color 0.15s;
}

.option-btn.correct {
  border-color: var(--correct);
  background: var(--correct-light);
}
.option-btn.correct .option-letter {
  background: var(--correct);
  color: white;
}

.option-btn.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-light);
}
.option-btn.incorrect .option-letter {
  background: var(--incorrect);
  color: white;
}

.option-btn.revealed-correct {
  border-color: var(--correct);
  background: var(--correct-light);
  opacity: 0.7;
}
.option-btn.revealed-correct .option-letter {
  background: var(--correct);
  color: white;
}

/* ── EXPLANATION ── */
.explanation {
  margin-top: 1.25rem;
  padding: 1.125rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.65;
  border: 1px solid var(--border);
  background: var(--neutral-light);
  display: none;
}

.explanation.show { display: block; }

.explanation-header {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.625rem;
  color: var(--text-muted);
}

.why-wrong { margin-top: 0.75rem; }
.why-wrong-item {
  margin-bottom: 0.375rem;
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.why-wrong-letter {
  font-weight: 700;
  color: var(--incorrect);
  flex-shrink: 0;
  min-width: 20px;
}
.why-wrong-correct { color: var(--correct); }

.study-links {
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.study-link-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.study-link {
  font-size: 0.78rem;
  color: var(--d4);
  text-decoration: none;
  background: var(--d4-light);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: opacity 0.15s;
}
.study-link:hover { opacity: 0.75; text-decoration: underline; }

/* ── NAV BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { opacity: 0.87; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--neutral-light); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.exam-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

/* ── RESULTS SCREEN ── */
.results-screen {
  text-align: center;
  padding: 3rem 2rem;
}

.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 8px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.score-ring.pass { border-color: var(--correct); }
.score-ring.fail { border-color: var(--incorrect); }

.score-ring .score-pct {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.score-ring .score-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── HOME PAGE CARDS ── */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.domain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.1s;
  border-top: 3px solid transparent;
}

.domain-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.domain-card.d1 { border-top-color: var(--d1); }
.domain-card.d2 { border-top-color: var(--d2); }
.domain-card.d3 { border-top-color: var(--d3); }
.domain-card.d4 { border-top-color: var(--d4); }
.domain-card.d5 { border-top-color: var(--d5); }

.domain-card-title { font-weight: 700; font-size: 0.95rem; }
.domain-card-sub { font-size: 0.78rem; color: var(--text-muted); }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.1s;
}
.action-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.action-icon { font-size: 2rem; line-height: 1; }
.action-title { font-weight: 700; font-size: 1.1rem; }
.action-sub { font-size: 0.82rem; color: var(--text-muted); }

/* ── UTILITY ── */
ul, ol { padding-left: 1.25rem; margin-bottom: 0.875rem; }
li { font-size: 0.875rem; margin-bottom: 0.25rem; line-height: 1.55; }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.mt-0 { margin-top: 0; }

/* ── SCROLLBAR ── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 1.5rem 1rem; }
  .exam-container { padding: 1.25rem 1rem; }
  .action-grid { grid-template-columns: 1fr; }
}
