/* ============================================================================
 * heat.css — hero treemap
 * Every colour resolves through the Moon tokens already declared on :root in
 * index.html. The only literals are the ramp fills, which are set inline by
 * heat.js because they are computed per tile.
 * ========================================================================== */

#heat-hero { display: flex; flex-direction: column; min-height: 0; }

/* ---- header ---- */
.hm-head {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 38px;
}
.hm-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--fg-2); text-transform: uppercase;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.hm-title .code { color: var(--up); font-family: var(--mono); }

.hm-dot {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--fg-4); background: none; padding: 0;
}
.hm-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-4); transition: background .2s, box-shadow .2s;
}
.hm-dot.on { color: var(--fg-2); }
.hm-dot.on::before {
  background: var(--up); box-shadow: 0 0 8px var(--up);
  animation: hm-pulse 1.6s ease-in-out infinite;
}
@keyframes hm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

#hm-breadth { display: flex; align-items: center; gap: 9px; }
.hm-bar { width: 132px; height: 5px; display: flex; gap: 1px; background: var(--bg-2); overflow: hidden; }
.hm-bar-up { background: var(--up-dim); }
.hm-bar-dn { background: var(--down-dim); }
.hm-breadth-lbl { font-family: var(--mono); font-size: 9.5px; color: var(--fg-3); white-space: nowrap; }

.hm-head-sp { flex: 1; }
.hm-find {
  display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px;
  border: 1px solid var(--line-2); background: var(--bg-1); border-radius: 3px;
}
.hm-find span { font-family: var(--mono); font-size: 10px; color: var(--fg-4); }
.hm-find input {
  width: 104px; border: 0; outline: 0; background: transparent; color: var(--fg);
  font-family: var(--mono); font-size: 10.5px; padding: 0;
}
.hm-find input::placeholder { color: var(--fg-4); }
.hm-find:focus-within { border-color: var(--up); }
#hm-stamp { font-family: var(--mono); font-size: 9.5px; color: var(--fg-4); white-space: nowrap; }

/* ---- control rail ---- */
#hm-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg-1);
}
.hm-seg { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.hm-seg-lbl {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  color: var(--fg-4); margin-right: 1px;
}
.hm-grp { display: flex; border: 1px solid var(--line-2); border-radius: 3px; overflow: hidden; }
.hm-grp .hm-chip { border: 0; border-radius: 0; border-right: 1px solid var(--line-2); }
.hm-grp .hm-chip:last-child { border-right: 0; }
.hm-spacer { flex: 1 1 auto; }

.hm-chip {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.08em;
  padding: 4px 8px; color: var(--fg-4); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 3px; cursor: pointer;
  transition: color .12s, background .12s, border-color .12s; white-space: nowrap;
}
.hm-chip:hover { color: var(--fg-2); background: var(--bg-hover); }
.hm-chip.on { color: var(--bg); background: var(--up); border-color: var(--up); font-weight: 700; }
.hm-chip:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }

/* ---- drill bar ---- */
#hm-drill {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
}
#hm-drill[hidden] { display: none; }
.hm-dk { color: var(--fg-4); }
.hm-dv { color: var(--fg); font-weight: 600; }
.hm-ds { color: var(--fg-3); text-transform: uppercase; }
.hm-dx { color: var(--down); font-family: var(--mono); font-size: 10px; margin-left: 4px; padding: 0; }
.hm-dx:hover { color: var(--fg); }

/* ---- map ---- */
#hm-map { position: relative; flex: 1; min-height: 0; height: 430px; overflow: hidden; background: var(--bg); }
.hm-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; color: var(--fg-4); text-align: center; padding: 0 24px;
}

.hm-group { position: absolute; overflow: hidden; }
.hm-ghead {
  position: absolute; inset: 0 0 auto 0; height: 16px; z-index: 2;
  display: flex; align-items: center; gap: 5px; padding: 0 4px;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.hm-ghead:hover { background: var(--bg-hover); }
.hm-grip { font-size: 8px; color: var(--fg-4); cursor: grab; letter-spacing: -1px; }
.hm-glabel {
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--fg-2); text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0;
}
.hm-gpct { font-family: var(--mono); font-size: 9px; flex: 0 0 auto; }
.hm-gpct.up { color: var(--up); } .hm-gpct.down { color: var(--down); } .hm-gpct.na { color: var(--fg-4); }

.hm-tile {
  position: absolute; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--bg); transition: filter .12s;
}
.hm-tile:hover { filter: brightness(1.45); z-index: 3; }
#hm-map:hover .hm-tile:not(:hover) { opacity: 0.82; }
.hm-tile.na { background: var(--bg-2) !important; }
.hm-tile.na .hm-t, .hm-tile.na .hm-v { color: var(--fg-4); }
.hm-tile.star { box-shadow: inset 0 0 0 1px var(--amber); }
.hm-t {
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.02em;
  color: rgba(255,255,255,0.96); line-height: 1.1; pointer-events: none;
}
.hm-v {
  font-family: var(--mono); font-weight: 500;
  color: rgba(255,255,255,0.84); line-height: 1.2; pointer-events: none;
}
@keyframes hm-flash-up { 0% { box-shadow: inset 0 0 0 2px var(--up); } 100% { box-shadow: none; } }
@keyframes hm-flash-dn { 0% { box-shadow: inset 0 0 0 2px var(--down); } 100% { box-shadow: none; } }

/* ---- tooltip ---- */
.hm-tip {
  position: absolute; z-index: 20; pointer-events: none;
  min-width: 216px; max-width: 250px; padding: 9px 10px;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
}
.hm-tip[hidden] { display: none; }
.hm-tip-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.hm-tip-t { font-family: var(--mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--fg); }
.hm-tip-c { font-family: var(--mono); font-size: 11px; }
.hm-tip-c.up { color: var(--up); } .hm-tip-c.down { color: var(--down); } .hm-tip-c.na { color: var(--fg-4); }
.hm-tip-n { font-size: 11px; color: var(--fg-3); line-height: 1.3; margin-bottom: 8px; }
.hm-spark {
  display: block; width: 100%; height: 46px; margin-bottom: 8px;
  background: var(--bg); border: 1px solid var(--line);
}
.hm-tip-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  font-family: var(--mono); font-size: 10px;
}
.hm-tip-grid .k { color: var(--fg-4); }
.hm-tip-grid .v { color: var(--fg-2); text-align: right; }
.hm-tip-grid .v.up { color: var(--up); } .hm-tip-grid .v.down { color: var(--down); }
.hm-approx { color: var(--fg-4); font-size: 8.5px; letter-spacing: 0.06em; }
.hm-tip-na { font-size: 10.5px; line-height: 1.45; color: var(--amber); }
.hm-tip-na code { font-family: var(--mono); font-size: 10px; color: var(--fg-2); }
.hm-tip-foot {
  margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; color: var(--fg-4);
}

/* ---- footer ---- */
#hm-footer {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 12px; border-top: 1px solid var(--line); background: var(--bg-1);
}
.hm-legend { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.hm-legend span { font-family: var(--mono); font-size: 9px; color: var(--fg-4); }
.hm-legend i { width: 13px; height: 7px; display: block; }
.hm-hint {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--fg-4);
}
.hm-count { flex: 0 0 auto; font-family: var(--mono); font-size: 9px; color: var(--fg-4); white-space: nowrap; }
.hm-miss { color: var(--amber); font-weight: 500; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  #hm-map { height: 380px; }
  .hm-find { display: none; }
}
@media (max-width: 720px) {
  .hm-head { gap: 10px; padding: 9px 10px; flex-wrap: wrap; }
  #hm-breadth { display: none; }
  #hm-controls { padding: 6px 10px; gap: 5px; }
  .hm-seg-lbl { display: none; }
  #hm-map { height: 320px; }
  .hm-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hm-dot.on::before { animation: none; }
  .hm-tile { transition: none; }
  .hm-tile[style*="animation"] { animation: none !important; }
}
