/* ==========================================================================
   Попап «Подобрать авто» (нативный <dialog>)
   Карточка — «лист», слева фото с клином триколора и стеклянными плашками,
   справа тёмная форма. Фон страницы под попапом размыт.
   ========================================================================== */

.modal {
  width: min(1040px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--c-on-dark);
  overflow: visible;
}
.modal::backdrop {
  background: rgba(8, 22, 38, .55);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
}
.modal[open] .modal__card { animation: modal-in .5s var(--ease-out); }
.modal[open]::backdrop { animation: modal-fade .35s ease-out; }
.modal.is-closing .modal__card { animation: modal-out .22s ease-in forwards; }
.modal.is-closing::backdrop { animation: modal-fade .22s ease-in reverse forwards; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(.96); border-radius: 12px; }
  to   { opacity: 1; transform: none; }
}
@keyframes modal-out { to { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes modal-fade { from { opacity: 0; } }

html.modal-open { overflow: hidden; }

.modal__card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border-radius: var(--shape-leaf);
  background: linear-gradient(160deg, var(--c-navy-800) 0%, var(--c-navy-900) 55%, var(--c-navy-950) 100%);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.modal__close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px 5px 14px 5px;
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 0 1px var(--c-on-dark-line);
  color: #fff;
  cursor: pointer;
  transition: background-color var(--t-fast), transform var(--t-base) var(--ease-out), border-radius var(--t-base) var(--ease-out);
}
.modal__close svg { width: 20px; height: 20px; }
.modal__close:hover { background: var(--c-red); transform: rotate(90deg); border-radius: 5px 14px 5px 14px; }

/* --- Левая часть: фото -------------------------------------------------- */
.modal__visual {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: 100%;
  padding: 28px;
  background: var(--c-navy-900) var(--modal-img) 85% 40% / cover no-repeat;
}
.modal__visual--fallback { background-position: 72% 50%; }
.modal__visual::before {         /* затемнение снизу под плашки */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(0deg, rgba(8, 22, 38, .92) 0%, rgba(8, 22, 38, .2) 55%, rgba(8, 22, 38, .05) 100%),
    linear-gradient(90deg, transparent 70%, rgba(13, 31, 51, .9) 100%);
}
/* фирменный клин триколора по правому краю фото */
.modal__wedge {
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 64px;
  z-index: -1;
  background: linear-gradient(180deg, #fff 0 33.3%, var(--c-blue) 33.3% 66.6%, var(--c-red) 66.6%);
  clip-path: polygon(78% 0, 100% 0, 100% 100%, 40% 100%);
  opacity: .9;
}
.modal__trust {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.modal__trust li {
  padding: 12px 16px;
  border-radius: 16px 5px 16px 5px;
  background: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, .8);
}
.modal__trust b { color: #fff; }

/* --- Правая часть: форма ------------------------------------------------ */
.modal__form {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: clamp(28px, 4vw, 52px) clamp(24px, 4vw, 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.eyebrow--dark { color: var(--c-red-400); }
.eyebrow--dark::before { box-shadow: none; }
.modal__title {
  margin: -4px 0 0;
  padding-right: 48px;
  font-family: var(--f-display);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.01em;
}
.modal__lead { margin: -4px 0 4px; color: var(--c-on-dark-muted); }
.modal__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal__group { margin: 0; padding: 0; border: 0; min-width: 0; }
.modal__group legend { padding: 0; margin-bottom: 8px; }
.modal .choice span { min-height: 46px; padding: 0 14px; }
.modal .choice img { border-radius: 3px 1px 3px 1px; }
.modal__submit { justify-self: start; min-height: 56px; padding-inline: 28px; }
.modal__submit[disabled] { opacity: .6; pointer-events: none; }
.modal__form .lead-form__status { grid-area: auto; margin: 0; }
.modal__form.is-sent > :not(.lead-form__status):not(.modal__title):not(.eyebrow) { display: none; }
.modal__form.is-sent .lead-form__status { font-size: var(--fs-md); }

/* --- Адаптив: на телефоне — «шторка» снизу ------------------------------ */
@media (max-width: 820px) {
  .modal {
    width: 100%;
    max-height: 100dvh;
    margin: auto 0 0;
  }
  .modal__card {
    grid-template-columns: 1fr;
    grid-template-rows: 150px auto;
    max-height: 94dvh;
    border-radius: 28px 28px 0 0;
  }
  .modal__visual { min-height: 0; padding: 16px 20px; background-position: 60% 30%; }
  .modal__trust { display: none; }
  .modal__wedge { top: auto; left: 0; right: 0; width: auto; height: 10px; clip-path: none;
    background: linear-gradient(90deg, #fff 0 33.3%, var(--c-blue) 33.3% 66.6%, var(--c-red) 66.6%); }
  .modal__fields { grid-template-columns: 1fr; }
  .modal__submit { justify-self: stretch; }
  @keyframes modal-in { from { transform: translateY(100%); } to { transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open] .modal__card, .modal[open]::backdrop, .modal.is-closing .modal__card { animation: none; }
}
