/* ============================================================
   Macrobase System — shared pieces for the service pages.
   Builds on the tokens and components in site.css; page-only
   styles live in assets/svc/<page>.css
   ============================================================ */

/* ---------- demo shell (inside .mock) ---------- */
.demo-pane { display: flex; flex-direction: column; gap: 14px; padding: 18px; min-width: 0; container-type: inline-size; }
.demo-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.demo-cols--wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
@container (max-width: 520px) {
  .demo-cols, .demo-cols--wide-left { grid-template-columns: minmax(0, 1fr); }
}
.demo-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.demo-note { font-size: 12px; line-height: 1.55; color: var(--muted); }
.demo-status { min-height: 18px; font-size: 12px; color: var(--success-text); }

/* ---------- chips (single- or multi-select buttons) ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--muted);
  font-family: var(--font-body); font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.chip-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.chip-btn.active, .chip-btn[aria-pressed="true"], .chip-btn[aria-selected="true"] {
  color: var(--on-accent); background: var(--accent); border-color: transparent; font-weight: 600;
}
.chip-btn.active:hover, .chip-btn[aria-pressed="true"]:hover, .chip-btn[aria-selected="true"]:hover { color: var(--on-accent); background: var(--accent-hover); }

/* ---------- option rows (checkbox / toggle lists) ---------- */
.opt-list { display: grid; gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 12.5px; color: var(--fg); cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.opt:hover { border-color: var(--border-strong); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-surface); }
.opt input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; cursor: pointer; }
.opt .opt-meta { margin-left: auto; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; }

/* ---------- key/value sheet + meters ---------- */
.sheet { display: grid; gap: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.sheet-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 12px; font-size: 12.5px; }
.sheet-row + .sheet-row { border-top: 1px solid var(--border); }
.sheet-row .k { color: var(--muted); }
.sheet-row .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.sheet-row .v.mono { font-weight: 500; }
.meter { height: 8px; border-radius: 999px; background: oklch(93.2% 0.006 31 / 0.08); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); box-shadow: 0 0 10px -2px var(--glow); transition: width 0.35s ease; }
.meter--ok > i { background: linear-gradient(90deg, oklch(68% 0.16 155 / 0.75), var(--success)); box-shadow: none; }
.meter--warn > i { background: linear-gradient(90deg, oklch(76% 0.15 80 / 0.75), var(--warn)); box-shadow: none; }

/* ---------- run trace (step-by-step activity list) ---------- */
.trace { display: grid; gap: 0; counter-reset: trace; }
.trace-step { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 0 0 14px; opacity: 0.38; transition: opacity 0.25s ease; }
.trace-step::before {
  counter-increment: trace; content: counter(trace);
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.trace-step::after { content: ""; position: absolute; left: 12px; top: 26px; bottom: 2px; width: 1px; background: var(--border); }
.trace-step:last-child { padding-bottom: 0; }
.trace-step:last-child::after { display: none; }
.trace-step.is-on { opacity: 1; }
.trace-step.is-on::before { border-color: var(--accent); background: var(--accent-surface); color: var(--accent-strong); }
.trace-step.is-done::before { content: "\2713"; border-color: oklch(68% 0.16 155 / 0.5); background: oklch(68% 0.16 155 / 0.14); color: var(--success-text); }
.trace-t { display: block; font-size: 13px; font-weight: 600; line-height: 1.4; }
.trace-d { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.trace-d code { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg); }

/* ---------- inline SVG figures and diagrams ---------- */
.figure {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--bg));
}
.figure > svg, .figure > img { display: block; width: 100%; height: auto; }
.figure-cap {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 11px 18px; border-top: 1px solid var(--border); background: var(--surface);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.figure-cap code { color: var(--accent-strong); }

/* shared SVG drawing classes so diagrams follow the theme */
.dg-box { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1; }
.dg-box--soft { fill: oklch(93.2% 0.006 31 / 0.03); stroke: var(--border); }
.dg-box--accent { fill: var(--accent-surface); stroke: var(--accent); }
.dg-line { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.dg-line--dash { stroke-dasharray: 4 6; }
.dg-line--accent { stroke: var(--accent-strong); }
.dg-dot { fill: var(--accent); }
.dg-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; fill: var(--fg); }
.dg-text { font-family: var(--font-body); font-size: 13px; fill: var(--muted); }
.dg-mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; fill: var(--muted); text-transform: uppercase; }
.dg-mono--accent { fill: var(--accent-strong); }

/* interactive diagram nodes */
.dg-node { cursor: pointer; }
.dg-node:focus { outline: none; }
.dg-node .dg-box { transition: stroke 0.16s ease, fill 0.16s ease; }
.dg-node:hover .dg-box, .dg-node:focus-visible .dg-box { stroke: var(--accent-strong); }
.dg-node.is-on .dg-box { fill: var(--accent-surface); stroke: var(--accent); }
.dg-node.is-on .dg-title { fill: var(--fg); }
.dg-link { fill: none; stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 4 6; transition: stroke 0.16s ease; }
.dg-link.is-on { stroke: var(--accent-strong); stroke-dasharray: 6 5; animation: dgFlow 0.9s linear infinite; }
@keyframes dgFlow { to { stroke-dashoffset: -22; } }

/* four-step variant (service pages with four stages) */
.steps--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .steps--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .steps--four { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- related services ---------- */
.related { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.related a {
  display: grid; gap: 6px; padding: 18px 20px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.related a:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.related code { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; color: var(--accent-strong); }
.related b { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.related span { font-size: 13.5px; line-height: 1.5; color: var(--muted); }

@media (max-width: 980px) {
  .related { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .related { grid-template-columns: minmax(0, 1fr); }
  .demo-pane { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .dg-link.is-on { animation: none; }
  .meter > i, .trace-step { transition: none; }
}
