/* ==========================================================
   Email Gate — Mask overlay for video showcase unlock
   Ported from Luminow report paywall, adapted for Purrchase.ai
   ========================================================== */

/* ── Mask overlay (covers the video grid) ── */
.email-gate-mask {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3.6vw, 34px);
  overflow: hidden;
  border-radius: 0;

  /* frosted shower-glass look */
  background: radial-gradient(
      ellipse 120% 80% at 30% 20%,
      rgba(255, 255, 255, 0.18),
      transparent 60%
    ),
    radial-gradient(
      ellipse 100% 60% at 80% 90%,
      rgba(255, 255, 255, 0.1),
      transparent 50%
    ),
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.08) 40%,
      rgba(200, 210, 220, 0.12) 70%,
      rgba(180, 195, 210, 0.18) 100%
    );
  backdrop-filter: blur(22px) saturate(1.25) brightness(1.06);
  -webkit-backdrop-filter: blur(22px) saturate(1.25) brightness(1.06);
  border: 1px solid rgba(255, 255, 255, 0.18);

  /* unlock transition — animates out before display:none */
  opacity: 1;
  transition: opacity 0.5s ease, backdrop-filter 0.5s ease,
    -webkit-backdrop-filter 0.5s ease;
  animation: emailGateFadeIn 0.4s ease;
}

/* subtle light-refraction streaks (like light through textured glass) */
.email-gate-mask::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background: repeating-linear-gradient(
      105deg,
      rgba(255, 255, 255, 0.6) 0px,
      transparent 1px,
      transparent 18px,
      rgba(255, 255, 255, 0.4) 19px,
      transparent 20px,
      transparent 42px
    ),
    repeating-linear-gradient(
      70deg,
      rgba(255, 255, 255, 0.3) 0px,
      transparent 1px,
      transparent 28px,
      rgba(255, 255, 255, 0.2) 29px,
      transparent 30px,
      transparent 56px
    );
}

/* water-droplet / condensation noise layer */
.email-gate-mask::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: radial-gradient(
      circle 2px at 15% 25%,
      rgba(255, 255, 255, 0.8),
      transparent
    ),
    radial-gradient(
      circle 1.5px at 40% 12%,
      rgba(255, 255, 255, 0.6),
      transparent
    ),
    radial-gradient(
      circle 2.5px at 70% 35%,
      rgba(255, 255, 255, 0.7),
      transparent
    ),
    radial-gradient(
      circle 1px at 25% 60%,
      rgba(255, 255, 255, 0.5),
      transparent
    ),
    radial-gradient(
      circle 2px at 55% 72%,
      rgba(255, 255, 255, 0.6),
      transparent
    ),
    radial-gradient(
      circle 1.5px at 85% 55%,
      rgba(255, 255, 255, 0.7),
      transparent
    ),
    radial-gradient(
      circle 2px at 10% 85%,
      rgba(255, 255, 255, 0.5),
      transparent
    ),
    radial-gradient(
      circle 1px at 60% 45%,
      rgba(255, 255, 255, 0.4),
      transparent
    ),
    radial-gradient(
      circle 2px at 90% 80%,
      rgba(255, 255, 255, 0.6),
      transparent
    ),
    radial-gradient(
      circle 1.5px at 35% 90%,
      rgba(255, 255, 255, 0.5),
      transparent
    );
  background-size: 200px 200px;
}

@keyframes emailGateFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* When unlocked, fade out the shower glass mask */
.email-gate-mask.unlocked {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0px) saturate(1) brightness(1);
  -webkit-backdrop-filter: blur(0px) saturate(1) brightness(1);
}

/* fully remove from layout after animation completes (JS adds this) */
.email-gate-mask.unlocked.hidden {
  display: none;
}

/* When locked, blur the grid behind (seen through frosted glass) */
.video-showcase__grid-wrap.gated,
.video-showcase__grid-wrap.gated .video-grid {
  max-height: 80vh;
  overflow: hidden;
}

.video-grid.gated .video-tile {
  pointer-events: none;
  user-select: none;
  filter: blur(6px) saturate(0.7) brightness(0.82);
  transition: filter 0.5s ease;
}

/* Unblur grid smoothly when unlocked */
.video-grid:not(.gated) {
  filter: none;
  transition: filter 0.5s ease;
}

.video-grid:not(.gated) .email-gate-mask {
  display: none;
}

.video-grid.gated .video-showcase__fade {
  display: none;
}

/* ── Card (frosted panel floating on the glass) ── */
.email-gate-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: clamp(28px, 5vw, 48px) clamp(24px, 4vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 0 0 0.5px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  text-align: center;
}

.email-gate-headline h3 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.6rem, 3.6vw, 2.2rem);
  line-height: 1.15;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.email-gate-copy {
  margin: 6px 0 0;
  color: #888;
  font-size: 0.85rem;
  line-height: 1.4;
  font-weight: 400;
}

/* ── Email form ── */
.email-gate-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  width: 100%;
}

.email-gate-otp-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  width: 100%;
}

.email-gate-form[hidden],
.email-gate-otp-form[hidden] {
  display: none;
}

.email-gate-form label,
.email-gate-otp-form label {
  display: none;
}

.email-gate-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Input row ── */
.email-gate-input-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  width: 100%;
}

.email-gate-input-row input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 999px;
  padding: 18px 24px;
  font-size: 1.05rem;
  font-weight: 400;
  color: #1a1a1a;
  background: #eeeeec;
  box-shadow: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  font-family: "Inter", -apple-system, sans-serif;
}

.email-gate-input-row input::placeholder {
  color: #999;
  font-weight: 400;
}

.email-gate-input-row input:focus {
  outline: none;
  background: #e8e8e5;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.email-gate-input-row input.error {
  box-shadow: 0 0 0 2px rgba(185, 31, 31, 0.4);
  background: #fdf2f2;
}

/* ── OTP slots ── */
.email-gate-otp-row {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: stretch;
  width: 100%;
}

.email-gate-otp-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  cursor: text;
}

.email-gate-otp-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.email-gate-otp-slot {
  aspect-ratio: 1;
  min-height: 0;
  width: 100%;
  max-width: 68px;
  margin-inline: auto;
  border-radius: 14px;
  border: 1.5px solid #e0dfdc;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: relative;
}

.email-gate-otp-slot.filled {
  background: #fff;
  border-color: #ccc;
}

.email-gate-otp-slot.active {
  border-color: #1a1a1a;
}

.email-gate-otp-slot.active::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 50%;
  background: #1a1a1a;
  border-radius: 1px;
  animation: emailGateOtpBlink 1s step-end infinite;
}

@keyframes emailGateOtpBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.email-gate-otp-slot.filled.active::after {
  display: none;
}

.email-gate-otp-wrap:focus-within .email-gate-otp-slot {
  background: #fff;
}

.email-gate-otp-wrap.error .email-gate-otp-slot {
  border-color: rgba(185, 31, 31, 0.5);
  background: #fdf8f8;
}

.email-gate-otp-hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  outline: none;
  opacity: 0;
}

/* ── Buttons ── */
.email-gate-input-row button,
.email-gate-otp-row button {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: #1a1a1a;
  min-height: 56px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.2s ease, transform 0.15s ease;
  font-family: "Inter", -apple-system, sans-serif;
}

.email-gate-input-row button:hover,
.email-gate-otp-row button:hover {
  background: #333;
}

.email-gate-input-row button:active,
.email-gate-otp-row button:active {
  transform: scale(0.98);
}

.email-gate-input-row button:disabled,
.email-gate-otp-row button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

#gateVerifyOtpBtn {
  background: linear-gradient(180deg, #2f3137 0%, #11141a 52%, #020202 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 10px 24px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#gateVerifyOtpBtn:hover {
  background: linear-gradient(180deg, #3a3c42 0%, #1a1d24 52%, #0a0a0a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 14px 28px rgba(0, 0, 0, 0.32);
}

/* ── OTP meta ── */
.email-gate-otp-sent {
  margin: 0;
  color: #999;
  font-size: 0.88rem;
  text-align: center;
  font-weight: 400;
}

.email-gate-otp-actions {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.email-gate-otp-meta {
  margin: 0;
  font-size: 0.82rem;
  color: #999;
}

.email-gate-link-btn {
  border: none;
  padding: 0;
  background: transparent;
  color: #888;
  font-size: 0.79rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  font-family: "Inter", -apple-system, sans-serif;
}

.email-gate-link-btn:hover {
  color: #555;
}

.email-gate-link-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.email-gate-otp-separator {
  color: #ccc;
  margin: 0 2px;
  user-select: none;
}

/* ── Note / message ── */
.email-gate-note {
  margin: 0;
  font-size: 0.73rem;
  color: #aaa;
  text-align: center;
}

.email-gate-note.error {
  color: #b91c1c;
}

.email-gate-note.success {
  color: #166534;
}

/* ── OTP step: hide note ── */
.email-gate-card[data-step="otp"] .email-gate-note {
  display: none;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .email-gate-mask {
    animation: none;
  }

  .email-gate-input-row button,
  .email-gate-otp-row button,
  .email-gate-link-btn,
  .video-grid.gated {
    transition: none;
  }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .email-gate-card {
    padding: 24px 18px;
    border-radius: 22px;
    gap: 20px;
  }

  .email-gate-input-row button,
  .email-gate-otp-row button {
    min-height: 50px;
    font-size: 0.92rem;
  }

  .email-gate-otp-slot {
    max-width: 56px;
    font-size: 1.3rem;
    border-radius: 10px;
  }
}
