/* WhatsApp Number field — country-code selector + local number input.
   Extends checkout's existing .ckt-* design system (assets/css/style.css)
   with the same tokens (var(--surface), var(--border), var(--primary), …)
   so it never needs its own light/dark rules — it inherits the site's. */

.ckt-required {
  color: var(--danger);
  margin-left: .15rem;
}

.ckt-phone-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ckt-phone-wrap:focus-within {
  border-color: var(--primary);
}

.ckt-phone-country {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  padding: .7rem .6rem;
  cursor: pointer;
  font-family: var(--font);
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  max-width: 44%;
}
.ckt-phone-country:hover { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.ckt-phone-country:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Flag: a fixed 24x18 box so the image never shifts surrounding layout
   while it loads (or if FlagCDN is slow/unreachable) — see .ckt-flag-img
   and the .ckt-flag-broken fallback below. */
.ckt-phone-flag {
  position: relative;
  width: 24px; height: 18px; flex-shrink: 0;
  border-radius: 3px; overflow: hidden;
  background: var(--bg-alt);
}
.ckt-phone-dial { white-space: nowrap; }
.ckt-phone-caret { width: 14px; height: 14px; color: var(--text-light); flex-shrink: 0; }

.ckt-phone-number {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  padding: .7rem .9rem;
  font-size: .92rem;
  font-family: var(--font);
  color: var(--text);
}

/* Dropdown panel — appended to <body> and positioned with `position:
   fixed` by whatsapp-phone-widget.js, specifically so it is never
   clipped by the checkout card, a modal, or any other ancestor with
   `overflow: hidden`. */
.ckt-phone-panel {
  z-index: 9999;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
}

.ckt-phone-search-wrap {
  padding: .6rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ckt-phone-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: .88rem;
  padding: .55rem .7rem;
  outline: none;
}
.ckt-phone-search:focus { border-color: var(--primary); }

.ckt-phone-list {
  overflow-y: auto;
  flex: 1;
}

.ckt-phone-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  box-sizing: border-box;
  background: none;
  border: none;
  padding: .55rem .8rem;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--text);
}
.ckt-phone-row:hover,
.ckt-phone-row:focus-visible { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ckt-phone-row-flag {
  position: relative;
  width: 24px; height: 18px; flex-shrink: 0;
  border-radius: 3px; overflow: hidden;
  background: var(--bg-alt);
}
.ckt-phone-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ckt-phone-row-dial { color: var(--text-muted); flex-shrink: 0; font-weight: 600; }

/* Flag images — loaded from FlagCDN (https://flagcdn.com), never bundled
   with the project (see whatsapp-phone-widget.js). Fixed dimensions
   prevent layout shift; object-fit keeps every flag's 4:3-ish source
   image cropped consistently to the 24x18 box. */
.ckt-flag-img {
  display: block;
  width: 24px; height: 18px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* Neutral fallback if a flag image fails to load (FlagCDN unreachable, or
   an ISO2 it doesn't have) — a plain CSS globe glyph, never a broken-image
   icon and never a Unicode flag emoji. The country name + dial code text
   next to it keeps the row fully usable either way. */
.ckt-phone-flag.ckt-flag-broken::after,
.ckt-phone-row-flag.ckt-flag-broken::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background:
    radial-gradient(circle at 50% 50%, transparent 3px, var(--text-light) 3.5px, var(--text-light) 4px, transparent 4.5px),
    linear-gradient(var(--text-light), var(--text-light)) center / 100% 1px no-repeat,
    linear-gradient(var(--text-light), var(--text-light)) center / 1px 100% no-repeat;
  background-color: var(--bg-alt);
}

.ckt-phone-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

@media (max-width: 640px) {
  .ckt-phone-country { max-width: 40%; padding: .7rem .5rem; }
  .ckt-phone-panel { max-height: 280px; }
}

/* Progressive Continue button: a fixed-min-height zone holding either the
   neutral guidance hint or the (fully hidden-until-ready) button, so
   swapping between the two never shifts anything below it — the min-height
   matches the button's own rendered height (see .ckt-continue-btn in
   style.css: ~.95rem vertical padding + 1rem/700-weight text). */
.ckt-continue-zone {
  position: relative;
  min-height: 3.3rem;
  display: flex;
  align-items: center;
}
.ckt-continue-hint {
  margin: 0;
  width: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.4;
}
/* Subtle fade + slight slide-in once every checkout requirement is met —
   `hidden` (set/cleared in JS) still fully removes it from layout and the
   accessibility/tab order while a requirement is unmet; this transition
   only plays for the moment it becomes visible. */
.ckt-continue-zone .ckt-continue-btn {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease;
}
.ckt-continue-zone .ckt-continue-btn.ckt-continue-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Express Checkout Element (Apple Pay / Google Pay) — the box and the
   separator both start hidden in the markup (see checkout/index.php) and
   are only ever revealed by JS once Stripe's own 'ready' event confirms a
   wallet is eligible, so there is never a blank box or a floating
   separator with nothing above it. #cktExpressCheckoutElement reserves the
   Element's own default button height so mounting it doesn't itself cause
   a jump once Stripe populates it. */
#cktExpressCheckoutElement {
  min-height: 44px;
}

.ckt-express-separator {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: .82rem;
}
.ckt-express-separator::before,
.ckt-express-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

@media (max-width: 640px) {
  #cktExpressCheckoutElement { min-height: 40px; }
}
