/* topic.css — CISC 271 shared styles, with dark/light mode */

/* ── LIGHT MODE (default) ─────────────── */
:root {
  --bg:     #f7f5f0;
  --bg2:    #ffffff;
  --bg3:    #eeece6;
  --border: #d8d4c8;
  --text:   #1a1814;
  --muted:  #6b6560;
  --ink:    #2c2820;
  --nav-bg:    #2c2820;
  --nav-text:  #e8e4d8;
  --nav-muted: #8a8070;
  --nav-sep:   #3a3428;
  --ans-bg:    #eeece6;
  --code-bg:   #ffffff;
}

/* ── DARK MODE ────────────────────────── */
[data-theme="dark"] {
  --bg:     #0f0e0c;
  --bg2:    #1a1814;
  --bg3:    #232018;
  --border: #332e28;
  --text:   #e8e4d8;
  --muted:  #8a8070;
  --ink:    #f0ece0;
  --nav-bg:    #0a0908;
  --nav-text:  #e8e4d8;
  --nav-muted: #6b6560;
  --nav-sep:   #2c2820;
  --ans-bg:    #232018;
  --code-bg:   #1a1814;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.65;
  transition: background 0.25s, color 0.25s;
}

/* TOP NAV */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 12px 48px;
  display: flex; align-items: center; gap: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.05em;
  transition: background 0.25s;
}
.topnav a.back { color: var(--nav-muted); text-decoration: none; transition: color 0.2s; }
.topnav a.back:hover { color: var(--nav-text); }
.topnav-sep   { color: var(--nav-sep); }
.topnav-title { color: var(--nav-text); flex: 1; }

/* THEME TOGGLE */
.theme-toggle {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--nav-sep);
  color: var(--nav-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.08em;
  padding: 4px 10px; border-radius: 3px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--nav-text); color: var(--nav-text); }
.theme-toggle .icon { font-size: 13px; }

/* PAGE LAYOUT */
.page-wrap { max-width: 860px; margin: 0 auto; padding: 60px 48px 100px; }

/* TOPIC HEADER */
.topic-header { margin-bottom: 56px; padding-bottom: 32px; border-bottom: 1px solid var(--border); }
.topic-eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--page-color, #c0392b); margin-bottom: 12px;
}
.topic-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(32px, 5vw, 52px); line-height: 1.1; font-weight: 700;
  color: var(--ink); margin-bottom: 16px;
}
.topic-header .intro { font-size: 16px; color: var(--muted); line-height: 1.7; max-width: 680px; }

/* SECTION HEADERS */
.section-head { display: flex; align-items: center; gap: 14px; margin: 48px 0 24px; }
.section-head h2 { font-family: 'Playfair Display', serif; font-size: 22px; color: var(--ink); white-space: nowrap; }
.section-head::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* FORMULA BLOCKS */
.formula-block {
  background: var(--bg2); border: 1px solid var(--border);
  border-left: 3px solid var(--page-color, #c0392b);
  border-radius: 0 4px 4px 0; padding: 24px 28px; margin-bottom: 16px;
  transition: background 0.25s, border-color 0.25s;
}
.formula-block h3 {
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  color: var(--ink); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em;
}
.formula-block .math-display {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 3px;
  padding: 16px 20px; margin: 10px 0; overflow-x: auto;
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; line-height: 1.8;
  color: var(--text); white-space: pre; transition: background 0.25s;
}
.formula-block p { font-size: 14px; color: var(--muted); line-height: 1.7; margin-top: 10px; }
.formula-block .note {
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg3); border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted);
  border-left: 2px solid var(--page-color, #c0392b);
}

/* KEY FACTS */
.key-facts {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; padding: 24px 28px; margin-bottom: 16px; transition: background 0.25s;
}
.key-facts h3 {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--page-color, #c0392b); margin-bottom: 16px;
}
.key-facts ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.key-facts li { font-size: 14px; color: var(--text); display: flex; gap: 12px; align-items: flex-start; line-height: 1.65; }
.key-facts li::before {
  content: '→'; font-family: 'IBM Plex Mono', monospace;
  color: var(--page-color, #c0392b); font-size: 12px; margin-top: 2px; flex-shrink: 0;
}

/* QUESTION ACCORDIONS */
details.question {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; margin-bottom: 10px; overflow: hidden;
  transition: border-color 0.2s, background 0.25s;
}
details.question:hover, details.question[open] { border-color: var(--page-color, #c0392b); }

summary.q-header {
  padding: 18px 22px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 14px;
  user-select: none; list-style: none;
}
summary.q-header::-webkit-details-marker { display: none; }

.q-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--page-color, #c0392b);
  background: color-mix(in srgb, var(--page-color, #c0392b) 10%, transparent);
  padding: 3px 8px; border-radius: 2px; white-space: nowrap; flex-shrink: 0; margin-top: 1px;
  border: 1px solid color-mix(in srgb, var(--page-color, #c0392b) 25%, transparent);
}
.q-text { font-size: 14px; color: var(--text); flex: 1; line-height: 1.6; }
.q-icon {
  font-size: 16px; color: var(--muted); flex-shrink: 0;
  transition: transform 0.2s; margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
}
details[open] .q-icon { transform: rotate(45deg); color: var(--page-color, #c0392b); }

.q-answer { border-top: 1px solid var(--border); padding: 20px 22px; }
.answer-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.15em; text-transform: uppercase; color: #8b5e00;
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.answer-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.answer-content {
  font-size: 14px; color: var(--text); line-height: 1.75;
  background: var(--ans-bg); padding: 16px 20px;
  border-radius: 3px; border: 1px solid var(--border);
  transition: background 0.25s;
}
.answer-content code {
  font-family: 'IBM Plex Mono', monospace; font-size: 13px;
  background: var(--code-bg); padding: 2px 6px;
  border-radius: 2px; border: 1px solid var(--border); color: var(--ink);
}

/* FOOTER */
footer {
  background: var(--bg3); border-top: 1px solid var(--border);
  padding: 20px 48px; display: flex; align-items: center;
  justify-content: space-between; font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--muted); letter-spacing: 0.05em;
  transition: background 0.25s;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* KATEX */
.katex-display { margin: 8px 0 !important; overflow-x: auto; }

/* RESPONSIVE */
@media (max-width: 700px) {
  .page-wrap { padding: 32px 20px 80px; }
  .topnav { padding: 12px 16px; gap: 10px; }
  .topnav-title { display: none; }
  footer { padding: 16px 20px; flex-direction: column; gap: 4px; text-align: center; }
}
