/* Physik K2 — dark minimalist study site */
:root {
  --bg: #0b0d10;
  --bg-raised: #12151a;
  --bg-inset: #0e1116;
  --border: #23282f;
  --text: #e4e7eb;
  --text-dim: #9aa3ad;
  --text-faint: #6b7480;
  --accent: #e8b45a;
  --accent-soft: rgba(232, 180, 90, 0.12);
  --blue: #6fa8dc;
  --red: #d97a7a;
  --green: #7fc98f;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
nav.sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
nav.sidebar .brand {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.25rem;
}
nav.sidebar .brand strong { color: var(--text); font-weight: 600; }
nav.sidebar ul { list-style: none; margin: 1.25rem 0 0; padding: 0; }
nav.sidebar li { margin: 0; }
nav.sidebar a {
  display: block;
  padding: 0.35rem 0.6rem;
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 0.92rem;
}
nav.sidebar a:hover { background: var(--bg-raised); text-decoration: none; color: var(--text); }
nav.sidebar a.active { color: var(--accent); background: var(--accent-soft); }
nav.sidebar .nav-section {
  margin-top: 1.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 0 0.6rem;
}
main { flex: 1; min-width: 0; }
.content { max-width: 880px; margin: 0 auto; padding: 2.5rem 2.5rem 6rem; }

/* Search */
.search-box { margin-top: 1.25rem; }
.search-box input {
  width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-results { margin-top: 0.5rem; }
.search-results a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.search-results a:hover { background: var(--bg-raised); color: var(--text); text-decoration: none; }
.search-results a small { color: var(--text-faint); display: block; }

/* Typography */
h1 { font-size: 2rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.35rem; font-weight: 620; margin: 2.75rem 0 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
h3 { font-size: 1.05rem; font-weight: 620; margin: 1.75rem 0 0.5rem; color: var(--text); }
p { margin: 0.7rem 0; }
.lede { font-size: 1.08rem; color: var(--text-dim); }
.subtle { color: var(--text-faint); font-size: 0.85rem; }
.kicker {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent); margin-bottom: 0.5rem; font-weight: 600;
}

/* Components */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.8rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}
.callout.warn { border-color: var(--red); background: rgba(217, 122, 122, 0.10); }
.callout.info { border-color: var(--blue); background: rgba(111, 168, 220, 0.10); }
.callout .label { font-weight: 650; font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.25rem; }
.callout.warn .label { color: var(--red); }
.callout.info .label { color: var(--blue); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
tr:hover td { background: var(--bg-raised); }

code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-inset); padding: 0.15em 0.35em; border-radius: 4px; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }

/* Figure / animation frame */
figure.viz {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 1.5rem 0;
  overflow: hidden;
}
figure.viz canvas { display: block; width: 100%; }
figure.viz .controls {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  padding: 0.7rem 1rem; border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text-dim);
}
figure.viz .controls label { display: flex; align-items: center; gap: 0.5rem; }
figure.viz .controls input[type="range"] { accent-color: var(--accent); width: 120px; }
figure.viz .controls output { font-family: var(--mono); min-width: 5.5em; }
figure.viz figcaption { padding: 0.6rem 1rem; font-size: 0.82rem; color: var(--text-faint); border-top: 1px solid var(--border); }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 1rem 0; }
.checklist li {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.55rem 0.8rem; border-radius: 8px;
}
.checklist li:hover { background: var(--bg-raised); }
.checklist input { margin-top: 0.35rem; accent-color: var(--accent); }
.checklist li.done span { color: var(--text-faint); text-decoration: line-through; }
.progress-bar {
  height: 6px; background: var(--bg-inset); border-radius: 3px; overflow: hidden; margin: 0.5rem 0 1.5rem;
}
.progress-bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }

/* Flashcards */
.flashcard {
  perspective: 1200px; cursor: pointer; margin: 1.5rem 0;
}
.flashcard .inner {
  position: relative; width: 100%; min-height: 220px;
  transition: transform 0.5s; transform-style: preserve-3d;
}
.flashcard.flipped .inner { transform: rotateX(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem; text-align: center; font-size: 1.05rem;
}
.flashcard .face.back { transform: rotateX(180deg); color: var(--text-dim); }
.flashcard .face .tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); margin-bottom: 0.75rem; }
.btn-row { display: flex; gap: 0.6rem; margin: 0.75rem 0 1.5rem; flex-wrap: wrap; }
button.btn {
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.45rem 1rem; font-size: 0.9rem; cursor: pointer; font-family: inherit;
}
button.btn:hover { border-color: var(--accent); color: var(--accent); }
button.btn.primary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Quiz */
.quiz-q { margin: 1.5rem 0; }
.quiz-q .options button {
  display: block; width: 100%; text-align: left; margin: 0.4rem 0;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.6rem 0.9rem; cursor: pointer; font-size: 0.95rem; font-family: inherit;
}
.quiz-q .options button:hover { border-color: var(--blue); }
.quiz-q .options button.correct { border-color: var(--green); background: rgba(127, 201, 143, 0.12); }
.quiz-q .options button.wrong { border-color: var(--red); background: rgba(217, 122, 122, 0.12); }
.quiz-q .expl { font-size: 0.85rem; color: var(--text-dim); margin: 0.4rem 0 0 0.2rem; display: none; }
.quiz-q.answered .expl { display: block; }

/* Formula cards */
.formula-card .katex { font-size: 1.15em; }
.formula-card .sym { font-size: 0.85rem; color: var(--text-dim); margin-top: 0.4rem; }
.formula-card .use { font-size: 0.82rem; color: var(--text-faint); margin-top: 0.3rem; }

/* Answer reveals */
details.reveal {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 1rem; margin: 0.5rem 0;
}
details.reveal summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
details.reveal .body { padding-top: 0.6rem; color: var(--text-dim); font-size: 0.95rem; }

/* Top countdown */
.countdown {
  display: inline-flex; gap: 0.5rem; align-items: baseline;
  font-family: var(--mono); font-size: 0.85rem; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.3rem 0.8rem;
}
.countdown strong { color: var(--accent); font-weight: 600; }

/* Footer */
footer { border-top: 1px solid var(--border); padding: 1.5rem 0 0; margin-top: 4rem; color: var(--text-faint); font-size: 0.8rem; }

/* Mobile nav */
nav.sidebar { display: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(11, 13, 16, 0.9); backdrop-filter: blur(8px); z-index: 20;
}
.topbar .brand { font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.topbar .brand strong { color: var(--text); }
.topbar .links { display: flex; gap: 1rem; font-size: 0.85rem; flex-wrap: wrap; }
.topbar .links a { color: var(--text-dim); }
.topbar .links a.active, .topbar .links a:hover { color: var(--accent); text-decoration: none; }
@media (min-width: 1000px) {
  nav.sidebar { display: block; }
  .topbar { display: none; }
}
