/* ClicToPay one-time payment page */

:root {
  --purple: #8b3dff;
  --purple-hover: #7b2cf2;
  --ink: #17172b;
  --muted: #6e6e85;
  --line: #e8e7f0;
  --navy: #0d1739;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  background-color: #a5a0da;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(42% 38% at 4% 2%, rgba(186, 132, 238, .95), transparent 72%),
    radial-gradient(38% 34% at 98% 98%, rgba(176, 140, 232, .85), transparent 72%),
    radial-gradient(46% 40% at 100% 0%, rgba(150, 178, 228, .8), transparent 72%),
    radial-gradient(44% 40% at 0% 100%, rgba(152, 168, 226, .8), transparent 72%),
    linear-gradient(135deg, #ab9fdd 0%, #a1a9da 50%, #a69cda 100%);
}
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 48px;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shell ---------- */

.shell {
  width: min(1350px, 100%, max(900px, calc((100vh - 96px) * 1.6)));
  aspect-ratio: 1.6;
  display: grid;
  grid-template-columns: 49fr 51fr;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 50px 90px -40px rgba(38, 26, 110, .55),
    0 18px 40px -18px rgba(38, 26, 110, .3);
}

/* ---------- Left panel: isometric card stack ---------- */

.art {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(70% 55% at 50% 60%, #121d47 0%, transparent 75%),
    var(--navy);
  container-type: size;
}

/* corner glows */
.art::before {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: -1;
  background:
    radial-gradient(18% 14% at 10% 8%, rgba(98, 140, 255, .95), transparent 100%),
    radial-gradient(16% 22% at 10% 44%, rgba(160, 96, 255, 1), transparent 100%),
    radial-gradient(12% 24% at 9% 26%, rgba(120, 110, 255, .7), transparent 100%),
    radial-gradient(22% 17% at 94% 94%, rgba(98, 150, 255, 1), transparent 100%),
    radial-gradient(16% 18% at 92% 78%, rgba(150, 100, 255, .9), transparent 100%);
  filter: blur(34px);
}

/* fine grain */
.art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 1em = design unit; scales with the panel */
.stage {
  position: absolute;
  inset: 0;
  font-size: min(2.4cqw, 2.05cqh);
}

.layer {
  --y: 0em;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24em;
  height: 15.2em;
  margin: -7.6em 0 0 -12em;
  translate: 0 var(--y);
  transition: translate .8s cubic-bezier(.2, .75, .2, 1);
  animation: float 7s ease-in-out infinite;
}
.layer--top    { --y: -6.4em; animation-delay: -1.2s; }
.layer--middle { --y: 1.6em;  animation-delay: -2.6s; }
.layer--bottom { --y: 9.2em;  animation-delay: -4s; }

.art:hover .layer--top    { --y: -8.2em; }
.art:hover .layer--bottom { --y: 10.8em; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-.45em); }
}

/* card plane → isometric top face (x axis up-right 30°, y axis down-right 30°) */
.card {
  position: absolute;
  inset: 0;
  border-radius: 1.15em;
  overflow: hidden;
  color: #fff;
  transform: matrix(.866, -.5, .866, .5, 0, 0);
}

.card--magenta {
  background:
    linear-gradient(180deg, transparent 45%, rgba(110, 0, 80, .35) 100%),
    linear-gradient(95deg, #e125d8 0%, #b81fe0 30%, #6b1de2 62%, #3a16d4 100%);
  box-shadow:
    -1.4em 1.4em 2.6em rgba(4, 6, 30, .55),
    inset 0 0 0 .06em rgba(255, 255, 255, .35);
}
.card-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, .16);
  stroke-width: .5;
}

.card--periwinkle {
  background: linear-gradient(100deg, #a2a0fc 0%, #908ef7 55%, #8582f1 100%);
  box-shadow:
    -1em 1em 2.2em rgba(6, 8, 40, .45),
    inset 0 0 0 .06em rgba(255, 255, 255, .45);
}
.card--periwinkle .visa { color: #1c27d6; }

.card--glass {
  background: linear-gradient(165deg, rgba(255, 255, 255, .2) 0%, rgba(255, 255, 255, .07) 55%, rgba(255, 255, 255, .14) 100%);
  -webkit-backdrop-filter: blur(.7em) saturate(1.25);
  backdrop-filter: blur(.7em) saturate(1.25);
  box-shadow:
    -1em 1em 2.4em rgba(6, 8, 40, .3),
    inset 0 0 0 .07em rgba(255, 255, 255, .55),
    inset .4em -.4em 1.4em rgba(255, 255, 255, .08);
}

.visa {
  position: absolute;
  top: 1.2em;
  left: 1.25em;
  font-size: 2.15em;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -.035em;
  line-height: 1;
}

.mc {
  position: absolute;
  top: 1.5em;
  left: 2.3em;
  width: 3.9em;
  height: 2.4em;
}
.mc i {
  position: absolute;
  top: 0;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
}
.mc i:first-child { left: 0; background: #eb001b; }
.mc i:last-child  { right: 0; background: #f79e1b; opacity: .9; }

.num {
  position: absolute;
  left: 1.5em;
  bottom: 3.05em;
  font-size: 1.42em;
  font-weight: 500;
  letter-spacing: .05em;
  line-height: 1;
  white-space: nowrap;
}

.name {
  position: absolute;
  left: 2.2em;
  bottom: 2.3em;
  max-width: 18em;
  font-size: .78em;
  line-height: 1;
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Right panel ---------- */

.details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(28px, 7.4%, 100px) clamp(24px, 7.4%, 100px) clamp(28px, 6.4%, 84px);
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 2.15vw, 30px);
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1.2;
}

.badge {
  flex: none;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--purple);
  white-space: nowrap;
  /* corner brackets */
  background:
    linear-gradient(currentColor, currentColor) top left / 6px 1.5px,
    linear-gradient(currentColor, currentColor) top left / 1.5px 6px,
    linear-gradient(currentColor, currentColor) top right / 6px 1.5px,
    linear-gradient(currentColor, currentColor) top right / 1.5px 6px,
    linear-gradient(currentColor, currentColor) bottom left / 6px 1.5px,
    linear-gradient(currentColor, currentColor) bottom left / 1.5px 6px,
    linear-gradient(currentColor, currentColor) bottom right / 6px 1.5px,
    linear-gradient(currentColor, currentColor) bottom right / 1.5px 6px;
  background-repeat: no-repeat;
}

.alert {
  margin: 24px 0 0;
  padding: 12px 16px;
  font-size: 14.5px;
  color: #a1251b;
  background: #fff4f2;
  border: 1px solid #fbd3cd;
  border-radius: 8px;
}
.alert[hidden] { display: none; }

.rows {
  margin: clamp(24px, 4.4vh, 44px) 0 0;
}
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 21px 0;
  border-bottom: 1px solid var(--line);
}
.row:first-child { border-top: 1px solid var(--line); }
.row dt { flex: none; color: var(--muted); }
.row dd {
  margin: 0;
  min-width: 0;
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
}
.row--amount dd { color: var(--purple); font-size: 18px; }
.mono { font-variant-numeric: tabular-nums; font-size: 14.5px; letter-spacing: .01em; }

.checkout {
  margin-top: auto;
  padding-top: clamp(28px, 5vh, 48px);
}

.total {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.total > span { font-weight: 500; }
.total-amount {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.total-amount small {
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
}
.total strong {
  font-size: 22px;
  font-weight: 500;
  color: var(--purple);
  white-space: nowrap;
}

.pay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  margin-top: clamp(24px, 5.4vh, 52px);
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: .02em;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 12px 26px -12px rgba(139, 61, 255, .75), inset 0 1px 0 rgba(255, 255, 255, .18);
  cursor: pointer;
  transition: background-color .2s, transform .2s, box-shadow .2s;
}
.pay:hover { background: var(--purple-hover); }
.pay:active { transform: translateY(1px); }
.pay:disabled { cursor: progress; background: #9c5bff; }
.pay.off, .pay.off:hover { cursor: not-allowed; background: #b9b4c7; box-shadow: none; transform: none; }
.pay:focus-visible,
.back:focus-visible,
.frame-full:focus-visible {
  outline: 3px solid rgba(139, 61, 255, .45);
  outline-offset: 3px;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.pay.is-busy .spinner,
.spinner--dark { display: inline-block; }
.spinner--dark {
  width: 32px;
  height: 32px;
  border-width: 3px;
  border-color: #e6e3f5;
  border-top-color: var(--purple);
}
@keyframes spin { to { transform: rotate(360deg); } }

.secure {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.secure svg { vertical-align: -2px; margin-right: 4px; }

/* paid view */
.paid { display: flex; flex-direction: column; align-items: flex-start; }
.paid-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 24px;
  border-radius: 50%;
  color: #fff;
  background: #16a34a;
  box-shadow: 0 0 0 8px #e7f8ee;
}
.paid-text { margin: 10px 0 0; color: var(--muted); }

/* ---------- Views: details <-> inline payment form ---------- */

.view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: view-in .26s ease-out;
}
.view[hidden] { display: none; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.shell.is-paying .details { padding: 16px 20px 20px; }

.frame-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 36px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.back:hover { background: #f5f4fa; border-color: #dcdae8; }
.frame-ref {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frame-ref:empty { visibility: hidden; }
.frame-full {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--purple);
  text-decoration: none;
  border-radius: 6px;
}
.frame-full:hover { text-decoration: underline; }

/* ClicToPay form measured at ~657 px tall (>= 480 px wide) to ~730 px (320 px). */
.frame-body {
  position: relative;
  flex: 1;
  min-height: 690px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.frame-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.frame-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}
.frame-loader[hidden] { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  body { padding: 32px; }
  .details { padding: clamp(28px, 6%, 64px); }
}

@media (max-width: 900px) {
  body { padding: 32px 24px; place-items: start center; }
  .shell {
    width: min(680px, 100%);
    aspect-ratio: auto;
    grid-template-columns: 1fr;
  }
  .art { height: clamp(220px, 50vw, 300px); }
  .stage { font-size: min(2.36cqw, 2.8cqh); }
  .layer--top    { --y: -5.6em; }
  .layer--middle { --y: 1em; }
  .layer--bottom { --y: 7.6em; }
  .art:hover .layer--top    { --y: -6.4em; }
  .art:hover .layer--bottom { --y: 8.4em; }
  .details { padding: 32px; }
  .shell.is-paying .details { padding: 16px; }
  .frame-body { min-height: 700px; }
  .checkout { margin-top: 0; padding-top: 28px; }
  .total { padding-top: 0; border-top: 0; }
  h1 { font-size: 26px; }
}

@media (max-width: 640px) {
  body { padding: 12px; }
  .shell { border-radius: 16px; }
  .details { padding: 28px 22px 26px; }
  h1 { font-size: 22px; }
  .row { padding: 15px 0; gap: 16px; }
  .total strong { font-size: 20px; }
  .row--stack { flex-wrap: wrap; gap: 4px 16px; }
  .row--stack dd { flex-basis: 100%; text-align: left; }
  .badge { font-size: 13px; }

  .shell.is-paying .details { padding: 12px 10px 10px; }
  .frame-body { min-height: 780px; border-radius: 8px; }
  .frame-head { flex-wrap: wrap; row-gap: 6px; }
  .frame-full { margin-left: auto; }
  .frame-ref { order: 3; flex-basis: 100%; font-size: 12px; text-align: left; }
}

@media (max-width: 360px) {
  .details { padding: 24px 18px; }
  .row { flex-wrap: wrap; gap: 2px 16px; }
  .row dd { text-align: left; }
  .frame-full { font-size: 12.5px; }
  body { padding: 8px; }
  .shell.is-paying .details { padding: 10px 4px 4px; }
  .frame-head { padding: 0 6px; }
  .frame-body { border: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spinner { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
