/*
 * munchterm plus: card and payment pages (payment, payment_return). Owned by the PAYMENT flow agent.
 *
 * Linked on every page after base.css (app/root.tsx), so every class in here is prefixed
 * `pay-` to keep it from touching another flow's pages. Anything a second flow needs belongs
 * in base.css (raise it with the orchestrator). Tokens, buttons, forms, notices, cards, the pass, chips,
 * tiles, rails, menus and the action bar are all in base.css already.
 *
 * /account/payment/return has no classes here: it renders the shared CheckoutReturnScreen,
 * styled in join.css, so both return pages look the same.
 *
 * Mobile first: the base rules are the 375px layout, the 900px query widens it.
 */

/* --- page ----------------------------------------------------------------------------------- */

.pay-head {
  margin-top: var(--s3);
}

.pay-head h1 {
  margin-bottom: var(--s2);
}

.pay-head .lede {
  margin: 0;
  color: var(--ink-muted);
}

.pay-error {
  margin-top: var(--s5);
}

.pay-sections {
  display: grid;
  gap: var(--s7);
  margin-top: var(--s6);
}

/* One primary action on screen at a time: the phone-only ActionBar and its `.desk-only` inline
   twin (both in base.css). */

/* --- card_alert: the overdue payment ------------------------------------------------------ */

/* Amber, never red: this is "action needed", not an ending. The word and the icon say it too. */
.pay-alert {
  padding: var(--s5) var(--s4);
  background: var(--warning-wash);
  border-left: 4px solid var(--warning-bright);
}

.pay-alert__state {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: 32px;
  margin: 0 0 var(--s3);
  padding: var(--s1) var(--s2) var(--s1) var(--s1);
  background: var(--warning-bright);
  color: #2b2116;
  font-family: var(--font-sub);
  font-size: var(--size-small);
  line-height: 1;
}

.pay-alert h2 {
  margin-bottom: var(--s2);
  text-wrap: balance;
}

.pay-alert__body {
  margin: 0;
  color: var(--ink);
}

.pay-alert__still {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid rgba(138, 81, 0, 0.18);
}

.pay-alert__still-head {
  margin: 0 0 var(--s2);
  color: var(--warning);
  font-size: var(--size-small);
}

.pay-alert__list {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pay-alert__list li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--s3);
  align-items: start;
  color: var(--ink);
  line-height: 24px;
}

.pay-alert__list .icon {
  color: var(--warning);
}

.pay-alert__form {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s5);
}

.pay-alert__form .handoff {
  margin: 0;
}

/* The second path, for when the card itself is the problem. A link, not a second button. */
.pay-alert__secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: var(--tap-min);
  margin-top: var(--s2);
  color: var(--ink);
  font-size: var(--size-small);
  text-underline-offset: 3px;
}

.pay-alert__secondary:hover {
  color: var(--pink-deep);
}

/* --- card_on_file: the card, drawn -------------------------------------------------------- */

.pay-cardfile {
  scroll-margin-top: calc(var(--header-total) + var(--s4));
}

.pay-cardfile .section-head {
  margin-bottom: var(--s4);
}

.pay-cardfile .section-head h2 {
  font-size: var(--size-h3);
}

.pay-cardfile__grid {
  display: grid;
  gap: var(--s5);
}

.pay-cardfile__side {
  display: grid;
  gap: var(--s4);
  align-content: start;
}

.pay-cardfile__flag {
  margin: 0;
  padding: var(--s3) var(--s4);
  background: var(--warning-wash);
  border-left: 4px solid var(--warning-bright);
  color: var(--ink);
  font-size: var(--size-small);
}

.pay-cardfile__flag--expired {
  background: var(--critical-wash);
  border-left-color: var(--critical);
}

.pay-cardfile__notes {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The card. Square (the shop's shape), the payment-card ratio, dark with the box logo's
   oversized square outline in pink in the corner, the way the pass carries it. */
.pay-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1.586;
  background: var(--dark);
  color: #fff;
}

.pay-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -56px;
  bottom: -72px;
  width: 170px;
  height: 170px;
  border: 26px solid rgba(255, 99, 99, 0.2);
  pointer-events: none;
}

.pay-card__face {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100%;
  padding: var(--s4) var(--s5);
}

.pay-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
}

.pay-card__brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--size-h3);
  letter-spacing: -0.01em;
  line-height: 1;
}

.pay-card__state {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: 32px;
  padding: var(--s1) var(--s2) var(--s1) var(--s1);
  background: var(--warning-bright);
  color: #2b2116;
  font-family: var(--font-sub);
  font-size: var(--size-tiny);
  line-height: 1;
  white-space: nowrap;
}

/* The contact chip: a square outline with a line through it. Decoration only. */
.pay-card__chip {
  position: relative;
  align-self: center;
  width: 38px;
  height: 28px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
}

.pay-card__chip::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.5px solid rgba(255, 255, 255, 0.55);
}

.pay-card__number {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.pay-card__dots {
  letter-spacing: 0.12em;
  opacity: 0.7;
}

.pay-card__exp {
  margin: var(--s1) 0 0;
  font-size: var(--size-small);
  line-height: 1.3;
}

.pay-card__exp-label {
  opacity: 0.7;
}

.pay-card--expired .pay-card__state {
  background: var(--critical-wash);
  color: var(--critical);
}

/* No card on file: an empty slot where the card would be, dashed like a pending pass. */
.pay-card--empty {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: var(--s1);
  padding: var(--s5);
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  color: var(--ink);
}

.pay-card--empty::after {
  border-color: var(--pink-wash);
}

.pay-card__empty-icon {
  display: inline-flex;
  margin-bottom: var(--s2);
  color: var(--pink);
}

.pay-card__empty-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
}

.pay-card__empty-detail {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--size-small);
}

/* --- text ---------------------------------------------------------------------------------- */

.pay-text {
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
}

.pay-text h2 {
  margin-bottom: var(--s2);
  font-size: var(--size-h3);
}

.pay-text p {
  margin: 0 0 var(--s2);
  color: var(--ink-muted);
}

.pay-text p:last-child {
  margin-bottom: 0;
}

/* --- wider screens --------------------------------------------------------------------------- */

@media (min-width: 900px) {
  .pay-alert {
    padding: var(--s6);
  }

  .pay-alert__form {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: var(--s4);
  }

  .pay-alert__form .btn--block {
    width: auto;
  }

  /* The card beside what it means and the button that changes it. */
  .pay-cardfile__grid {
    grid-template-columns: 300px 1fr;
    gap: var(--s6);
    align-items: start;
  }
}

/* A printed payment page is rare, but the card should print as a plain outline. */
@media print {
  .pay-card {
    border: 1px solid #000;
    background: #fff;
    color: #000;
  }

  .pay-card::after {
    display: none;
  }
}
