/* Premium secure card checkout (inspired by Keves-Merch ckp card) */
:root {
  --ap-ink: #0f172a;
  --ap-muted: #64748b;
  --ap-line: #e2e8f0;
  --ap-soft: #f8fafc;
  --ap-accent: #0f766e;
  --ap-accent-2: #115e59;
  --ap-danger: #be123c;
  --ap-shadow: 0 28px 80px rgba(8, 12, 22, 0.38);
}

.ap-pay-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(6, 10, 18, 0.72);
}

.ap-pay-overlay.is-open {
  display: flex;
  animation: apFadeIn 0.18s ease-out;
}

.ap-pay-shell {
  width: 100%;
  max-width: 420px;
  max-height: min(94vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--ap-shadow);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: apRise 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, opacity;
  transform: translateZ(0);
}

.ap-pay-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--ap-line);
  background: linear-gradient(180deg, #fcfdff, #fff);
  position: sticky;
  top: 0;
  z-index: 2;
}

.ap-pay-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ap-pay-brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(201, 162, 39, 0.55);
}

.ap-pay-brand-copy strong {
  display: block;
  color: var(--ap-ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
}

.ap-pay-brand-copy span {
  display: block;
  color: var(--ap-muted);
  font-size: 11px;
  margin-top: 2px;
}

.ap-pay-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.ap-pay-close:hover { background: #e2e8f0; }

.ap-pay-amount {
  padding: 14px 18px 4px;
  text-align: center;
}

.ap-pay-amount .label {
  color: var(--ap-muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.ap-pay-amount .value {
  color: var(--ap-ink);
  font-size: 32px;
  font-weight: 780;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* --- Live credit card visual --- */
.ap-card-wrap {
  perspective: 1200px;
  margin: 10px 18px 14px;
}

.ap-card-scene {
  width: 100%;
  max-width: 340px;
  height: 188px;
  margin: 0 auto;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.ap-card-scene.is-flipped {
  transform: rotateY(180deg);
}

.ap-cf-num {
  position: relative;
  z-index: 1;
  font: 600 19px/1.2 "Courier New", ui-monospace, monospace;
  letter-spacing: 0.12em;
  direction: ltr;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: opacity 0.12s ease;
}

.ap-card-f,
.ap-card-b {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ap-card-f {
  background: linear-gradient(135deg, #121826 0%, #16213e 42%, #0f3460 100%);
  color: #fff;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.ap-card-f::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  right: -50px;
  top: -70px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.22), transparent 68%);
  pointer-events: none;
}

.ap-card-b {
  background: linear-gradient(135deg, #1c1c2e 0%, #2a2a44 100%);
  transform: rotateY(180deg);
  overflow: hidden;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
}

.ap-cf-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.ap-chip {
  width: 42px;
  height: 32px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, #e8c872 0%, #c9a227 45%, #a8841a 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  position: relative;
}

.ap-chip::after {
  content: "";
  position: absolute;
  inset: 6px 5px;
  border: 1px solid rgba(90, 60, 10, 0.35);
  border-radius: 3px;
}

.ap-card-brand {
  height: 26px;
  display: flex;
  align-items: center;
}

.ap-card-brand img {
  height: 24px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.ap-card-brand .visa-text {
  font: 900 italic 20px/1 Arial, sans-serif;
  color: #fff;
  letter-spacing: -1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.ap-cf-bot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.ap-cf-micro {
  display: block;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 3px;
}

.ap-cf-name,
.ap-cf-exp {
  display: block;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ap-cb-mag {
  height: 42px;
  margin-top: 22px;
  background: #0b0b12;
}

.ap-cb-strip {
  margin: 18px 18px 0;
  height: 38px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    90deg,
    #f4f4f5 0 8px,
    #e4e4e7 8px 16px
  );
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
}

.ap-cb-cvv {
  background: #fff;
  color: #111;
  font: 700 14px/1 ui-monospace, monospace;
  letter-spacing: 0.18em;
  padding: 6px 10px;
  border-radius: 4px;
  direction: ltr;
}

.ap-pay-body {
  padding: 2px 18px 18px;
}

/* Wallets are hidden until the script decides which ones this device supports */
.ap-pay-wallets {
  display: none;
  gap: 8px;
  margin-bottom: 12px;
}

.ap-pay-wallets.is-visible {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}

.ap-wallet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 7px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.ap-wallet-btn svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.ap-wallet-apple {
  background: #000;
  color: #fff;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.22);
}

.ap-wallet-google {
  background: #fff;
  color: #3c4043;
  border-color: #dadce0;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.ap-wallet-btn:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.ap-wallet-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.ap-wallet-btn.is-loading {
  position: relative;
  color: transparent;
}

.ap-wallet-btn.is-loading svg {
  visibility: hidden;
}

.ap-wallet-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: apSpin 0.7s linear infinite;
}

.ap-wallet-apple.is-loading::after {
  border-color: #fff;
  border-top-color: transparent;
}

.ap-wallet-google.is-loading::after {
  border-color: #5f6368;
  border-top-color: transparent;
}

/* Side by side needs ~180px per button - below that they stack full width */
@media (max-width: 400px) {
  .ap-pay-wallets.is-visible {
    grid-auto-flow: row;
    grid-auto-columns: auto;
  }
}

.ap-pay-divider {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--ap-muted);
  font-size: 11.5px;
  font-weight: 650;
}

.ap-pay-divider.is-visible {
  display: flex;
}

.ap-pay-divider::before,
.ap-pay-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ap-line);
}

.ap-pay-field {
  margin-bottom: 11px;
}

.ap-pay-field label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 650;
}

.ap-pay-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--ap-line);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ap-pay-input-wrap:focus-within {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.ap-pay-input-wrap input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 48px 12px 14px;
  font-size: 15px;
  color: var(--ap-ink);
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.ap-pay-input-wrap input::placeholder {
  color: #94a3b8;
  letter-spacing: 0.08em;
}

.ap-pay-input-wrap .brand-mark {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ap-pay-input-wrap .brand-mark.is-visible {
  opacity: 1;
}

.ap-pay-input-wrap .brand-mark img {
  max-height: 18px;
  max-width: 34px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.ap-pay-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 10px;
}

.ap-pay-error {
  display: none;
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f2;
  color: var(--ap-danger);
  font-size: 13px;
  border: 1px solid #fecdd3;
}

.ap-pay-error.is-visible { display: block; }

.ap-pay-submit {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #115e59 0%, #0f766e 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.ap-pay-submit:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.ap-pay-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ap-pay-trust {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 13px;
}

.ap-pay-trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--ap-soft);
  border: 1px solid var(--ap-line);
}

.ap-pay-trust-item .ap-trust-ico {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #ecfdf5;
  color: #0f766e;
}

.ap-pay-trust-item .ap-trust-ico img {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
}

.ap-pay-trust-item .ap-trust-ico svg {
  width: 16px;
  height: 16px;
}

.ap-pay-trust-item strong {
  display: block;
  font-size: 11px;
  color: var(--ap-ink);
  line-height: 1.2;
}

.ap-pay-trust-item span {
  display: block;
  font-size: 10px;
  color: var(--ap-muted);
  margin-top: 2px;
}

.ap-pay-footnote {
  margin-top: 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.45;
}

.ap-pay-accepted {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--ap-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ap-pay-accepted > span {
  color: #64748b;
  font-size: 11px;
  font-weight: 650;
}

.ap-pay-accepted-logos {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ap-pay-accepted-logos img {
  height: 16px;
  width: auto;
  display: block;
  opacity: 0.92;
}

.ap-pay-3ds {
  display: none;
  padding: 32px 22px 28px;
  text-align: center;
}

.ap-pay-3ds.is-visible { display: block; }

.ap-pay-3ds .ap-3ds-hero {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0f172a, #1e293b);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
  color: #f8fafc;
}

.ap-pay-3ds .ap-3ds-hero svg {
  width: 34px;
  height: 34px;
}

.ap-pay-3ds h3 {
  color: var(--ap-ink);
  font-size: 18px;
  font-weight: 750;
  margin-bottom: 8px;
}

.ap-pay-3ds p {
  color: var(--ap-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.ap-pay-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid #dbe4ee;
  border-top-color: #0f766e;
  animation: apSpin 0.8s linear infinite;
}

.ap-pay-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 85% 0%, rgba(201, 162, 39, 0.16), transparent 50%),
    radial-gradient(800px 420px at 0% 100%, rgba(15, 118, 110, 0.18), transparent 45%),
    #0b1220;
}

.ap-pay-page .ap-pay-shell { max-width: 440px; }

@keyframes apFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes apSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 420px) {
  .ap-pay-amount .value { font-size: 28px; }
  .ap-card-scene { height: 172px; }
  .ap-cf-num { font-size: 16px; }
  .ap-pay-trust { grid-template-columns: 1fr; }
}
