/* ============================================================
 * Utilities Bunker — Harmonics Distortion (THD) v2.1
 * File: /assets/css/modules/electronics/harmonics.v2.1.css
 * Purpose:
 * - Tool-only layout + spectrum view + harmonic entry list styling
 * - Mobile-first, 44x44 touch targets, clamp typography
 * Notes:
 * - Do NOT modify /assets/css/ub-toolkit.v2.1.css
 * ============================================================ */

/* ============================== Tool tokens (scoped) ============================== */
:root{
  --hd-radius: 16px;
  --hd-gap: 14px;
}

/* ============================== Header row helper ============================== */
.ub-headrow{
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
}

/* ============================== Hero layout ============================== */
.hd-hero{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--hd-gap);
}

/* Stack on tablet/mobile */
@media (max-width: 980px){
  .hd-hero{
    grid-template-columns: 1fr;
  }
}

/* ============================== Spectrum lab panel ============================== */
.hd-lab{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--hd-radius);
  padding: 12px;
}

.hd-lab-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 10px;
  flex-wrap:wrap;
  margin-bottom: 8px;
}

.hd-lab-title{
  font-size: clamp(13px, 1.2vw, 14px);
  font-weight: 950;
  letter-spacing: .01em;
}

.hd-lab-sub{
  font-size: 12px;
  color: var(--ub-muted);
  margin-top: 2px;
}

/* ============================== KPI tiles ============================== */
.hd-kpis{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  justify-content:flex-end;
}

.hd-kpi{
  min-width: 112px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}

.hd-kpi .k{
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ub-muted);
}

.hd-kpi .v{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
  margin-top: 2px;
}

/* ============================== Quality pill ============================== */
.hd-risk{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
  font-size: 12px;
  font-weight: 950;
  min-height: 44px;
  margin-top: 8px;
}

.hd-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ub-muted);
}

/* JS toggles these classes */
.hd-dot.is-good{ background: var(--ub-success); }
.hd-dot.is-warn{ background: var(--ub-warning); }
.hd-dot.is-bad{  background: var(--ub-danger); }

/* ============================== Spectrum SVG ============================== */
.hd-spectrum{
  width: 100%;
  height: auto;
  margin-top: 10px;
  display:block;
  border-radius: 14px;
}

/* Bars */
.hd-bar{
  fill: rgba(0,0,0,.16);
  stroke: rgba(0,0,0,.20);
  stroke-width: 1;
}

/* Fundamental stands out */
.hd-bar--fund{
  fill: rgba(249,58,19,.28);
  stroke: rgba(249,58,19,.55);
}

html.ub-theme-dark .hd-bar{
  fill: rgba(255,255,255,.12);
  stroke: rgba(255,255,255,.16);
}

html.ub-theme-dark .hd-bar--fund{
  fill: rgba(249,58,19,.25);
  stroke: rgba(249,58,19,.55);
}

/* Focus ring for SVG when tabbing (if any text is focusable later) */
.hd-spectrum :focus{
  outline:none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius: 10px;
}

/* ============================== Presets row ============================== */
.hd-preset-row{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
  margin-top: 10px;
}

.hd-preset-row .ub-chip{
  min-height: 44px;
  padding: 10px 12px;
}

/* ============================== Harmonics list ============================== */
.hd-hlist{
  margin-top: 10px;
  border: 1px solid var(--ub-border);
  border-radius: var(--ub-radius-2);
  background: var(--ub-surface-2);
  overflow:hidden;
}

.hd-hlist-head{
  padding: 12px 14px;
  border-bottom: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}

.hd-hlist-head .t{
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ub-muted);
}

.hd-hlist-head .s{
  margin-top: 4px;
  font-size: 12px;
  color: var(--ub-muted);
}

/* Rows: mobile-first stack, then split */
.hd-hrows{
  padding: 12px 14px 14px;
  display:grid;
  gap: 12px;
}

.hd-hrow{
  display:grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ub-border);
  border-radius: 14px;
  background: var(--ub-card-bg);
}

@media (min-width: 769px){
  .hd-hrow{
    grid-template-columns: 120px 1fr;
    align-items:center;
  }
}

.hd-hlabel{
  display:flex;
  align-items:center;
  gap: 8px;
  font-family: var(--ub-mono);
  font-weight: 950;
  color: var(--ub-text);
  min-height: 44px;
}

.hd-hlabel .n{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-2);
  font-size: 14px;
}

.hd-hlabel .x{
  color: var(--ub-muted);
  font-weight: 900;
}

.hd-hlabel .f{
  color: var(--ub-muted);
  font-weight: 900;
}

/* Ensure the input+unit stack even if toolkit changes */
.hd-hrow .ub-inputrow{
  display:block !important;
}
.hd-hrow .ub-inputrow > input,
.hd-hrow .ub-inputrow > select{
  display:block !important;
  width: 100% !important;
}
.hd-hrow .ub-inputrow > select{
  margin-top: 6px;
}

/* Slight hover affordance (desktop only) */
@media (hover:hover){
  .hd-hrow:hover{
    background: var(--ub-surface-3);
  }
}

/* ============================== Work output formatting ============================== */
.ub-work{
  font-family: var(--ub-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

/* Details polish */
.ub-collapsible summary{
  cursor:pointer;
  font-weight: 950;
  min-height: 44px;
  display:flex;
  align-items:center;
}
.ub-collapsible summary:focus{
  outline:none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius: 12px;
}

/* Rail helper */
.ub-btn--block{ width:100%; }

/* Small screens */
@media (max-width: 520px){
  .hd-kpi{ min-width: 98px; }
  .hd-hlabel{ gap: 6px; }
}
