/* sankey.css */

#sankeyWrap,
.sankey-wrap {
  position: relative;
  width: 100%;
  height: 520px;
  overflow: visible;
  transform: translateZ(0);
}

#sankeySvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

#sankeyPanel {
  position: absolute;
  z-index: 50;

  width: 420px;
  max-width: min(520px, calc(100% - 24px));

  background: rgba(15,15,15,0.82);
  color: rgba(255,255,255,0.92);

  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);

  padding: 12px;
  line-height: 1.25;
  backdrop-filter: blur(6px);

  display: none;
  left: 0;
  top: 0;

  pointer-events: none; /* never steal hover */
}

#sankeyPanel .sk-kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  font-size: 12px;
}

#sankeyPanel .sk-k {
  color: rgba(255,255,255,0.65);
}

#sankeyPanel .sk-v {
  color: rgba(255,255,255,0.92);
}

#sankeyPanel .sk-detail {
  white-space: pre-wrap;
  word-break: break-word;
}

#sankeyPanel .sk-detail ul {
  margin: 0;
  padding-left: 18px;
}

#sankeyPanel .sk-detail li {
  margin: 4px 0;
}

/* Optional hover helpers (you can toggle classes from JS if desired) */
#sankeySvg .sk-link-hover { stroke-opacity: 0.55 !important; }
#sankeySvg .sk-node-hover { filter: drop-shadow(0 0 6px rgba(255,214,74,0.22)); }

@media (max-width: 520px) {
  #sankeyPanel {
    width: auto;
    max-width: calc(100% - 24px);
  }
  #sankeyPanel .sk-kv {
    grid-template-columns: 84px 1fr;
  }
}

.sankey-bundle-slider {
  width: 75%;
  margin: 25px auto 5px;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  column-gap: 6px;
}

.sankey-asset-nav {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
}

.sankey-asset-nav svg {
  width: 20px;
  height: 20px;
}

.sankey-asset-nav:hover {
  background: rgba(255,255,255,0.10);
}

.sankey-asset-nav:focus-visible {
  outline: 2px solid rgba(255,214,74,0.85);
  outline-offset: 2px;
}

.sankey-boxes-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.sankey-asset-box {
  padding: 8px 10px;
  min-height: 34px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);

  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  text-align: center;

  cursor: pointer;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  opacity: 0.90;
  background: rgba(255,255,255,0.10);
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);

  transition: transform 120ms ease, opacity 120ms ease, outline-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.sankey-asset-box:not(.sankey-bundle-pill--current) {
  opacity: 0.62;
  filter: saturate(0.90);
}

.sankey-asset-box:hover {
  opacity: 0.90;
  transform: translateY(-1px);
}

.sankey-bundle-pill--current:hover {
  opacity: 1;
}

.sankey-bundle-pill--current {
  opacity: 1;
  outline: 2px solid rgba(255,214,74,0.95);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(255,214,74,0.14);
  min-width: 100%;
}

.sankey-box-label {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sankey-bundle-pill--current .sankey-box-label {
  padding-right: 34px; /* space for bulb */
}

.sankey-bundle-bulb {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  z-index: 3;
  border: 3px solid transparent;
  background:
    linear-gradient(#2f3347, #2f3347) padding-box,
    linear-gradient(90deg, #FF5AE1 0%, #6D96FF 100%) border-box;
}

.sankey-bundle-bulb:focus-visible {
  outline: 2px solid rgba(255,214,74,0.85);
  outline-offset: 2px;
}

.sankey-bundle-pill--current {
  position: relative;
}

#sankeyRotateBtn.heatmap-rotate-btn {
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
}

#sankeyRotateBtn.heatmap-rotate-btn:hover {
  background: rgba(255,255,255,0.10);
}

.overlay-modal--filter-backdrop[hidden] {
  display: none !important;
}

body.overlay-modal--filter-open #sankeyBundleOverlay.overlay-modal--filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(2,6,23,0.62);
  backdrop-filter: blur(8px);

  pointer-events: auto;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter.sankey-overlay {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;

  border-radius: var(--radius);
  border: 1px solid rgba(99,102,241,0.30);
  background: var(--card);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);

  color: rgba(255,255,255,0.92);
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 14px 16px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-title {
  margin: 0;
  line-height: 1;
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0.2px;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.92);

  font-size: 22px;
  line-height: 1;
  cursor: pointer;

  padding: 6px 8px;
  border-radius: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-close:hover {
  background: rgba(99,102,241,0.14);
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-body {
  padding: 14px 16px;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(148,163,184,0.18);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-footer button.sankey-icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  color: #fff;
}

body.overlay-modal--filter-open #sankeyBundleOverlay .overlay-modal--filter-footer button.sankey-icon-btn:hover {
  background: rgba(255, 255, 255, 0.10);
}

.sankey-overlay-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sankey-overlay-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.68);
  margin-top: -2px;
}

.sankey-overlay-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sankey-overlay-block {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px 12px;
}

.sankey-overlay-block-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: rgba(255,255,255,0.72);
  margin-bottom: 8px;
  text-transform: none;
}

.sankey-overlay-text {
  font-size: 13px;
  color: rgba(255,255,255,0.92);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.sankey-overlay-list {
  margin: 0;
  padding-left: 18px;
}

.sankey-overlay-list li {
  margin: 6px 0;
  color: rgba(255,255,255,0.90);
  line-height: 1.35;
}

.sankey-overlay-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.sankey-watchlist {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.sankey-watch {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 10px 10px;
}

.sankey-watch-k {
  font-size: 12px;
  color: rgba(255,255,255,0.60);
  margin-bottom: 6px;
  font-weight: 800;
}

.sankey-watch-v {
  font-size: 13px;
  color: rgba(255,255,255,0.92);
  line-height: 1.35;
  word-break: break-word;
}

.muted {
  color: rgba(255,255,255,0.55);
}

@media (max-width: 720px) {
  .sankey-bundle-slider {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .sankey-boxes-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #sankeyBoxPrev,
  #sankeyBoxNext {
    display: none;
  }

  #sankeyWrap,
  .sankey-wrap {
    height: 420px;
    min-height: 220px;
  }
}

@media (max-width: 900px) {
  .sankey-watchlist {
    grid-template-columns: 1fr;
  }
}