/* DMIT Atlas — single stylesheet. Domain colors arrive via the
   --domain-color custom property set inline from domains.json, so adding a
   domain never means touching CSS. */

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

main, .site-header, .site-footer {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: 1rem;
}

.site-header { padding-top: 1.25rem; }
.site-header h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.tagline { margin: 0; color: var(--muted); }
.subtitle { margin: 0 0 0.15rem; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.02em; }
.intro { margin: 0.9rem 0 1rem; max-width: 60rem; }
.bar-label { color: var(--muted); font-size: 0.85rem; align-self: center; margin-right: 0.15rem; }
.badge-dives { border: 1.5px solid #059669; color: #047857; border-radius: 999px; }
.study-tools { margin: 0.25rem 0 0.9rem; color: var(--muted); font-size: 0.9rem; max-width: 60rem; }
.study-tools a { color: inherit; }
.breadcrumb { margin: 0 0 0.5rem; }
a { color: #1d4ed8; }

/* ---------- toolbar / legend ---------- */

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 0.5rem;
}

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; font-size: 0.85rem; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.1rem 0.55rem;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
.legend-item:hover { border-color: var(--line); background: var(--card); }
.legend-item[aria-pressed="true"] { border-color: #1e293b; background: var(--card); }
.swatch { width: 0.8rem; height: 0.8rem; border-radius: 3px; display: inline-block; }

#view-toggle {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}
#view-toggle:hover { border-color: #94a3b8; }

/* ---------- the map ---------- */

#map, #mini-map {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none; /* panzoom.js owns gestures */
  cursor: grab;
}
#map { height: min(70vh, 640px); }
#mini-map { height: 300px; }
#map:active, #mini-map:active { cursor: grabbing; }

.map-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.4rem; }

.term-label { font-size: 15px; font-weight: 700; fill: var(--muted); }

.node rect {
  fill: var(--card);
  stroke: var(--domain-color, #94a3b8);
  stroke-width: 2.5;
}
.node:hover rect, .node:focus-visible rect { stroke-width: 4.5; }
.node:focus-visible { outline: none; }
.node-code { font-size: 15px; font-weight: 700; fill: var(--ink); }
.node-title { font-size: 12px; fill: var(--muted); }
.node.awaiting rect { stroke-dasharray: 6 4; }
.node.current rect { fill: #fefce8; stroke-width: 4.5; }
.node.dim, .edge.dim { opacity: 0.22; }
.node text { pointer-events: none; }

.edge { stroke: #94a3b8; stroke-width: 2; cursor: help; }
.edge:hover { stroke: #475569; stroke-width: 3.5; }
.edge-coreq { stroke-dasharray: 8 5; }
.edge-inferred { stroke-dasharray: 2 5; stroke-linecap: round; }

#map:focus-visible, #mini-map:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

.gate-bar { fill: #64748b; opacity: 0.5; }
.gate-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--muted); }
.edge-gate { stroke: #64748b; stroke-width: 3; }
.gate.dim { opacity: 0.22; }

/* ---------- cluster overlay ---------- */

.cluster-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; }
.cluster-chip {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  cursor: pointer;
}
.cluster-chip:hover { border-color: #64748b; }
.cluster-chip[aria-pressed="true"] { background: #1e293b; border-color: #1e293b; color: #fff; }
.lens-story {
  margin: 0.65rem 0 0;
  padding: 0.6rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid #1e293b;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.lens-story strong { color: var(--ink); }
.course-list li.dim { opacity: 0.35; }

/* ---------- list view & badges ---------- */

.course-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.course-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.course-list .unlocks { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1.5px solid var(--domain-color, var(--line));
  background: var(--card);
  white-space: nowrap;
}
.status-complete { border-color: #059669; color: #047857; }
.status-partial { border-color: #d97706; color: #b45309; }
.status-awaiting-outline { border-color: #94a3b8; color: var(--muted); font-style: italic; }

/* ---------- course page ---------- */

section { margin-block: 1.75rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }

.unlocks-callout {
  border-left: 4px solid #d97706;
  background: #fffbeb;
  padding: 0.6rem 0.9rem;
  border-radius: 0 8px 8px 0;
  font-weight: 500;
}

.edge-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.edge-list li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1rem; }
.edge-head { margin: 0; }
.edge-why { margin: 0.35rem 0 0; color: var(--muted); }
.edge-kind { font-style: italic; }

.topics dt { font-weight: 700; margin-top: 0.9rem; border-radius: 6px; }
.topics dd { margin: 0.15rem 0 0 0; color: var(--muted); }
.topic-anchor { color: inherit; text-decoration: none; }
.topic-anchor:hover::after { content: " #"; color: var(--muted); font-weight: 400; }
.topics dt:target { background: #fef9c3; outline: 6px solid #fef9c3; }

/* ---------- deep dives (Phase 2 attachments) ---------- */

.dive {
  margin-top: 0.6rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink); /* dives sit inside a muted <dd> — restore full ink */
}
.dive > summary { padding: 0.6rem 0.9rem; cursor: pointer; border-radius: 10px; }
.dive > summary:hover { background: #f1f5f9; }
.dive[open] > summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.dive-kind {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.05rem 0.5rem;
  border: 1.5px solid #1e293b;
  border-radius: 999px;
}
.dive-meta { color: var(--muted); font-size: 0.85rem; }
.dive form { padding: 0.25rem 0.9rem 0.9rem; }

.quiz-question { border: 0; border-top: 1px solid var(--line); margin: 0.75rem 0 0; padding: 0.6rem 0 0; }
.quiz-question legend { font-weight: 600; padding: 0; }
.quiz-choice {
  display: block;
  margin: 0.45rem 0;
  padding: 0.45rem 0.65rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.quiz-choice:hover { border-color: #94a3b8; }
.quiz-choice.is-right { border-color: #059669; background: #ecfdf5; }
.quiz-choice.is-wrong { border-color: #dc2626; background: #fef2f2; }
.quiz-choice.is-answer { border-color: #059669; }
.choice-why { margin: 0.35rem 0 0 1.4rem; color: var(--muted); font-size: 0.85rem; }
.quiz-check {
  font: inherit;
  font-size: 0.9rem;
  margin-top: 0.6rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}
.quiz-check:hover { border-color: #94a3b8; }
.quiz-result { font-weight: 600; margin: 0.5rem 0 0; }
.dive-foot { margin: 0; padding: 0 0.9rem 0.75rem; color: var(--muted); font-size: 0.8rem; }

.diagram-body { padding: 0.25rem 0.9rem 0.9rem; }
.diagram-body > p.muted { margin: 0.25rem 0 0.6rem; font-size: 0.9rem; }
.diagram-body figure { margin: 0; }
.diagram-body svg {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.diagram-body figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.85rem; }

.walk-body { padding: 0.25rem 0.9rem 0.9rem; }
.walk-body > p.muted { margin: 0.25rem 0 0.6rem; font-size: 0.9rem; }
.walk-map { margin: 0.5rem 0 0.75rem; padding-left: 1.4rem; }
.walk-map li { margin: 0.15rem 0; }
.walk-map-step {
  font: inherit;
  font-size: 0.9rem;
  border: 0;
  background: none;
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  text-align: left;
}
.walk-map-step:hover { background: #f1f5f9; color: var(--ink); }
.walk-map-step.is-visited { color: var(--ink); }
.walk-map-step.is-current { font-weight: 600; background: #fef9c3; }
.walk-step { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.walk-step-title { margin: 0 0 0.4rem; font-size: 1rem; }
.walk-step p { margin: 0.4rem 0; }
.walk-code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
}
.walk-ref { font-size: 0.9rem; }
.walk-recap {
  border-top: 1px solid var(--line);
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  color: var(--muted);
  font-style: italic;
}
.walk-nav { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.walk-nav .quiz-check { margin-top: 0; }
.walk-nav .quiz-check:disabled { opacity: 0.4; cursor: default; }

.muted { color: var(--muted); }
.status-note { color: var(--muted); font-size: 0.9rem; }
.course-footer { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 0.75rem; color: var(--muted); font-size: 0.85rem; }
.site-footer { color: var(--muted); font-size: 0.85rem; padding-block: 1.5rem; }

@media (max-width: 640px) {
  #map { height: 60vh; }
  .map-toolbar { flex-direction: column; align-items: flex-start; }
}
