/* =================================================================
   WriteFlow — Checkout
   Single-page checkout (entry view → SDK pay view). Reuses brand
   tokens from styles.css.
   ================================================================= */

/* Background slot — soft gradient field that runs behind the whole
   page so the checkout doesn't feel marooned on flat off-white. */
.checkout-body {
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}
.checkout-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(110, 123, 255, 0.10), transparent 70%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(255, 63, 177, 0.10), transparent 70%),
    radial-gradient(ellipse 50% 30% at 50% 0%, rgba(43, 216, 255, 0.07), transparent 70%);
}

/* ============ Minimal nav ============ */
.nav--checkout .nav-inner { justify-content: space-between; }
.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-back:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

/* ============ Page shell ============ */
.checkout {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 100px var(--pad-x) 80px;
}

/* ============ Two-column grid ============ */
.checkout-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 880px) {
  .checkout-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

/* ============ Order summary card ============ */
.checkout-summary {
  position: sticky;
  top: 88px;
}
@media (max-width: 880px) {
  .checkout-summary { position: static; }
}
.checkout-summary-card {
  background: white;
  border-radius: 24px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 28px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.04);
}
.checkout-summary-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.checkout-summary-title {
  font-family: var(--ff-display);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.checkout-summary-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.checkout-summary-amount {
  font-family: var(--ff-display);
  font-size: 40px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
}
.checkout-summary-period {
  font-size: 16px;
  color: var(--ink-2);
}
.checkout-summary-permonth {
  margin: 8px 0 24px;
  font-size: 14px;
  color: var(--ink-2);
}
.checkout-summary-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 20px;
}
.checkout-summary-features li {
  position: relative;
  padding: 6px 0 6px 24px;
  font-size: 14px;
  color: var(--ink);
}
.checkout-summary-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: var(--grad);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 6L9 17l-5-5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 6L9 17l-5-5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.checkout-summary-trust {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trust-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.trust-row svg {
  flex-shrink: 0;
  color: var(--brand-2);
}

/* ============ Content area ============ */
.checkout-content {
  min-width: 0; /* prevent grid blowout when SDK renders wide content */
}

/* Headings shared by entry view */
.checkout-heading {
  font-family: var(--ff-display);
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0 0 12px;
  color: var(--ink);
}
.checkout-sub {
  font-size: 18px;
  color: var(--ink-2);
  margin: 0 0 36px;
  line-height: 1.5;
  max-width: 520px;
}

/* ============ Entry view ============ */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.entry-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
.entry-legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  padding: 0;
}
.entry-submit {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* ============ Plan options ============ */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-option {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 22px 24px;
  cursor: pointer;
  text-align: left;
  font-family: var(--ff-body);
  color: var(--ink);
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.plan-option:hover {
  border-color: rgba(110, 123, 255, 0.4);
  transform: translateY(-2px);
}
.plan-option:focus-visible {
  outline: 3px solid rgba(110, 123, 255, 0.4);
  outline-offset: 2px;
}
.plan-option[aria-checked="true"] {
  border-color: transparent;
  background:
    linear-gradient(white, white) padding-box,
    var(--grad) border-box;
  box-shadow: 0 12px 32px rgba(110, 123, 255, 0.12);
}
.plan-option--featured {
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(90deg, rgba(110, 123, 255, 0.25), rgba(255, 63, 177, 0.25)) border-box;
  border-color: transparent;
}
.plan-option-badge {
  position: absolute;
  top: -10px;
  right: 20px;
  background: var(--grad);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.plan-option-main {
  min-width: 0;
}
.plan-option-name {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.plan-option-meta {
  font-size: 13px;
  color: var(--ink-2);
}
.plan-option-price {
  text-align: right;
  font-family: var(--ff-display);
  white-space: nowrap;
}
.plan-option-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.plan-option-period {
  font-size: 13px;
  color: var(--ink-2);
  margin-left: 2px;
}
.plan-option-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s ease;
}
.plan-option-check svg { opacity: 0; transition: opacity 0.2s ease; }
.plan-option[aria-checked="true"] .plan-option-check {
  background: var(--grad);
  border-color: transparent;
}
.plan-option[aria-checked="true"] .plan-option-check svg { opacity: 1; }

/* ============ Form ============ */
.checkout-field-label {
  display: block;
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 10px;
  line-height: 1.5;
}
.checkout-field {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  font-family: var(--ff-body);
  font-size: 17px;
  color: var(--ink);
  background: white;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.checkout-field:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(110, 123, 255, 0.12);
}
.checkout-field.is-invalid {
  border-color: var(--brand-4);
  box-shadow: 0 0 0 4px rgba(255, 63, 177, 0.12);
}
.checkout-field-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.checkout-field-error {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--brand-4);
}

/* ============ Buttons ============ */
.checkout-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: 999px;
  font-family: var(--ff-body);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  border: none;
}
.checkout-btn-lg {
  padding: 16px 28px;
  font-size: 17px;
  width: 100%;
  justify-content: center;
}
.checkout-btn:focus-visible {
  outline: 3px solid rgba(110, 123, 255, 0.4);
  outline-offset: 3px;
}
.checkout-btn-primary {
  background: var(--ink);
  color: white;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.checkout-btn-primary:hover:not(:disabled) {
  background: #000;
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.checkout-btn-ghost {
  background: transparent;
  color: var(--ink-2);
  padding: 12px 18px;
}
.checkout-btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}
.checkout-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ============ Pay (fallback) ============ */
/* The SDK renders its own modal; this card is only shown if the
   SDK couldn't load and we need to redirect to pay.rev.cat. */
.checkout-pay-fallback[hidden] {
  display: none !important;
}
.checkout-pay {
  margin-top: 12px;
}
.checkout-pay-fallback {
  margin-top: 16px;
  background: white;
  border-radius: 18px;
  border: 1px solid rgba(255, 63, 177, 0.25);
  padding: 22px;
}

/* Inline button spinner used while the SDK is loading. */
.checkout-spinner-sm {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.checkout-spinner-sm[hidden] { display: none; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

.checkout-fineprint {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0;
  text-align: center;
}
.checkout-fineprint a {
  color: var(--ink);
  text-decoration: underline;
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  .plan-option:hover { transform: none; }
  .checkout-btn:hover { transform: none; }
}

/* ============ Footer override ============ */
.footer--checkout { padding: 24px var(--pad-x); }
.footer--checkout .footer-inner { gap: 0; }
