/* =============================================================
   ZARAS — /industries — Trade Constellation (v2)
   -------------------------------------------------------------
   v2: Migrated 4 information-tier text uses from --ink-faint
   (~1.7:1) to --ink-label (~6.5:1, AAA on plain bg).
   -------------------------------------------------------------
   Console-framed constellation of 18 trade nodes mapped onto
   6 operating shape anchors. Sibling readout to .field-map —
   reuses corner brackets, dot-grid backdrop, monospace HUD,
   bottom telemetry strip, signal teal active color.

   Tokens consumed (declared on :root in industries.html):
     --bg, --ink, --ink-sub, --ink-mute, --ink-faint,
     --rule, --rule-hi,
     --signal, --signal-ink, --signal-weak, --signal-rule,
     --mono, --sans
   ============================================================= */

/* ---------- Section wrapper ---------- */
.trades {
  padding: 96px 0 80px;
  border-top: 1px solid var(--rule);
}
.trades-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
  max-width: 64ch;
}
.trades-head .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.trades-proof {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0;
}
.trades-head h2 {
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  font-size: clamp(32px, 4.4vw, 56px);
  text-wrap: balance;
}
.trades-intro {
  color: var(--ink-sub);
  font-size: clamp(14px, 1.1vw, 16px);
  line-height: 1.6;
  max-width: 56ch;
  margin-top: 4px;
}
.trades-stage { margin-top: 8px; }

/* ---------- Long-tail strip ---------- */
.trades-longtail {
  margin-top: 28px;
  padding: 20px 24px;
  border: 1px solid var(--rule);
  border-top: none;
  display: flex;
  gap: 16px;
  align-items: baseline;
  flex-wrap: wrap;
  background: rgba(255,250,240,0.012);
}
.trades-longtail .label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  flex: 0 0 auto;
}
.trades-longtail-list {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink-sub);
  line-height: 1.6;
  letter-spacing: 0.005em;
  flex: 1 1 auto;
  min-width: 200px;
}

/* =============================================================
   CONSTELLATION CONTAINER
   ============================================================= */
.trade-constellation {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 520px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(118,199,178,0.05), transparent 70%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #0d0c0a 0%, #050504 100%);
  border: 1px solid var(--rule-hi);
  overflow: hidden;
  font-family: var(--mono);
  color: var(--ink);
  /* Dot-grid backdrop — matches field-map idiom */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(118,199,178,0.04), transparent 70%),
    radial-gradient(rgba(255,250,240,0.04) 1px, transparent 1px),
    linear-gradient(180deg, #0d0c0a 0%, #050504 100%);
  background-size: 100% 100%, 22px 22px, 100% 100%;
  background-position: center, 0 0, 0 0;
}

/* ---------- Corner brackets ---------- */
.trade-constellation .tc-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--rule-hi);
  pointer-events: none;
  z-index: 4;
}
.trade-constellation .tc-corner.tl { top: 14px;    left: 14px;  border-top: 1px solid;    border-left: 1px solid; }
.trade-constellation .tc-corner.tr { top: 14px;    right: 14px; border-top: 1px solid;    border-right: 1px solid; }
.trade-constellation .tc-corner.bl { bottom: 14px; left: 14px;  border-bottom: 1px solid; border-left: 1px solid; }
.trade-constellation .tc-corner.br { bottom: 14px; right: 14px; border-bottom: 1px solid; border-right: 1px solid; }

/* ---------- HUD readouts ---------- */
.trade-constellation .tc-head {
  position: absolute;
  top: 22px;
  left: 28px;
  right: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
  z-index: 4;
}
.trade-constellation .tc-head .lhs,
.trade-constellation .tc-head .rhs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trade-constellation .tc-head .rhs { text-align: right; align-items: flex-end; }
.trade-constellation .tc-head .name {
  color: var(--ink);
  letter-spacing: 0.18em;
}
.trade-constellation .tc-head .sub {
  color: var(--ink-label);
  font-size: 9px;
  letter-spacing: 0.18em;
}

/* ---------- Geometry SVG ---------- */
.trade-constellation .tc-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
}

/* ---------- HTML overlay (focusable) ---------- */
.trade-constellation .tc-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Shape anchor button */
.tc-anchor {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
  font-family: var(--mono);
  /* Fix 2.3 — anchor labels at --ink-sub so they clearly frame the field
     in default state without competing with trade labels. */
  color: var(--ink-sub);
  transition:
    color 320ms cubic-bezier(.22,.61,.36,1),
    transform 320ms cubic-bezier(.22,.61,.36,1);
}
.tc-anchor .ring {
  width: 12px; height: 12px;
  border-radius: 50%;
  /* Fix 2.3 — slightly stronger ring stroke for default-state authority. */
  border: 1px solid var(--ink-sub);
  background: rgba(0,0,0,0.4);
  transition:
    border-color 320ms cubic-bezier(.22,.61,.36,1),
    background 320ms cubic-bezier(.22,.61,.36,1),
    box-shadow 320ms cubic-bezier(.22,.61,.36,1),
    transform 320ms cubic-bezier(.22,.61,.36,1);
}
.tc-anchor .lbl {
  font-size: 10px;
  /* Fix 2.3 — slight tracking down for monospace clarity at small sizes. */
  letter-spacing: 0.10em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tc-anchor .count {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-label);
  font-variant-numeric: tabular-nums;
}
.tc-anchor:hover,
.tc-anchor:focus-visible,
.tc-anchor[aria-pressed="true"] {
  color: var(--signal-ink);
}
.tc-anchor:hover .ring,
.tc-anchor:focus-visible .ring,
.tc-anchor[aria-pressed="true"] .ring {
  border-color: var(--signal);
  background: var(--signal-weak);
  box-shadow: 0 0 0 4px rgba(118,199,178,0.10);
  transform: scale(1.15);
}

/* Trade button — JS sets transform inline (translate(0, -50%)) so the dot
   sits on the computed coordinate and the label flows to the right. */
.tc-trade {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
  font-family: var(--sans);
  color: var(--ink);
  white-space: nowrap;
  transition:
    opacity 320ms cubic-bezier(.22,.61,.36,1),
    color 320ms cubic-bezier(.22,.61,.36,1),
    transform 320ms cubic-bezier(.22,.61,.36,1);
  border-radius: 4px;
}
.tc-trade .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-sub);
  flex: 0 0 auto;
  transition:
    background 320ms cubic-bezier(.22,.61,.36,1),
    box-shadow 320ms cubic-bezier(.22,.61,.36,1),
    transform 320ms cubic-bezier(.22,.61,.36,1);
}
.tc-trade .lbl {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1;
}
.tc-trade[data-tier="tier1"] .dot {
  width: 10px; height: 10px;
  background: var(--ink);
  box-shadow: 0 0 12px 2px rgba(118,199,178,0.04);
}
.tc-trade[data-tier="tier1"] .lbl {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.012em;
}
.tc-trade[data-tier="tier2"] {
  opacity: 0.78;
}

/* Activated state — own button */
.tc-trade:hover,
.tc-trade:focus-visible,
.tc-trade[aria-pressed="true"] {
  color: var(--signal-ink);
  opacity: 1;
}
.tc-trade:hover .dot,
.tc-trade:focus-visible .dot,
.tc-trade[aria-pressed="true"] .dot {
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(118,199,178,0.16), 0 0 14px 2px rgba(118,199,178,0.45);
  transform: scale(1.4);
}

/* Fix 2.2 — active-label backdrop chip.
   Restrained chip behind the active label so the trade dominates its own
   shape badge below. Padding/margin cancel so the surrounding layout and
   collision pass don't shift. */
.tc-trade:hover .lbl,
.tc-trade:focus-visible .lbl,
.tc-trade[aria-pressed="true"] .lbl,
.tc-overlay[data-active="true"] .tc-trade[data-related="true"] .lbl {
  color: var(--ink);
  background: var(--bg-raise);
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--rule);
}

/* Faded state — set by JS via data-faded on the overlay root */
.tc-overlay[data-active="true"] .tc-trade:not([data-related="true"]) {
  opacity: 0.32;
  color: var(--ink-mute);
}
.tc-overlay[data-active="true"] .tc-trade[data-tier="tier2"]:not([data-related="true"]) {
  opacity: 0.22;
}
.tc-overlay[data-active="true"] .tc-trade[data-related="true"] {
  opacity: 1;
  color: var(--signal-ink);
  z-index: 2;
}
.tc-overlay[data-active="true"] .tc-trade[data-related="true"] .dot {
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(118,199,178,0.14), 0 0 12px 1px rgba(118,199,178,0.32);
}
.tc-overlay[data-active="true"] .tc-anchor:not([data-related="true"]):not([aria-pressed="true"]) {
  opacity: 0.5;
}

/* Trade detail badge — appears next to active trade.
   Position is set inline by JS via computeBadgePosition (Fix 1.3) so it
   never overlaps a shape anchor. */
.tc-detail {
  position: absolute;
  pointer-events: none;
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-sub);
  background: rgba(13,12,10,0.85);
  border: 1px solid var(--signal-rule);
  padding: 5px 9px;
  white-space: nowrap;
  z-index: 3;
  opacity: 0;
  transition: opacity 220ms ease;
}
.tc-detail[data-show="true"] { opacity: 1; }
.tc-detail .badge {
  display: inline-block;
  padding: 1px 0;
  color: var(--signal-ink);
}
.tc-detail .sep {
  color: var(--ink-label);
}

/* ---------- Bottom telemetry / legend ---------- */
.trade-constellation .tc-telem {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 11px 28px;
  border-top: 1px solid var(--rule);
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
  z-index: 4;
}
.trade-constellation .tc-telem .legend {
  display: flex; gap: 18px; flex-wrap: wrap;
}
.trade-constellation .tc-telem .legend .item {
  display: inline-flex; align-items: center; gap: 8px;
}
.trade-constellation .tc-telem .legend .swatch {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
}
.trade-constellation .tc-telem .legend .swatch.t2 {
  width: 7px; height: 7px;
  background: transparent;
  border: 1px solid var(--ink-sub);
}
.trade-constellation .tc-telem .legend .swatch.line {
  width: 14px; height: 1px; border-radius: 0;
  background: var(--signal-rule);
}
.trade-constellation .tc-telem .legend .swatch.anchor {
  width: 10px; height: 10px; border-radius: 50%;
  background: transparent;
  border: 1px solid var(--ink-mute);
}
.trade-constellation .tc-telem .stats {
  display: flex; gap: 20px; color: var(--ink-sub);
}
.trade-constellation .tc-telem .stats .stat {
  display: inline-flex; gap: 8px;
}
.trade-constellation .tc-telem .stats .k { color: var(--ink-label); }
.trade-constellation .tc-telem .stats .v {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Live region (visually hidden) ---------- */
.tc-live {
  position: absolute;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* =============================================================
   MOBILE — vertical grouped stacks (< 768px)
   ============================================================= */
.trade-constellation[data-mode="mobile"] {
  aspect-ratio: auto;
  min-height: 0;
  padding: 56px 18px 56px;
  background-image:
    radial-gradient(rgba(255,250,240,0.04) 1px, transparent 1px),
    linear-gradient(180deg, #0d0c0a 0%, #050504 100%);
  background-size: 22px 22px, 100% 100%;
}
.trade-constellation[data-mode="mobile"] .tc-svg,
.trade-constellation[data-mode="mobile"] .tc-overlay,
.trade-constellation[data-mode="mobile"] .tc-detail {
  display: none;
}
.trade-constellation[data-mode="mobile"] .tc-head {
  position: static;
  margin-bottom: 28px;
  padding: 0 4px;
}
.trade-constellation[data-mode="mobile"] .tc-telem {
  position: static;
  margin-top: 24px;
  padding: 14px 4px 0;
}
.trade-constellation[data-mode="mobile"] .tc-telem .stats { display: none; }

.tc-stack {
  display: grid;
  gap: 20px;
}
.tc-stack-group {
  border: 1px solid var(--rule);
  padding: 16px 16px 18px;
  background: rgba(255,250,240,0.012);
}
.tc-stack-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.tc-stack-group-head .lbl {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}
.tc-stack-group-head .count {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.tc-stack-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tc-pill {
  background: transparent;
  border: 1px solid var(--rule-hi);
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition:
    border-color 220ms ease,
    background 220ms ease,
    color 220ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
}
.tc-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-sub);
  flex: 0 0 auto;
}
.tc-pill[data-tier="tier1"] {
  font-weight: 500;
}
.tc-pill[data-tier="tier1"] .dot {
  width: 8px; height: 8px;
  background: var(--ink);
}
.tc-pill[aria-pressed="true"] {
  border-color: var(--signal);
  background: rgba(118,199,178,0.06);
  color: var(--signal-ink);
}
.tc-pill[aria-pressed="true"] .dot {
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(118,199,178,0.14);
}
.tc-stack-detail {
  margin-top: 12px;
  padding: 14px 12px 12px;
  border-top: 1px dashed var(--signal-rule);
  display: none;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-sub);
}
.tc-stack-detail[data-show="true"] { display: block; }
.tc-stack-detail .name {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
  margin-bottom: 8px;
  font-weight: 500;
}
.tc-stack-detail .badges {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tc-stack-detail .badge {
  border: 1px solid var(--signal-rule);
  color: var(--signal-ink);
  padding: 3px 7px;
  font-size: 9.5px;
  letter-spacing: 0.16em;
}

/* =============================================================
   Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .tc-trade,
  .tc-anchor,
  .tc-anchor .ring,
  .tc-trade .dot {
    transition-property: opacity, color, background, border-color;
  }
  .tc-trade:hover,
  .tc-trade:focus-visible,
  .tc-trade[aria-pressed="true"] {
    /* JS-set inline transform persists; nothing to override */
  }
}

/* =============================================================
   Small-screen tweaks below 480
   ============================================================= */
@media (max-width: 480px) {
  .trade-constellation[data-mode="mobile"] {
    padding: 40px 14px 40px;
  }
  .tc-stack-pills {
    grid-template-columns: 1fr;
  }
}
