/* ===========================
   CALCULATOR PAGE
   =========================== */

.header--solid {
  background: rgba(0, 0, 0, 0.92) !important;
}

.nav__link--active {
  color: var(--accent) !important;
}

.calc-hero {
  padding: 140px 0 40px;
  text-align: center;
}

.calc-hero h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  line-height: 1.1;
}

.calc-hero__sub {
  max-width: 640px;
  margin: 0 auto 20px;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.calc-hero__note {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent-soft, rgba(25, 181, 143, 0.1));
  border: 1px solid var(--accent-line, rgba(25, 181, 143, 0.3));
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* ===========================
   LAYOUT
   =========================== */
.calc-wrap {
  padding: 0 0 var(--section-gap);
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 40px;
  align-items: start;
}

/* ===========================
   FORM
   =========================== */
.calc-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.calc-section[open] {
  border-color: var(--accent-line, rgba(25, 181, 143, 0.3));
}

.calc-section__header {
  list-style: none;
  padding: 20px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  user-select: none;
}

.calc-section__header::-webkit-details-marker {
  display: none;
}

.calc-section__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft, rgba(25, 181, 143, 0.1));
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}

.calc-section__title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.calc-section__badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.calc-section__toggle {
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 300;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.calc-section[open] .calc-section__toggle {
  transform: rotate(45deg);
}

.calc-section__body {
  padding: 4px 24px 24px;
  border-top: 1px solid var(--border-card);
}

/* ===========================
   FIELDS
   =========================== */
.calc-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2, rgba(255, 255, 255, 0.05));
}

.calc-field:last-child {
  border-bottom: none;
}

.calc-field__label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.calc-field__hint {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Number stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  background: var(--surface-2, rgba(0, 0, 0, 0.3));
  overflow: hidden;
  flex-shrink: 0;
}

.stepper__btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition), color var(--transition);
}

.stepper__btn:hover {
  background: var(--accent-soft, rgba(25, 181, 143, 0.1));
  color: var(--accent);
}

.stepper input {
  width: 56px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper input:focus {
  outline: none;
  background: var(--accent-soft, rgba(25, 181, 143, 0.1));
}

/* Checkbox */
.calc-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.calc-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.calc-check__box {
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: var(--line-1, rgba(255, 255, 255, 0.09));
  border: 1px solid var(--border-card);
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

.calc-check__box::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #999;
  transition: transform var(--transition), background var(--transition);
}

.calc-check input:checked ~ .calc-check__box {
  background: var(--accent-line, rgba(25, 181, 143, 0.3));
  border-color: var(--accent);
}

.calc-check input:checked ~ .calc-check__box::after {
  transform: translateX(22px);
  background: var(--accent);
}

/* Number input (for m2) */
.calc-input {
  width: 140px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  background: var(--surface-2, rgba(0, 0, 0, 0.3));
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition);
}

.calc-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* название объекта — текст, а не число: шире и без табличных цифр */
.calc-input--text {
  width: 100%;
  max-width: 420px;
  font-weight: 500;
  font-variant-numeric: normal;
}

.calc-input--text::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.calc-field--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

/* подпись у поля площади — как у всех остальных полей (серая, 0.9rem) */
.calc-field--stacked .calc-field__label {
  font-weight: 500;
}

/* ===========================
   RESULT PANEL (STICKY)
   =========================== */
.calc-result {
  position: sticky;
  top: 100px;
  padding: 28px;
  background: linear-gradient(180deg, var(--accent-soft, rgba(25, 181, 143, 0.1)), var(--surface-1, rgba(255, 255, 255, 0.025)));
  border: 1px solid var(--accent-line, rgba(25, 181, 143, 0.3));
  border-radius: 14px;
}

.calc-result__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-2, rgba(255, 255, 255, 0.05));
}

.calc-result__title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calc-result__pkg {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.calc-result__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--surface-2, rgba(0, 0, 0, 0.3));
  border-radius: 10px;
  font-size: 0.82rem;
}

.calc-result__meta-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.calc-result__meta-row b {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.calc-result__breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.calc-result__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.9rem;
}

.calc-result__row-label {
  color: var(--text-secondary);
}

.calc-result__row-value {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.calc-result__total {
  padding: 18px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #12876b 100%);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.calc-result__total-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.calc-result__total-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.calc-result__cta {
  width: 100%;
  text-align: center;
}

.calc-result__disclaimer {
  margin-top: 14px;
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Empty state */
.calc-result.is-empty .calc-result__pkg {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

.calc-result.is-empty .calc-result__total {
  background: var(--surface-1, rgba(255, 255, 255, 0.025));
  border: 1px dashed var(--border-card);
}

.calc-result.is-empty .calc-result__total-value,
.calc-result.is-empty .calc-result__total-label {
  color: var(--text-muted);
}

/* ===========================
   RESPONSIVE
   =========================== */
/* ===========================
   ЛИПКАЯ ПОЛОСА С ИТОГОМ
   Только на мобильных: там блок результата уезжает в конец формы, и без
   полосы сумма не видна, пока не долистаешь.
   =========================== */
.calc-bar {
  display: none;
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  z-index: 1002;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line-2, rgba(255, 255, 255, 0.05));
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.calc-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calc-bar__sum {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.calc-bar__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calc-bar__value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calc-bar__cta {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 22px;
  font-size: 0.85rem;
}

/* до первого введённого значения показывать «0 ₽» незачем;
   два класса против одного — скрытие перебивает display:flex из медиазапроса */
.calc-bar.is-empty {
  display: none;
}

@media (max-width: 1100px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }

  .calc-result {
    position: static;
  }
}

@media (max-width: 768px) {
  .calc-hero {
    padding: 110px 0 28px;
  }

  .calc-section__header {
    padding: 16px 18px;
  }

  .calc-section__body {
    padding: 4px 18px 20px;
  }

  .calc-field {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .calc-field__label {
    font-size: 0.9rem;
  }

  /* было flex-end — контролы уезжали вправо, и взгляд прыгал по диагонали */
  .calc-field .stepper,
  .calc-field .calc-check,
  .calc-field .calc-input {
    align-self: flex-start;
  }

  .calc-field .calc-input {
    width: 100%;
  }

  .calc-result {
    padding: 22px;
  }

  .calc-bar {
    display: flex;
  }

  /* место под полосу, иначе дисклеймер прячется под ней */
  .calc-wrap {
    padding-bottom: 96px;
  }
}

/* ===========================
   CTA + ПОПАП «СКАЧАТЬ СМЕТУ»
   =========================== */
.calc-result__cta {
  border: none;
  cursor: pointer;
  font: inherit;
}

.calc-result__cta.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* пока смета сохраняется в базу — до секунды на медленной сети */
.calc-result__cta.is-busy,
.calc-bar__cta.is-busy {
  opacity: 0.7;
  cursor: progress;
}

/* «Сбросить» — тихая кнопка под CTA: нужна редко и не должна спорить с ней.
   Появляется только когда есть что сбрасывать (скрывает calculator.js). */
.calc-result__reset {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.calc-result__reset:hover {
  color: var(--text-secondary);
}

/* взведённое состояние: следующий клик действительно чистит форму */
.calc-result__reset.is-armed {
  color: var(--text-primary);
}

.calc-result__reset[hidden] {
  display: none;
}

/* затемнение */
