/* ==========================================================================
   Opt-in Popup: Qualifizierungsfrage, dann Formular
   Nutzt die Variablen aus styles.css und muss deshalb danach geladen werden.
   Welcher Schritt sichtbar ist, steuert allein data-step am Dialog.
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  pointer-events: none;
}

.modal.open {
  visibility: visible;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 20, 15, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.modal.open .modal-backdrop {
  opacity: 1;
}

.modal-dialog {
  position: relative;
  width: min(100%, 520px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 30px 28px;
  background: var(--panel);
  border-radius: 22px;
  box-shadow: 0 40px 90px rgba(21, 20, 15, 0.3), 0 0 0 1px rgba(21, 20, 15, 0.05);
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.modal.open .modal-dialog {
  opacity: 1;
  transform: none;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

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

/* ------------------------------------------------------------- Kopf ---- */

.modal-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 44px;
}

.modal-cover {
  flex: none;
  width: 46px;
  height: 65px;
  border-radius: 3px 5px 5px 3px;
  object-fit: cover;
  box-shadow: 3px 3px 0 -1px #ece6d8, 6px 8px 16px rgba(21, 20, 15, 0.22);
  transform: rotate(-4deg);
}

.modal-kicker {
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal-product {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nw {
  white-space: nowrap;
}

.modal-dialog[data-step="1"] [data-kicker-2],
.modal-dialog[data-step="2"] [data-kicker-1] {
  display: none;
}

/* Fortschritt: nach dem ersten Klick schon fast voll, das zieht durch */
.progress {
  height: 6px;
  margin: 18px 0 22px;
  border-radius: 6px;
  background: var(--well);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #d8b873);
  transition: width 0.5s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.modal-dialog[data-step="2"] .progress span {
  width: 88%;
}

/* ----------------------------------------------------------- Schritte ---- */

.step {
  display: none;
}

.modal-dialog[data-step="1"] .step-1,
.modal-dialog[data-step="2"] .step-2 {
  display: block;
  animation: step-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
}

.step h2 {
  font-size: clamp(21px, 2.4vw, 25px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.modal-lead {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 112px;
  padding: 14px 14px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.choice:hover {
  border-color: var(--gold);
  background: #fdfbf6;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(140, 106, 42, 0.12);
}

.choice[aria-pressed="true"] {
  border-color: var(--gold-deep);
  background: rgba(190, 156, 103, 0.12);
}

.choice-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(190, 156, 103, 0.16);
  color: var(--gold-deep);
}

.choice strong {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}

.choice > span:last-child {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px 0 14px;
}

/* Kanal-Badge wie im Videokurs, hier in Hell */
.modal-channel {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(190, 156, 103, 0.14);
  border: 1px solid rgba(140, 106, 42, 0.32);
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.step-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -4px;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.step-back:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------ Formular ---- */

.field {
  position: relative;
  margin-bottom: 12px;
  min-width: 0;
}

.field input {
  width: 100%;
  min-width: 0;
  padding: 22px 14px 8px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  /* 16px, sonst zoomt iOS beim Fokus in das Feld */
  font-size: 16px;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.field input::placeholder {
  color: transparent;
}

.field label {
  position: absolute;
  left: 15px;
  top: 16px;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.16s ease, color 0.16s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--panel);
  box-shadow: 0 0 0 4px rgba(190, 156, 103, 0.16);
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-9px) scale(0.75);
  color: var(--gold-deep);
}

.field .hint {
  display: block;
  max-height: 0;
  margin-top: 6px;
  overflow: hidden;
  opacity: 0;
  color: var(--bad);
  font-size: 12.5px;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}

.field.invalid input,
.field-phone.invalid select {
  border-color: rgba(180, 71, 61, 0.6);
  background-color: #fdf4f2;
}

.field.invalid label {
  color: var(--bad);
}

.field.invalid .hint {
  max-height: 40px;
  opacity: 1;
}

.field.valid input {
  border-color: rgba(24, 169, 87, 0.45);
}

.field.valid::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  pointer-events: none;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318a957' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* Telefonfeld mit Vorwahl davor */
.field-phone {
  display: grid;
  grid-template-columns: 112px 1fr;
}

.field-phone select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 28px 0 14px;
  border: 1.5px solid var(--line);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--surface) no-repeat right 11px center / 11px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6a5e' stroke-width='3' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.field-phone select:focus {
  outline: none;
  border-color: var(--gold);
}

.field-phone input {
  border-radius: 0 12px 12px 0;
}

.field-phone label {
  left: 127px;
}

.field-phone .hint {
  grid-column: 1 / -1;
}

/* Bei sichtbarem Hinweis wandert die Mitte nach unten, der Haken bleibt am Feld */
.field-phone.valid::after {
  top: 27px;
}

.btn-submit {
  position: relative;
  width: 100%;
  margin-top: 4px;
  padding: 19px 24px;
  font-size: 16.5px;
}

.btn-submit[data-loading="true"] {
  pointer-events: none;
  color: transparent;
}

.btn-submit[data-loading="true"]::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(26, 20, 4, 0.25);
  border-top-color: var(--on-gold);
  animation: spin 0.7s linear infinite;
}

.form-fehler {
  margin: 10px 0 0;
  color: var(--bad);
  font-size: 13px;
  text-align: center;
}

.form-fehler[hidden] {
  display: none;
}

.form-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.form-consent svg {
  flex: none;
  margin-top: 2px;
  color: var(--gold-deep);
}

.form-consent a {
  color: var(--gold-deep);
}

.form-error {
  margin-top: 12px;
  color: var(--bad);
  font-size: 13px;
  text-align: center;
}

/* Honeypot: kein display:none, das erkennen die besseren Bots */
.gotcha {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --------------------------------------------------------------- Handy ---- */

/* Bottom-Sheet statt schwebender Box */
@media (max-width: 640px) {
  .modal {
    padding: 0;
    place-items: end center;
  }
  .modal-dialog {
    width: 100%;
    max-height: 94dvh;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
  }
  .modal-dialog::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: -10px auto 14px;
    border-radius: 4px;
    background: var(--well);
  }
  .modal-close {
    top: 12px;
    right: 12px;
  }
  .modal-cover {
    width: 38px;
    height: 54px;
  }
  .mp-extra {
    display: none;
  }
  .progress {
    margin: 14px 0 18px;
  }
  .modal-lead {
    margin-bottom: 16px;
  }
  .choice {
    min-height: 0;
    padding: 12px;
  }
  .choice-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
  }
  .choice strong {
    font-size: 14.5px;
  }
  .choice > span:last-child {
    font-size: 12px;
  }
  .field-phone {
    grid-template-columns: 104px 1fr;
  }
  .field-phone label {
    left: 119px;
  }
}
