/* Resource Wheel, /dc/code/<code> navigation component.
   Ships with the SSR list styled first; the radial wheel is added by
   /js/resource-wheel.js and only ever appears on wide viewports.

   Colour rule (mission-level, not cosmetic): this palette is deliberately
   DISJOINT from the secondary-condition graph's grant-rate scale on the same
   page. No red, no amber, and the one green sits far from that scale's
   success green, so a navigation colour can never be read as an outcome. */

:root {
  --rw-core: #1f4a85;
  --rw-evidence: #0f766e;
  --rw-ratings: #b07a1f;
  --rw-secondary: #6d5bd0;
  --rw-linked: #2a6f97;
  --rw-research: #8a3d6b;
}
:root[data-theme="dark"] {
  --rw-core: #7fb0f0;
  --rw-evidence: #4dbfb2;
  --rw-ratings: #e8b54a;
  --rw-secondary: #a99af0;
  --rw-linked: #6bb6de;
  --rw-research: #e08ac0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rw-core: #7fb0f0;
    --rw-evidence: #4dbfb2;
    --rw-ratings: #e8b54a;
    --rw-secondary: #a99af0;
    --rw-linked: #6bb6de;
    --rw-research: #e08ac0;
  }
}

.rw {
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
}
.rw-h {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.25rem;
  color: var(--color-primary);
  margin: 0 0 .2rem;
  text-align: center;
}
.rw-i {
  text-align: center;
  color: var(--color-text-muted);
  font-size: .9rem;
  max-width: var(--prose-measure, 68ch);
  margin: 0 auto 1rem;
}

/* ---- view toggle (added by JS only, so no dead control without it) ---- */
.rw-views { display: flex; gap: .5rem; justify-content: center; margin-bottom: 1rem; }
.rw-views button {
  min-height: 44px;
  padding: .4rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
}
.rw-views button[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}
.rw-views button:hover { border-color: var(--color-primary); }

/* ---- the wheel ---- */
/* The view toggle hides one half with the `hidden` attribute, and a display
   rule on the element itself would beat that attribute. Both views were on
   screen at once until this landed. */
.rw [hidden] { display: none !important; }
.rw-stage { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: center; }
@media (max-width: 900px) { .rw-stage { grid-template-columns: minmax(0, 1fr); } }
.rw-svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
/* Labels never take the click themselves; the .rw-hit rect behind each node
   covers the circle and the label together and receives it instead. */
.rw-svg text { font-family: inherit; paint-order: stroke; pointer-events: none; }
.rw-hit { fill: transparent; pointer-events: all; }
.rw-node { cursor: pointer; }
.rw-node:focus { outline: none; }
.rw-node:focus-visible .rw-shape { stroke: var(--color-text); stroke-width: 4; }
.rw-leaf { transition: opacity .18s; }
@media (prefers-reduced-motion: reduce) { .rw-leaf { transition: none; } }

.rw-detail {
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 190px;
}
.rw-detail h3 { margin: 0 0 .2rem; font-size: 1rem; color: var(--color-primary); }
.rw-detail .rw-kind {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted);
}
.rw-detail p { font-size: .88rem; line-height: 1.55; margin: .5rem 0 .75rem; }
.rw-detail a.rw-go {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  padding: 0 1rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-on-accent, #06162a);
  background: var(--color-accent);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
}
.rw-detail a.rw-go:hover, .rw-detail a.rw-go:focus-visible { border-color: var(--color-primary); }

/* ---- the list, which is what SSR renders and phones keep ---- */
.rw-cat {
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md);
  margin-bottom: .6rem;
  overflow: hidden;
  background: var(--color-surface);
}
.rw-cat > summary {
  min-height: 52px;
  padding: .85rem 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--color-text);
  list-style: none;
}
.rw-cat > summary::-webkit-details-marker { display: none; }
.rw-cat > summary:hover { border-color: var(--color-primary); }
.rw-cat > summary:focus-visible { outline: 3px solid var(--color-primary); outline-offset: -3px; }
.rw-count { color: var(--color-text-muted); font-weight: 500; margin-left: auto; white-space: nowrap; }
.rw-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; background: var(--rw-core); }
.rw-cat[data-rw-theme="core"] .rw-dot { background: var(--rw-core); }
.rw-cat[data-rw-theme="evidence"] .rw-dot { background: var(--rw-evidence); }
.rw-cat[data-rw-theme="ratings"] .rw-dot { background: var(--rw-ratings); }
.rw-cat[data-rw-theme="secondary"] .rw-dot { background: var(--rw-secondary); }
.rw-cat[data-rw-theme="linked"] .rw-dot { background: var(--rw-linked); }
.rw-cat[data-rw-theme="research"] .rw-dot { background: var(--rw-research); }

.rw-items { list-style: none; margin: 0; padding: .35rem .75rem .85rem; background: var(--color-bg-alt); }
.rw-items li { margin: .45rem 0; }
/* Grid item min-width is auto, so a long unbroken condition name would scroll
   the whole phone sideways without this pair. */
.rw-item {
  display: block;
  padding: .6rem .7rem;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  overflow-wrap: anywhere;
}
.rw-item:hover, .rw-item:focus-visible { border-color: var(--color-primary); }
.rw-item-t { display: block; font-weight: 700; color: var(--color-primary); font-size: .95rem; }
.rw-item-d { display: block; font-size: .82rem; color: var(--color-text-muted); line-height: 1.45; }
