/* ============================================================
   Utilities Bunker — House Affordability Calculator (v2.1)
   File: /assets/css/modules/calculators/financialcalculators/house-affordability-calculator.v2.1.css
   Purpose:
   - Tool-only layout + affordability summary visuals + work formatting
   - No changes to ub-toolkit.v2.1.css required
   - Mobile-first, 44x44 touch targets, clamp typography
   ============================================================ */

/* Tool-scoped tokens */
:root{
  --ha-radius: 16px;
  --ha-gap: 14px;
  --ha-soft: rgba(0,0,0,.06);
  --ha-meter-bg: rgba(0,0,0,.08);
  --ha-fill-a: var(--ub-btn-grad-a);
  --ha-fill-b: var(--ub-btn-grad-b);
}

html.ub-theme-dark:root{
  --ha-soft: rgba(255,255,255,.06);
  --ha-meter-bg: rgba(255,255,255,.10);
}

/* Main hero layout */
.ub-hero{
  display:grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: var(--ha-gap);
}

@media (max-width: 980px){
  .ub-hero{
    grid-template-columns: 1fr;
  }
}

/* Left visual lab */
.ub-afford-lab{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--ha-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:112px;
  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 chips */
.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[aria-pressed="true"]{
  border-color:rgba(249,58,19,.55);
  box-shadow:0 0 0 4px rgba(249,58,19,.12);
}

/* Visual section */
.ub-visual{
  margin-top:12px;
  display:grid;
  gap:12px;
}

.ub-meter-card{
  border:1px solid var(--ub-border);
  background:var(--ub-card-bg);
  border-radius:14px;
  padding:12px;
}

.ub-meter-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.ub-meter-title{
  font-size:13px;
  font-weight:950;
  letter-spacing:.01em;
}

.ub-meter-value{
  font-family:var(--ub-mono);
  font-size:13px;
  font-weight:950;
}

.ub-meter{
  position:relative;
  margin-top:10px;
  height:14px;
  border-radius:999px;
  background:var(--ha-meter-bg);
  overflow:hidden;
  border:1px solid var(--ub-border);
}

.ub-meter-fill{
  height:100%;
  width:0%;
  border-radius:999px;
  background:linear-gradient(92deg, var(--ha-fill-a), var(--ha-fill-b));
  transition:width .18s ease;
}

.ub-meter-note{
  margin:10px 0 0;
  font-size:12px;
  color:var(--ub-muted);
}

.ub-breakdown-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:10px;
}

.ub-breakdown-card{
  border:1px solid var(--ub-border);
  background:var(--ub-card-bg);
  border-radius:14px;
  padding:12px;
  min-height:78px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.ub-breakdown-label{
  font-size:11px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--ub-muted);
}

.ub-breakdown-value{
  margin-top:4px;
  font-family:var(--ub-mono);
  font-size:15px;
  font-weight:950;
  overflow-wrap:anywhere;
}

/* Preset row */
.ub-preset-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:10px;
}

.ub-preset-row .ub-chip{
  min-height:44px;
  padding:10px 12px;
}

/* Input area helpers */
.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;
}

/* Sliders */
.ub-range{
  width:min(420px, 100%);
  height:44px;
  accent-color:var(--ub-btn-grad-b);
}

.ub-slider-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

/* Work output */
.ub-work{
  font-family:var(--ub-mono);
  font-size:13px;
  line-height:1.55;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

/* Details 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;
}

/* Table wrapper safety */
.ub-table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

/* Rail helpers */
.ub-btn--block{
  width:100%;
}

/* Focus targets */
.ub-wheel .ub-chip:focus,
.ub-preset-row .ub-chip:focus{
  outline:none;
  box-shadow:0 0 0 4px var(--ub-focus);
}

/* Small screens */
@media (max-width: 640px){
  .ub-breakdown-grid{
    grid-template-columns:1fr;
  }

  .ub-kpis{
    justify-content:flex-start;
  }

  .ub-kpi{
    min-width:98px;
  }

  .ub-meter-head{
    align-items:flex-start;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .ub-meter-fill{
    transition:none;
  }
}