/* =========================================================
   TENET — модальная форма
========================================================= */

/* ---------- Overlay ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;

  /* Блюр фона */
  backdrop-filter: blur(6px) brightness(0.55);
  -webkit-backdrop-filter: blur(6px) brightness(0.55);

  /* Плавное появление */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Окно ---------- */
.modal-box {
  position: relative;
  width: 100%;
  max-width: 520px;          /* ~50-55% на десктопе */
  max-height: 92vh;
  overflow-y: auto;
  padding: 42px 44px 36px;
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);

  /* Появление самого окна */
  transform: translateY(24px) scale(0.97);
  transition: transform 0.3s ease;
}

.modal-overlay.is-visible .modal-box {
  transform: translateY(0) scale(1);
}

/* Скролл на мобильных */
@media (max-width: 560px) {
  .modal-box {
    padding: 32px 24px 28px;
    max-width: 100%;
    border-radius: 14px;
  }
}

/* ---------- Крестик закрытия ---------- */
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--gray);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.modal-close:hover {
  background: var(--red);
  transform: rotate(90deg);
}

.modal-close span {
  display: block;
  width: 14px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: background var(--transition);
}

.modal-close:hover span { background: var(--white); }

.modal-close span:first-child  { transform: translateY(3.5px) rotate(45deg);  }
.modal-close span:last-child   { transform: translateY(-3.5px) rotate(-45deg); }

/* ---------- Заголовок ---------- */
.modal-title {
  margin-bottom: 26px;
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--ink);
}

/* ---------- Поля ---------- */
.modal-field {
  margin-bottom: 18px;
}

.modal-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.modal-req {
  color: var(--red);
  font-size: 0.9rem;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--gray);
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.modal-input:focus {
  background: var(--white);
  border-color: var(--red);
}

.modal-input.is-error {
  border-color: var(--red);
  background: #fff5f6;
}

/* ---------- Ошибка ---------- */
.modal-error {
  display: block;
  min-height: 18px;
  margin-top: 5px;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---------- Дисклеймер ---------- */
.modal-disclaimer {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 0.7rem;
}

/* ---------- Чекбоксы ---------- */
.modal-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  user-select: none;
}

.modal-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.modal-check-box {
  flex-shrink: 0;
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: var(--gray);
  border: 1.5px solid #c8cbce;
  border-radius: 5px;
  transition: background var(--transition), border-color var(--transition);
}

.modal-checkbox input:checked ~ .modal-check-box {
  background: var(--red);
  border-color: var(--red);
}

/* Галочка */
.modal-check-box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--white);
  border-top: none;
  border-left: none;
  transform: rotate(45deg) scale(0);
  transform-origin: center;
  transition: transform 0.18s ease;
}

.modal-checkbox input:checked ~ .modal-check-box::after {
  transform: rotate(45deg) scale(1);
}

/* Фокус-кольцо */
.modal-checkbox input:focus-visible ~ .modal-check-box {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.modal-link {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Кнопка отправки ---------- */
.modal-submit {
  margin-top: 22px;
  padding: 14px;
  font-size: 0.92rem;
  border-radius: 10px;
}

/* ---------- Экран успеха ---------- */
.modal-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0 10px;
  text-align: center;
  animation: successFadeIn 0.4s ease;
}

@keyframes successFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-success-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 22px;
  color: var(--red);
}

.modal-success-icon svg {
  width: 100%;
  height: 100%;
}

.modal-success h3 {
  margin-bottom: 10px;
  font-size: 1.5rem;
  color: var(--ink);
}

.modal-success p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Блокировка прокрутки страницы ---------- */
body.modal-open {
  overflow: hidden;
}