/* Roadmap page: graph canvas (nodes, SVG edges, legend) and the level guide below it. */

/* The page scrolls vertically: graph first, then the readable level guide. */
#roadmap-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* Graph paper */
#graph-scroll {
  overflow-x: auto;   /* wide graphs scroll sideways on small screens; the guide follows below */
  display: flex;
  padding: 36px 40px 72px; /* bottom room for the legend */
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--dot) 1px, transparent 1px),
    linear-gradient(90deg, var(--dot) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  border-bottom: 2px solid var(--ink);
}

/* margin:auto centres the graph when it fits, and falls back to the top-left
   (fully scrollable) when it's bigger than the window - align-items:center
   would cut off the top with no way to scroll to it. */
#graph-wrap {
  position: relative; /* width/height set by graph.js */
  flex-shrink: 0;
  margin: auto;
}

#graph-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}

.graph-empty { text-align: center; color: var(--faint); padding-top: 200px; }

/* ── Nodes: index cards with the topic's colour as a side stripe ── */
.node {
  position: absolute;
  width: 170px; height: 46px; /* keep in sync with NODE_W / NODE_H in js/graph.js */
  transform: translateX(-50%);
  display: flex; align-items: center; justify-content: center;
  padding: 0 10px 0 16px;
  text-align: center;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--node-tx);
  background: var(--node-bg);
  border: 2px solid var(--node-bd);
  border-radius: 4px;
  box-shadow: inset 7px 0 0 var(--nc, var(--accent));
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .2s;
}
.node:hover, .node:focus-visible {
  outline: none;
  transform: translateX(-50%) translate(-2px, -2px);
  box-shadow: inset 7px 0 0 var(--nc, var(--accent)), 4px 4px 0 var(--shadow-color);
}
/* available: ready to start - lifted off the page */
.node.available { box-shadow: inset 7px 0 0 var(--nc), 3px 3px 0 var(--shadow-color); }

/* completed: teal card with a stamped check */
.node.completed {
  background: var(--node-done-bg); color: var(--node-done-tx);
  border-color: var(--done);
  box-shadow: inset 7px 0 0 var(--done);
}
.node.completed::after {
  content: "✓";
  position: absolute; top: -10px; right: -10px;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
  color: var(--on-ink); background: var(--done);
  border: 2px solid var(--bg);
}

/* Locked = prerequisites not done yet. A dashed outline shows the recommended
   order, but it's still a normal link: it lights up on hover and opens. */
.node.locked {
  opacity: .62;
  border-style: dashed; border-color: var(--muted);
  box-shadow: inset 7px 0 0 color-mix(in srgb, var(--nc) 45%, transparent);
}
.node.locked:hover, .node.locked:focus-visible { opacity: 1; border-color: var(--ink); }

/* The graph builds itself: rows appear one after another (--d = row, set by graph.js).
   "backwards" fill only covers the delay, so hover transforms work afterwards. */
.node { animation: node-in .45s cubic-bezier(.2, .8, .3, 1.2) backwards; animation-delay: calc(var(--d, 0) * 110ms + 80ms); }
@keyframes node-in { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.96); } }
.edge { animation: edge-in .5s ease backwards; animation-delay: calc(var(--d, 0) * 110ms + 60ms); }
@keyframes edge-in { from { opacity: 0; } }

/* "Start here" for newcomers: a soft ring breathing around the starting topics */
.node.pulse::before {
  content: ""; position: absolute; inset: -7px;
  border: 2px solid var(--nc); border-radius: 7px;
  animation: start-pulse 2.2s ease-out 1s infinite;
  pointer-events: none;
}
@keyframes start-pulse {
  0%   { opacity: .7; transform: scale(.97); }
  70%  { opacity: 0;  transform: scale(1.08); }
  100% { opacity: 0;  transform: scale(1.08); }
}

/* ── Edges: pencil lines ── */
.edge {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  transition: stroke .2s, stroke-width .2s;
}
.edge.done { stroke: var(--done); stroke-dasharray: none; stroke-width: 2.25; }
.edge.lit  { stroke: var(--accent); stroke-dasharray: none; stroke-width: 2.5; }

/* ── Legend ── */
#legend {
  position: absolute; bottom: -50px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 22px;
  font-family: var(--font-mono); font-size: 11px; color: var(--faint);
  white-space: nowrap;
}
.leg-item { display: flex; align-items: center; gap: 7px; }
.leg-dot { width: 12px; height: 12px; border-radius: 2px; border: 1.5px solid var(--ink); }
.leg-dot.completed { background: var(--done); border-color: var(--done); }
.leg-dot.available { background: var(--surface); box-shadow: 2px 2px 0 var(--shadow-color); }
.leg-dot.locked    { background: transparent; border-style: dashed; border-color: var(--muted); }

/* ── Level bar: language + level tabs ── */
.level-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.lang-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text);
  padding-right: 16px; border-right: 1px solid var(--border);
}
.lang-chip i { font-size: 18px; color: var(--accent); }
.lang-chip:hover { color: var(--accent); }
.level-tabs { display: flex; gap: 6px; }
.level-tab {
  font-family: var(--font-mono); font-size: 12px; color: var(--faint);
  padding: 5px 11px; border-radius: 4px;
  border: 1.5px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.level-tab:hover { color: var(--text); border-color: var(--border); }
.level-tab.active { color: var(--on-ink); background: var(--ink); border-color: var(--ink); }
.level-num { font-weight: 600; }
.level-desc { font-size: 13px; color: var(--faint); }

/* ── Level guide (indexable content below the graph) ── */
.level-guide {
  max-width: 820px; margin: 0 auto; padding: 56px 24px 72px;
  color: var(--body-text); font-size: 17px; line-height: 1.75;
}
.level-guide h1 {
  font-family: var(--font-display); font-size: clamp(30px, 4vw, 42px); font-weight: 600;
  line-height: 1.12; letter-spacing: -0.02em; color: var(--text); margin-bottom: 20px;
}
.level-guide h2 {
  font-family: var(--font-display); font-size: 25px; font-weight: 600; color: var(--text);
  margin: 48px 0 18px; padding-top: 22px; border-top: 1px solid var(--border);
}
.guide-intro p { margin-bottom: 15px; }
.guide-intro strong { color: var(--text); font-weight: 600; }
.guide-intro em { font-family: var(--font-display); font-style: italic; }
.guide-intro code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--inline-code-bg); color: var(--inline-code-fg);
  padding: 1px 5px; border-radius: 3px;
}

/* Exercise list: a numbered table of contents */
.guide-list { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.guide-card {
  display: flex; gap: 20px; align-items: baseline;
  padding: 18px 8px 18px 4px;
  border-bottom: 1px solid var(--border);
  transition: background .15s, padding .15s;
}
.guide-card:hover { background: var(--surface); padding-left: 12px; }
.guide-num {
  flex-shrink: 0; width: 34px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--accent);
}
.guide-num::before { content: "0"; }
.guide-list li:nth-child(n+10) .guide-num::before { content: ""; }
.guide-body { display: flex; flex-direction: column; gap: 2px; }
.guide-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--text); line-height: 1.25; }
.guide-sub { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.guide-desc { font-size: 15.5px; line-height: 1.6; margin-top: 6px; }
.guide-req { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* FAQ: question in Fraunces, answer indented with an ink rule */
.guide-faq dt {
  font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--text);
  margin-top: 26px;
}
.guide-faq dd { margin-top: 8px; padding-left: 16px; border-left: 2px solid var(--marker); }
