/* Checkout page: secure-payment hint, numbered form steps, order summary and
 * the result screens. Prototype design, see js/modules/checkout.js. */

/* Header extras (the brand block comes from layout/header.css) */

.secure-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-700);
}

.secure-hint .icon {
  --icon-size: 18px;
  color: var(--nx-pulse);
}

/* Back to the landing, above the page title */

.checkout__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-500);
  transition: color .2s var(--ease);
}

.checkout__back:hover {
  color: var(--nx-ink);
}

.checkout__back .icon {
  --icon-size: 16px;
  transform: rotate(180deg);
  transition: transform .2s var(--ease);
}

.checkout__back:hover .icon {
  transform: rotate(180deg) translateX(3px);
}

/* Page frame */

.checkout {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) var(--gutter) clamp(56px, 8vw, 96px);
}

.checkout__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-bottom: clamp(22px, 3vw, 34px);
}

.checkout__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
}

.checkout__main {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.checkout__aside {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

.notice {
  padding: 14px 16px;
  margin-bottom: 20px;
  border-radius: var(--r);
  background: var(--nx-bone-2);
  border: 1px solid var(--nx-bone-3);
  font-size: 14px;
  color: var(--nx-700);
}

.link {
  color: var(--nx-pulse);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--nx-ink);
}

/* Form steps */

.checkout-form[hidden],
.result[hidden] {
  display: none;
}

.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3vw, 30px);
}

.step__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.step__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--nx-ink);
  color: var(--nx-white);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field[hidden] {
  display: none;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-800);
}

/* The 1px border uses --nx-500 so the control edge reaches 3:1 against the
 * white card (WCAG 1.4.11); --nx-300 would not. */
.field__input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--nx-ink);
  background: var(--nx-white);
  border: 1px solid var(--nx-500);
  border-radius: var(--r);
  scroll-margin: 96px 0 140px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.field__input:hover {
  border-color: var(--nx-ink);
}

.field__input:focus-visible {
  outline: none;
  border-color: var(--nx-pulse-hover);
  box-shadow: 0 0 0 3px var(--nx-pulse-soft), 0 0 0 4px var(--nx-pulse-hover);
}

.field__input::placeholder {
  color: var(--nx-500);
}

.field__input--select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("../../images/icons/chevron-down-md.svg");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.field__input[aria-invalid="true"] {
  border-color: var(--nx-danger-ink);
  box-shadow: 0 0 0 1px var(--nx-danger-ink);
}

.field__input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 1px var(--nx-danger-ink), 0 0 0 4px rgba(239, 68, 68, .28);
}

.field__hint {
  font-size: 13px;
  color: var(--nx-500);
  line-height: 1.5;
}

.field__error {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--nx-danger-ink);
}

.field__error[hidden] {
  display: none;
}

/* Checkboxes */

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.check__input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--nx-pulse);
  cursor: pointer;
  scroll-margin: 96px 0 140px;
}

.check__input[aria-invalid="true"] {
  outline: 2px solid var(--nx-danger-ink);
  outline-offset: 2px;
}

.check__label {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--nx-700);
  cursor: pointer;
}

.field__error--check {
  margin-top: -8px;
  padding-left: 32px;
}

/* Payment info block */

.pay-box {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px;
  border-radius: var(--r);
  background: var(--nx-bone-2);
  border: 1px solid var(--nx-bone-3);
}

.pay-box__icon {
  --icon-size: 24px;
  margin-top: 1px;
  color: var(--nx-pulse);
}

.pay-box__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pay-box__text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--nx-600);
}

.pay-box__brands {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.pay-box__brand {
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--nx-white);
  border: 1px solid var(--nx-300);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--nx-700);
}

/* Submit */

.checkout-form__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkout-form__submit {
  width: 100%;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.checkout-form__submit:disabled {
  cursor: progress;
  opacity: .85;
  transform: none;
}

.checkout-form__submit.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: var(--nx-white);
  animation: nxSpin .8s linear infinite;
}

.checkout-form__legal {
  text-align: center;
  font-size: 13px;
  color: var(--nx-500);
}

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

/* Order summary */

.summary {
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 50px -36px rgba(14, 28, 42, .35);
  overflow: hidden;
}

/* Only shown on mobile, where the card collapses into a bar */
.summary__toggle {
  display: none;
}

.summary__body {
  padding: clamp(22px, 2.6vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary__eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--nx-500);
}

.summary__plan {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.summary__price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.summary__price {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.035em;
}

.summary__period {
  font-size: 14px;
  color: var(--nx-500);
}

.summary__features {
  list-style: none;
  margin: 4px 0 0;
  padding: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border-top: 1px solid var(--nx-bone-3);
}

.summary__features li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
  color: var(--nx-700);
}

.summary__features .icon {
  --icon-size: 17px;
  margin-top: 2px;
  color: var(--nx-pulse);
}

.summary__change {
  align-self: flex-start;
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-pulse);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.summary__change:hover {
  color: var(--nx-ink);
}

.summary__totals {
  margin: 8px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--nx-bone-3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14.5px;
  color: var(--nx-700);
}

.summary__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.summary__row--total {
  padding-top: 12px;
  border-top: 1px solid var(--nx-bone-3);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--nx-ink);
}

.summary__note {
  font-size: 13px;
  line-height: 1.55;
  color: var(--nx-500);
}

.summary__help {
  font-size: 13.5px;
  color: var(--nx-600);
}

.summary__help a {
  color: var(--nx-pulse);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Result / return screens */

.result__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 40px);
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 50px -36px rgba(14, 28, 42, .35);
}

.result__badge {
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--nx-bone-2);
  border: 1px solid var(--nx-300);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--nx-700);
}

.result__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--r-pill);
  background: var(--nx-bone-2);
  color: var(--nx-ink);
}

.result__icon .icon {
  --icon-size: 28px;
}

.result__card--success .result__icon {
  background: rgba(34, 197, 94, .14);
  color: var(--nx-success-ink);
}

.result__card--warning .result__icon {
  background: #FEF3C7;
  color: var(--nx-warning-ink);
}

.result__card--danger .result__icon {
  background: #FEE2E2;
  color: var(--nx-danger-ink);
}

.result__card--info .result__icon {
  background: #DBEAFE;
  color: var(--nx-info-ink);
}

.result__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.15;
}

.result__title:focus-visible {
  outline: none;
}

.result__text {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--nx-600);
  max-width: 46ch;
}

.result__meta {
  padding: 10px 16px;
  border-radius: var(--r);
  background: var(--nx-bone-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-800);
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
  width: 100%;
}

.result__actions .btn {
  font-size: 16px;
  padding: 14px 24px;
  border: 1.5px solid transparent;
  cursor: pointer;
}

.result__actions .btn--ghost {
  border-color: var(--nx-300);
}

.result__help {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--nx-500);
}

/* Result screens have no order to summarize: the card takes the page */
.checkout--result .checkout__layout {
  grid-template-columns: minmax(0, 1fr);
}

.checkout--result .checkout__aside {
  display: none;
}

.checkout--result .checkout__main {
  grid-column: 1;
}

/* Below 800px (same point where the landing stacks its comparison table) the
 * layout becomes one column, the summary collapses into a bar at the top and
 * the pay button pins itself to the bottom edge. */
@media (max-width: 800px) {
  .checkout__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .checkout__aside,
  .checkout__main {
    grid-column: 1;
  }

  .checkout__aside {
    grid-row: 1;
    position: static;
  }

  .checkout__main {
    grid-row: 2;
  }

  .summary__toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14.5px;
    color: var(--nx-ink);
    text-align: left;
  }

  .summary__toggle-text {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 0;
    min-width: 0;
  }

  .summary__bar-plan {
    font-family: var(--font-display);
    font-weight: 600;
  }

  .summary__bar-total {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  /* "Plan X · $Y · Ver detalle" */
  .summary__bar-total::before,
  .summary__bar-action::before {
    content: "·";
    display: inline-block;
    margin: 0 8px;
    color: var(--nx-500);
    font-weight: 400;
    text-decoration: none;
  }

  .summary__bar-action {
    color: var(--nx-pulse);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .summary__toggle .icon {
    --icon-size: 18px;
    transition: transform .3s var(--ease);
  }

  .summary__toggle[aria-expanded="true"] .icon {
    transform: rotate(180deg);
  }

  .summary[data-open="false"] .summary__body {
    display: none;
  }

  .summary__body {
    border-top: 1px solid var(--nx-bone-3);
    padding-top: 20px;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Sticky inside the form: it holds until the form ends, so the button is
   * always in reach without covering the result screens. */
  .checkout-form__actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 0 calc(var(--gutter) * -1);
    padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
    background: rgba(250, 250, 250, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--nx-bone-3);
  }

  .checkout-form__legal {
    display: none;
  }
}

@media (max-width: 420px) {
  .pay-box {
    flex-direction: column;
  }

  .summary__toggle {
    padding: 14px;
    font-size: 13.5px;
  }

  .summary__bar-total::before,
  .summary__bar-action::before {
    margin: 0 6px;
  }
}
