/* graph: SVG renderer for AS paths (js/lib/graph.js). Ink, paper and hairlines only. */

.g-root { position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); overflow: hidden; }

/* toolbar + legend (bar itself is RTL) */
.g-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding-block: 8px; padding-inline: 14px 8px; border-block-end: 1px solid var(--line); }
.g-tools { display: flex; gap: 6px; flex: 0 0 auto; }
.g-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-width: 0;
  font-size: .82rem; color: var(--text-2); line-height: 1.7; }
.g-legend li { display: inline-flex; align-items: center; gap: 8px; }
.g-legend-note { color: var(--text-2); }
.g-sep { display: inline-block; inline-size: 1px; block-size: 14px; margin-inline: 10px; background: var(--line); vertical-align: middle; }
.g-sw { inline-size: 28px; block-size: 10px; flex: 0 0 auto; }
.g-sw-line { stroke: var(--hair-2); stroke-width: 1.5; }
.g-sw-line.is-mor { stroke: var(--strong); stroke-width: 3.5; }
.g-sw-line.is-backup { stroke: var(--text-2); stroke-width: 1.8; stroke-dasharray: 5 3; }

/* stage */
.g-stage { position: relative; flex: 1 1 auto; min-height: 0; background: var(--white); }
.g-svg { display: block; inline-size: 100%; cursor: grab; touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.g-svg:not([height]) { block-size: clamp(320px, 58vh, 420px); }
.is-panning .g-svg { cursor: grabbing; }

.g-tip { position: absolute; inset-inline: 12px; inset-block-end: 12px; margin-inline: auto; inline-size: fit-content;
  max-inline-size: calc(100% - 24px); padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--header-glass); border: 1px solid var(--hair-2); box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-size: .82rem; font-weight: 700; color: var(--text); pointer-events: none; text-align: center; }

/* edges */
.g-e { fill: none; stroke: var(--hair-2); stroke-linecap: round; }
.g-e.is-backup { stroke: var(--text-2); stroke-dasharray: 6 4; }
.g-e.is-mor { stroke: var(--strong); }
.g-mk path { fill: var(--hair-2); }
.g-mk-backup path { fill: var(--text-2); }
.g-mk-mor path { fill: var(--strong); }

.g-el-bg { fill: var(--white); stroke: var(--line); stroke-width: 1; }
.g-el-t { fill: var(--text-2); font: 600 10px/1 var(--font-mono); }
.g-el.is-mor .g-el-t { fill: var(--strong); font-weight: 700; }

/* nodes */
.g-n { cursor: default; outline: none; }
.g-n[tabindex] { cursor: pointer; }
.g-box { fill: var(--input); stroke: var(--hair-2); stroke-width: 1; }
.g-t1 { fill: var(--strong); font: 700 12px/1 var(--font-mono); }
.g-t2 { fill: var(--muted-ink); font: 500 10.5px/1 var(--font); }

.g-n-set .g-box { fill: var(--white); stroke-dasharray: 4 3; }
.g-n-set .g-t1 { font-weight: 600; fill: var(--text); }
.g-n-prefix .g-box { fill: var(--chip-bg); stroke: var(--strong); stroke-width: 1.5; }
.g-n-prefix .g-t1 { font-size: 12.5px; }
.g-n-prefix.is-matched .g-box { fill: var(--strong); }
.g-n-prefix.is-matched .g-t1 { fill: var(--paper); }
.g-n.is-origin .g-box, .g-n.is-mor .g-box { stroke: var(--strong); stroke-width: 2; }
.g-n.is-focus .g-box { fill: var(--strong); stroke: var(--strong); stroke-width: 2; }
.g-n.is-focus .g-t1, .g-n.is-focus .g-t2 { fill: var(--paper); }

.g-n[tabindex]:hover .g-box { stroke: var(--text); }
.g-n:focus-visible .g-box { stroke: var(--text); stroke-width: 3; }

/* hover / focus: related paths stay, the rest fades */
.is-hl .g-e:not(.is-on), .is-hl .g-n:not(.is-on), .is-hl .g-el:not(.is-on) { opacity: .16; }
.is-hl .g-e.is-on:not(.is-mor):not(.is-backup) { stroke: var(--text-2); }

@media (prefers-reduced-motion: no-preference) {
  .g-e, .g-n, .g-el { transition: opacity var(--dur-hover) var(--ease); }
}

/* full screen (native API, or the fixed fallback) */
.g-root:fullscreen { border-radius: 0; border: 0; inline-size: 100%; block-size: 100%; }
.g-root.is-full { position: fixed; inset: 0; z-index: 95; border-radius: 0; border: 0; }
.g-root:fullscreen .g-svg, .g-root.is-full .g-svg { block-size: 100%; position: absolute; inset: 0; touch-action: none; }
.g-root:fullscreen .g-stage, .g-root.is-full .g-stage { flex: 1 1 auto; }
.g-root::backdrop { background: var(--paper); }

@media (max-width: 560px) {
  .g-bar { padding-inline: 10px 6px; }
  .g-legend-note { display: none; }
  .g-svg:not([height]) { block-size: 340px; }
}
