/*
 * My Plan (PlanPage.js) — the page behind the account page's plan card.
 *
 * The account page's shell one tier up (edit-profile.css, my-slips.css —
 * the same shell each): fixed at z-index 71, fading while the sheet lifts,
 * its own scroller, a footer pinned under it for the one action.
 *
 * Three parts. The standing card: gold — the tier's colour and nothing
 * else's in tokens.css — on the badge when the plan is paid for, quiet
 * otherwise. The offers: one tier, its durations as radio rows in one
 * card, the picked row ringed in the accent the way the filter sheet's
 * chips are, and the tier's benefits as a ticked list under them. The
 * footer: the accent CTA with the price on it and Paystack's name under
 * it, or, while a browser checkout is being waited on, the wait itself.
 */

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

.plan {
  --enter-y: 12px;

  position: fixed;
  inset: 0;
  z-index: 71;
  display: flex;
  max-width: var(--app-max-width);
  margin-inline: auto;
  background: var(--bg);
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
}

.plan[hidden] {
  display: none;
}

.plan [hidden] {
  display: none !important;
}

.plan[data-open="true"] {
  --enter-y: 0px;

  opacity: 1;
}

.plan__sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: var(--safe-top);
  transform: translateY(var(--enter-y));
  transition: transform var(--duration) var(--easing);
}

.plan__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.plan-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: 0 var(--space-4) var(--space-6);
}

/* Toasts above the footer, where the eye is after a payment. */
.plan .slip-toasts {
  position: absolute;
  right: 0;
  bottom: calc(96px + var(--space-4) + var(--safe-bottom));
  left: 0;
}

/* --- Top row -------------------------------------------------------------------- */

.plan-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline: calc(var(--space-1) * -1);
  padding-top: var(--space-4);
}

.plan-top__title {
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
}

/* --- Skeleton --------------------------------------------------------------------- */

.plan-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.plan-skeleton__standing {
  height: 112px;
  border-radius: var(--radius-xl);
}

.plan-skeleton__line {
  width: var(--w, 40%);
  height: 14px;
  margin-top: var(--space-3);
  border-radius: var(--radius-full);
}

.plan-skeleton__option {
  height: 64px;
  border-radius: var(--radius-lg);
}

/* --- Standing --------------------------------------------------------------------- */

.plan-standing {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.plan-standing__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* The account page's plan badge, the same size and the same rule: gold on
   a paid plan, quiet on anything else. */
.plan-standing__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.plan-standing[data-type="paid_subscription"] .plan-standing__badge {
  background: var(--gold-bg);
  color: var(--gold);
}

.plan-standing__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.plan-standing__name {
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: 1.2;
}

.plan-standing__line {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.plan-standing__note {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.plan-standing__cancel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* The way out of renewing, quiet: text in the error colour, no fill. */
.plan .plan-standing__cancel-link {
  align-self: flex-start;
  margin-left: calc(var(--space-3) * -1);
  color: var(--error-strong);
}

/* The inline confirmation that takes the link's place. */
.plan-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
}

.plan-confirm__text {
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.plan-confirm__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.plan-confirm__keep,
.plan-confirm__stop {
  justify-content: center;
  height: 40px;
}

.plan-confirm__stop {
  background: var(--error-soft);
  color: var(--error-strong);
}

.plan-confirm__stop:disabled,
.plan-confirm__keep:disabled {
  opacity: 0.6;
}

/* --- Offers --------------------------------------------------------------------------- */

.plan-offers {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.plan-tier {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.plan-tier__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-1);
}

.plan-tier__name {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.3px;
}

.plan-tier__description {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* The durations, one card, hairlines between — the account page's list. */
.plan-options {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.plan-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  text-align: left;
  transition:
    background-color var(--duration) var(--easing),
    transform var(--spring-duration) var(--spring);
}

.plan-option + .plan-option {
  border-top: 1px solid var(--border);
}

.plan-option[data-pressed="true"] {
  background: var(--surface-sunken);
}

.plan-option[data-selected="true"] {
  background: var(--accent-tint);
}

/* The radio: a ring that fills in the accent when picked. */
.plan-option__radio {
  flex: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-full);
  transition:
    border-color var(--duration) var(--easing),
    box-shadow var(--duration) var(--easing);
}

.plan-option[data-selected="true"] .plan-option__radio {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface);
  background: var(--accent);
}

.plan-option__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.plan-option__label {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.plan-option__sub {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.plan-option__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.plan-option__amount {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

/* What the longer duration saves: a success pill, since it is good news. */
.plan-option__save {
  padding: 1px var(--space-2);
  background: var(--success-soft);
  border-radius: var(--radius-full);
  color: var(--success-strong);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
}

/* --- Benefits ----------------------------------------------------------------------------- */

.plan-benefits {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.plan-benefits__label {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.plan-benefits__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
}

.plan-benefit {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.plan-benefit__tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  background: var(--accent-tint);
  border-radius: var(--radius-full);
  color: var(--accent);
}

/* --- Footer --------------------------------------------------------------------------------- */

.plan-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.plan-pay:disabled {
  cursor: default;
}

/* Held while the checkout is open or being prepared: still the accent, so
   the amount stays readable, just not for pressing. */
.plan-pay:disabled:not([data-loading="true"]) {
  opacity: 0.7;
}

.plan-pay__note {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  text-align: center;
}

/* The wait for a checkout that opened in a browser: a spinner, the one
   line, and the way to call it off. */
.plan-waiting {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.plan-waiting__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: boot-spin 0.9s linear infinite;
}

.plan-waiting__text {
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.plan .plan-waiting__stop {
  grid-column: 2;
  justify-self: start;
  margin-left: calc(var(--space-3) * -1);
}

/* --- Reduced motion ----------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .plan,
  .plan__sheet,
  .plan-option,
  .plan-option__radio {
    transition: none;
  }

  .plan-waiting__spinner {
    animation: none;
  }
}
