/* SudaPay hosted checkout.
   Split out of index.html so the page can run under a Content-Security-Policy
   with no unsafe-inline. */

:root {
  --bg-from: #0a1f3f;
  --bg-to: #0d3b66;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #ffffff;
  --ink-dim: #9fb3c8;
  --ink-faint: #64798f;
  --brand: #4fc3f7;
  --brand-deep: #0288d1;
  --ok: #66bb6a;
  --warn: #ffa726;
  --bad: #ef5350;
  --radius: 14px;
  --gap: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg-from) 0%, var(--bg-to) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
  line-height: 1.5;
}

.container {
  /* Room for the docked pay bar, so the last field is never underneath it. */
  padding-bottom: 104px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  max-width: 440px;
  width: min(92%, 440px);
}

.logo { font-size: 30px; font-weight: 700; text-align: center; }
.logo span { color: var(--brand); }
.subtitle {
  color: var(--ink-dim);
  font-size: 13px;
  margin: 4px 0 20px;
  text-align: center;
}

/* ---- amount ------------------------------------------------------------ */

.amount-box {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  text-align: center;
}
.amount-label { font-size: 13px; color: var(--ink-dim); }
.amount-value {
  font-size: 34px;
  font-weight: 700;
  margin: 4px 0 2px;
  /* An amount is a number: keep its digits and separators in logical order
     even inside an RTL paragraph. */
  direction: ltr;
  unicode-bidi: isolate;
}
.amount-currency { font-size: 14px; color: var(--brand); }
.intent-id {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---- notices ----------------------------------------------------------- */

.notice {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: var(--gap);
}
.notice strong { display: block; margin-bottom: 2px; }
.notice--sandbox {
  background: rgba(255, 167, 38, 0.12);
  border: 1px solid rgba(255, 167, 38, 0.45);
  color: #ffcc80;
}
.notice--sandbox strong { color: var(--warn); }
.notice--secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ok);
  background: none;
  padding: 0;
  margin-bottom: var(--gap);
}

/* ---- card preview ------------------------------------------------------ */

/* ID-1, the size a real card is: 85.60 x 53.98 mm. The old preview was 1.82:1,
   which reads as a stretched box rather than a card. */
.card-preview {
  position: relative;
  aspect-ratio: 1.586;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  direction: ltr;
  background:
    radial-gradient(120% 90% at 85% 0%, #3f51b5 0%, rgba(63, 81, 181, 0) 55%),
    linear-gradient(150deg, #101a4a 0%, #1b2a6b 45%, #24357f 100%);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* A single soft highlight sweeping the face. Flat fill is what made the old one
   look like a coloured rectangle. */
.card-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    108deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.04) 26%,
    rgba(255, 255, 255, 0) 46%
  );
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; }
.card-brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.95);
}

.card-chiprow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

/* EMV contact plate. Its absence was the loudest tell that this was not a card. */
.card-chip {
  position: relative;
  width: 40px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(145deg, #f7e08c 0%, #d9b451 45%, #f2d98a 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: none;
}
.card-chip::before,
.card-chip::after {
  content: '';
  position: absolute;
  background: rgba(0, 0, 0, 0.28);
}
/* The two horizontal contact separations. */
.card-chip::before {
  inset-inline: 4px;
  top: 9px;
  height: 1px;
  box-shadow: 0 11px 0 rgba(0, 0, 0, 0.28);
}
/* The vertical one. */
.card-chip::after {
  inset-block: 4px;
  left: 50%;
  width: 1px;
}

/* Contactless: three arcs, drawn rather than shipped as an image so it stays
   crisp and costs no request under the CSP. */
.card-contactless {
  width: 18px;
  height: 22px;
  flex: none;
  background-image:
    radial-gradient(circle at 0 50%, transparent 5px, rgba(255, 255, 255, 0.85) 5px, rgba(255, 255, 255, 0.85) 6.4px, transparent 6.6px),
    radial-gradient(circle at 0 50%, transparent 9px, rgba(255, 255, 255, 0.7) 9px, rgba(255, 255, 255, 0.7) 10.4px, transparent 10.6px),
    radial-gradient(circle at 0 50%, transparent 13px, rgba(255, 255, 255, 0.55) 13px, rgba(255, 255, 255, 0.55) 14.4px, transparent 14.6px);
}

.card-number-display {
  margin-top: 6px;
  font-size: clamp(14px, 4.4vw, 18px);
  letter-spacing: 1.6px;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(255, 255, 255, 0.97);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-foot { margin-top: 0; }
.card-holder {
  margin-top: 6px;
  direction: ltr;
  /* Clears the scheme mark sitting in the bottom-right corner. */
  padding-inline-end: 96px;
  min-width: 0;
}
.card-cell { direction: ltr; text-align: left; min-width: 0; }
.card-cell--holder { flex: 1; min-width: 0; }
.card-label {
  font-size: 8.5px;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  margin-bottom: 1px;
  /* Arabic text, left-aligned: the face is LTR, and a label that drifts to the
     opposite edge from its value stops looking like a label for it. */
  direction: rtl;
  text-align: left;
}
.card-value {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.94);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom-right, where a scheme mark actually sits — not competing with the
   brand in the top-left corner. */
.card-scheme {
  position: absolute;
  right: 20px;
  bottom: 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  direction: ltr;
  min-height: 14px;
  white-space: nowrap;
}

/* ---- form -------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  outline: none;
  transition: border-color 0.15s;
  direction: ltr;
  text-align: left;
  font-family: inherit;
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus-visible { border-color: var(--brand); }
.field input[aria-invalid='true'] { border-color: var(--bad); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

.field-error {
  color: var(--bad);
  font-size: 12px;
  margin-top: 5px;
  min-height: 0;
}
.field-error:empty { display: none; }

.pay-dock {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg-to) 62%, rgba(13, 59, 102, 0));
}
.pay-dock .pay-btn { width: min(92%, 440px); margin-top: 0; }


.pay-btn {
  width: 100%;
  min-height: 52px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #04223a;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pay-btn:hover:not(:disabled) { opacity: 0.92; }
.pay-btn:active:not(:disabled) { transform: scale(0.99); }
.pay-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pay-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- result ------------------------------------------------------------ */

#result-screen { text-align: center; }
.result-icon { font-size: 46px; margin-bottom: 12px; line-height: 1; }
.result-title { font-size: 21px; font-weight: 700; margin-bottom: 8px; }
.result-msg {
  font-size: 14px;
  color: var(--ink-dim);
  margin-bottom: 20px;
  line-height: 1.7;
}
.result-details {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: start;
  font-size: 13px;
  margin-bottom: 18px;
}
.result-details:empty { display: none; }
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.detail-row dt { color: var(--ink-dim); }
.detail-row dd {
  color: var(--brand);
  font-weight: 600;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: end;
}
.retry-btn { margin-bottom: 10px; }

.back-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.back-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
.spinner--lg { width: 44px; height: 44px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  * { transition: none !important; }
}

.powered {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 20px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 14px;
}
.powered strong { color: var(--brand); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }
