/* "Premature optimization is the root of all evil" — made tangible.
   The bars are the profile: a program spends almost all its time in a few percent
   of its code. Optimize the tiny parts and the total barely moves; optimize the
   hotspot and it plummets. Measure first, then cut only the critical few percent.
   Vanilla JS, no deps, no build. Dark theme. Palette shared with sibling widgets:
   green = a real speedup (the win), neutral otherwise. No red. */

#hotspot-profiler {
  --hp-win: #30d158;                 /* a real speedup — the win */
  --hp-bar: #6f7bdc;                 /* calm cost bar (indigo) */
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  background: var(--color-bg-elevated, #111111);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  padding: clamp(16px, 3vw, 26px);
  margin: 2.5rem 0;
  color: var(--color-text-primary, #ffffff);
}

.hp-title { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
.hp-explain {
  font-size: 0.9rem; line-height: 1.55; margin: 8px 0 18px;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.7));
}

.hp-rows { display: flex; flex-direction: column; gap: 8px; }
.hp-row {
  display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px;
}
@media (max-width: 560px) {
  .hp-row { grid-template-columns: 1fr auto; grid-template-areas: "name btn" "bar bar"; }
  .hp-name { grid-area: name; } .hp-track { grid-area: bar; } .hp-opt { grid-area: btn; }
}
.hp-name {
  font-family: var(--font-mono, "SF Mono", Monaco, monospace); font-size: 0.82rem;
  color: var(--color-text-secondary, rgba(255,255,255,0.72)); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.hp-track {
  position: relative; height: 26px; border-radius: 6px;
  background: rgba(255,255,255,0.05); overflow: hidden;
}
.hp-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 6px;
  background: var(--hp-bar); width: 0;
  transition: width 0.5s cubic-bezier(.2,.7,.2,1), background 0.3s;
}
.hp-row.is-opt .hp-fill { background: rgba(111,123,220,0.4); }
.hp-pct {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono, monospace); font-size: 0.72rem; color: #fff;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.hp-opt {
  appearance: none; cursor: pointer; font: inherit; font-size: 0.78rem;
  background: transparent; color: var(--color-text-primary, #fff);
  border: 1px solid var(--color-border, rgba(255,255,255,0.16)); border-radius: 7px; padding: 5px 11px;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s; white-space: nowrap;
}
.hp-opt:hover:not(:disabled) { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.05); }
.hp-opt:disabled { opacity: 0.5; cursor: default; }
.hp-row.is-opt .hp-opt { color: var(--hp-win); border-color: rgba(48,209,88,0.4); }

/* readout */
.hp-readout {
  margin-top: 18px; display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  background: var(--color-bg-surface, #1a1a1a);
  border: 1px solid var(--color-border-subtle, rgba(255,255,255,0.08));
  border-radius: 12px; padding: 14px 16px; transition: border-color 0.25s;
}
.hp-readout.is-win { border-color: var(--hp-win); }
.hp-metric { font-size: 0.82rem; color: var(--color-text-secondary, rgba(255,255,255,0.6)); }
.hp-metric b { display: block; font-size: 1.5rem; font-weight: 700; color: #fff; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hp-metric--speed b { color: #fff; }
.hp-readout.is-win .hp-metric--speed b { color: var(--hp-win); }

.hp-status {
  margin-top: 12px; font-size: 0.88rem; line-height: 1.5; min-height: 1.4em;
  color: var(--color-text-secondary, rgba(255,255,255,0.72));
}
.hp-status b { color: #fff; }
.hp-status .hp-good { color: var(--hp-win); font-weight: 650; }

.hp-reset {
  margin-top: 14px; appearance: none; cursor: pointer; font: inherit; font-size: 0.84rem;
  background: transparent; color: var(--color-text-primary, #fff);
  border: 1px solid var(--color-border, rgba(255,255,255,0.15)); border-radius: 8px; padding: 7px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.hp-reset:hover { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.05); }

.hp-noscript { font-size: 0.9rem; color: var(--color-text-secondary, rgba(255,255,255,0.65)); line-height: 1.6; }
