/* Shared stylesheet for /teach books. Copied to ~/.claude/teaching/<topic>/assets/style.css on first use. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-elev: #f4f1ea;
  --text: #1c1b18;
  --text-muted: #6b6862;
  --border: #e5e1d8;
  --accent: #c2410c;
  --accent-soft: #fde2cf;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --warn: #ca8a04;
  --warn-soft: #fef9c3;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #161513;
  --surface: #201f1c;
  --surface-elev: #2a2825;
  --text: #f4f1ea;
  --text-muted: #a39d92;
  --border: #353230;
  --accent: #fb923c;
  --accent-soft: #3f2515;
  --good: #4ade80;
  --good-soft: #14532d;
  --warn: #facc15;
  --warn-soft: #422006;
  --bad: #f87171;
  --bad-soft: #450a0a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ══════════════════════════════════════════
   SHARED COMPONENTS
   ══════════════════════════════════════════ */

.badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}
.badge.tag { font-family: var(--mono); font-size: 0.7rem; }
.badge.related { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

.bloom-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.bloom-none    { background: var(--good-soft);  color: var(--good); }
.bloom-some    { background: var(--warn-soft);  color: var(--warn); }
.bloom-working { background: var(--accent-soft); color: var(--accent); }

.topic-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  background: var(--surface-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

.theme-toggle {
  font-size: 1.1rem;
  padding: 0.4rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  transition: border-color 200ms ease;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }

.back-link {
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color 200ms ease;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.meta-dates { font-size: 0.8rem; color: var(--text-muted); }

/* ══════════════════════════════════════════
   LANDING PAGES
   ══════════════════════════════════════════ */

.landing-header {
  padding: 3rem 2rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.landing-nav { margin-bottom: 1rem; }
.global-header h1::before { content: '⊞ '; opacity: 0.5; font-size: 0.8em; }
.landing-header h1 { font-size: 2.5rem; margin: 0 0 0.25rem; text-transform: capitalize; }
.subtitle { color: var(--text-muted); margin: 0 0 1.25rem; font-size: 0.95rem; }

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.search {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-width: 220px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tag-filter, .topic-filter { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag-chip, .topic-chip {
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 200ms ease;
}
.tag-chip:hover, .topic-chip:hover { color: var(--text); border-color: var(--accent); }
.tag-chip.active, .topic-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.tag-chip.clear { color: var(--bad); border-color: var(--bad-soft); }
.tag-chip.clear:hover { background: var(--bad-soft); }

.entries-grid {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 2rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.entry-card {
  display: block;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 200ms ease, border-color 200ms ease;
  color: var(--text);
  text-decoration: none;
}
.entry-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.entry-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.entry-title { font-size: 1.15rem; margin: 0 0 0.4rem; }
.entry-desc { font-size: 0.92rem; color: var(--text-muted); margin: 0 0 0.85rem; line-height: 1.5; }
.entry-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
}

/* ══════════════════════════════════════════
   ENTRY PAGE — LAYOUT
   ══════════════════════════════════════════ */

.entry-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(6px);
}
.entry-nav { display: flex; gap: 1rem; align-items: center; }

.entry {
  max-width: 780px;
  margin: 2rem auto 4rem;
  padding: 0 2rem;
}
.entry h1 { font-size: 2.2rem; margin: 0 0 0.75rem; }
.entry h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.entry h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; color: var(--text-muted); }

/* ══════════════════════════════════════════
   SECTION 1: HOOK
   ══════════════════════════════════════════ */

.hook { margin-bottom: 1.5rem; }
.hook-text {
  font-size: 1.12rem;
  font-style: italic;
  padding: 1rem 1.25rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0 0 0.85rem;
  line-height: 1.6;
}
.entry-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   SECTION 2: KEY COMPONENTS (PRE-TRAINING)
   ══════════════════════════════════════════ */

.key-components { margin: 2rem 0; }

.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.term-card {
  height: 120px;
  cursor: pointer;
  perspective: 800px;
  border-radius: var(--radius);
  position: relative;
}
.term-card .term-front,
.term-card .term-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  backface-visibility: hidden;
  transition: transform 0.4s ease;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.4;
}
.term-card .term-front {
  background: var(--surface);
  font-weight: 600;
}
.term-card .term-back {
  background: var(--accent-soft);
  color: var(--text);
  transform: rotateY(180deg);
}
.term-card:hover .term-front,
.term-card:focus .term-front { border-color: var(--accent); }
.term-card.flipped .term-front { transform: rotateY(-180deg); }
.term-card.flipped .term-back { transform: rotateY(0deg); }

/* Definition list variant (SOME calibration) */
.key-components dl { margin: 1rem 0; }
.key-components dt { font-weight: 600; margin-top: 0.85rem; }
.key-components dd { margin: 0.15rem 0 0 1.25rem; color: var(--text-muted); font-size: 0.95rem; }

/* Collapsed variant (WORKING calibration) */
.terms-collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 1rem;
  background: var(--surface);
}
.terms-collapsible summary {
  cursor: pointer;
  padding: 0.75rem 0;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
}
.terms-collapsible summary::-webkit-details-marker { display: none; }

/* ══════════════════════════════════════════
   SECTION 3: CONCRETE EXAMPLE
   ══════════════════════════════════════════ */

.file-ref {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.file-ref code { font-family: var(--mono); }

pre {
  position: relative;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
}
pre.diagram { background: var(--surface); color: var(--text-muted); }
code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code {
  background: var(--surface-elev);
  border: 1px solid var(--border);
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--font);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:focus { opacity: 1; }

/* ══════════════════════════════════════════
   SECTION 4: VISUAL MODEL
   ══════════════════════════════════════════ */

.visual-container {
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  overflow: hidden;
}

.step-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.diagram-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
}

/* SVG active state (Signaling #2) */
.diagram-svg .step-el { opacity: 0.25; transition: opacity 300ms ease, fill 300ms ease; }
.diagram-svg .step-el.active { opacity: 1; }
.diagram-svg .node-rect { fill: var(--surface-elev); stroke: var(--border); stroke-width: 1.5; rx: 6; transition: fill 300ms ease, stroke 300ms ease; }
.diagram-svg .node-rect.active { fill: var(--accent-soft); stroke: var(--accent); }
.diagram-svg .node-text { fill: var(--text); font-family: var(--font); font-size: 13px; }
.diagram-svg .edge-line { stroke: var(--border); stroke-width: 1.5; fill: none; }
.diagram-svg .edge-line.active { stroke: var(--accent); stroke-width: 2; }
.diagram-svg .label-text { fill: var(--text-muted); font-family: var(--font); font-size: 11px; }

.step-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}
.step-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 200ms ease;
}
.step-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.step-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.step-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.step-btn.primary:hover:not(:disabled) { opacity: 0.9; }

.step-explanation {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0;
  min-height: 1.4em;
  transition: opacity 200ms ease;
  line-height: 1.5;
}

/* Comparison table with heatmap */
table.compare {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.92rem;
}
table.compare th, table.compare td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
table.compare th { background: var(--surface-elev); font-weight: 600; }
table.compare td[data-score] { transition: background 300ms ease; }
table.compare tr.winner td { border-left: 3px solid var(--good); }

/* Canvas for large graphs */
canvas.concept-graph {
  display: block;
  width: 100%;
  border-radius: calc(var(--radius) - 4px);
  cursor: grab;
}
canvas.concept-graph:active { cursor: grabbing; }

/* ══════════════════════════════════════════
   SECTION 5: DEEPER
   ══════════════════════════════════════════ */

.deeper {
  margin-top: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 1.25rem;
}
.deeper summary {
  cursor: pointer;
  padding: 1rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.deeper summary::-webkit-details-marker { display: none; }
.deeper summary::before { content: '▸'; color: var(--accent); font-size: 0.85rem; transition: transform 200ms ease; }
.deeper[open] summary::before { transform: rotate(90deg); }
.deeper summary h2 {
  display: inline;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 1.2rem;
}
.deeper-content { padding-bottom: 1.25rem; }

.antipattern {
  background: var(--bad-soft);
  border-left: 3px solid var(--bad);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.92rem;
}
.antipattern pre { background: var(--surface-elev); margin: 0.5rem 0; }

/* ══════════════════════════════════════════
   SECTION 6: CROSS-LINKS & SOURCES
   ══════════════════════════════════════════ */

.cross-links { margin-top: 2.25rem; }

.related-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  margin: 0.5rem 0;
  transition: border-color 200ms ease, transform 200ms ease;
}
.related-card:hover { border-color: var(--accent); transform: translateX(3px); text-decoration: none; }
.related-card strong { font-size: 0.95rem; color: var(--accent); }
.related-card span { font-size: 0.875rem; color: var(--text-muted); }

.sources {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.sources h3 { font-size: 0.95rem; color: var(--text-muted); margin: 0 0 0.5rem; font-weight: 600; }
.sources ul { padding-left: 1.2rem; margin: 0; }
.sources li { font-size: 0.85rem; color: var(--text-muted); margin: 0.3rem 0; }
.sources a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.sources a:hover { color: var(--accent); }

/* Hover popover for cross-links */
.link-popover {
  position: absolute;
  z-index: 200;
  max-width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  pointer-events: none;
}
.link-popover[hidden] { display: none; }
.popover-title { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; }
.popover-summary { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* ══════════════════════════════════════════
   SECTION 7: ADAPTIVE RECALL / QUIZ
   ══════════════════════════════════════════ */

.recall { margin-top: 2.25rem; }

.quiz { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 1rem; }

.quiz-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.question-text {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0 0 0.85rem;
  line-height: 1.4;
}
.options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.option {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  text-align: left;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  transition: all 200ms ease;
}
.option:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.option:disabled { cursor: default; }
.option.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.option.wrong   { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad);  }

.feedback {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.feedback.hidden { display: none; }
.feedback.feedback-correct { background: var(--good-soft); color: var(--good); }
.feedback.feedback-wrong   { background: var(--bad-soft);  color: var(--bad);  }
.feedback-icon { font-weight: 700; flex-shrink: 0; }
.feedback-text { margin: 0; }

.reveal-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  margin-top: 0.5rem;
  transition: all 200ms ease;
}
.reveal-btn:hover { border-color: var(--warn); color: var(--warn); }

.answer {
  margin-top: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}
.answer.hidden { display: none; }

/* Open-ended recall (WORKING calibration) */
.recall-open ol { padding-left: 1.3rem; margin-top: 0.75rem; }
.recall-open li {
  margin: 0.6rem 0;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border-left: 3px solid var(--warn);
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

@media (max-width: 640px) {
  .landing-header, .entries-grid, .entry { padding-left: 1.25rem; padding-right: 1.25rem; }
  .entry h1 { font-size: 1.75rem; }
  .controls { gap: 0.5rem; }
  .search { min-width: 0; flex: 1; }
  .term-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .step-controls { flex-wrap: wrap; }
  .entry-nav { gap: 0.5rem; }
}
