/* ============================================================
   Utilities Bunker — Thermal Resistance Chain (v2.1)
   File: /assets/css/modules/electronics/thermal-chain.v2.1.css
   Purpose:
   - Tool-only layout + thermal chain diagram + segment list UI
   - No changes to ub-toolkit.v2.1.css
   - Mobile-first, 44x44 touch targets, clamp typography
   ============================================================ */

/* ============================== Local tokens (tool-scoped) ============================== */
:root{
  --tc-radius: 16px;
  --tc-gap: 14px;
  --tc-soft: rgba(0,0,0,.06);
}

/* ============================== Tool hero layout ============================== */
.ub-hero{
  display:grid;
  grid-template-columns: 1.10fr 0.90fr;
  gap: var(--tc-gap);
}

/* Stack on tablet/mobile */
@media (max-width: 980px){
  .ub-hero{ grid-template-columns: 1fr; }
}

/* ============================== Lab panel ============================== */
.ub-lab{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--tc-radius);
  padding: 12px;
}

.ub-lab-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 10px;
  flex-wrap:wrap;
  margin-bottom: 8px;
}

.ub-lab-title{
  font-size: clamp(13px, 1.2vw, 14px);
  font-weight: 950;
  letter-spacing: .01em;
}

.ub-lab-sub{
  font-size: 12px;
  color: var(--ub-muted);
  margin-top: 2px;
}

/* ============================== KPI tiles ============================== */
.ub-kpis{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  justify-content:flex-end;
}

.ub-kpi{
  min-width: 122px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}

.ub-kpi .k{
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ub-muted);
}

.ub-kpi .v{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
  margin-top: 2px;
}

/* ============================== Status pill ============================== */
.ub-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;
}

.ub-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ub-muted);
}

/* ============================== Preset chip grid (tool) ============================== */
.ub-wheel{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin-top: 10px;
}

.ub-wheel .ub-chip{
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-chip-bg);
  color: var(--ub-chip-text);
  font-weight: 900;
  cursor: pointer;
  user-select:none;
}

.ub-wheel .ub-chip:hover{ background: var(--ub-chip-hover); }

.ub-wheel .ub-chip:focus{
  outline: none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius: 12px;
}

/* ============================== Thermal chain diagram ============================== */
.tc-chain{
  margin-top: 12px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
  border-radius: 14px;
  padding: 12px;
  display:grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 10px;
  align-items:center;
}

/* Collapse to a vertical flow on smaller screens */
@media (max-width: 720px){
  .tc-chain{
    grid-template-columns: 1fr;
  }
}

.tc-node{
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-2);
  border-radius: 14px;
  padding: 10px 10px;
  min-height: 64px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap: 6px;
}

.tc-badge{
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ub-muted);
}

.tc-sub{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
}

.tc-link{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 8px;
}

.tc-line{
  width: 100%;
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-3);
}

.tc-pill{
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-2);
  font-family: var(--ub-mono);
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 720px){
  .tc-link{ align-items:flex-start; }
  .tc-line{ width: 100%; height: 10px; }
  .tc-pill{ white-space: normal; }
}

/* ============================== Custom segments list ============================== */
.tc-custom{
  border-top: 1px solid rgba(0,0,0,.06);
  margin-top: 12px;
  padding-top: 12px;
}
html.ub-theme-dark .tc-custom{
  border-top: 1px solid rgba(255,255,255,.10);
}

.tc-seglist{
  margin-top: 10px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.tc-seg-empty{
  padding: 12px;
  border: 1px dashed var(--ub-border);
  border-radius: 14px;
  background: var(--ub-surface-2);
  color: var(--ub-muted);
  font-size: 13px;
}

.tc-seg-row{
  display:grid;
  grid-template-columns: 1.2fr 0.6fr auto 140px;
  gap: 10px;
  align-items:center;
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-2);
  border-radius: 14px;
  padding: 10px;
}

@media (max-width: 720px){
  .tc-seg-row{
    grid-template-columns: 1fr;
  }
}

.tc-seg-row input[type="text"],
.tc-seg-row input[type="number"]{
  width: 100%;
  min-height: var(--ub-hit);
  padding: 10px 12px;
  border-radius: var(--ub-radius-1);
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-1);
  color: var(--ub-text);
  font-size: var(--ub-fs-2);
}

.tc-seg-unit{
  font-family: var(--ub-mono);
  font-weight: 950;
  color: var(--ub-muted);
  padding: 0 6px;
  white-space: nowrap;
}

@media (max-width: 720px){
  .tc-seg-unit{ padding: 0; }
}

.tc-seg-delbtn{
  width: 100%;
  min-height: var(--ub-hit);
}

/* ============================== Inline error / hint polish (safe) ============================== */
.hint{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ub-muted);
}

.ub-inline-error{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ub-danger);
  font-weight: 800;
  min-height: 16px;
}

/* ============================== Work area (tool) ============================== */
.ub-work{
  font-family: var(--ub-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

/* Details styling (tool enhancement) */
.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;
}

/* Full-width rail buttons helper (tool-only, safe) */
.ub-btn--block{ width: 100%; }

/* Small screens polish */
@media (max-width: 520px){
  .ub-kpi{ min-width: 108px; }
  .ub-wheel{ grid-template-columns: 1fr; }
}
