/* ─── Popup: Audit lead-magnet · 2026-05-19 ───────────────────────────
   Modal with form (desktop) → bottom-sheet (mobile <768px).
   Triggered via [data-popup-open="popup-audit"] click.
   States: form (idle/focus/error/loading), success, network-error.
   ───────────────────────────────────────────────────────────────────── */

.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.popup-overlay[hidden] { display: none !important; }

.popup-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 13, 20, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  animation: popup-scrim-in 240ms ease-out;
}
@keyframes popup-scrim-in { from { opacity: 0; } to { opacity: 1; } }

.popup-sheet {
  position: relative;
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(10, 13, 20, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popup-sheet-in 260ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center center;
}
@keyframes popup-sheet-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.popup-handle { display: none; }

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: rgba(13, 17, 23, 0.6);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s, color 0.2s;
}
.popup-close:hover { background: rgba(13, 17, 23, 0.06); color: var(--ink, #0d1117); }
.popup-close:focus-visible {
  outline: 2px solid var(--brand, #0066ff);
  outline-offset: 2px;
}

.popup-content {
  overflow-y: auto;
  padding: 36px 32px 28px;
  -webkit-overflow-scrolling: touch;
}

.popup-state[hidden] { display: none; }

.popup-title {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink, #0d1117);
  margin: 0 0 10px;
  padding-right: 32px; /* room for close button */
}
.popup-sub {
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(13, 17, 23, 0.66);
  margin: 0 0 18px;
}

.popup-bullets {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: grid;
  gap: 8px;
}
.popup-bullets li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 0.93rem;
  line-height: 1.5;
  color: rgba(13, 17, 23, 0.82);
}
.popup-bullet-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 102, 255, 0.10);
  color: var(--brand, #0066ff);
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.popup-form { margin: 0; }

.popup-field {
  margin-bottom: 14px;
}
.popup-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(13, 17, 23, 0.78);
  margin-bottom: 6px;
}
.popup-req {
  color: #ef4444;
  font-weight: 700;
  margin-left: 2px;
}
.popup-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px; /* min 16px to prevent iOS auto-zoom */
  color: var(--ink, #0d1117);
  background: #ffffff;
  border: 1.5px solid rgba(13, 17, 23, 0.14);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.popup-input::placeholder { color: rgba(13, 17, 23, 0.36); }
.popup-input:hover { border-color: rgba(13, 17, 23, 0.28); }
.popup-input:focus {
  outline: none;
  border-color: var(--brand, #0066ff);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}
.popup-helper {
  font-size: 12px;
  color: rgba(13, 17, 23, 0.52);
  margin-top: 5px;
}
.popup-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 5px;
  min-height: 0;
  display: none;
}
.popup-field.is-error .popup-input {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.04);
}
.popup-field.is-error .popup-input:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}
.popup-field.is-error .popup-error { display: block; }
.popup-field.is-error .popup-helper { display: none; }

.popup-consent {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(13, 17, 23, 0.7);
  cursor: pointer;
  margin: 6px 0 18px;
  user-select: none;
}
.popup-consent input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand, #0066ff);
  cursor: pointer;
}
.popup-consent a {
  color: var(--brand, #0066ff);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.popup-net-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  font-size: 13px;
  color: #b91c1c;
  margin-bottom: 14px;
}
.popup-net-error[hidden] { display: none !important; }
.popup-net-retry {
  background: transparent;
  border: 0;
  color: #b91c1c;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

.popup-submit {
  width: 100%;
  height: 56px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand, #0066ff) 0%, #6366f1 100%);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 102, 255, 0.28);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.popup-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 102, 255, 0.34);
}
.popup-submit:active:not(:disabled) { transform: translateY(0); }
.popup-submit:focus-visible {
  outline: 3px solid rgba(0, 102, 255, 0.4);
  outline-offset: 2px;
}
.popup-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.popup-submit-spinner { display: none; }
.popup-form.is-loading .popup-submit-text { display: none; }
.popup-form.is-loading .popup-submit-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: popup-spin 700ms linear infinite;
}
.popup-form.is-loading .popup-submit::before {
  content: "Отправляем...";
  font-size: 1.02rem;
  font-weight: 700;
}
@keyframes popup-spin { to { transform: rotate(360deg); } }

.popup-consent-hint {
  font-size: 11px;
  text-align: center;
  color: rgba(13, 17, 23, 0.5);
  margin-top: 8px;
  display: none;
}
.popup-form:not(.is-consent-ok) .popup-submit:disabled ~ .popup-consent-hint {
  display: block;
}

.popup-trust {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: center;
  color: rgba(13, 17, 23, 0.48);
  margin-top: 14px;
  line-height: 1.5;
}

/* ─── Success state ─── */
.popup-state--success {
  text-align: center;
  padding: 12px 0 4px;
}
.popup-success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.popup-success-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(13, 17, 23, 0.7);
  margin: 0 auto 22px;
  max-width: 360px;
}
.popup-success-close {
  height: 48px;
  padding: 0 28px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink, #0d1117);
  background: rgba(13, 17, 23, 0.06);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.popup-success-close:hover { background: rgba(13, 17, 23, 0.1); }

/* ─── Mobile: bottom-sheet ─── */
@media (max-width: 768px) {
  .popup-overlay { padding: 0; align-items: flex-end; }
  .popup-sheet {
    width: 100%;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    animation: popup-sheet-up 280ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes popup-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .popup-handle {
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(13, 17, 23, 0.18);
    border-radius: 2px;
  }
  .popup-content { padding: 32px 24px 24px; }
  .popup-close { top: 18px; right: 14px; width: 44px; height: 44px; }
  .popup-title { font-size: 1.25rem; padding-right: 40px; }
  .popup-sub { font-size: 0.9rem; }
}

/* ─── Hero CTA secondary text-link (referenced from popup-audit.js scope) ─── */
.hero-cta-secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 18px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand, #0066ff);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
  text-decoration-color: rgba(0, 102, 255, 0.35);
  transition: text-decoration-color 0.2s, color 0.2s, transform 0.2s;
  min-height: 44px;
}
.hero-cta-secondary:hover {
  color: var(--brand-dark, #0052cc);
  text-decoration-color: var(--brand, #0066ff);
}
.hero-cta-secondary:hover .hero-cta-arrow {
  transform: translateX(3px);
}
.hero-cta-secondary:focus-visible {
  outline: 2px solid var(--brand, #0066ff);
  outline-offset: 4px;
  border-radius: 6px;
}
.hero-cta-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  text-decoration: none;
  font-weight: 700;
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .popup-scrim, .popup-sheet { animation: none; }
  .popup-submit { transition: none; }
  .popup-submit:hover:not(:disabled) { transform: none; }
}

/* ─── Funnel note + optional label (added 2026-05-21) ─── */
.popup-funnel-note {
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(13, 17, 23, 0.58);
  margin: -8px 0 18px;
  padding: 10px 14px;
  background: rgba(13, 17, 23, 0.035);
  border-left: 2px solid rgba(13, 17, 23, 0.14);
  border-radius: 6px;
}
.popup-opt {
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(13, 17, 23, 0.45);
  margin-left: 6px;
  letter-spacing: 0;
}
@media (max-width: 640px) {
  .popup-funnel-note { font-size: 0.8rem; padding: 9px 12px; }
  .popup-opt { font-size: 0.75rem; }
}
