/* Know Your Home — in-pillar calculator widgets (/js/kyh-calculators.js).
   Scoped under .kyh-calc; inherits the .kyh theme contract
   (--surface/--ink/--ink-soft/--ink-muted/--rule/--tint/--accent/--accent-ink),
   so light/dark/auto all work without extra rules. */

.kyh-calc {
  display: block;
  margin: 30px 0;
  padding: 22px 22px 26px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
}

.kyh-calc__title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.kyh-calc__intro {
  margin: 6px 0 18px;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---- state selector ---- */
.kyh-calc__state { margin: 0 0 18px; }
.kyh-calc__state-lbl {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
}
.kyh-calc__select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c8a73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.kyh-calc__select:focus { outline: none; border-color: var(--accent); }

/* ---- controls: unified slider + typeable box fields ---- */
.kyh-calc__controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px 28px;
}
@media (min-width: 560px) { .kyh-calc__controls { grid-template-columns: 1fr 1fr; } }

.kyh-calc__field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 22px;
  margin-bottom: 7px;
}
.kyh-calc__field-head label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
}

/* each field = a wide editable box with its slider directly beneath it, kept in sync */
.kyh-calc__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.kyh-calc__box {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.kyh-calc__box:focus-within { border-color: var(--accent); }
.kyh-calc__num {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kyh-calc__num:focus { outline: none; }
.kyh-calc__row input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* never show the native number-spinner arrows in a calculator */
.kyh-calc input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.kyh-calc input[type="number"]::-webkit-outer-spin-button,
.kyh-calc input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- outputs ---- */
.kyh-calc__outputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 22px 0 4px;
}
@media (min-width: 560px) { .kyh-calc__outputs { grid-template-columns: repeat(3, 1fr); } }

.kyh-calc__out {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg);
  text-align: center;
}
.kyh-calc__out.is-big {
  background: var(--tint);
  border-color: var(--accent);
}
.kyh-calc__out-val {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600;
  font-size: clamp(20px, 4.5vw, 26px);
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kyh-calc__out.is-big .kyh-calc__out-val { color: var(--accent-ink); }
.kyh-calc__out-lbl {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.25;
}

/* ---- break-even chart ---- */
.kyh-calc__chart-wrap { margin-top: 20px; }
.kyh-calc__chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.kyh-calc__svg { width: 100%; height: auto; display: block; }
.kyh-calc__curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.kyh-calc__cost-line { stroke: var(--ink-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.kyh-calc__dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.kyh-calc__svg-lbl { fill: var(--ink-muted); font-size: 10px; font-family: "Inter", sans-serif; }

.kyh-calc__note {
  margin: 16px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* ---- repair-or-replace verdict + threshold bar ---- */
.kyh-calc__verdict {
  margin: 20px 0 4px;
  padding: 14px 16px;
  border-radius: 12px;
  text-align: center;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600;
  font-size: clamp(20px, 5vw, 26px);
  border: 1px solid var(--rule);
}
.kyh-calc__verdict.is-repair    { background: var(--tint); color: var(--accent-ink); border-color: var(--accent); }
.kyh-calc__verdict.is-replace   { background: rgba(212, 160, 76, 0.14); color: #9a6b18; border-color: #d4a04c; }
.kyh-calc__verdict.is-borderline { background: var(--bg); color: var(--ink-soft); }
html[data-theme="dark"] .kyh-calc__verdict.is-replace { color: #e6b563; }

.kyh-calc__bar-wrap { margin-top: 20px; }
.kyh-calc__bar {
  position: relative;
  height: 14px;
  background: var(--tint);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.kyh-calc__bar-fill {
  height: 100%;
  border-radius: 8px 0 0 8px;
  transition: width 0.15s ease;
}
.kyh-calc__bar-fill.is-repair  { background: var(--accent); }
.kyh-calc__bar-fill.is-replace { background: #d4a04c; }
.kyh-calc__bar-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink-soft);
  transform: translateX(-1px);
}

/* ---- prefix / suffix units inside an editable box ---- */
.kyh-calc__unit {
  padding: 0 10px 0 0;
  font-size: 14px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.kyh-calc__unit.pre { padding: 0 0 0 10px; }

/* segmented $ / % toggle — sits inside the field box, flush right; the input flex-grows to push it over */
.kyh-calc__seg {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--rule);
  border-radius: 7px;
  overflow: hidden;
}
/* inside the box: the toggle fills the full field height and sits flush right, like an input addon */
.kyh-calc__box .kyh-calc__seg {
  align-self: stretch;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--rule);
  border-radius: 0;
}
.kyh-calc__box .kyh-calc__toggle {
  display: flex;
  align-items: center;
  padding: 0 11px;
  line-height: 1;
}
.kyh-calc__toggle {
  border: 0;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  padding: 1px 9px;
  cursor: pointer;
}
.kyh-calc__toggle.is-on { background: var(--accent); color: #fff; }
html[data-theme="dark"] .kyh-calc__toggle.is-on { color: #11150f; }
