/* Google-Maps-style pan/zoom widget: #dep-graph-viewport is the fixed-size,
   clipped "window"; #dep-graph-stage is the child dependency-graph.js
   moves/scales with a CSS transform (translate() for pan, scale() for
   zoom) to slide and magnify the SVG within it. */
.dep-graph-viewport {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 6px;
  height: 70vh;
  min-height: 420px;
  cursor: grab;
  /* Panning is driven entirely by our own pointer handlers -- this stops
     the browser's default touch-scroll/pinch-zoom from fighting them on
     touchscreens. */
  touch-action: none;
  user-select: none;
}

.dep-graph-viewport.is-dragging {
  cursor: grabbing;
}

.dep-graph-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.dep-graph-stage svg {
  display: block;
}

/* Overlaid control cluster in the viewport's corner -- zoom, reset,
   optional-dependency toggle, and PNG export all live here, Google-Maps-
   style, instead of a separate toolbar row above the graph. */
.dep-graph-controls {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 1;
}

.dep-graph-controls button {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 4px;
  background: var(--sy-c-background, #fff);
  color: var(--sy-c-text, #222);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.dep-graph-controls button:hover {
  background: rgba(128, 128, 128, 0.15);
}

#dep-graph-zoom-reset,
#dep-graph-toggle-optional,
#dep-graph-export {
  font-size: 1rem;
}

/* The optional-dependency toggle's pressed/active state -- inverted like a
   standard toolbar toggle button, since it isn't a momentary action like
   the other buttons here. */
#dep-graph-toggle-optional[aria-pressed="true"] {
  background: var(--sy-c-text, #222);
  color: var(--sy-c-background, #fff);
}

/* Reference device template switch -- bottom-left corner, mirroring
   .dep-graph-controls's styling but as a horizontal segmented control
   (text-labeled buttons of unequal width) rather than a vertical icon
   stack. */
.dep-graph-template-switch {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  display: flex;
  flex-direction: row;
  gap: 0.3rem;
  z-index: 1;
}

.dep-graph-template-switch button {
  padding: 0.3rem 0.6rem;
  height: 2.1rem;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 4px;
  background: var(--sy-c-background, #fff);
  color: var(--sy-c-text, #222);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.dep-graph-template-switch button:hover {
  background: rgba(128, 128, 128, 0.15);
}

.dep-graph-template-switch button[aria-pressed="true"] {
  background: var(--sy-c-text, #222);
  color: var(--sy-c-background, #fff);
}

/* This page has no sub-headings, so the theme's right-hand "on this page"
   sidebar is always empty here -- hide it and let the article column grow
   into that space, since a ~50-node graph needs all the width it can get
   to stay legible. Scoped with :has() instead of touching custom.css
   globally, so it only ever applies on a page that actually renders this
   container. */
body:has(#dep-graph-viewport) #rside {
  display: none;
}

/* Hiding #rside above only empties its own box -- shibuya.css's ".sy-main"
   rule at the >=1280px breakpoint unconditionally reserves 34rem (18rem for
   the left nav + 16rem for #rside) regardless of whether #rside is actually
   shown, so the article column stayed narrow with a blank gap on the right.
   Reserve only the 18rem the left nav actually still uses. */
@media (min-width: 1280px) {
  body:has(#dep-graph-viewport) .sy-main {
    width: calc(100% - 18rem);
  }
}

/* ".max-w-6xl" (on this page, only the article's own content wrapper --
   checked, nothing else on this page carries the class) caps prose width
   at 1152px regardless of how much the two overrides above freed up. A
   ~50-node graph isn't prose that benefits from a comfortable line length,
   so drop the cap here and let it use the rest of the article column,
   short of its own padding. */
body:has(#dep-graph-viewport) .max-w-6xl {
  max-width: none;
}

/* The 1152px above turned out to still be capped one level up: ".sy-container"
   itself is capped at 90rem/1440px and centered (`mx-auto`) regardless of
   viewport width, so on any wider screen there was symmetric dead space on
   both sides of the whole page, not just to the right of the graph. Drop
   that cap too -- the article wrapper's own xl:px-12 padding is what's left
   to keep the graph off the very edge of the window. */
body:has(#dep-graph-viewport) .sy-container {
  max-width: none;
}

.dep-graph-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.dep-graph-legend__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dep-graph-legend__swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  border: 1px solid rgba(128, 128, 128, 0.5);
}

.dep-graph-legend__line {
  display: inline-block;
  width: 1.75rem;
  height: 0;
  border-top: 2px solid currentColor;
}

.dep-graph-legend__line--dashed {
  border-top-style: dashed;
}

/* Glow/role colors shared by the graph's node-selection highlight and the
   parameters table below it -- kept as custom properties so both follow the
   same light/dark switch shibuya drives via [data-color-mode], the same
   pattern dependency-graph.js's CATEGORY_COLORS follows in JS. */
:root {
  --dep-glow-selected: #1b2733;
  --dep-glow-ancestor: #7a5ea0;
  --dep-glow-descendant: #1f7a5c;
  --dep-role-req: #c05621;
  --dep-role-req-bg: #fbede3;
  --dep-role-out: #1f7a5c;
  --dep-role-out-bg: #e6f2ec;
  --dep-role-up: #7a5ea0;
  --dep-role-up-bg: #f0ebf6;
  --dep-role-fine: #1f5fa8;
  --dep-role-fine-bg: #e6f0fa;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-color-mode="light"]) {
    --dep-glow-selected: #ffffff;
    --dep-glow-ancestor: #a98fcb;
    --dep-glow-descendant: #4caf8c;
    --dep-role-req: #e08050;
    --dep-role-req-bg: #33231a;
    --dep-role-out: #4caf8c;
    --dep-role-out-bg: #162c24;
    --dep-role-up: #a98fcb;
    --dep-role-up-bg: #241e2e;
    --dep-role-fine: #6fa8dc;
    --dep-role-fine-bg: #16283d;
  }
}
:root[data-color-mode="dark"] {
  --dep-glow-selected: #ffffff;
  --dep-glow-ancestor: #a98fcb;
  --dep-glow-descendant: #4caf8c;
  --dep-role-req: #e08050;
  --dep-role-req-bg: #33231a;
  --dep-role-out: #4caf8c;
  --dep-role-out-bg: #162c24;
  --dep-role-up: #a98fcb;
  --dep-role-up-bg: #241e2e;
  --dep-role-fine: #6fa8dc;
  --dep-role-fine-bg: #16283d;
}

/* ---------- search bar ---------- */
.dep-graph-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.8rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 8px;
  background: var(--sy-c-background, #fff);
  color: var(--sy-c-text, #222);
}
.dep-graph-search:focus {
  outline: 2px solid var(--dep-glow-ancestor);
  outline-offset: -1px;
}

/* ---------- node/edge click-selection: fade + colored glow ---------- */
.dep-graph-stage svg .node {
  cursor: pointer;
  transition: opacity 120ms ease;
}
.dep-graph-stage svg .node.dep-node--faded {
  opacity: 0.28;
}
.dep-graph-stage svg .node.dep-node--selected path,
.dep-graph-stage svg .node.dep-node--selected polygon {
  stroke: var(--dep-glow-selected);
  stroke-width: 3px;
  filter: drop-shadow(0 0 6px var(--dep-glow-selected));
}
.dep-graph-stage svg .node.dep-node--ancestor path,
.dep-graph-stage svg .node.dep-node--ancestor polygon {
  stroke: var(--dep-glow-ancestor);
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 5px var(--dep-glow-ancestor));
}
.dep-graph-stage svg .node.dep-node--descendant path,
.dep-graph-stage svg .node.dep-node--descendant polygon {
  stroke: var(--dep-glow-descendant);
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 5px var(--dep-glow-descendant));
}
.dep-graph-stage svg .edge {
  transition: opacity 120ms ease;
}
.dep-graph-stage svg .edge.dep-edge--faded {
  opacity: 0.15;
}
.dep-graph-stage svg .edge.dep-edge--ancestor path {
  stroke: var(--dep-glow-ancestor);
}
.dep-graph-stage svg .edge.dep-edge--ancestor polygon {
  fill: var(--dep-glow-ancestor);
  stroke: var(--dep-glow-ancestor);
}
.dep-graph-stage svg .edge.dep-edge--descendant path {
  stroke: var(--dep-glow-descendant);
}
.dep-graph-stage svg .edge.dep-edge--descendant polygon {
  fill: var(--dep-glow-descendant);
  stroke: var(--dep-glow-descendant);
}

/* ---------- calibration parameters panel ---------- */
.dep-params-panel {
  margin-top: 1rem;
}
.dep-params-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.dep-params-controls {
  display: flex;
  gap: 0.4rem;
}
.dep-params-controls button {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 6px;
  background: var(--sy-c-background, #fff);
  color: var(--sy-c-text, #222);
  cursor: pointer;
}
.dep-params-controls button:hover {
  background: rgba(128, 128, 128, 0.15);
}
.dep-params-controls button[aria-pressed="true"] {
  background: var(--sy-c-text, #222);
  color: var(--sy-c-background, #fff);
}
.dep-params-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.82rem;
  color: var(--sy-c-text, #222);
  opacity: 0.75;
}
.dep-params-legend__item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.dep-params-legend__swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  border: 1px solid rgba(128, 128, 128, 0.5);
}
.dep-params-legend__swatch--req {
  background: var(--dep-role-req-bg);
  border-color: var(--dep-role-req);
}
.dep-params-legend__swatch--out {
  background: var(--dep-role-out-bg);
  border-color: var(--dep-role-out);
}
.dep-params-legend__swatch--up {
  background: var(--dep-role-up-bg);
  border-color: var(--dep-role-up);
}
.dep-params-legend__swatch--fine {
  background: var(--dep-role-fine-bg);
  border-color: var(--dep-role-fine);
}
.dep-params-body {
  font-size: 0.9rem;
}
.dep-params-hint {
  color: var(--sy-c-text, #222);
  opacity: 0.7;
}
.dep-params-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.dep-params-name {
  font-size: 1.05rem;
  font-weight: 650;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.dep-params-cat {
  font-size: 0.82rem;
  opacity: 0.7;
}
.dep-params-doclink {
  font-size: 0.82rem;
  margin-left: auto;
}
.dep-params-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.dep-params-pill {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(128, 128, 128, 0.4);
}
.dep-params-pill--up {
  background: var(--dep-role-up-bg);
  border-color: var(--dep-role-up);
  color: var(--dep-role-up);
}
.dep-params-pill--req {
  background: var(--dep-role-req-bg);
  border-color: var(--dep-role-req);
  color: var(--dep-role-req);
}
.dep-params-pill--out {
  background: var(--dep-role-out-bg);
  border-color: var(--dep-role-out);
  color: var(--dep-role-out);
}
.dep-params-pill--fine {
  background: var(--dep-role-fine-bg);
  border-color: var(--dep-role-fine);
  color: var(--dep-role-fine);
}
.dep-params-note {
  font-size: 0.82rem;
  opacity: 0.75;
  margin: 0.4rem 0;
}
.dep-params-tablewrap {
  overflow-x: auto;
  margin-top: 0.6rem;
}
.dep-params-tablewrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}
.dep-params-tablewrap th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.4);
  background: var(--sy-c-background, #fff);
}
.dep-params-tablewrap td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
  vertical-align: top;
}
.dep-params-grouprow td {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  background: rgba(128, 128, 128, 0.08);
}
.dep-params-field {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.dep-params-hash {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  opacity: 0.7;
  font-size: 0.8rem;
  white-space: nowrap;
}
.dep-params-role {
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.8rem;
}
.dep-params-also {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.7;
}
.dep-params-source {
  font-size: 0.8rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  opacity: 0.8;
}
tr.dep-params-row--req td:first-child {
  box-shadow: inset 3px 0 0 var(--dep-role-req);
}
tr.dep-params-row--out td:first-child {
  box-shadow: inset 3px 0 0 var(--dep-role-out);
}
tr.dep-params-row--up td:first-child {
  box-shadow: inset 3px 0 0 var(--dep-role-up);
}
tr.dep-params-row--fine td:first-child {
  box-shadow: inset 3px 0 0 var(--dep-role-fine);
}
tr.dep-params-row--req {
  background: var(--dep-role-req-bg);
}
tr.dep-params-row--out {
  background: var(--dep-role-out-bg);
}
tr.dep-params-row--up {
  background: var(--dep-role-up-bg);
}
tr.dep-params-row--fine {
  background: var(--dep-role-fine-bg);
}
tr.dep-params-row--req .dep-params-role {
  color: var(--dep-role-req);
}
tr.dep-params-row--out .dep-params-role {
  color: var(--dep-role-out);
}
tr.dep-params-row--up .dep-params-role {
  color: var(--dep-role-up);
}
tr.dep-params-row--fine .dep-params-role {
  color: var(--dep-role-fine);
}
tr.dep-params-row--dim {
  opacity: 0.55;
}
