/* Vault Blueprint v2 — paired with /assets/infra-canvas-v2.js */

.v2-root {
  --v2-bg:        #0a0c10;
  --v2-bg-panel:  #0f1218;
  --v2-bg-card:   #161a22;
  --v2-border:    #242935;
  --v2-border-hl: #3a4255;
  --v2-text-hi:   #f0f4f8;
  --v2-text-mid:  #8a93a6;
  --v2-text-lo:   #4f5668;
  --v2-accent:    #06b6d4;
  --v2-glow:      rgba(6, 182, 212, 0.4);
  --v2-violet:    rgba(167, 139, 250, 0.55);

  --v2-display:   'Audiowide', system-ui, sans-serif;
  --v2-sans:      'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --v2-mono:      'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--v2-bg);
  color: var(--v2-text-hi);
  font-family: var(--v2-sans);
  font-feature-settings: "ss01", "cv11";
  border: 1px solid var(--v2-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 90px rgba(6, 182, 212, 0.10),
    0 0 0 1px rgba(6, 182, 212, 0.04),
    inset 0 0 80px rgba(6, 6, 14, 0.6);
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.v2-root::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 6%, rgba(167,139,250,0.10), transparent 38%),
    radial-gradient(ellipse at 50% 32%, rgba(6,182,212,0.08), transparent 60%),
    radial-gradient(ellipse at 30% 75%, rgba(236,72,153,0.05), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* =========================================================================
 * HEADER (shared shape, modifier classes per layout)
 * ========================================================================= */

.v2-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--v2-border);
  background: linear-gradient(180deg, rgba(10,12,16,0.96), rgba(10,12,16,0.5));
}

.v2-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.v2-header-titles {
  min-width: 0;
}

.v2-blip {
  flex: 0 0 auto;
  display: inline-block;
  width: 8px; height: 8px;
  margin-top: 14px;
  border-radius: 50%;
  background: var(--v2-accent);
  box-shadow: 0 0 8px var(--v2-accent), 0 0 18px var(--v2-glow);
  animation: v2-blip 2.4s ease-in-out infinite;
}

@keyframes v2-blip {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

.v2-eyebrow {
  font-family: var(--v2-sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--v2-text-lo);
  font-weight: 500;
}

.v2-title {
  font-family: var(--v2-display);
  font-size: 22px;
  letter-spacing: 0.16em;
  color: var(--v2-text-hi);
  text-shadow: 0 0 12px var(--v2-glow);
  margin: 2px 0 4px;
  font-weight: 400;
  line-height: 1;
}

.v2-slash { color: var(--v2-accent); opacity: 0.8; margin: 0 1px; }

.v2-spec {
  font-family: var(--v2-mono);
  font-size: 11px;
  color: var(--v2-text-mid);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.v2-mheader-meta {
  font-family: var(--v2-mono);
  font-size: 11px;
  color: var(--v2-text-mid);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.v2-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.v2-verified-tag {
  font-family: var(--v2-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--v2-text-lo);
  text-transform: uppercase;
}

.v2-counts {
  font-family: var(--v2-mono);
  font-size: 11px;
  color: var(--v2-text-mid);
  text-align: right;
  white-space: nowrap;
}

/* Expand button */
.v2-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.28);
  border-radius: 5px;
  color: #d6e9f0;
  font-family: var(--v2-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.v2-expand-btn:hover,
.v2-expand-btn:focus-visible {
  background: rgba(6, 182, 212, 0.16);
  border-color: rgba(6, 182, 212, 0.55);
  color: #ffffff;
  outline: none;
}

.v2-expand-btn:active { transform: scale(0.97); }

.v2-expand-icon {
  display: inline-flex;
  width: 11px; height: 11px;
}

.v2-expand-icon svg { width: 100%; height: 100%; display: block; }

.v2-expand-btn--mobile {
  padding: 6px 8px;
  margin-left: auto;
}

.v2-expand-btn--mobile .v2-expand-icon {
  width: 16px; height: 16px;
}

.v2-root[data-layout="mobile"] .v2-expand-btn {
  font-size: 10px;
  padding: 8px 12px;
  letter-spacing: 0.14em;
}

/* =========================================================================
 * STAGE / SVG (desktop)
 * ========================================================================= */

.v2-stage {
  position: relative;
  z-index: 1;
}

.v2-stage--desktop {
  padding: 12px;
}

.v2-svg-wrap {
  width: 100%;
  display: block;
}

.v2-svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: default;
  shape-rendering: geometricPrecision;
  text-rendering: optimizeLegibility;
}

.v2-svg text {
  paint-order: stroke;
  -webkit-font-smoothing: antialiased;
}

/* SVG text classes (apply CSS that doesn't translate cleanly to SVG attrs) */
.v2-svg-mono {
  font-family: var(--v2-mono);
}
.v2-svg-tag {
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.v2-svg-tier-label {
  font-family: var(--v2-sans);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}
.v2-svg-tier-label--mcp {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  font-weight: 600;
  opacity: 0.78;
}
.v2-node-label {
  font-family: var(--v2-sans);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.v2-node-sub {
  font-family: var(--v2-mono);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

/* =========================================================================
 * NODES — interactive states
 * ========================================================================= */

.v2-node {
  cursor: pointer;
  transform-origin: center;
  transition: opacity 0.2s ease, filter 0.2s ease;
  outline: none;
}

.v2-node .v2-node-bg {
  transition: stroke 0.15s ease, stroke-width 0.15s ease, fill 0.15s ease;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5)) drop-shadow(0 0 6px rgba(10, 12, 16, 0.85));
}

.v2-node:hover .v2-node-bg,
.v2-node:focus-visible .v2-node-bg,
.v2-node.is-focused .v2-node-bg,
.v2-node.is-neighbor .v2-node-bg {
  stroke-width: 1.5;
  filter: brightness(1.12);
}

.v2-node.is-focused .v2-node-bg {
  stroke: var(--v2-accent);
  stroke-width: 2;
  filter: drop-shadow(0 0 10px var(--v2-glow));
}

.v2-node.is-dimmed { opacity: 0.32; }

/* =========================================================================
 * EDGES — dual-layer with animated pulse
 * ========================================================================= */

.v2-edge {
  transition: opacity 0.2s ease;
}

.v2-edge-base {
  opacity: 0.16;
  transition: opacity 0.2s ease;
}

.v2-edge-flow {
  opacity: 0.42;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

@keyframes v2-flow-public    { to { stroke-dashoffset: -28; } }
@keyframes v2-flow-admin     { to { stroke-dashoffset: -36; } }
@keyframes v2-flow-data      { to { stroke-dashoffset: -32; } }
@keyframes v2-flow-ai        { to { stroke-dashoffset: -30; } }
@keyframes v2-flow-analytics { to { stroke-dashoffset: -38; } }
@keyframes v2-flow-mcp       { to { stroke-dashoffset: -26; } }
@keyframes v2-flow-agent     { to { stroke-dashoffset: -32; } }
@keyframes v2-flow-edit      { to { stroke-dashoffset: -30; } }
@keyframes v2-flow-feedback  { to { stroke-dashoffset:  40; } }
@keyframes v2-flow-scan      { to { stroke-dashoffset: -50; } }

.v2-flow-public    { animation: v2-flow-public    3.0s linear infinite; }
.v2-flow-admin     { animation: v2-flow-admin     4.0s linear infinite; }
.v2-flow-data      { animation: v2-flow-data      3.5s linear infinite; }
.v2-flow-ai        { animation: v2-flow-ai        3.2s linear infinite; }
.v2-flow-analytics { animation: v2-flow-analytics 4.5s linear infinite; }
.v2-flow-mcp       { animation: v2-flow-mcp       2.6s linear infinite; }
.v2-flow-agent     { animation: v2-flow-agent     3.5s linear infinite; }
.v2-flow-edit      { animation: v2-flow-edit      3.0s linear infinite; }
.v2-flow-feedback  { animation: v2-flow-feedback  4.5s linear infinite; }
.v2-flow-scan      { animation: v2-flow-scan      6.0s linear infinite; }

.v2-edge.is-active .v2-edge-base { opacity: 0.55; }
.v2-edge.is-active .v2-edge-flow {
  opacity: 1;
  filter: url(#v2-glow);
}

.v2-edge.is-dimmed .v2-edge-base { opacity: 0.05; }
.v2-edge.is-dimmed .v2-edge-flow { opacity: 0.05; }

/* =========================================================================
 * FOOTER LEGEND (desktop)
 * ========================================================================= */

.v2-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 22px;
  border-top: 1px solid var(--v2-border);
  background: rgba(10, 12, 16, 0.85);
  flex-wrap: wrap;
}

.v2-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.v2-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.v2-legend-item:hover { opacity: 1 !important; }
.v2-legend-item.is-active { opacity: 1 !important; }
.v2-legend-item.is-dimmed { opacity: 0.3; }

.v2-legend-label {
  font-family: var(--v2-mono);
  font-size: 11.25px;
  color: var(--v2-text-mid);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.v2-meta {
  display: flex;
  align-items: center;
  gap: 24px;
}

.v2-meta-block {
  text-align: right;
}

.v2-meta-label {
  font-family: var(--v2-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--v2-text-lo);
  text-transform: uppercase;
}

.v2-meta-value {
  font-family: var(--v2-mono);
  font-size: 10.5px;
  color: var(--v2-text-mid);
  margin-top: 2px;
}

/* =========================================================================
 * MOBILE COMPACT CHART (purpose-built vertical SVG schematic)
 * ========================================================================= */

.v2-root[data-layout="mobile"] {
  max-width: 760px;
  border-radius: 14px;
  --v2-text-mid: #9aa8bc;
}

.v2-mheader {
  position: relative;
  z-index: 5;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 12px;
  background: linear-gradient(180deg, rgba(10,12,16,0.96), rgba(10,12,16,0.78));
}

.v2-mheader .v2-header-left {
  width: auto;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.v2-mheader .v2-header-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.v2-mheader .v2-blip { margin-top: 10px; }

.v2-mheader .v2-title {
  font-size: 18px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-mheader .v2-spec {
  display: none;
}

.v2-mheader-meta {
  font-family: var(--v2-mono);
  font-size: 10px;
  color: var(--v2-text-lo);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stage / SVG */
.v2-stage--mobile {
  position: relative;
  z-index: 1;
  padding: 4px 10px 8px;
}

.v2-svg-wrap--mobile {
  width: 100%;
  display: block;
}

.v2-svg--mobile {
  display: block;
  width: 100%;
  height: auto;
}

/* Mobile SVG type */
.v2-svg--mobile .v2-svg-tier-label,
.v2-svg--mobile .v2-mband-label {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  font-weight: 700;
}
.v2-svg--mobile .v2-svg-tag,
.v2-svg--mobile .v2-mband-vps {
  font-size: 9px;
  letter-spacing: 0.18em;
}
.v2-svg--mobile .v2-mnode-label {
  font-family: var(--v2-sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  pointer-events: none;
}

/* Resting flow trails */
.v2-mflow-line,
.v2-mflow-dot {
  transition: opacity 0.25s ease;
}
.v2-mflow-line.is-dimmed,
.v2-mflow-dot.is-dimmed {
  opacity: 0;
}

/* Mobile cross-tier links — invisible at rest, light up when active */
.v2-mxlink {
  opacity: 0;
  transition: opacity 0.22s ease, filter 0.22s ease;
  pointer-events: none;
}
.v2-mxlink.is-active {
  opacity: 1;
  filter: url(#v2-mglow);
}
.v2-mxlink-base { opacity: 0.6; }
.v2-mxlink-flow {
  opacity: 0.95;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* Mobile node pills */
.v2-mnode {
  cursor: pointer;
  outline: none;
  transition: opacity 0.18s ease, filter 0.18s ease;
}
.v2-mnode .v2-mnode-bg {
  transition: stroke 0.15s ease, stroke-width 0.15s ease, filter 0.18s ease;
}
.v2-mnode:focus-visible .v2-mnode-bg,
.v2-mnode.is-neighbor .v2-mnode-bg {
  stroke: var(--v2-border-hl);
  stroke-width: 1.3;
  filter: brightness(1.12);
}
.v2-mnode.is-focused .v2-mnode-bg {
  stroke: var(--v2-accent);
  stroke-width: 2;
  filter: drop-shadow(0 0 8px var(--v2-glow));
}
.v2-mnode.is-dimmed { opacity: 0.34; }

/* Detail strip beneath the chart */
.v2-mdetail {
  position: relative;
  z-index: 2;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--v2-border);
  background: rgba(10, 12, 16, 0.7);
}
.v2-mdetail-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 32px;
  justify-content: center;
}
.v2-mdetail-label {
  font-family: var(--v2-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--v2-text-mid);
  transition: color 0.18s ease;
}
.v2-mdetail-sub {
  font-family: var(--v2-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--v2-text-lo);
  text-transform: lowercase;
}
.v2-mdetail.is-active .v2-mdetail-label {
  color: var(--v2-text-hi);
  text-shadow: 0 0 10px var(--v2-glow);
}
.v2-mdetail.is-active .v2-mdetail-sub {
  color: var(--v2-text-mid);
  text-transform: none;
}

/* Mobile footer (legend) — compacted */
.v2-footer--mobile {
  padding: 10px 14px 12px;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: flex-start;
}
.v2-footer--mobile .v2-meta { display: none; }
.v2-footer--mobile .v2-legend { gap: 4px 14px; }
.v2-footer--mobile .v2-legend-label {
  font-size: 10px;
}

/* =========================================================================
 * EXPANDED (fullscreen) STATE
 * ========================================================================= */

.v2-root.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 9999;
  max-width: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  border-radius: 0;
  border: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  animation: v2-expand-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.v2-root.is-expanded .v2-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: auto;
  padding: 16px 22px;
}

.v2-root.is-expanded .v2-svg-wrap {
  margin: auto;
  width: 100%;
  max-width: 1400px;
}

.v2-root.is-expanded .v2-svg {
  width: 100%;
  height: auto;
  max-height: 100%;
}

@keyframes v2-expand-in {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}

body.v2-expanded {
  overflow: hidden;
}

/* Mobile expand: the compact mobile chart simply fills the viewport.
 * The SVG already has phone-friendly proportions, so no 1400px overrides. */
.v2-root[data-layout="mobile"].is-expanded .v2-stage {
  padding: 10px 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  align-items: flex-start;
  justify-content: center;
}

.v2-root[data-layout="mobile"].is-expanded .v2-svg-wrap--mobile {
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
}

.v2-root[data-layout="mobile"].is-expanded .v2-svg--mobile {
  width: 100%;
  height: auto;
}

.v2-root[data-layout="mobile"].is-expanded .v2-mdetail {
  border-top: 1px solid var(--v2-border);
}

.v2-root[data-layout="mobile"].is-expanded .v2-footer--mobile {
  padding: 10px 14px;
}

.v2-root[data-layout="mobile"].is-expanded .v2-mheader {
  padding: 14px 18px 12px;
}

@media (min-width: 761px) {
  .v2-root.is-expanded .v2-header { padding: 16px 28px; }
  .v2-root.is-expanded .v2-title { font-size: 26px; }
}

/* =========================================================================
 * REDUCED MOTION
 * ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  .v2-blip,
  .v2-edge-flow,
  .v2-mflow-dot,
  .v2-mxlink-flow,
  .v2-root.is-expanded {
    animation: none !important;
  }
  .v2-edge-base { opacity: 0.45 !important; }
  .v2-edge-flow { opacity: 0 !important; }
  .v2-mxlink-base { opacity: 0.6 !important; }
  .v2-mxlink-flow { opacity: 0 !important; }
}
