/* Learning roadmaps: the map, topic drawer, progress bar and quizzes.
   Used by roadmaps/*.html together with assets/js/roadmap.js. Colours come from the tokens in style.css. */

.rm-head { padding: 28px 0 8px; }
.rm-head h1 { margin-bottom: 8px; }
.rm-head p { color: var(--muted); max-width: 760px; margin: 0; }

/* ---------- Progress bar and toolbar ---------- */
.rm-bar {
  position: sticky; top: 57px; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin: 18px 0 8px; box-shadow: 0 4px 16px rgba(0,0,0,.04);
}
.rm-bar-top { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.rm-pct { font: 700 1.5rem/1 var(--mono); min-width: 3.2em; }
.rm-progress { flex: 1 1 200px; min-width: 160px; }
.rm-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; }
.rm-track span { display: block; height: 100%; transition: width .3s; }
.rm-track .done { background: var(--ok); }
.rm-track .doing { background: var(--accent); opacity: .55; }
.rm-sub { color: var(--muted); font-size: .82rem; margin-top: 5px; }
.rm-actions { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
#rm-continue { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.rm-content [id], .rm-quiz { scroll-margin-top: 170px; }
.rm-bar .segmented { flex-wrap: wrap; }
.rm-bar-bottom { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.rm-legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .78rem; margin-left: auto; }
.rm-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid var(--border); vertical-align: -2px; margin-right: 4px; background: var(--surface); }
.rm-legend .l-done { background: var(--ok-soft); border-color: var(--ok); }
.rm-legend .l-doing { border-color: var(--accent); background: var(--accent-soft); }
.rm-legend .l-opt { border-style: dashed; }
.rm-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); margin: 12px 0; font-size: .92rem; }

/* ---------- The map ---------- */
.rm-map { position: relative; padding: 8px 0 24px; }
.rm-map::before {                                 /* the spine */
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px;
  background: linear-gradient(var(--accent), var(--border) 92%); border-radius: 3px; opacity: .55;
}
.rm-stage-head {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; width: fit-content; max-width: 100%;
  margin: 26px auto 16px; padding: 8px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: .95rem;
}
.rm-stage-head:first-child { margin-top: 4px; }
.rm-stage-head .lvl { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.rm-stage-head .cnt { font: 600 .78rem var(--mono); opacity: .75; }
.rm-nodes { display: grid; grid-template-columns: 1fr 1fr; column-gap: 76px; row-gap: 12px; }
.rm-node {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px;
  padding: 9px 12px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border); border-radius: 10px;
  font: 500 .92rem/1.3 var(--sans); transition: border-color .15s, transform .15s, opacity .2s, background .2s;
}
.rm-node:hover { border-color: var(--accent); transform: translateY(-1px); }
.rm-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rm-node::after {                                 /* connector to the spine */
  content: ""; position: absolute; top: 50%; width: 38px; height: 2px; background: var(--border);
}
.rm-node.left::after { left: 100%; }
.rm-node.right::after { right: 100%; }
.rm-node .t { flex: 1; min-width: 0; }
.rm-node .m { color: var(--muted); font: 500 .72rem var(--mono); white-space: nowrap; }
.rm-node .s {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border);
  display: grid; place-items: center; font-size: .75rem; color: transparent;
}
.rm-node.optional { border-style: dashed; }
.rm-node.doing { border-color: var(--accent); }
.rm-node.doing .s { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.rm-node.done { background: var(--ok-soft); border-color: var(--ok); }
.rm-node.done .s { background: var(--ok); border-color: var(--ok); color: #fff; }
.rm-node.done .t { color: var(--ok); }
.rm-node.dim { opacity: .32; }
.rm-node.next { box-shadow: 0 0 0 3px var(--accent-soft); }
.rm-node.next .m::before { content: "next · "; color: var(--accent); }

@media (max-width: 680px) {
  .rm-map::before { left: 13px; }
  .rm-stage-head { margin-left: 0; }
  .rm-nodes { grid-template-columns: 1fr; padding-left: 34px; }
  .rm-node.left::after, .rm-node.right::after { left: auto; right: 100%; width: 21px; }
  .rm-bar { position: static; padding: 10px 12px; }
  .rm-actions { width: 100%; }
  #rm-continue { flex: 1 1 100%; }
  .rm-content [id], .rm-quiz { scroll-margin-top: 70px; }
  .rm-stage-head .lvl { display: none; }
  .rm-legend { margin-left: 0; }
}

/* ---------- Topic drawer ---------- */
.rm-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; opacity: 0; transition: opacity .2s; }
.rm-backdrop.show { opacity: 1; }
.rm-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -10px 0 40px rgba(0,0,0,.15);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease;
}
.rm-drawer.show { transform: none; }
.rm-drawer-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.rm-drawer-head .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.rm-drawer-head h2 { margin: 6px 0 8px; font-size: 1.3rem; }
.rm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rm-chip { font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.rm-chip.cert { background: var(--accent-soft); color: var(--accent); }
.rm-status { display: flex; margin-top: 12px; }
.rm-status button { flex: 1; }
.rm-status button.active[data-status="done"] { background: var(--ok); color: #fff; }
.rm-drawer-body { flex: 1; overflow: auto; padding: 4px 18px 18px; }
.rm-drawer-body > p { margin: 10px 0; }
.rm-drawer-foot { display: flex; gap: 8px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); }
.rm-drawer-foot .btn { flex: 1; }
@media (max-width: 680px) {
  .rm-drawer { top: auto; height: 88vh; width: 100%; border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; transform: translateY(100%); }
}

/* ---------- Topic content (shared by the drawer and the detailed list) ---------- */
.rm-topic h4, .rm-drawer-body h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.rm-checklist { list-style: none; padding: 0; margin: 0; }
.rm-checklist li { margin: 0; }
.rm-checklist label { display: flex; gap: 9px; align-items: flex-start; padding: 5px 0; cursor: pointer; color: var(--text); font-size: .92rem; font-weight: 400; margin: 0; }
.rm-checklist input { margin-top: 3px; flex: none; accent-color: var(--ok); }
.rm-checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.rm-resources { padding-left: 18px; margin: 0; }
.rm-resources li { margin: 4px 0; }
.rm-resources .kind { color: var(--muted); font-size: .78rem; margin-left: 4px; }
.rm-practice { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 8px; margin: 0; }
.rm-problems { list-style: none; padding: 0; margin: 0; }
.rm-problems label { display: flex; gap: 9px; align-items: flex-start; padding: 4px 0; cursor: pointer; color: var(--text); font-size: .92rem; font-weight: 400; margin: 0; }
.rm-problems label > span { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.rm-problems input { margin-top: 3px; flex: none; accent-color: var(--ok); }
.rm-problems input:checked + span a { color: var(--muted); text-decoration: line-through; }
.rm-diff { flex: none; font-size: .7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.rm-diff.easy { color: var(--ok); background: var(--ok-soft); }
.rm-diff.medium { color: var(--warn); background: var(--surface-2); }
.rm-diff.hard { color: var(--err); background: var(--err-soft); }
.rm-solved { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ok); margin-left: 6px; }
.rm-solved:empty { display: none; }
.rm-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.rm-tools a { display: inline-block; font-size: .82rem; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; }
.rm-tools a:hover { border-color: var(--accent); }

/* ---------- Detailed list below the map ---------- */
.rm-content { margin-top: 40px; }
.rm-content > h2.rm-detail-title { margin-bottom: 4px; }
.rm-stage { margin-top: 28px; }
.rm-stage > h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rm-stage > h2 .lvl { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.rm-stage > p { color: var(--muted); }
.rm-topic { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px 16px; margin: 12px 0; }
.rm-topic[data-optional] { border-style: dashed; }
.rm-topic > h3 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 1.08rem; }
.rm-topic.is-done > h3::before { content: "✓"; color: #fff; background: var(--ok); width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; }
.rm-topic .rm-meta { color: var(--muted); font-size: .8rem; margin: 0 0 8px; }
.rm-topic p { margin: 8px 0; }
.rm-open { margin-left: auto; }

/* ---------- Stage quiz ---------- */
.rm-quiz { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
.rm-quiz > h3 { margin: 0 0 4px; font-size: 1.05rem; }
.rm-quiz .score { color: var(--muted); font-size: .88rem; }
.rm-q { margin-top: 14px; }
.rm-q > p { font-weight: 600; margin: 0 0 6px; }
.rm-q ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rm-q ol button {
  width: 100%; text-align: left; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: 400 .9rem/1.4 var(--sans); cursor: pointer;
}
.rm-q ol button:hover:not(:disabled) { border-color: var(--accent); }
.rm-q ol button:disabled { cursor: default; }
.rm-q ol button.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.rm-q ol button.wrong { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.rm-q > p.rm-why { font-size: .88rem; font-weight: 400; color: var(--muted); margin: 6px 0 0; }
.js .rm-why { display: none; }
.js .rm-q.answered .rm-why { display: block; }

@media print {
  .site-header, .site-footer, .rm-bar, .rm-map, .rm-drawer, .rm-backdrop, .rm-open, .rm-banner, .rm-quiz { display: none !important; }
  .rm-topic { break-inside: avoid; border-color: #ccc; }
  .rm-content { margin-top: 0; }
}
