/* ==========================================================================
   Stepica — site popup (inc/popup.php · assets/js/popup.js)
   Native <dialog>: rendered in the top layer, so it never shifts the page.
   Desktop: centered card (split = brand panel + form, compact = one column).
   Mobile:  bottom sheet.
   ========================================================================== */
html.spop-lock { overflow: hidden; scrollbar-gutter: stable; }

.spop {
  width: min(960px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  color: var(--text-body);
}
.spop--compact { width: min(560px, calc(100% - 32px)); }
.spop::backdrop {
  background: rgba(10, 15, 35, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.spop[open]::backdrop { animation: spopFade .3s ease both; }
.spop.is-closing::backdrop { animation: spopFade .22s ease reverse both; }

.spop-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  max-height: calc(100dvh - 32px);
  border-radius: 28px;
  background: var(--white);
  box-shadow: 0 40px 120px rgba(6, 10, 28, 0.5);
  overflow: hidden;
}
.spop--compact .spop-card { grid-template-columns: 1fr; }
.spop[open] .spop-card { animation: spopIn .5s cubic-bezier(.2, .9, .3, 1.15) both; }
.spop.is-closing .spop-card { animation: spopOut .22s ease both; }

@keyframes spopFade { from { opacity: 0; } }
@keyframes spopIn { from { opacity: 0; transform: translateY(26px) scale(0.96); } }
@keyframes spopOut { to { opacity: 0; transform: translateY(14px) scale(0.97); } }

/* ---------- Close ---------- */
.spop-close {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--off-white);
  color: var(--text-dark);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), transform .3s var(--ease);
}
.spop-close:hover { background: var(--primary); color: var(--white); transform: rotate(90deg); }
.spop--compact .spop-close { background: rgba(255, 255, 255, 0.14); color: var(--white); }
.spop--compact .spop-close:hover { background: var(--white); color: var(--primary); }

/* ---------- Brand panel ---------- */
.spop-brand {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  padding: 48px 44px 40px;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 10%, rgba(69, 114, 183, 0.55), transparent 45%),
    radial-gradient(circle at 0% 100%, rgba(249, 115, 22, 0.22), transparent 42%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #2a4580 100%);
  color: rgba(255, 255, 255, 0.78);
}
.spop-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%);
  mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.spop-rings {
  position: absolute;
  z-index: -1;
  right: -110px;
  bottom: -110px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.spop-rings::after { content: ''; position: absolute; inset: 50px; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, 0.12); }

/* Optional photo behind the brand panel. */
.spop-photo-wrap { position: absolute; inset: 0; z-index: -2; }
.spop-photo { width: 100%; height: 100%; object-fit: cover; }
.spop--photo .spop-brand { background: var(--navy); }
.spop--photo .spop-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(16, 22, 44, 0.55) 0%, rgba(16, 22, 44, 0.88) 60%, rgba(16, 22, 44, 0.96) 100%);
}

.spop-eyebrow {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
  padding: 7px 15px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--white);
}
.spop-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.25); animation: spopPulse 2s ease-in-out infinite; }
@keyframes spopPulse { 50% { box-shadow: 0 0 0 7px rgba(249, 115, 22, 0); } }

.spop-title {
  margin-bottom: 14px;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--white);
  text-wrap: balance;
  outline: none;
}
.spop-hl {
  background: linear-gradient(90deg, var(--teal-light), #ffd2ad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.spop-text { font-size: 0.98rem; line-height: 1.7; color: rgba(255, 255, 255, 0.76); }
.spop-points { display: grid; gap: 12px; margin-top: 24px; }
.spop-points li { display: flex; align-items: center; gap: 12px; font-size: 0.94rem; font-weight: 500; color: var(--white); }
.spop-points i {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(157, 188, 232, 0.2);
  color: var(--teal-light);
  font-size: 0.66rem;
}
.spop-contact { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 30px; }
.spop-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.spop-chip:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-2px); }
.spop-chip--whatsapp i { color: #4ade80; }

/* ---------- Form side ---------- */
.spop-body { display: flex; flex-direction: column; padding: 48px 44px 36px; overflow-y: auto; overscroll-behavior: contain; }
.spop-form-title { padding-right: 44px; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--text-dark); line-height: 1.3; }
.spop-form-text { margin-top: 6px; font-size: 0.92rem; color: var(--dark-gray); }
.spop-form { margin-top: 24px; }
.spop-cta { width: 100%; }
.spop-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; font-size: 0.8rem; color: var(--mid-gray); }

/* Compact: brand panel becomes a header band. */
.spop--compact .spop-brand { padding: 36px 36px 30px; }
.spop--compact .spop-title { padding-right: 40px; font-size: clamp(1.45rem, 2.6vw, 1.8rem); }
.spop--compact .spop-points { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; }
.spop--compact .spop-points li { font-size: 0.86rem; }
.spop--compact .spop-contact { padding-top: 18px; }
.spop--compact .spop-body { padding: 30px 36px 28px; }
.spop--compact .spop-form-title { padding-right: 0; }

/* Admin-only form placeholder. */
.spop-ph { display: grid; gap: 12px; padding: 18px; border: 2px dashed var(--border); border-radius: var(--radius-md); }
.spop-ph-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spop-ph-field { display: block; height: 46px; border-radius: 10px; background: linear-gradient(90deg, var(--light-gray), var(--off-white)); }
.spop-ph-field--tall { height: 92px; }
.spop-ph-btn { display: block; height: 50px; border-radius: 50px; background: linear-gradient(90deg, var(--primary), var(--teal)); opacity: 0.85; }
.spop-ph small { font-size: 0.78rem; color: var(--dark-gray); text-align: center; }
.spop-cta + .spop-ph { margin-top: 16px; }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 760px) {
  .spop,
  .spop--compact { width: 100%; max-height: 92dvh; margin: auto 0 0; }
  .spop-card {
    grid-template-columns: 1fr;
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 26px 26px 0 0;
  }
  .spop-card::before {
    content: '';
    position: absolute;
    z-index: 4;
    top: 9px;
    left: 50%;
    width: 44px;
    height: 5px;
    margin-left: -22px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.4);
  }
  .spop[open] .spop-card { animation-name: spopUp; animation-duration: .4s; }
  .spop.is-closing .spop-card { animation-name: spopDown; }
  .spop-brand { padding: 34px 22px 24px; }
  .spop-title { padding-right: 44px; font-size: 1.45rem; }
  .spop-text { font-size: 0.92rem; }
  .spop-points { display: none; }
  .spop-contact { padding-top: 16px; }
  .spop-body { padding: 26px 22px 24px; overflow: visible; }
  .spop-close { top: 18px; right: 14px; background: rgba(255, 255, 255, 0.14); color: var(--white); }
}
@keyframes spopUp { from { transform: translateY(100%); } }
@keyframes spopDown { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  .spop[open] .spop-card,
  .spop[open]::backdrop,
  .spop-dot { animation: none; }
}

/* ==========================================================================
   Size fixes: the card never grows past the viewport — the form column
   scrolls inside it, so the Submit button is always reachable.
   ========================================================================== */
.spop { width: min(880px, calc(100% - 32px)); }
.spop-card {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  grid-template-rows: minmax(0, 1fr);
}
.spop--compact .spop-card { grid-template-rows: auto minmax(0, 1fr); }
.spop-brand { padding: 40px 36px 34px; min-height: 0; }
.spop-body { min-height: 0; padding: 36px 36px 26px; scrollbar-width: thin; }
.spop-title { font-size: clamp(1.5rem, 2.6vw, 1.95rem); margin-bottom: 12px; }
.spop-text { font-size: 0.93rem; line-height: 1.65; }
.spop-points { gap: 10px; margin-top: 20px; }
.spop-points li { font-size: 0.9rem; }
.spop-form-title { font-size: 1.25rem; }
.spop-form { margin-top: 18px; }
.spop-note { margin-top: 14px; }

/* Compact Forminator inside the popup.
   Forminator prints per-form CSS with ID selectors (#forminator-module-N),
   which beat class selectors — so these few spacing rules are scoped to the
   popup's ID and marked !important. They affect the popup form only. */
#stepica-popup .forminator-ui .forminator-row,
#stepica-popup .forminator-ui .forminator-col,
#stepica-popup .forminator-ui .forminator-field { margin-bottom: 0 !important; padding-bottom: 0 !important; }
#stepica-popup .forminator-ui .forminator-row:not(:last-child) { margin-bottom: 10px !important; }
#stepica-popup .forminator-ui .forminator-row.forminator-row-last { margin-top: 14px !important; }
#stepica-popup .forminator-ui .forminator-label {
  margin: 0 0 4px !important;
  padding: 0 !important;
  font-size: 0.78rem !important;
  line-height: 1.3 !important;
}
#stepica-popup .forminator-ui .forminator-input,
#stepica-popup .forminator-ui select.forminator-select--field:not(.forminator-select2),
#stepica-popup .forminator-ui .select2-selection--single {
  height: auto !important;
  min-height: 0 !important;
  padding: 9px 13px !important;
  font-size: 0.88rem !important;
  line-height: 1.35 !important;
}
#stepica-popup .forminator-ui .select2-selection--single .select2-selection__rendered { padding: 0 !important; line-height: 1.35 !important; }
#stepica-popup .forminator-ui .forminator-textarea {
  height: 68px !important;
  min-height: 68px !important;
  padding: 9px 13px !important;
  font-size: 0.88rem !important;
  line-height: 1.45 !important;
}
#stepica-popup .forminator-ui .forminator-description,
#stepica-popup .forminator-ui .forminator-error-message { margin-top: 2px !important; font-size: 0.72rem !important; line-height: 1.3 !important; }
#stepica-popup .forminator-ui .forminator-button-submit { padding: 11px 22px !important; font-size: 0.92rem !important; }
#stepica-popup .forminator-ui .forminator-response-message { margin-bottom: 12px !important; padding: 10px 14px !important; }

/* Select2 list opened inside the popup. The form is its positioning
   reference (Select2 doesn't add the scroll offset of a scrolling ancestor,
   so without this the list lands on top of the field when the popup body
   is scrolled — and the same tap selects an option and closes it). */
.spop .forminator-ui.forminator-custom-form { position: relative; }
.spop .forminator-select-dropdown-container--open { z-index: 20; }
.spop .forminator-select-dropdown .select2-results__options { max-height: 200px; }

/* Shorter desktop screens (laptops): trim the brand panel. */
@media (min-width: 761px) and (max-height: 820px) {
  .spop-points { display: none; }
  .spop-brand { padding: 32px 32px 28px; }
  .spop-body { padding: 30px 32px 22px; }
  .spop-contact { padding-top: 20px; }
}
@media (min-width: 761px) and (max-height: 660px) {
  .spop-text,
  .spop-eyebrow { display: none; }
  .spop-title { font-size: 1.45rem; }
  .spop-form-text { display: none; }
}

/* Mobile bottom sheet: compact header so the form starts higher. */
@media (max-width: 760px) {
  .spop,
  .spop--compact { width: 100%; }
  .spop-card { grid-template-columns: 1fr; grid-template-rows: none; }
  .spop-brand { padding: 30px 20px 20px; }
  .spop-eyebrow { margin-bottom: 12px; padding: 5px 12px; font-size: 0.75rem; }
  .spop-title { font-size: 1.3rem; margin-bottom: 8px; }
  .spop-text { font-size: 0.88rem; line-height: 1.55; }
  .spop-contact { padding-top: 14px; gap: 8px; }
  .spop-chip { padding: 7px 12px; font-size: 0.8rem; }
  .spop-body { padding: 22px 20px 20px; }
  .spop-form-title { font-size: 1.12rem; }
}
@media (max-width: 760px) {
  .spop-text { display: none; }
  .spop-title { margin-bottom: 0; }
}

/* ==========================================================================
   Max height 600px on desktop / tablet.
   ========================================================================== */
@media (min-width: 761px) {
  .spop,
  .spop-card { max-height: min(600px, calc(100dvh - 32px)); }
  .spop-brand { padding: 32px 32px 26px; }
  .spop-eyebrow { margin-bottom: 16px; }
  .spop-title { font-size: clamp(1.4rem, 2.3vw, 1.75rem); }
  .spop-text { font-size: 0.9rem; line-height: 1.6; }
  .spop-points { margin-top: 16px; gap: 8px; }
  .spop-points li { font-size: 0.86rem; }
  .spop-contact { padding-top: 18px; }
  .spop-body { padding: 26px 30px 18px; }
  .spop-form-title { font-size: 1.15rem; padding-right: 40px; }
  .spop-form-text { margin-top: 2px; font-size: 0.85rem; }
  .spop-form { margin-top: 14px; }
  .spop-note { margin-top: 10px; font-size: 0.75rem; }
  .spop-close { top: 12px; right: 12px; width: 36px; height: 36px; font-size: 0.95rem; }
}

/* ==========================================================================
   Mobile: compact floating card (12px from the sides and bottom).
   Input text stays 16px so iOS doesn't zoom in on focus.
   ========================================================================== */
@media (max-width: 760px) {
  .spop,
  .spop--compact {
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
    margin: auto auto 12px;
  }
  .spop-card {
    max-height: calc(100dvh - 24px);
    border-radius: 22px;
  }
  .spop-card::before { display: none; }
  html.spop-lock { scrollbar-gutter: auto; }

  .spop-brand { padding: 16px 52px 14px 16px; }
  .spop-eyebrow { margin-bottom: 8px; padding: 4px 10px; font-size: 0.7rem; gap: 7px; }
  .spop-dot { width: 6px; height: 6px; }
  .spop-title { padding-right: 0; font-size: 1.12rem; line-height: 1.25; }
  .spop-contact { padding-top: 10px; gap: 6px; }
  .spop-chip { padding: 5px 10px; font-size: 0.74rem; gap: 6px; }
  .spop-rings { width: 200px; height: 200px; right: -80px; bottom: -90px; }
  .spop-close { top: 12px; right: 12px; width: 32px; height: 32px; font-size: 0.85rem; }

  .spop-body { padding: 14px 16px 12px; }
  .spop-form-title { font-size: 1rem; padding-right: 0; }
  .spop-form-text { margin-top: 1px; font-size: 0.78rem; }
  .spop-form { margin-top: 10px; }
  .spop-note { margin-top: 8px; font-size: 0.7rem; }

  #stepica-popup .forminator-ui .forminator-row:not(:last-child) { margin-bottom: 8px !important; }
  #stepica-popup .forminator-ui .forminator-row.forminator-row-last { margin-top: 10px !important; }
  #stepica-popup .forminator-ui .forminator-label { margin-bottom: 3px !important; font-size: 0.74rem !important; }
  #stepica-popup .forminator-ui .forminator-input,
  #stepica-popup .forminator-ui select.forminator-select--field:not(.forminator-select2),
  #stepica-popup .forminator-ui .select2-selection--single {
    padding: 7px 12px !important;
    font-size: 16px !important;
    line-height: 1.3 !important;
    border-radius: 10px !important;
  }
  #stepica-popup .forminator-ui .forminator-textarea {
    height: 58px !important;
    min-height: 58px !important;
    padding: 7px 12px !important;
    font-size: 16px !important;
    line-height: 1.35 !important;
    border-radius: 10px !important;
  }
  #stepica-popup .forminator-ui .forminator-button-submit { padding: 10px 18px !important; font-size: 0.9rem !important; }
}
/* Very short phones: drop the call/WhatsApp chips to keep the form in view. */
@media (max-width: 760px) and (max-height: 700px) {
  .spop-contact { display: none; }
}
@keyframes spopUp { from { opacity: 0; transform: translateY(40px); } }
@keyframes spopDown { to { opacity: 0; transform: translateY(40px); } }
