/* ---------- плавающий виджет трейд-ина ---------- */

.tiw {
  position: fixed;
  left: 24px;
  bottom: calc(24px + var(--tiw-shift, 0px));
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px 12px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(213, 0, 28, .38);
  transition: background-color .18s, transform .18s;
}
.tiw:hover { background: var(--red-dark); }
.tiw:active { transform: translateY(1px); }

.tiw__icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
}
.tiw__icon .icon { width: 24px; height: 24px; }

.tiw__body { display: grid; gap: 3px; }
.tiw__title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tiw__benefit { font-size: 13px; color: rgba(255, 255, 255, .82); }

/* блик — тот же, что на красных кнопках страницы */
.tiw::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 48px;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .45) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-20deg);
  pointer-events: none;
  animation: tiw-shine 5s linear infinite;
}
@keyframes tiw-shine {
  0% { left: -60%; }
  18% { left: 130%; }
  100% { left: 130%; }
}

/* выпадающий список с поиском — вместо нативного select */

.tiw-select { position: relative; }

.tiw-select__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}
.tiw-select__btn:disabled { cursor: default; }
.tiw-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiw-select__btn:not(.is-filled) .tiw-select__value { color: var(--muted); }

.tiw-select__chevron {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--ink);
  transition: transform .18s;
}
.tiw-select__btn[aria-expanded="true"] .tiw-select__chevron { transform: rotate(180deg); }

.tiw-select__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  max-height: 292px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
}

.tiw-select--up .tiw-select__menu { top: auto; bottom: calc(100% + 4px); }

.tiw-select__search {
  flex: none;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  font: inherit;
  color: var(--ink);
  outline: none;
}

.tiw-select__list { overflow-y: auto; overscroll-behavior: contain; }

.tiw-select__option {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.tiw-select__option:hover { background: var(--bg-soft); }
.tiw-select__option.is-active { color: var(--red); font-weight: 600; }

.tiw-select__group {
  margin: 0;
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tiw-select__empty { margin: 0; padding: 14px 16px; font-size: 14px; line-height: 1.45; color: var(--muted); }

.tiw-error { margin: 0; font-size: 12px; color: var(--red); }
.tiw-field--error .field__input { border-color: var(--red); }
.consent.tiw-field--error .tiw-error { grid-column: 1 / -1; }
.consent.tiw-field--error input { outline: 2px solid var(--red); outline-offset: 2px; }

/* модалка — две колонки: слева кадр линейки с оффером, справа форма.
   На узких экранах кадр становится баннером над формой. */
.tiw-modal .modal__dialog {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 420px 1fr;
  align-items: stretch;
  padding: 0;
  gap: 0;
}

.tiw-modal__media { position: relative; display: grid; min-height: 320px; background: var(--ink); }
.tiw-modal__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 45% 74%;
}

.tiw-modal__caption {
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 32px;
  background: linear-gradient(180deg, rgba(36, 30, 32, .92) 0%, rgba(36, 30, 32, .6) 45%, rgba(36, 30, 32, 0) 85%);
  color: #fff;
}
.tiw-modal .modal__title { color: #fff; font-size: 26px; line-height: 1.15; }

.tiw-modal__benefit {
  display: grid;
  gap: 2px;
  justify-self: start;
  margin: 0;
  padding: 10px 16px;
  background: var(--red);
}
.tiw-modal__benefit span { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .85); }
.tiw-modal__benefit b { font-size: 26px; font-weight: 700; line-height: 1.15; }

.tiw-modal .form { padding: 66px 36px 32px; gap: 18px; align-content: center; }
.tiw-modal .form__grid { gap: 14px 18px; }
.tiw-modal .modal__close { color: var(--ink); z-index: 2; }

@media (max-width: 860px) {
  .tiw-modal .modal__dialog { width: min(520px, 100%); grid-template-columns: 1fr; }
  .tiw-modal .modal__close { color: #fff; }
  .tiw-modal .modal__title { padding-right: 48px; }
  /* на узком экране кадр не показываем: машины всё равно перекрываются текстом */
  .tiw-modal__media { min-height: 0; background: var(--red); }
  .tiw-modal__media img { display: none; }
  .tiw-modal__caption { background: none; }
  .tiw-modal__benefit { padding: 0; background: none; }
  .tiw-modal__caption { padding: 20px; }
  .tiw-modal .modal__title { font-size: 20px; }
  .tiw-modal__benefit b { font-size: 24px; }
  .tiw-modal .form { padding: 20px; gap: 14px; }
  .tiw-modal .form__grid { gap: 12px; }
  .tiw-modal .field__input { min-height: 48px; }
  .tiw-modal .consent { font-size: 11px; }
}

@media (max-width: 820px) {
  .tiw {
    left: 12px;
    bottom: calc(12px + var(--tiw-shift, 0px));
    padding: 10px 16px 10px 10px;
  }
  .tiw__icon { width: 38px; height: 38px; }
  .tiw__icon .icon { width: 20px; height: 20px; }
  .tiw__title, .tiw__benefit { font-size: 12px; }
}

/* низкие окна (ноутбуки 13", мобильный браузер с панелями) — ужимаем по вертикали */
@media (max-height: 720px) {
  .tiw-modal { padding: 12px; }
  .tiw-modal .modal__dialog { max-height: 96vh; }
  .tiw-modal__caption { padding: 22px 24px; }
  .tiw-modal .modal__title { font-size: 22px; }
  .tiw-modal__benefit b { font-size: 24px; }
  .tiw-modal .form { padding: 62px 28px 24px; gap: 12px; }
  .tiw-modal .form__grid { gap: 10px 18px; }
  .tiw-modal .field__input { min-height: 46px; }
  .tiw-modal .btn { min-height: 48px; }
}

@media (max-height: 720px) and (max-width: 860px) {
  .tiw-modal .modal__title { font-size: 19px; }
  .tiw-modal__caption { padding: 16px 20px; }
  .tiw-modal .form { padding: 18px 20px; }
}

/* совсем низкие окна — например, телефон в альбомной ориентации */
@media (max-height: 560px) {
  .tiw-modal { padding: 8px; }
  .tiw-modal .modal__dialog { max-height: 98vh; }
  .tiw-modal__media { min-height: 0; }
  .tiw-modal__caption { padding: 14px 18px; }
  .tiw-modal .modal__title { font-size: 18px; }
  .tiw-modal__benefit b { font-size: 20px; }
  .tiw-modal .form { padding: 14px 18px; gap: 10px; }
  .tiw-modal__caption { gap: 8px; }
  .tiw-modal .form__grid { gap: 6px 18px; }
  .tiw-modal .field__input { min-height: 42px; }
  .tiw-modal .consent { font-size: 11px; }
  .tiw-modal .btn { min-height: 42px; }
}

/* две колонки на низком окне: крестик стоит над формой, освобождаем ему место */
@media (max-height: 560px) and (min-width: 861px) {
  .tiw-modal .form { padding-top: 62px; }
}
