/* ═══════════════════════════════════════════════
   CodPay — Country Gate
   Full-viewport pre-landing experience. Mobile-first.
   No modal / no dark backdrop-blur "popup" feel — the
   gate IS the page until a country is chosen.
═══════════════════════════════════════════════ */

#codpay-country-gate {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  opacity: 0;
  overflow: hidden;
  background: var(--primary, #12121E);
  transition: opacity .3s ease;
}
#codpay-country-gate.is-visible { display: block; }
#codpay-country-gate.is-shown   { opacity: 1; }

html.codpay-gate-lock,
body.codpay-gate-lock { overflow: hidden; height: 100%; }

/* ── Background layer ─────────────────────────── */
#codpay-country-gate .gate-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
#codpay-country-gate .gate-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s ease, transform 8s ease;
  transform: scale(1.04);
}
#codpay-country-gate.is-shown .gate-bg-img { opacity: 1; transform: scale(1); }

#codpay-country-gate .gate-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,10,20,.55) 0%, rgba(10,10,20,var(--gate-overlay, .55)) 45%, rgba(10,10,20,.92) 100%);
}
#codpay-country-gate.has-gradient .gate-bg-overlay {
  background:
    linear-gradient(180deg, rgba(10,10,20,.5) 0%, rgba(10,10,20,var(--gate-overlay, .55)) 40%, rgba(10,10,20,.93) 100%),
    linear-gradient(135deg, color-mix(in srgb, var(--gate-accent, #E8284A) 35%, transparent) 0%, transparent 55%);
}
#codpay-country-gate.has-blur .gate-bg-img { filter: blur(6px); }

#codpay-country-gate .gate-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: .35;
  pointer-events: none;
}
#codpay-country-gate .gate-shape-a {
  width: 46vw; height: 46vw;
  top: -12vw; inset-inline-end: -14vw;
  background: radial-gradient(circle, var(--gate-accent, #E8284A) 0%, transparent 70%);
}
#codpay-country-gate .gate-shape-b {
  width: 40vw; height: 40vw;
  bottom: -16vw; inset-inline-start: -12vw;
  background: radial-gradient(circle, #F5A623 0%, transparent 70%);
}

/* ── Scroll + content container ───────────────── */
#codpay-country-gate .gate-scroll {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#codpay-country-gate .gate-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 18px 40px;
  box-sizing: border-box;
  max-width: 920px;
  margin: 0 auto;
}

/* ── Header / hero copy ───────────────────────── */
#codpay-country-gate .gate-header {
  text-align: center;
  margin-bottom: 26px;
  transform: translateY(10px);
  opacity: 0;
  transition: opacity .5s ease .1s, transform .5s ease .1s;
}
#codpay-country-gate.is-shown .gate-header { opacity: 1; transform: translateY(0); }

#codpay-country-gate .gate-logo {
  max-width: 130px;
  max-height: 64px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
}

#codpay-country-gate .gate-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
#codpay-country-gate .gate-trust span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  padding: 5px 11px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
#codpay-country-gate .gate-trust svg { flex-shrink: 0; opacity: .9; }

#codpay-country-gate .gate-title {
  font-family: var(--font);
  font-size: clamp(24px, 6vw, 40px);
  line-height: 1.2;
  font-weight: 900;
  color: #fff;
  margin: 0 0 10px;
  text-shadow: 0 2px 20px rgba(0,0,0,.3);
}
#codpay-country-gate .gate-desc {
  font-family: var(--font);
  font-size: clamp(13px, 3vw, 16px);
  color: rgba(255,255,255,.8);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
  transition: opacity .25s ease;
}
#codpay-country-gate .gate-desc:empty { display: none; }
#codpay-country-gate .gate-title.is-swapping,
#codpay-country-gate .gate-desc.is-swapping { opacity: 0; }

/* ── Country card grid ─────────────────────────── */
#codpay-country-gate .gate-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 620px) {
  #codpay-country-gate .gate-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 900px) {
  #codpay-country-gate .gate-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
}

#codpay-country-gate .gate-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--gate-btn-radius, 18px);
  overflow: hidden;
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  transform: translateY(14px) scale(.97);
  opacity: 0;
  transition: transform .4s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, border-color .25s ease, opacity .4s ease;
  -webkit-tap-highlight-color: transparent;
}
#codpay-country-gate.is-shown .gate-card {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition-delay: calc(var(--gate-i, 0) * 45ms + .15s);
}
#codpay-country-gate .gate-card:hover,
#codpay-country-gate .gate-card:focus-visible {
  border-color: var(--gate-accent, #E8284A);
  box-shadow: 0 16px 40px rgba(0,0,0,.35), 0 0 0 3px color-mix(in srgb, var(--gate-accent, #E8284A) 35%, transparent);
  transform: translateY(-4px) scale(1.015);
}
#codpay-country-gate .gate-card.is-active {
  border-color: var(--gate-accent, #E8284A);
  box-shadow: 0 0 0 3px var(--gate-accent, #E8284A), 0 16px 44px rgba(0,0,0,.4);
}
#codpay-country-gate .gate-card[disabled] { pointer-events: none; }

#codpay-country-gate .gate-card-media {
  position: absolute;
  inset: 0;
  background-color: rgba(255,255,255,.05);
  background-size: cover;
  background-position: center;
  transition: transform .5s ease;
}
#codpay-country-gate .gate-card:hover .gate-card-media { transform: scale(1.06); }
#codpay-country-gate .gate-card-media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,10,20,.05) 0%, rgba(10,10,20,.85) 100%);
}

#codpay-country-gate .gate-card-product {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 38%;
  max-width: 90px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.35));
  pointer-events: none;
}

#codpay-country-gate .gate-card-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px;
  text-align: start;
}

#codpay-country-gate .gate-card-flag {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  margin-bottom: 4px;
}
#codpay-country-gate .gate-card-flag-text {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 4px;
}

#codpay-country-gate .gate-card-name {
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
}
#codpay-country-gate .gate-card-subtitle {
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  line-height: 1.3;
}
#codpay-country-gate .gate-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gate-btn-text, #fff);
  background: var(--gate-accent, #E8284A);
  padding: 5px 10px;
  border-radius: 999px;
  transition: background .2s ease, transform .2s ease;
}
#codpay-country-gate .gate-card:hover .gate-card-cta,
#codpay-country-gate .gate-card.is-active .gate-card-cta {
  transform: translateX(-2px);
}
[dir="ltr"] #codpay-country-gate .gate-card:hover .gate-card-cta,
[dir="ltr"] #codpay-country-gate .gate-card.is-active .gate-card-cta {
  transform: translateX(2px);
}

/* Suggested/default country (admin-configured) — visual hint only,
   still requires an explicit tap like every other option. */
#codpay-country-gate .gate-card-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 2;
  background: var(--gate-accent, #E8284A);
  color: #fff;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}

/* Ripple feedback on tap/click */
#codpay-country-gate .gate-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  transform: scale(0);
  animation: codpay-ripple .55s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes codpay-ripple {
  to { transform: scale(2.6); opacity: 0; }
}

/* ── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #codpay-country-gate,
  #codpay-country-gate * {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  #codpay-country-gate .gate-card { transform: none !important; opacity: 1 !important; }
}

/* ── Small phones ──────────────────────────────── */
@media (max-width: 380px) {
  #codpay-country-gate .gate-content { padding: 22px 12px 30px; }
  #codpay-country-gate .gate-grid { gap: 9px; }
  #codpay-country-gate .gate-card-body { padding: 9px; }
}
