/* =========================================================
   Ипотечный калькулятор Sanaly — стили
   ========================================================= */

:root {
  --c-primary: #2c4ea6;
  --c-primary-dark: #22418f;
  --c-primary-light: #dfe8fa;
  --c-navy: #1a2a5a;
  --c-text: #1f2f5f;
  --c-muted: #6b7ca8;
  --c-muted-2: #8e9bc0;
  --c-border: #d8e1f2;
  --c-bg-soft: #eef3fb;
  --c-card: rgba(255, 255, 255, 0.94);
  --c-danger: #c23c3c;
  --c-success: #2c4ea6;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 10px 40px rgba(26, 42, 90, 0.08);

  /* Фоновая фотография (опционально): url("img/hero.jpg") */
  --hero-image: none;

  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Каркас ---------- */

.calc {
  position: relative;
  padding: 100px 0 100px;
  overflow: hidden;
  isolation: isolate;
}

.calc__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    var(--hero-image) right top / auto 100% no-repeat,
    radial-gradient(1200px 600px at 100% 0%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    radial-gradient(900px 500px at 85% 40%, rgba(171, 196, 240, 0.65), rgba(171, 196, 240, 0) 60%),
    linear-gradient(135deg, #f5f8fd 0%, #e4ecf9 45%, #cfdcf3 100%);
}

.calc__inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.calc__head { margin-bottom: 22px; }

.calc__brand {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.calc__title {
  margin: 6px 0 6px;
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--c-navy);
}

.calc__subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--c-muted);
}

.calc__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--c-card);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px 24px;
  backdrop-filter: blur(6px);
}

.card--results {
  background: rgba(244, 247, 253, 0.92);
}

.card__title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--c-navy);
}

.card__title--sm { font-size: 17px; }

.card__subtitle {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--c-muted);
}

/* ---------- Селект ЖК ---------- */

.field { margin-bottom: 18px; }

.field__label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-navy);
}

.select {
  position: relative;
  display: flex;
  align-items: center;
}

.select__icon,
.select__chevron {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-muted-2);
  display: flex;
  pointer-events: none;
}

.select__icon { left: 14px; }
.select__chevron { right: 16px; color: var(--c-navy); }

.select__control {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 46px;
  font: inherit;
  font-size: 14px;
  color: var(--c-text);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select__control:focus-visible {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(44, 78, 166, 0.15);
}

.select__control.is-placeholder { color: var(--c-muted-2); }

/* ---------- Бегунки ---------- */

.range { margin-bottom: 14px; }

.range__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-navy);
}

.range__bubble {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid #b9c6e4;
}

.range__bubble--input:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(44, 78, 166, 0.15);
}

.range__input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px; /* меньше 16px iOS увеличивает страницу при фокусе */
  font-weight: 700;
  color: var(--c-navy);
  text-align: right;
  padding: 4px 0;
  outline: none;
}

.range__slider { height: 6px; }

.range__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--c-muted-2);
}

/* noUiSlider — переопределения под дизайн */
.noUi-target.range__slider {
  background: #dbe3f3;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  height: 6px;
}

.noUi-horizontal .noUi-handle {
  width: 22px;
  height: 22px;
  right: -11px;
  top: -8px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--c-primary);
  box-shadow: 0 2px 8px rgba(26, 42, 90, 0.2);
  cursor: grab;
}

.noUi-handle::before,
.noUi-handle::after { display: none; }

.noUi-handle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(44, 78, 166, 0.2);
}

.noUi-active { cursor: grabbing; }

.noUi-connect { background: var(--c-primary); }

/* ---------- Карточки выбора: взнос и срок ---------- */

.choice { margin: 0; padding: 0; border: 0; min-width: 0; }
.choice legend { padding: 0; margin-bottom: 6px; }
.choice__grid { display: grid; gap: 8px; }
.choice__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.option { position: relative; display: flex; cursor: pointer; }
.option__input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.option__card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  text-align: center;
  background: #fff;
  border: 1px solid #c8d3ec;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 0 transparent;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.option__card--term { align-items: flex-start; padding: 8px 12px; text-align: left; }

.option:hover .option__card { border-color: #7d93cd; background: #f6f8fd; }

.option__input:checked + .option__card {
  border-color: var(--c-primary);
  background: #e8eefb;
  box-shadow: inset 0 0 0 1px var(--c-primary);
}

.option__input:focus-visible + .option__card { outline: 3px solid rgba(44, 78, 166, 0.35); outline-offset: 1px; }

.option__title { font-size: 15px; font-weight: 700; color: var(--c-navy); }
.option__payment { font-size: 18px; font-weight: 800; line-height: 1.3; color: var(--c-navy); }
.option__sub { font-size: 12px; line-height: 1.35; color: var(--c-muted); }

/* ---------- Результаты ---------- */

.results { margin: 8px 0 12px; }

.results__item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
  padding: 7px 0;
  border-bottom: 1px solid #d5def2;
}

.results__label { font-size: 13px; color: var(--c-muted); }
.results__value { margin: 0 0 0 auto; font-size: 17px; font-weight: 800; color: var(--c-navy); text-align: right; }
.results__item--main { display: block; }
.results__item--main .results__value { margin: 0; text-align: left; font-size: 30px; line-height: 1.25; }
.results__extra { font-size: 11px; font-weight: 400; color: var(--c-muted); }

.results.is-invalid .results__value { opacity: 0.35; }

.results-error {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fff1f1;
  border: 1px solid #f3cccc;
  color: #a33;
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Заявка ---------- */

.lead__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.input {
  position: relative;
  display: flex;
  align-items: center;
}

.input__icon {
  position: absolute;
  left: 14px;
  display: flex;
  color: var(--c-muted-2);
  pointer-events: none;
}

.input__control {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  font: inherit;
  font-size: 14px;
  color: var(--c-text);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input__control::placeholder { color: var(--c-muted-2); }

.input__control:focus-visible {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(44, 78, 166, 0.15);
}

.input__control.is-error { border-color: var(--c-danger); }

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 12px;
  font-size: 12.5px;
  color: var(--c-muted);
  cursor: pointer;
  user-select: none;
}

.consent a { color: var(--c-primary); }

.consent__box {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.consent__mark {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 5px;
  border: 1.5px solid #b9c6e4;
  background: #fff;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.consent__mark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s;
}

.consent__box:checked + .consent__mark {
  background: var(--c-primary);
  border-color: var(--c-primary);
}

.consent__box:checked + .consent__mark::after { transform: rotate(45deg) scale(1); }

.consent__box:focus-visible + .consent__mark {
  box-shadow: 0 0 0 3px rgba(44, 78, 166, 0.2);
}

.lead__error {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--c-danger);
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}

.btn--block { width: 100%; }

.btn--primary {
  background: var(--c-primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--c-primary-dark); }
.btn--primary:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-loading .btn__text { opacity: 0.7; }

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(44, 78, 166, 0.3);
}

/* ---------- Модалка ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 42, 90, 0.35);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal__card {
  position: relative;
  width: 100%;
  max-width: 330px;
  padding: 36px 24px 24px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(26, 42, 90, 0.25);
  text-align: center;
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--c-navy);
  border-radius: 8px;
  cursor: pointer;
}

.modal__close:hover { background: var(--c-bg-soft); }

.modal__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #e6edfa;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__title {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 700;
  color: var(--c-navy);
  line-height: 1.3;
}

.modal__text {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-muted);
}

.modal .btn {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

body.modal-open { overflow: hidden; }

/* ---------- Адаптив ---------- */

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

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

@media (max-width: 560px) {
  .card { padding: 12px; }
  .lead__row { grid-template-columns: 1fr; }
}

/* Дисклеймер под результатами калькулятора */
.calc-disclaimer {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--c-muted);
}
