/* ==========================================================================
   MetalSharp: graphics routes on the landing page. Hairline panels, one
   soft color per route, and a flow diagram whose wires carry small light
   pulses (added by pages.js) into a Metal chip. Motion runs only while the
   section is on screen and stops under prefers-reduced-motion.
   ========================================================================== */

.rt-section {
  --r-mullion: #8fd2ff;
  --r-vkd3d: #b6a8ff;
  --r-d3dmetal: #d6dce8;
  --r-opengl: #f2a6d6;
  background: radial-gradient(50% 40% at 50% 0%, rgba(110, 130, 230, 0.07), transparent 70%);
}

/* ── Runtimes ────────────────────────────────────────────────────────── */
.rt-runtimes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.rt-runtime { display: grid; align-content: start; gap: 0.7rem; padding: clamp(1.4rem, 3vw, 2.2rem); background: rgba(11, 15, 23, 0.6); }
.rt-runtime + .rt-runtime { border-left: 1px solid var(--line); }
.rt-code { color: var(--accent); font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; }
.rt-runtime h3 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); font-weight: 600; letter-spacing: -0.035em; }
.rt-runtime > p:not(.rt-code):not(.rt-file) { color: var(--muted); font-size: 0.97rem; line-height: 1.6; }
.rt-runtime a { color: var(--text-soft); text-decoration-color: var(--line-strong); }
.rt-runtime a:hover { color: var(--text); }
.rt-specs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0.6rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.rt-specs dt { color: var(--dim); font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; }
.rt-specs dd { margin: 0.3rem 0 0; color: var(--text); font-family: var(--font-mono); font-size: 0.86rem; }
.rt-file { margin-top: 0.3rem; color: var(--dim); font-family: var(--font-mono); font-size: 0.72rem; }

/* ── Flow diagram ────────────────────────────────────────────────────── */
.rt-flow {
  margin: 1.2rem 0 0;
  padding: clamp(1.1rem, 2.6vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(45% 60% at 88% 50%, rgba(120, 140, 240, 0.09), transparent 70%),
    rgba(11, 15, 23, 0.6);
}
.rt-flow-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.6rem; }
.rt-flow figcaption { color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }
.rt-flow-scroll { position: relative; max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.rt-flow svg { display: block; width: 100%; min-width: 700px; height: auto; overflow: visible; }

.rt-col-label { fill: var(--dim); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }

.rt-edge { fill: none; stroke-width: 1.2; stroke-linecap: round; transition: stroke 0.25s, stroke-width 0.25s, opacity 0.25s; }
.rt-edge[data-r="mullion"] { stroke: color-mix(in srgb, var(--r-mullion) 34%, transparent); }
.rt-edge[data-r="vkd3d"] { stroke: color-mix(in srgb, var(--r-vkd3d) 34%, transparent); }
.rt-edge[data-r="d3dmetal"] { stroke: color-mix(in srgb, var(--r-d3dmetal) 28%, transparent); }
.rt-edge[data-r="opengl"] { stroke: color-mix(in srgb, var(--r-opengl) 34%, transparent); }

.rt-pulse { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 7 93; stroke-dashoffset: 100; filter: url(#rt-glow); opacity: 0; transition: opacity 0.25s; }
.rt-pulse[data-r="mullion"] { stroke: var(--r-mullion); }
.rt-pulse[data-r="vkd3d"] { stroke: var(--r-vkd3d); }
.rt-pulse[data-r="d3dmetal"] { stroke: var(--r-d3dmetal); }
.rt-pulse[data-r="opengl"] { stroke: var(--r-opengl); }
.rt-section.is-live .rt-pulse { opacity: 0.85; animation: rt-pulse var(--dur, 2.6s) linear infinite; animation-delay: var(--delay, 0s); }

.rt-node rect { fill: #0d121c; stroke: rgba(170, 190, 240, 0.18); stroke-width: 1; transition: stroke 0.25s, fill 0.25s, opacity 0.25s; }
.rt-node text { fill: var(--text-soft); font-family: var(--font-mono); font-size: 11.5px; text-anchor: middle; dominant-baseline: central; transition: fill 0.25s, opacity 0.25s; }
.rt-node--route { --rc: var(--text-soft); }
.rt-node--route[data-r="mullion"] { --rc: var(--r-mullion); }
.rt-node--route[data-r="vkd3d"] { --rc: var(--r-vkd3d); }
.rt-node--route[data-r="d3dmetal"] { --rc: var(--r-d3dmetal); }
.rt-node--route[data-r="opengl"] { --rc: var(--r-opengl); }
.rt-node--route rect { fill: #111724; stroke: rgba(170, 190, 240, 0.22); }
.rt-node-dot { fill: var(--rc); }
.rt-node--route text { fill: var(--text); font-family: var(--font-body); font-size: 13.5px; font-weight: 500; text-anchor: start; }
.rt-node--route .rt-node-sub { fill: var(--dim); font-family: var(--font-mono); font-size: 9.5px; font-weight: 400; }

.rt-core-body { fill: url(#rt-core-fill); stroke: url(#rt-core-stroke); stroke-width: 1.2; }
.rt-core-pins path { stroke: rgba(170, 190, 240, 0.3); stroke-width: 2; }
.rt-core-die { fill: rgba(140, 160, 255, 0.06); stroke: rgba(169, 185, 255, 0.45); stroke-width: 1; }
.rt-core-label { fill: var(--text); font-family: var(--font-mono); font-size: 16px; font-weight: 500; letter-spacing: 0.34em; text-anchor: middle; dominant-baseline: central; }
.rt-core-sub { fill: var(--accent); font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.3em; text-anchor: middle; dominant-baseline: central; }
.rt-section.is-live .rt-core-die { animation: rt-core 3.2s ease-in-out infinite; }

/* Trace one route: dim the rest, light its path. */
.rt-flow[data-focus] .rt-edge { opacity: 0.14; }
.rt-flow[data-focus] .rt-pulse { opacity: 0; }
.rt-flow[data-focus] .rt-node { opacity: 0.3; }
.rt-flow[data-focus="mullion"] [data-r~="mullion"],
.rt-flow[data-focus="vkd3d"] [data-r~="vkd3d"],
.rt-flow[data-focus="d3dmetal"] [data-r~="d3dmetal"],
.rt-flow[data-focus="opengl"] [data-r~="opengl"] { opacity: 1; }
.rt-flow[data-focus="mullion"] .rt-edge[data-r="mullion"] { stroke: var(--r-mullion); stroke-width: 1.8; }
.rt-flow[data-focus="vkd3d"] .rt-edge[data-r="vkd3d"] { stroke: var(--r-vkd3d); stroke-width: 1.8; }
.rt-flow[data-focus="d3dmetal"] .rt-edge[data-r="d3dmetal"] { stroke: var(--r-d3dmetal); stroke-width: 1.8; }
.rt-flow[data-focus="opengl"] .rt-edge[data-r="opengl"] { stroke: var(--r-opengl); stroke-width: 1.8; }
.rt-flow[data-focus="mullion"] .rt-node--route[data-r="mullion"] rect,
.rt-flow[data-focus="vkd3d"] .rt-node--route[data-r="vkd3d"] rect,
.rt-flow[data-focus="d3dmetal"] .rt-node--route[data-r="d3dmetal"] rect,
.rt-flow[data-focus="opengl"] .rt-node--route[data-r="opengl"] rect { stroke: var(--rc); }

.rt-legend { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rt-legend button {
  --rc: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 34px;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 500 0.78rem var(--font-body);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.rt-legend button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--rc); }
.rt-legend button[data-focus-route=""]::before { background: var(--accent-grad); }
.rt-legend button[data-focus-route="mullion"] { --rc: var(--r-mullion); }
.rt-legend button[data-focus-route="vkd3d"] { --rc: var(--r-vkd3d); }
.rt-legend button[data-focus-route="d3dmetal"] { --rc: var(--r-d3dmetal); }
.rt-legend button[data-focus-route="opengl"] { --rc: var(--r-opengl); }
.rt-legend button:hover { color: var(--text); border-color: var(--line-strong); }
.rt-legend button[aria-pressed="true"] { color: var(--text); border-color: color-mix(in srgb, var(--rc) 55%, transparent); background: color-mix(in srgb, var(--rc) 8%, transparent); }

/* ── Route matrix ────────────────────────────────────────────────────── */
.rt-matrix-wrap { position: relative; max-width: 100%; margin-top: 1.2rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.rt-matrix { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 0.92rem; }
.rt-matrix caption { padding: 1.1rem 1.25rem 0.3rem; color: var(--dim); font-size: 0.82rem; text-align: left; }
.rt-matrix th,
.rt-matrix td { padding: 0.95rem 1rem; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.rt-matrix thead th { white-space: nowrap; color: var(--dim); font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }
.rt-matrix thead .rt-group { padding-bottom: 0.2rem; border-bottom: 0; }
.rt-matrix thead .rt-group span { display: block; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line-strong); }
.rt-matrix tbody tr:last-child > * { border-bottom: 0; }
.rt-matrix tbody tr { --rc: var(--text); outline: none; transition: background 0.2s; }
.rt-matrix tr[data-route="mullion"] { --rc: var(--r-mullion); }
.rt-matrix tr[data-route="vkd3d"] { --rc: var(--r-vkd3d); }
.rt-matrix tr[data-route="d3dmetal"] { --rc: var(--r-d3dmetal); }
.rt-matrix tr[data-route="opengl"] { --rc: var(--r-opengl); }
.rt-matrix tbody tr:hover,
.rt-matrix tbody tr:focus-visible,
.rt-matrix tbody tr.is-focus { background: color-mix(in srgb, var(--rc) 5%, transparent); }
.rt-matrix th[scope="row"] { min-width: 15rem; text-align: left; }
.rt-matrix th[scope="row"] strong { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-size: 1rem; font-weight: 500; letter-spacing: -0.01em; }
.rt-matrix th[scope="row"] strong::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--rc); }
.rt-matrix th[scope="row"] span { display: block; margin-top: 0.2rem; padding-left: calc(6px + 0.6rem); color: var(--dim); font-size: 0.82rem; font-weight: 400; }
.rt-matrix th[scope="row"] a { color: inherit; text-decoration: none; }
.rt-matrix th[scope="row"] a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rt-matrix .rt-version { color: var(--text-soft); font-family: var(--font-mono); font-size: 0.76rem; text-align: left; white-space: nowrap; }
.rt-matrix .rt-version small { display: block; color: var(--dim); font-size: 0.7rem; }
.rt-matrix .rt-sep { border-left: 1px solid var(--line); }
.rt-yes, .rt-no { display: inline-block; vertical-align: middle; }
.rt-yes { width: 8px; height: 8px; border-radius: 50%; background: var(--rc, var(--text)); }
.rt-no { width: 10px; height: 1px; background: var(--dim); opacity: 0.55; }

/* ── Notes ───────────────────────────────────────────────────────────── */
.rt-notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 1.6rem; margin: 3rem 0 0; padding: 0; list-style: none; }
.rt-notes li { padding-top: 1.3rem; border-top: 1px solid var(--line-strong); }
.rt-notes b { color: var(--accent); font: 500 0.7rem var(--font-mono); }
.rt-notes h3 { display: inline; margin-left: 0.55rem; font-size: 1.05rem; font-weight: 500; letter-spacing: -0.015em; }
.rt-notes p { margin-top: 0.6rem; color: var(--muted); font-size: 0.95rem; line-height: 1.6; }

@keyframes rt-pulse { to { stroke-dashoffset: 0; } }
@keyframes rt-core { 50% { fill: rgba(140, 160, 255, 0.16); } }

@media (max-width: 860px) {
  .rt-runtimes, .rt-notes { grid-template-columns: minmax(0, 1fr); }
  .rt-runtime + .rt-runtime { border-left: 0; border-top: 1px solid var(--line); }
  .rt-flow-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .rt-section .rt-pulse, .rt-section .rt-core-die { animation: none !important; }
  .rt-section .rt-pulse { opacity: 0 !important; }
  .rt-edge, .rt-node rect, .rt-node text, .rt-matrix tbody tr { transition: none; }
}
