/* ==========================================================
   Delta Dental Clinics — Модуль попапов v2 (STOM-61)
   Казань и Сургут.
   Соответствует токенам лендинга Дельта:
   Golos Text + Onest, #0B3C5D, #00A0E3, #EAF6FD
   Полная поддержка: Desktop (диалог) и Mobile (<768px: bottom sheet)
   ========================================================== */

/* ---------- Контейнер и обертка попапов ---------- */
.dd-popups-v2 {
  position: relative;
  z-index: 99999;
}

.dd-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
  z-index: 100000;
  box-sizing: border-box;
}

.dd-popup.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.dd-popup[hidden] {
  display: none !important;
}

/* Фон / Backdrop */
.dd-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 60, 93, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Карточка попапа / Box */
.dd-popup__box {
  position: relative;
  z-index: 2;
  background: #ffffff;
  border-radius: var(--radius-plate, 28px);
  padding: 28px 32px 28px;
  max-width: 520px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(11, 60, 93, 0.32);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.dd-popup.is-open .dd-popup__box {
  transform: scale(1) translateY(0);
}

/* Для квиза даём немного шире под плитку */
.dd-popup--c .dd-popup__box {
  max-width: 580px;
}

/* Индикатор свайпа для мобилок */
.dd-popup__drag-handle {
  display: none;
}

/* Кнопка закрытия (крестик) */
.dd-popup__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(11, 60, 93, 0.12);
  background: #F3F8FB;
  color: var(--color-brand-navy, #0B3C5D);
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.15s ease, transform 0.12s ease;
  padding: 0;
}

.dd-popup__close::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 999px;
}

.dd-popup__close:hover {
  background: var(--plate-accent, #EAF6FD);
  transform: scale(1.06);
}

/* ---------- Верхняя часть (Бейдж, Заголовок, Челюсть) ---------- */
.dd-popup__badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-right: 40px;
}

.dd-popup__badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  background: #EAF6FD;
  color: #0090D6;
  border: 1px solid rgba(0, 160, 227, 0.28);
  letter-spacing: 0.01em;
}

.dd-popup__badge--accent {
  background: #FFF7ED;
  color: #C2410C;
  border-color: rgba(234, 88, 12, 0.28);
}

.dd-popup__hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dd-popup__intro {
  flex: 1;
}

.dd-popup__title {
  font-family: var(--font-family-display, 'Golos Text', sans-serif);
  font-size: 23px;
  font-weight: 800;
  color: var(--color-brand-navy, #0B3C5D);
  line-height: 1.25;
  margin: 0 0 10px;
}

.dd-popup__text {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 14.5px;
  line-height: 1.48;
  color: #4A5568;
  margin: 0;
}

.dd-popup__jaw-wrap {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  background: radial-gradient(circle, #EAF6FD 0%, rgba(234, 246, 253, 0) 72%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dd-popup__jaw-img {
  width: 100%;
  height: auto;
  max-height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(11, 60, 93, 0.16));
}

/* ---------- Форма ---------- */
.dd-popup__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.dd-popup__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-brand-navy, #0B3C5D);
  text-align: left;
}

.dd-popup__field input[type="text"],
.dd-popup__field input[type="tel"] {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(11, 60, 93, 0.16);
  background: #ffffff;
  color: var(--color-text-primary, #1A1A1A);
  outline: none;
  box-sizing: border-box;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dd-popup__field input[type="text"]:focus,
.dd-popup__field input[type="tel"]:focus {
  border-color: var(--color-brand-blue, #00A0E3);
  box-shadow: 0 0 0 3px rgba(0, 160, 227, 0.15);
}

.dd-popup__field.is-error input {
  border-color: var(--color-error, #B42318);
  background: #FFF8F8;
}

.dd-popup__field-err {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-error, #B42318);
  min-height: 0;
}

.dd-popup__field-err:empty {
  display: none;
}

/* Чекбоксы согласий */
.dd-popup__field--check {
  flex-direction: row;
  align-items: flex-start;
  gap: 9px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.38;
  color: #55697A;
  margin-top: 2px;
  cursor: pointer;
}

.dd-popup__field--check input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-brand-blue, #00A0E3);
}

.dd-popup__link {
  color: var(--color-brand-blue, #00A0E3);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dd-popup__link:hover {
  color: var(--color-brand-blue-dark, #0090D6);
}

.dd-popup__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Кнопка отправки */
.dd-popup__btn {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.dd-popup__btn--primary {
  background: linear-gradient(180deg, var(--color-brand-blue-light, #1FB4F0) 0%, var(--color-brand-blue-dark, #0090D6) 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #0672AD,
    0 8px 20px rgba(0, 160, 227, 0.32);
  margin-top: 6px;
}

.dd-popup__btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.dd-popup__btn--primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 1px 0 #0672AD,
    0 4px 10px rgba(0, 160, 227, 0.25);
}

.dd-popup__btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.dd-popup__btn--secondary {
  background: #EAF6FD;
  color: #0090D6;
  border: 1px solid rgba(0, 160, 227, 0.3);
  margin-top: 14px;
}

.dd-popup__btn--secondary:hover {
  background: #d8edf9;
}

.dd-popup__note {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 12px;
  color: #64748B;
  text-align: center;
  margin: 4px 0 0;
}

.dd-popup__legal {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 10.5px;
  color: #94A3B8;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 4px 0 0;
}

.dd-popup__form-err {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-error, #B42318);
  background: #FFF0F0;
  border: 1px solid rgba(180, 35, 24, 0.2);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 4px 0;
  text-align: center;
}

/* ---------- Экран успеха / Success ---------- */
.dd-popup__success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px;
}

.dd-popup__success[hidden] {
  display: none !important;
}

.dd-popup__success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #EAF6FD;
  color: #0090D6;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.dd-popup__success-title {
  font-family: var(--font-family-display, 'Golos Text', sans-serif);
  font-size: 22px;
  font-weight: 800;
  color: var(--color-brand-navy, #0B3C5D);
  margin: 0 0 10px;
  line-height: 1.3;
}

.dd-popup__success-text {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 14.5px;
  line-height: 1.48;
  color: #4A5568;
  margin: 0 0 14px;
}

.dd-popup__branch-note {
  font-size: 13.5px;
  line-height: 1.45;
  color: #0B3C5D;
  background: #EAF6FD;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ---------- Квиз (Попап В) ---------- */
.dd-popup__progress {
  width: 100%;
  height: 6px;
  background: rgba(11, 60, 93, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 14px;
}

.dd-popup__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1FB4F0, #0090D6);
  border-radius: 999px;
  transition: width 0.28s ease;
}

.dd-popup__step-count {
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 12px;
  font-weight: 700;
  color: #0090D6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}

.dd-popup__quiz-question {
  font-family: var(--font-family-display, 'Golos Text', sans-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-brand-navy, #0B3C5D);
  line-height: 1.3;
  margin: 0 0 14px;
}

.dd-popup__screen[hidden] {
  display: none !important;
}

.dd-popup__tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.dd-popup__tile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid rgba(11, 60, 93, 0.14);
  border-radius: 14px;
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-brand-navy, #0B3C5D);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  box-sizing: border-box;
}

.dd-popup__tile:hover {
  border-color: var(--color-brand-blue, #00A0E3);
  background: #F8FCFE;
  transform: translateY(-1px);
}

.dd-popup__tile:active,
.dd-popup__tile[aria-pressed="true"] {
  border-color: var(--color-brand-blue, #00A0E3);
  background: #EAF6FD;
}

.dd-popup__tile-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  object-fit: contain;
}

.dd-popup__quiz-foot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 14px;
}

.dd-popup__quiz-back {
  background: none;
  border: none;
  color: #64748B;
  font-family: var(--font-family, 'Onest', sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.dd-popup__quiz-back:hover {
  color: var(--color-brand-navy, #0B3C5D);
}

.dd-popup__phone-note {
  font-size: 12px;
  color: #0090D6;
  margin-top: 2px;
}

/* ---------- Мобильная адаптация (<768px: Bottom Sheet) ---------- */
@media (max-width: 767.98px) {
  .dd-popup {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .dd-popup__box {
    max-width: 100%;
    width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    max-height: 88dvh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .dd-popup.is-open .dd-popup__box {
    transform: translateY(0);
  }

  .dd-popup__drag-handle {
    display: block;
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(11, 60, 93, 0.18);
    margin: 0 auto 14px;
  }

  .dd-popup__close {
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    font-size: 22px;
  }

  .dd-popup__title {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .dd-popup__text {
    font-size: 13.5px;
    line-height: 1.42;
  }

  .dd-popup__jaw-wrap {
    width: 76px;
    height: 76px;
  }

  .dd-popup__jaw-img {
    max-height: 76px;
  }

  .dd-popup__tile {
    min-height: 48px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .dd-popup__tile-icon {
    width: 32px;
    height: 32px;
  }
}

/* Поддержка prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .dd-popup,
  .dd-popup__box,
  .dd-popup__progress-bar,
  .dd-popup__tile {
    transition: none !important;
    transform: none !important;
  }
}
