/* =========================================================================
 *  industry-mindmap.css
 *  產業心智圖（SVG）相關樣式
 *  - 由 industry-maps.html 直接引用
 *  - 配對程式：static/industry-workbench.js（drawMindMap / build*NodeMarkup）
 *  - 對應 HTML class：.iw-map-stage / .iw-map-svg / .iw-map-node / .iw-map-link
 *  - 從 industry-workbench.css 抽離出來（2026-05-26）
 * ========================================================================= */

/* ───────── stage 容器 ───────── */
.iw-map-stage {
  position: relative;
  height: 620px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(219, 234, 254, 0.45), transparent 70%),
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  background-size: auto, 28px 28px, 28px 28px, auto;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.iw-map-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  min-height: 360px;
}

.iw-map-svg.is-panning,
.iw-map-node.is-dragging {
  cursor: grabbing;
}

/* ───────── 連線 ───────── */
.iw-map-link {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.iw-map-link--major {
  stroke: color-mix(in srgb, var(--ink-soft, #475569) 18%, #cbd5e1);
  stroke-width: 1.8;
  opacity: 0.7;
}

/* ───────── 節點通用 ───────── */
.iw-map-node {
  cursor: pointer;
  transition: transform 0.14s ease;
}

.iw-map-node:hover {
  transform: translateY(-1px);
}

.iw-map-node__bg {
  stroke-width: 1.4;
  transition: stroke 0.12s ease, fill 0.12s ease;
}

.iw-map-node__accent {
  pointer-events: none;
  fill: var(--node-accent, #3b82f6);
}

.iw-map-node__glow {
  fill: none;
  stroke: var(--node-accent, #3b82f6);
  stroke-width: 3;
  opacity: 0.55;
  pointer-events: none;
}

.iw-map-node.is-active .iw-map-node__glow {
  opacity: 0.85;
}

.iw-map-node__title,
.iw-map-node__sub,
.iw-map-node__meta,
.iw-map-node__major-label,
.iw-map-node__major-meta,
.iw-map-node__stock-code,
.iw-map-node__stock-role,
.iw-map-node__more-label,
.iw-map-node__label {
  pointer-events: none;
  dominant-baseline: middle;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

/* fallback 通用 label */
.iw-map-node__label {
  fill: #334155;
  font-weight: 600;
}

/* ───────── 大產業 ───────── */
.iw-map-node--major .iw-map-node__bg {
  fill: color-mix(in srgb, var(--node-accent, #3b82f6) 12%, #ffffff);
  stroke: color-mix(in srgb, var(--node-accent, #3b82f6) 55%, #cbd5e1);
}

.iw-map-node--major.is-active .iw-map-node__bg {
  fill: color-mix(in srgb, var(--node-accent, #3b82f6) 22%, #ffffff);
  stroke: var(--node-accent, #2563eb);
  stroke-width: 2;
}

.iw-map-node__major-label {
  fill: #0f172a;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.iw-map-node__major-meta {
  fill: color-mix(in srgb, var(--node-accent, #3b82f6) 45%, #475569);
  font-weight: 600;
}

/* ───────── 子產業 ───────── */
.iw-map-node--industry .iw-map-node__bg {
  fill: #ffffff;
  stroke: #e2e8f0;
}

.iw-map-node--industry:hover .iw-map-node__bg {
  stroke: color-mix(in srgb, var(--node-accent, #3b82f6) 45%, #94a3b8);
}

.iw-map-node--industry.is-active .iw-map-node__bg {
  stroke: var(--node-accent, #2563eb);
  stroke-width: 2;
  fill: color-mix(in srgb, var(--node-accent, #3b82f6) 4%, #ffffff);
}

.iw-map-node__title {
  fill: #0f172a;
  font-weight: 700;
}

.iw-map-node__sub {
  fill: #64748b;
  font-weight: 500;
}

.iw-map-node__meta {
  fill: #94a3b8;
  font-weight: 600;
}

/* ───────── 階段徽章（成長 / 過熱 / 震盪 …） ───────── */
.iw-map-stage-tag rect {
  fill: #f1f5f9;
  stroke: #e2e8f0;
}

.iw-map-stage-tag text {
  fill: #475569;
  font-weight: 700;
  dominant-baseline: middle;
}

.iw-map-stage-tag--good rect {
  fill: #ecfdf5;
  stroke: #a7f3d0;
}

.iw-map-stage-tag--good text {
  fill: #047857;
}

.iw-map-stage-tag--warn rect {
  fill: #fff7ed;
  stroke: #fed7aa;
}

.iw-map-stage-tag--warn text {
  fill: #c2410c;
}

.iw-map-stage-tag--bad rect {
  fill: #fef2f2;
  stroke: #fecaca;
}

.iw-map-stage-tag--bad text {
  fill: #b91c1c;
}

/* ───────── 代表股 ───────── */
.iw-map-node--stock .iw-map-node__bg {
  fill: #ffffff;
  stroke: #dbeafe;
}

.iw-map-node--stock:hover .iw-map-node__bg {
  stroke: #93c5fd;
}

.iw-map-node--stock.is-active .iw-map-node__bg {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 2;
}

.iw-map-node__stock-code {
  fill: #0f172a;
  font-weight: 700;
}

.iw-map-node__stock-role {
  fill: #64748b;
  font-weight: 500;
}

/* ───────── +N 更多 ───────── */
.iw-map-node--more .iw-map-node__bg,
.iw-map-node__bg--more {
  fill: #fffbeb;
  stroke: #fcd34d;
  stroke-width: 1.2;
  stroke-dasharray: 4 3;
}

.iw-map-node--more:hover .iw-map-node__bg {
  fill: #fef3c7;
  stroke: #f59e0b;
}

.iw-map-node__more-label {
  fill: #b45309;
  font-weight: 700;
}

/* ───────── tooltip 卡片 ───────── */
.iw-map-tooltip {
  position: absolute;
  z-index: 4;
  max-width: 280px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #f1f5f9;
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
  transform: translate(14px, 14px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.iw-map-tooltip b {
  display: block;
  margin: 2px 0 4px;
  color: #ffffff;
  font-size: 13px;
}

.iw-map-tooltip__card {
  display: grid;
  gap: 4px;
}

.iw-map-tooltip__type {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--node-accent, #93c5fd);
  font-weight: 700;
}

.iw-map-tooltip__body {
  margin: 0;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.5;
}

.iw-map-tooltip__hint {
  margin: 4px 0 0;
  color: #93c5fd;
  font-size: 10px;
  font-weight: 600;
}

/* ───────── 手機提示 ───────── */
.iw2-map-mobile-hint {
  margin: 8px 4px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* ───────── 工具列（segmented control 風格） ───────── */
.iw2-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.iw2-map-toolbar__group {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: #f1f5f9;
  border-radius: 8px;
  gap: 2px;
}

.iw2-map-toolbar__group .iw-mini-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}

.iw2-map-toolbar__group .iw-mini-btn:hover {
  background: rgba(15, 23, 42, 0.05);
  color: #0f172a;
}

.iw2-map-toolbar__group .iw-mini-btn.is-primary {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* ───────── 圖例 ───────── */
.iw2-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 4px 0;
  font-size: 11px;
  color: #64748b;
}

.iw2-map-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.iw2-map-legend__item::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
}

.iw2-map-legend__item--major::before {
  background: color-mix(in srgb, #3b82f6 14%, #ffffff);
  border-color: #93c5fd;
  border-left-width: 4px;
}

.iw2-map-legend__item--industry::before {
  background: #ffffff;
  border-color: #cbd5e1;
  border-left-width: 3px;
  border-left-color: #94a3b8;
}

.iw2-map-legend__item--stock::before {
  background: #ffffff;
  border-color: #93c5fd;
  border-radius: 6px;
}

.iw2-map-legend__item--more::before {
  background: #fffbeb;
  border-color: #fcd34d;
  border-style: dashed;
}

/* ───────── AI 供應鏈 ECharts 樹 ───────── */
.iw-map-stage.iw-map-stage--supply-tree {
  height: min(88vh, 980px);
  min-height: 620px;
  background: #fff;
  position: relative;
}

.iw-mind-drawer__body .iw2-mind-panel--supply {
  min-height: 0;
}

.iw-mind-drawer__body .iw2-mind-panel--supply .iw2-mind-card--panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.iw-mind-drawer__body .iw2-mind-panel--supply .iw-map-stage--supply-tree {
  flex: 1;
  width: 100%;
  height: auto;
  max-height: none;
  min-height: calc(95dvh - 168px);
}

.iw-mind-drawer__body .iw2-mind-panel--supply .iw2-map-legend {
  flex-shrink: 0;
  margin-top: 6px;
  padding-top: 6px;
}

.iw-supply-tree-quick-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  font-family: inherit;
}

.iw-supply-tree-quick-btn:hover {
  background: #1d4ed8;
}

.iw-supply-tree-chart {
  width: 100%;
  height: 100%;
  min-height: 0;
}

@media (max-width: 1024px) {
  .iw-mind-drawer__body .iw2-mind-panel--supply .iw-map-stage--supply-tree {
    min-height: calc(95dvh - 188px);
  }
}

.iw2-map-legend--supply .iw2-map-legend__item--up::before {
  border-left: 4px solid #4338ca;
  background: #eef2ff;
}

.iw2-map-legend--supply .iw2-map-legend__item--mid::before {
  border-left: 4px solid #2563eb;
  background: #eff6ff;
}

.iw2-map-legend--supply .iw2-map-legend__item--down::before {
  border-left: 4px solid #0d9488;
  background: #f0fdfa;
}

.iw2-map-legend--supply .iw2-map-legend__item--core::before {
  border-left: 4px solid #2563eb;
  background: #dbeafe;
}

.iw2-map-legend--supply .iw2-map-legend__item--sub::before {
  border-left: 4px solid #7c3aed;
  background: #ede9fe;
}

.iw2-map-legend--supply .iw2-map-legend__item--ext::before {
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
}

/* ───────── 圖表工具：AI 供應鏈總覽（左下整合圖） ───────── */
.iw-adv-charts--ai-overview {
  grid-template-columns: 1fr 1fr;
}

.iw-adv-supply-mount--overview {
  height: min(1200px, calc(92dvh - 200px));
  min-height: 520px;
}

.iw-adv-supply-mount--drawer {
  flex: 1;
  min-height: min(960px, calc(88dvh - 180px));
  height: min(960px, calc(88dvh - 160px));
}

.iw-mind-drawer-pane--ai-supply.is-active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.iw-mind-drawer-pane--ai-supply .iw-adv-section--supply-drawer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 4px 2px 8px;
}

.iw-mind-drawer-pane--ai-supply .iw-adv-supply-mount--drawer {
  flex: 1;
  min-height: 480px;
  height: auto;
  max-height: none;
}

@media (max-width: 1024px) {
  .iw-adv-supply-mount--overview {
    min-height: 420px;
    height: min(720px, calc(88dvh - 160px));
  }
}

.iw-adv-supply-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.iw-adv-supply-legend {
  margin-bottom: 10px;
}

.iw-adv-supply-mount {
  height: min(960px, calc(88dvh - 180px));
  min-height: 560px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.iw-adv-supply-mount .iw-map-stage.iw-map-stage--supply-tree {
  height: 100% !important;
  min-height: inherit !important;
  max-height: none;
}

.iw2-map-supply-hint {
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.55;
  color: #64748b;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.iw-linkish {
  appearance: none;
  border: none;
  padding: 0;
  background: none;
  color: #2563eb;
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.iw-linkish:hover {
  color: #1d4ed8;
}

@media (max-width: 1024px) {
  .iw-adv-supply-mount {
    min-height: 420px;
    height: min(720px, calc(88dvh - 160px));
  }
}
