/* =========================================================================
 * theme.css — UI テーマ（Agent5 所有）
 * ダークネイビー基調 + シャンパンゴールド差し色。旧 style.css のトーンを踏襲・拡張。
 * 金融ダッシュ風の上質さ・余白。globe.gl は #globeViz を背景に敷く。
 * ======================================================================= */

:root {
  --navy-900: #060b16;
  --navy-800: #0a1222;
  --navy-700: #0f1a2e;
  --navy-600: #16233b;
  --line: rgba(201, 168, 106, 0.16);
  --line-soft: rgba(255, 255, 255, 0.06);
  --gold: #c9a86a;
  --gold-bright: #e6cf9a;
  --gold-dim: rgba(201, 168, 106, 0.55);
  --text: #e8ecf4;
  --text-dim: #8a97ac;
  --text-faint: #56617a;
  --glass-bg: rgba(8, 13, 24, 0.88);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  --radius: 14px;
  --sans: "Noto Sans JP", system-ui, sans-serif;
  --serif: "Cormorant Garamond", "Noto Sans JP", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 70% 20%, #12203a 0%, transparent 60%),
    radial-gradient(1000px 900px at 20% 90%, #0c1526 0%, transparent 55%),
    var(--navy-900);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#globeViz {
  position: absolute; inset: 0;
  z-index: 0;
  cursor: grab;
}
#globeViz:active { cursor: grabbing; }

/* パネルはすべて #ui 配下（クリック透過を避けるため個別に pointer-events を持つ） */
#ui { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#ui > .panel { pointer-events: auto; }

/* ---------- ガラスパネル共通 ---------- */
.panel { position: absolute; z-index: 5; }
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.panel-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-dim);
  font-weight: 500;
  margin-bottom: 12px;
}

/* ---------- ブランド ---------- */
#brand {
  position: absolute; top: 26px; left: 28px; z-index: 6;
  display: flex; align-items: center; gap: 14px;
}
.brand-mark {
  font-size: 26px; color: var(--gold);
  text-shadow: 0 0 20px rgba(201, 168, 106, 0.45);
}
.brand-text h1 {
  font-family: var(--serif);
  font-size: 22px; font-weight: 600;
  letter-spacing: 0.14em; color: var(--gold-bright);
  line-height: 1;
}
.brand-text p {
  font-size: 11px; color: var(--text-dim);
  letter-spacing: 0.18em; margin-top: 5px;
}

/* ---------- レイヤーバー（上部中央・registry 駆動） ---------- */
#layerBar {
  top: 26px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 18px;
  padding: 12px 16px; max-width: calc(100vw - 420px);
}
.layer-group { display: flex; flex-direction: column; gap: 7px; }
.layer-group + .layer-group {
  padding-left: 18px; border-left: 1px solid var(--line-soft);
}
.group-label {
  font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 500;
}
.layer-row { display: flex; gap: 6px; flex-wrap: wrap; }
.layer-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim); font-family: var(--sans); font-size: 12.5px;
  font-weight: 500; letter-spacing: 0.04em; padding: 8px 14px;
  border-radius: 9px; cursor: pointer; transition: all 0.22s ease;
  white-space: nowrap;
}
.layer-toggle:hover { color: var(--text); border-color: var(--line-soft); }
.layer-toggle .lt-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); transition: all 0.22s ease; flex-shrink: 0;
}
.layer-toggle.is-active { color: var(--gold-bright); border-color: var(--gold-dim); }
.layer-toggle.base.is-active {
  color: var(--navy-900);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 4px 14px rgba(201, 168, 106, 0.28);
}
.layer-toggle.base.is-active .lt-dot { background: var(--navy-800); }
.layer-toggle.overlay.is-active { background: rgba(201, 168, 106, 0.12); }
.layer-toggle.is-active .lt-dot { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* ---------- 指標パネル（左） ---------- */
#indicatorPanel {
  top: 108px; left: 28px; width: 250px; padding: 20px;
  max-height: calc(100vh - 160px); overflow-y: auto;
  transition: opacity 0.2s ease;
}
#indicatorPanel.is-busy { opacity: 0.6; pointer-events: none; }
.indicator-list { display: flex; flex-direction: column; gap: 7px; }
.ind-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  border: 1px solid transparent; background: rgba(255, 255, 255, 0.02);
  border-radius: 10px; padding: 11px 13px; cursor: pointer;
  text-align: left; transition: all 0.22s ease; width: 100%;
}
.ind-btn:hover { background: rgba(201, 168, 106, 0.07); border-color: var(--line-soft); }
.ind-btn.is-active { background: rgba(201, 168, 106, 0.1); border-color: var(--gold-dim); }
.ind-name { font-size: 14px; color: var(--text); font-weight: 500; }
.ind-btn.is-active .ind-name { color: var(--gold-bright); }
.ind-sub {
  font-size: 10px; color: var(--text-faint);
  font-family: ui-monospace, "SF Mono", monospace; letter-spacing: 0.02em;
}

/* ---------- 凡例 ---------- */
.legend { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.legend-bar {
  height: 9px; border-radius: 5px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(201,168,106,0.4));
}
.legend-ends {
  display: flex; justify-content: space-between; margin-top: 7px;
  font-size: 10px; color: var(--text-faint); letter-spacing: 0.05em;
}
.data-source {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
  font-size: 10px; line-height: 1.7; color: var(--text-faint);
}

/* ---------- ランキング（右） ---------- */
#rankingPanel {
  top: 108px; right: 28px; width: 252px; padding: 20px;
  max-height: calc(100vh - 160px); overflow-y: auto;
}
.ranking-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.rank-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: background 0.18s ease; border: 1px solid transparent;
}
.rank-item:hover { background: rgba(201, 168, 106, 0.08); border-color: var(--line-soft); }
.rank-num {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  color: var(--gold); width: 22px; text-align: center; flex-shrink: 0;
}
.rank-item:nth-child(-n+3) .rank-num { color: var(--gold-bright); }
.rank-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rank-name {
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.rank-val { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.rank-empty { font-size: 12px; color: var(--text-faint); padding: 8px 10px; }

/* ---------- 操作（右下） ---------- */
#controls {
  bottom: 28px; right: 28px; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: 340px;
}
.ctrl-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim); font-family: var(--sans); font-size: 12px;
  font-weight: 500; letter-spacing: 0.05em; padding: 9px 15px;
  border-radius: 9px; cursor: pointer; transition: all 0.22s ease;
}
.ctrl-btn:hover { color: var(--text); border-color: var(--gold-dim); }
.ctrl-btn.is-active { color: var(--gold-bright); border-color: var(--gold-dim); }
.ctrl-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); transition: all 0.22s ease;
}
.ctrl-btn.is-active .ctrl-dot { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
#updateBtn { border-color: var(--gold-dim); color: var(--gold-bright); }
#updateBtn:hover { background: rgba(201, 168, 106, 0.12); }
#updateBtn.is-loading { opacity: 0.6; pointer-events: none; }
.update-status {
  font-size: 10px; color: var(--text-faint); flex-basis: 100%;
  min-height: 12px; letter-spacing: 0.03em;
}
.update-status.ok { color: #6fbf9a; }
.update-status.err { color: #c98a6a; }

/* ---------- ツールチップ ---------- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: rgba(6, 11, 22, 0.92);
  border: 1px solid var(--gold-dim);
  border-radius: 11px; padding: 13px 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  min-width: 168px; max-width: 280px;
  left: 0; top: 0;
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tt-name { font-size: 15px; font-weight: 700; color: var(--gold-bright); margin-bottom: 4px; }
.tt-ind { font-size: 10px; color: var(--text-faint); letter-spacing: 0.08em; margin-bottom: 8px; }
.tt-val {
  font-size: 20px; font-weight: 300; color: var(--text);
  font-family: var(--serif); letter-spacing: 0.01em;
}
.tt-val .unit { font-size: 12px; color: var(--text-dim); margin-left: 3px; font-family: var(--sans); }
.tt-nodata { font-size: 13px; color: var(--text-faint); }
.tt-extra { font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* ---------- ローディング ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--navy-900);
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
#loader.hide { opacity: 0; pointer-events: none; visibility: hidden; }
.loader-ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(201, 168, 106, 0.2);
  border-top-color: var(--gold); animation: spin 0.9s linear infinite;
}
.loader-text { font-size: 12px; color: var(--text-dim); letter-spacing: 0.2em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1000px) {
  #indicatorPanel, #rankingPanel { width: 216px; }
  #layerBar { max-width: calc(100vw - 40px); }
  #brand { top: 20px; left: 18px; }
  .brand-text h1 { font-size: 18px; }
}
@media (max-width: 720px) {
  #layerBar {
    top: auto; bottom: 96px; left: 14px; right: 14px; transform: none;
    max-width: none; overflow-x: auto; justify-content: flex-start;
  }
  #indicatorPanel {
    top: auto; bottom: 168px; left: 14px; right: 14px; width: auto;
    max-height: 40vh;
  }
  #rankingPanel { display: none; }
  #controls { bottom: 14px; right: 14px; left: 14px; max-width: none; justify-content: center; }
}
