/* ==========================================================================
   APFlash shared theme - design tokens + common components
   Linked from every page: <link rel="stylesheet" href="/assets/theme.css">
   Page-specific styles (hero, quiz card, article layout, etc.) stay local
   to each page's own <style> block and may override anything here.
   ========================================================================== */

:root {
  --bg:           #f8f8fb;
  --surface:      #ffffff;
  --border:       #e4e3ec;
  --fg:           #18172a;
  --fg-mid:       #5c5878;
  --fg-dim:       #a09db8;
  --accent:       #2563eb;
  --accent-light: #dbeafe;
  --accent-mid:   #1d4ed8;
  --success:      #059669;
  --success-light:#ecfdf5;
  --danger:       #dc2626;
  --danger-light: #fef2f2;
  --sans: 'Inter', system-ui, sans-serif;
}
/* Theme is an explicit user choice (see the toggle button + site.js), not
   tied to the OS/browser color-scheme preference - light is always the
   default until someone clicks the toggle. */
:root[data-theme="dark"] {
  --bg: #0f0e1a; --surface: #18172a; --border: #2a2840;
  --fg: #eeedf8; --fg-mid: #8d8aaa; --fg-dim: #504d6a;
  --accent: #60a5fa; --accent-light: rgba(96,165,250,.12); --accent-mid: #3b82f6;
  --success: #34d399; --success-light: rgba(52,211,153,.08);
  --danger: #f87171; --danger-light: rgba(248,113,113,.08);
  color-scheme: dark;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Site header / logo ──
   Markup: <header class="site-header"><a href="/" class="logo-text">AP<em>Flash</em></a></header>
   (nav-style headers use class="logo" - same rules apply via the shared selector) */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
}
.logo-text, .logo {
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo-text em, .logo-text span,
.logo em, .logo span { font-style: normal; color: var(--accent); }

/* ── Theme toggle ──
   Markup: <button class="theme-toggle" id="themeToggle" aria-label="Toggle theme">🌙</button>
   Wired up in site.js; sits at the end of the header/nav row. */
.theme-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-mid);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Shared buttons ── */
.btn, .btn-primary, .btn-ghost {
  font-family: var(--sans);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 26px;
  border-radius: 9px;
  border: none;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-ghost {
  background: transparent;
  color: var(--fg-mid);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--fg); border-color: var(--fg-mid); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn:disabled, .btn-primary:disabled, .btn-ghost:disabled { opacity: .4; cursor: default; }

/* ── FAQ accordion ──
   Markup: <div class="faq-item"><h3>Question <span class="faq-icon">+</span></h3>
             <div class="faq-answer"><p>Answer</p></div></div>
   Toggled by adding/removing the "open" class (see site.js) */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: 16px 0; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
.faq-item:first-child { padding-top: 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 {
  display: flex; justify-content: space-between; align-items: flex-start;
  font-size: 14px; font-weight: 700; color: var(--fg); line-height: 1.4; margin: 0;
}
.faq-item.open h3 { margin-bottom: 6px; }
.faq-icon {
  display: inline-block; font-size: 20px; font-weight: 300; color: var(--fg-dim);
  flex-shrink: 0; margin-left: 14px; margin-top: -1px;
  transition: transform 0.25s ease; line-height: 1;
}
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.32s ease; }
.faq-item.open .faq-answer { max-height: 600px; }
.faq-item p, .faq-answer p { font-size: 14px; line-height: 1.7; color: var(--fg-mid); margin: 0; }

/* ── Secondary nav bar (back link + current-page crumb + optional action) ──
   Markup: <div class="quiz-header">
             <a href="..." class="btn btn-ghost btn-sm">← Back</a>
             <span class="header-crumb">Current page</span>
             <div class="header-right"><a href="..." class="btn btn-ghost btn-sm">Action →</a></div>
           </div>
   Used below the site-header on quiz screens, subject landing screens,
   guide pages and the guides index for consistent back/crumb navigation. */
.quiz-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; flex-wrap: wrap;
}
.quiz-back { flex-shrink: 0; }
.header-crumb { font-size: 13px; color: var(--fg-mid); white-space: nowrap; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

/* ── Footer base ── */
footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--fg-dim);
  border-top: 1px solid var(--border);
}
footer a { color: var(--fg-dim); text-decoration: none; }
footer a:hover { color: var(--fg); }
