/* ═══════════════════════════════════════════════════════════
   HouseBuilder — единый калькулятор (hb-calc)
   Один вид на всех страницах. Токены берутся из design-system.css.
   Создан 2026-09-11: до этого 17 legacy-калькуляторов рисовали
   собственную тёмную тему (#0d1117 + #22d47b + Inter), а сайт —
   светлую (Manrope + #ff4d2a). Человек видел два разных продукта.
   ═══════════════════════════════════════════════════════════ */

.hb-calc {
  --c-bg: var(--hb-bg, #fff);
  --c-surface: var(--hb-surface, #fafaf9);
  --c-surface2: var(--hb-surface-2, #f4f4f3);
  --c-border: var(--hb-border, #e7e5e4);
  --c-ink: var(--hb-ink, #0c0a09);
  --c-muted: var(--hb-ink-muted, #57534e);
  --c-faint: var(--hb-ink-faint, #a8a29e);
  --c-cta: var(--hb-cta, #ff4d2a);
  --c-cta-hover: var(--hb-cta-hover, #e63d1a);
  --c-radius: var(--hb-radius, 11px);
  --c-radius-card: var(--hb-radius-card, 14px);

  font-family: var(--hb-font, 'Manrope', system-ui, -apple-system, sans-serif);
  color: var(--c-ink);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-card);
  box-shadow: var(--hb-shadow-md, 0 4px 12px rgba(0,0,0,.06));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
  gap: 0;
  overflow: hidden;
  max-width: 1080px;
  margin: 0 auto;
  box-sizing: border-box;
}
.hb-calc *, .hb-calc *::before, .hb-calc *::after { box-sizing: border-box; }

/* ── Левая колонка: поля ── */
.hb-calc__form { padding: 22px 24px 24px; min-width: 0; }
.hb-calc__title {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em;
  margin: 0 0 2px; color: var(--c-ink);
}
.hb-calc__sub { font-size: 12.5px; color: var(--c-muted); margin: 0 0 16px; line-height: 1.45; }

.hb-calc__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.hb-calc__field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hb-calc__field--wide { grid-column: 1 / -1; }
.hb-calc__label {
  font-size: 11px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.hb-calc__input, .hb-calc__select {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--c-ink); background: var(--c-bg);
  border: 1.5px solid var(--c-border); border-radius: var(--c-radius);
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
  min-height: 44px;
}
.hb-calc__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%2357534e' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.hb-calc__input:focus, .hb-calc__select:focus {
  outline: none; border-color: var(--c-cta); box-shadow: 0 0 0 3px var(--hb-cta-tint, #fff1ec);
}
.hb-calc__hint { font-size: 11px; color: var(--c-faint); }

/* ── Правая колонка: результат ── */
.hb-calc__result {
  background: var(--c-surface); border-left: 1px solid var(--c-border);
  padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.hb-calc__headline-label {
  font-size: 11px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.hb-calc__headline {
  font-size: clamp(26px, 3.4vw, 34px); font-weight: 800; letter-spacing: -.02em;
  line-height: 1.05; color: var(--c-ink); font-variant-numeric: tabular-nums;
}
.hb-calc__perm2 { font-size: 12.5px; color: var(--c-muted); margin-top: 2px; }

.hb-calc__alt { display: flex; flex-direction: column; gap: 7px; }
.hb-calc__alt-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--c-border);
}
.hb-calc__alt-row:last-child { border-bottom: none; }
.hb-calc__alt-label { color: var(--c-muted); }
.hb-calc__alt-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.hb-calc__sections { display: flex; flex-direction: column; gap: 1px; }
.hb-calc__sec {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 5px 0;
}
.hb-calc__sec-label { color: var(--c-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-calc__sec-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.hb-calc__cta {
  display: block; text-align: center; padding: 13px 18px; border-radius: var(--c-radius);
  background: var(--c-cta); color: #fff; font-weight: 700; font-size: 14px;
  text-decoration: none; border: none; cursor: pointer; font-family: inherit;
  transition: background .15s; min-height: 46px;
}
.hb-calc__cta:hover { background: var(--c-cta-hover); color: #fff; text-decoration: none; }
.hb-calc__cta--ghost {
  background: transparent; color: var(--c-ink); border: 1.5px solid var(--c-border);
}
.hb-calc__cta--ghost:hover { background: var(--c-surface2); color: var(--c-ink); }

.hb-calc__note { font-size: 11px; color: var(--c-faint); line-height: 1.5; }
.hb-calc__note b { color: var(--c-muted); font-weight: 700; }

.hb-calc__error {
  grid-column: 1 / -1; padding: 14px 18px; font-size: 13px;
  background: var(--hb-error-bg, #fef2f2); color: var(--hb-error, #991b1b);
}

/* ── Мобильная раскладка ── */
@media (max-width: 860px) {
  .hb-calc { grid-template-columns: 1fr; }
  .hb-calc__result { border-left: none; border-top: 1px solid var(--c-border); }
  .hb-calc__form { padding: 18px 16px 20px; }
  .hb-calc__result { padding: 18px 16px 20px; }
  .hb-calc__grid { gap: 11px 12px; }
}
@media (max-width: 420px) {
  .hb-calc__grid { grid-template-columns: 1fr; }
}

/* ── Тёмные страницы: виджет остаётся светлой карточкой,
      но не конфликтует с тёмным фоном вокруг ── */
.hb-calc[data-on-dark="1"] { box-shadow: 0 18px 40px -10px rgba(0,0,0,.5); }

/* ── Блок «что добавить к стройке» (2026-09-11) ──
   Необязательные разделы: отделка, инженерия, молниезащита, отмостка, крыльцо.
   Все сняты по умолчанию — в стоимость входит только стройка. */
.hb-calc__optional {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--c-border);
}
.hb-calc__optional-title {
  font-size: 11px; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px;
}
.hb-calc__optional-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px;
}
.hb-calc__field--check {
  flex-direction: row; align-items: center; gap: 8px; min-height: 32px;
}
.hb-calc__check {
  width: 18px; height: 18px; flex: 0 0 18px; margin: 0; cursor: pointer;
  accent-color: var(--c-cta);
}
.hb-calc__check-label {
  font-size: 13px; font-weight: 600; color: var(--c-ink); cursor: pointer; user-select: none;
}
.hb-calc__optional-note {
  margin-top: 10px; font-size: 11px; line-height: 1.5; color: var(--c-faint);
}
@media (max-width: 420px) {
  .hb-calc__optional-grid { grid-template-columns: 1fr; }
}
