/* ─── Watch industry 3D graph ────────────────────────────────
   Palette slots come from the validated data-viz reference palette
   (dark column). Categorical uses only the first three slots — a graph
   is an all-pairs form, where any two nodes can end up side by side.
   Depth uses a single-hue ordinal blue ramp.                            */

.viz-root {
  /* categorical — validated all-pairs on the dark surface */
  --series-1:   #3987e5;   /* company */
  --series-2:   #d95926;   /* brand   */
  --series-3:   #199e70;   /* model   */
  --series-off: #5c5f66;   /* folded into "Other" / deselected */

  /* ordinal — blue ramp, monotone light→dark */
  --depth-0: #b7d3f6;
  --depth-1: #6da7ec;
  --depth-2: #2a78d6;
  --depth-3: #184f95;

  --viz-surface: #14161a;  /* == var(--background), the canvas backdrop */
  --nav-h: 4rem;
}

/* ─── Stage ──────────────────────────────────────────────── */
.viz-stage {
  position: fixed;
  top: var(--nav-h); left: 0; right: 0; bottom: 0;
  background: var(--viz-surface);
  overflow: hidden;
}
.viz-canvas { position: absolute; inset: 0; }
.viz-canvas canvas { display: block; outline: none; }

/* Node labels — HTML projected onto the scene each frame (see industry-graph.js) */
.viz-labels-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.viz-node-label {
  position: absolute; top: 0; left: 0;
  will-change: transform;
  font-size: .6875rem;
  font-weight: 500;
  line-height: 1;
  color: #e9eaec;
  background: rgba(20,22,26,.6);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: .25rem;
  padding: .1875rem .375rem;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.viz-node-label.tier-0 {
  font-size: .75rem;
  font-weight: 600;
  color: #ffffff;
  border-color: rgba(255,255,255,.16);
}

/* Brand logos — HTML projected onto the scene, same technique as labels (see
   industry-graph.js). Sits under the labels layer (z-index 4 vs 5) so a name
   badge always reads on top of the artwork behind it. */
.viz-logos-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}
.viz-node-logo {
  position: absolute; top: 0; left: 0;
  will-change: transform;
  border-radius: 50%;
  background: #f3f0ea;   /* most brand marks are dark-on-transparent; a warm-white disc keeps them legible on the dark canvas */
  border: 1.5px solid var(--series-2);
  box-shadow: 0 1px 6px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: opacity .15s;
}
.viz-node-logo img {
  width: 78%; height: 78%;
  object-fit: contain;
}

/* Vignette keeps the outer nodes from fighting the panels. */
.viz-stage::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.45) 100%);
}

/* ─── Floating panels ────────────────────────────────────── */
.viz-panel {
  position: absolute;
  z-index: 10;
  border-radius: var(--radius);
  background: rgba(20, 22, 26, .82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: var(--shadow-glass);
}

.viz-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem;
  padding: .75rem .875rem;
  border-bottom: 1px solid var(--border);
}
.viz-panel-title {
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-fg);
}
.viz-panel-body { padding: .875rem; overflow-y: auto; }

/* Controls — left */
.viz-controls {
  top: 1rem; left: 1rem;
  width: 17.5rem;
  max-height: calc(100% - 2rem);
  display: flex; flex-direction: column;
}
/* Leave the bottom strip free for the legend bar. */
.viz-controls { max-height: calc(100% - 5.5rem); }
.viz-controls .viz-panel-body { max-height: calc(100vh - var(--nav-h) - 10rem); }

/* Details — right */
.viz-details {
  top: 1rem; right: 1rem;
  width: 20rem;
  max-height: calc(100% - 2rem);
  display: flex; flex-direction: column;
  transform: translateX(calc(100% + 1.5rem));
  opacity: 0;
  transition: transform .32s cubic-bezier(.4,0,.2,1), opacity .32s;
}
.viz-details.open { transform: translateX(0); opacity: 1; }
.viz-details .viz-panel-body { max-height: calc(100vh - var(--nav-h) - 7rem); }

/* Legend — horizontal bar, bottom centre (clear of both side panels) */
.viz-legend {
  bottom: 1rem;
  left: 19.5rem; right: 22rem;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 42rem);
  padding: .625rem .875rem;
  display: flex; align-items: center; gap: .875rem;
  flex-wrap: wrap;
}

/* Hint — bottom right, above the details panel's footprint */
.viz-hint {
  bottom: 1rem; right: 1rem;
  padding: .5rem .75rem;
  font-size: .6875rem;
  color: var(--muted-fg);
  display: flex; gap: .875rem; flex-wrap: wrap;
}
.viz-hint kbd {
  font: inherit;
  background: var(--accent);
  border: 1px solid var(--border);
  border-radius: .25rem;
  padding: 0 .3rem;
  color: var(--foreground);
}

/* ─── Control groups ─────────────────────────────────────── */
.viz-group { margin-bottom: 1rem; }
.viz-group:last-child { margin-bottom: 0; }
.viz-group-label {
  display: block;
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-fg);
  margin-bottom: .5rem;
}

/* Segmented control */
.viz-seg {
  display: flex;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .1875rem;
  gap: .1875rem;
}
.viz-seg button {
  flex: 1;
  font: inherit; font-size: .75rem; font-weight: 500;
  color: var(--muted-fg);
  background: transparent; border: 0;
  border-radius: .375rem;
  padding: .375rem .25rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.viz-seg button:hover { color: var(--foreground); }
.viz-seg button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
}

/* Toggle rows */
.viz-check {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem .375rem;
  border-radius: .375rem;
  cursor: pointer;
  font-size: .8125rem;
  transition: background .15s;
  user-select: none;
}
.viz-check:hover { background: var(--accent); }
.viz-check input { accent-color: var(--primary); cursor: pointer; margin: 0; }
.viz-check .viz-swatch { flex: none; }
.viz-check-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-count {
  flex: none;
  font-size: .6875rem;
  color: var(--muted-fg);
  font-variant-numeric: tabular-nums;
}

.viz-swatch {
  width: .625rem; height: .625rem;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 0 8px currentColor;
}
.viz-swatch-sq { border-radius: .1875rem; }

/* Logo-size slider */
.viz-range {
  width: 100%;
  margin-top: .375rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Scrollable owner list */
.viz-scroll {
  max-height: 11rem;
  overflow-y: auto;
  margin: 0 -.375rem;
  padding: 0 .375rem;
}

/* Compare-mode slot pills */
.viz-compare-hint {
  font-size: .6875rem;
  color: var(--muted-fg);
  margin-bottom: .5rem;
  line-height: 1.4;
}

/* ─── Legend ─────────────────────────────────────────────── */
.viz-legend-items { display: flex; align-items: center; gap: .875rem; flex-wrap: wrap; }
.viz-legend-item {
  display: flex; align-items: center; gap: .4375rem;
  font-size: .75rem;
  color: var(--foreground);
  max-width: 13rem;
}
.viz-legend-item > span:not(.viz-count) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viz-legend-rels {
  padding-left: .875rem;
  border-left: 1px solid var(--border);
  display: flex; align-items: center; gap: .875rem;
  flex-wrap: wrap;
}
.viz-legend-rel {
  display: flex; align-items: center; gap: .5rem;
  font-size: .6875rem; color: var(--muted-fg);
}
.viz-legend-line {
  width: 1.25rem; height: 0;
  border-top-width: 2px; border-top-style: solid;
  flex: none;
}

/* ─── Detail panel ───────────────────────────────────────── */
.viz-detail-pills {
  display: flex; align-items: center; gap: .375rem;
  flex-wrap: wrap;
  margin-bottom: .625rem;
}
.viz-detail-kind {
  display: inline-flex; align-items: center; gap: .375rem;
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .1875rem .5rem;
  border-radius: 999px;
  border: 1px solid currentColor;
}
/* Homage base wears the site's own accent, not a series colour — it marks
   relevance to Martin's builds, not another data category. */
.viz-detail-kind.is-homage {
  color: var(--primary);
  background: hsl(35 84% 62% / .1);
}
.viz-detail-name {
  font-size: 1.125rem; font-weight: 600;
  line-height: 1.3;
  margin-bottom: .75rem;
}
.viz-detail-logo {
  width: 3rem; height: 3rem;
  border-radius: 50%;
  background: #f3f0ea;
  border: 1.5px solid var(--series-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  float: right;
  margin: 0 0 .5rem .75rem;
}
.viz-detail-logo img { width: 78%; height: 78%; object-fit: contain; }
.viz-detail-note {
  font-size: .75rem; color: var(--muted-fg);
  line-height: 1.5;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

/* Provenance badge — research confidence, from the Source attribute */
.viz-prov {
  margin-top: 1rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .6875rem;
  color: var(--muted-fg);
}
.viz-prov.is-verified { color: #199e70; }

.viz-attrs { display: grid; grid-template-columns: auto 1fr; gap: .375rem .75rem; font-size: .8125rem; }
.viz-attrs dt { color: var(--muted-fg); white-space: nowrap; }
.viz-attrs dd { color: var(--foreground); }

/* Attribute values that navigate to another node (e.g. Country) */
.viz-inline-link {
  font: inherit;
  color: var(--foreground);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px dashed var(--border);
  transition: color .15s, border-color .15s;
}
.viz-inline-link:hover { color: var(--primary); border-bottom-color: var(--primary); }

.viz-section-label {
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-fg);
  margin: 1rem 0 .5rem;
  padding-top: .875rem;
  border-top: 1px solid var(--border);
}

/* Ownership chain breadcrumb */
.viz-chain { display: flex; flex-direction: column; gap: 0; }
.viz-chain-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem .375rem;
  border-radius: .375rem;
  font-size: .8125rem;
  cursor: pointer;
  border: 0; background: transparent;
  color: var(--foreground);
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: background .15s;
}
.viz-chain-item:hover { background: var(--accent); }
.viz-chain-item.current { background: var(--accent); font-weight: 600; }
.viz-chain-rung {
  color: var(--muted-fg);
  font-size: .625rem;
  padding-left: .75rem;
  line-height: 1;
}

/* Related-node list */
.viz-rel-list { display: flex; flex-direction: column; gap: .125rem; }
.viz-rel-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem .375rem;
  border-radius: .375rem;
  font-size: .8125rem;
  cursor: pointer;
  border: 0; background: transparent;
  color: var(--foreground);
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: background .15s;
}
.viz-rel-item:hover { background: var(--accent); }
.viz-rel-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-rel-more { font-size: .6875rem; color: var(--muted-fg); padding: .25rem .375rem; }

/* ─── Search ─────────────────────────────────────────────── */
.viz-search-wrap { position: relative; }
.viz-results {
  position: absolute; top: calc(100% + .375rem); left: 0; right: 0;
  z-index: 20;
  background: rgba(20, 22, 26, .96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: .5rem;
  box-shadow: var(--shadow-elev);
  max-height: 15rem; overflow-y: auto;
  display: none;
}
.viz-results.open { display: block; }
.viz-result {
  display: flex; align-items: center; gap: .5rem;
  padding: .4375rem .625rem;
  font-size: .8125rem;
  cursor: pointer;
  border: 0; background: transparent;
  color: var(--foreground);
  font-family: inherit; text-align: left; width: 100%;
}
.viz-result:hover, .viz-result.active { background: var(--accent); }
.viz-result span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-result small { margin-left: auto; color: var(--muted-fg); font-size: .6875rem; flex: none; }

/* ─── Tooltip ────────────────────────────────────────────── */
.viz-tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  padding: .375rem .625rem;
  border-radius: .375rem;
  background: rgba(20, 22, 26, .95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-elev);
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .12s;
}
.viz-tooltip.show { opacity: 1; }
.viz-tooltip .viz-tooltip-sub { color: var(--muted-fg); font-size: .6875rem; }

/* ─── Status / loading ───────────────────────────────────── */
.viz-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .75rem;
  color: var(--muted-fg);
  font-size: .875rem;
  z-index: 15;
  text-align: center;
  padding: 1rem;
}
.viz-spinner {
  width: 1.75rem; height: 1.75rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: viz-spin .7s linear infinite;
}
@keyframes viz-spin { to { transform: rotate(360deg); } }

.viz-stat-row {
  display: flex; gap: 1rem;
  font-size: .6875rem; color: var(--muted-fg);
  padding-top: .75rem; margin-top: .75rem;
  border-top: 1px solid var(--border);
}
.viz-stat b { display: block; font-size: .9375rem; color: var(--foreground); font-variant-numeric: tabular-nums; }

/* ─── Table view (accessibility fallback) ────────────────── */
.viz-table-toggle { width: 100%; margin-top: .75rem; }
.viz-table-wrap {
  position: absolute; inset: 0;
  z-index: 30;
  background: var(--viz-surface);
  overflow: auto;
  padding: 1.5rem;
  display: none;
}
.viz-table-wrap.open { display: block; }
.viz-table-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
  position: sticky; top: 0; z-index: 2;
  background: var(--viz-surface);
  padding-bottom: .5rem;
}
.viz-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.viz-table th, .viz-table td {
  text-align: left; padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}
.viz-table th {
  position: sticky; top: 0;
  background: var(--viz-surface);
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted-fg);
}
.viz-table tbody tr:hover { background: var(--accent); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .viz-controls, .viz-details {
    width: auto; left: .5rem; right: .5rem;
    max-height: 45%;
  }
  .viz-controls { top: .5rem; }
  .viz-details { top: auto; bottom: .5rem; transform: translateY(calc(100% + 1rem)); }
  .viz-details.open { transform: translateY(0); }
  .viz-controls .viz-panel-body, .viz-details .viz-panel-body { max-height: 40vh; }
  .viz-legend, .viz-hint { display: none; }
  .viz-table-toggle { top: auto; bottom: .5rem; left: .5rem; transform: none; }
}
