/* ==========================================================================
   Component · Pricing
   Plan cards with a billing-cycle toggle, plus a comparison table that turns
   into stacked rows on a phone rather than scrolling sideways.
   ========================================================================== */

/* ---- Cycle toggle -------------------------------------------------------- */

.cycle-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.28rem;
  margin-bottom: clamp(2rem, 1.5rem + 1.5vw, 3rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
}

.cycle-toggle__option {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 40px;
  padding-inline: 1.1rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-gentle),
    color var(--duration-fast) var(--ease-gentle);
}

.cycle-toggle__option:hover {
  color: var(--color-text-primary);
}

.cycle-toggle__option[aria-pressed="true"] {
  background: var(--color-fill-inverse);
  color: var(--color-text-inverse);
}

.cycle-toggle__badge {
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  /* Not #fff: white on the accent is 3.06:1 at this size, and AA wants 4.5.
     --color-text-inverse is near-black in dark and white in light, so it
     passes against the accent in both themes. */
  color: var(--color-text-inverse);
  font-size: 0.6875rem;
  font-weight: 600;
}

.cycle-toggle__option[aria-pressed="true"] .cycle-toggle__badge {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

/* ---- Plan cards ---------------------------------------------------------- */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.plan--featured {
  border-color: var(--color-accent);
}

.plan__flag {
  position: absolute;
  top: -0.7rem;
  inset-inline-start: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.plan__name {
  font-size: var(--text-card-title);
  line-height: 1.15;
}

.plan__tagline {
  margin-top: 0.5rem;
  min-height: 3em;
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  line-height: 1.5;
}

/* Only the selected cycle's price is in the document flow. */
.plan__price {
  display: none;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 1.1rem;
}

[data-cycle="monthly"]  .plan__price[data-cycle="monthly"],
[data-cycle="yearly"]   .plan__price[data-cycle="yearly"],
[data-cycle="lifetime"] .plan__price[data-cycle="lifetime"] {
  display: flex;
}

.plan__price-value {
  color: var(--color-text-primary);
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.plan__price-suffix {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

/* An unfilled price reads as "look in the app", never as a wrong number. */
.plan__price-pending {
  font-size: var(--text-sub);
  font-weight: 600;
  color: var(--color-text-tertiary);
}

.plan__note {
  margin-top: 0.4rem;
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.plan__cta {
  margin-top: 1.5rem;
  width: 100%;
}

.plan__highlights {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-hairline);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}

.plan__highlights li {
  position: relative;
  padding-inline-start: 1.4rem;
  line-height: 1.45;
}

.plan__highlights li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.42em;
  width: 9px;
  height: 5px;
  border-inline-start: 1.6px solid var(--color-accent);
  border-bottom: 1.6px solid var(--color-accent);
  rotate: -45deg;
}

/* ---- Comparison ---------------------------------------------------------- */

.compare {
  margin-top: clamp(2rem, 1.5rem + 1.5vw, 3rem);
  overflow-x: auto;
  contain: paint;
}

.compare__table {
  width: 100%;
  /* separate, not collapse: Chrome does not honour `position: sticky` on a
     table cell inside a collapsed-border table, so the pinned first column
     simply scrolled away. With zero spacing and borders only on one edge, it
     renders identically. */
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-caption);
}

.compare__table th,
.compare__table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-hairline);
  text-align: start;
}

.compare__table thead th {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-weight: 600;
  border-bottom-color: var(--color-border-strong);
}

.compare__table tbody th {
  font-weight: 400;
  color: var(--color-text-secondary);
}

.compare__table td {
  text-align: center;
  color: var(--color-text-primary);
}

.compare__table tbody tr:hover {
  background: var(--color-tile-hover);
}

.cell-icon {
  display: inline-block;
}

.cell-icon--yes {
  width: 18px;
  height: 18px;
  color: var(--color-accent);
}

.cell-icon--no {
  color: var(--color-text-tertiary);
}

.fine-print {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 76ch;
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  line-height: 1.55;
}

/* Below 46em the table becomes stacked blocks: a row per feature, each cell
   labelled with its plan. Sideways scrolling through a price table is the
   thing people give up on. */
@media (max-width: 46em) {
  .compare__table,
  .compare__table tbody,
  .compare__table tr,
  .compare__table td,
  .compare__table tbody th {
    display: block;
  }

  .compare__table thead {
    display: none;
  }

  .compare__table tr {
    padding-block: 0.9rem;
    border-bottom: 1px solid var(--color-hairline);
  }

  .compare__table tbody th {
    padding: 0 0 0.5rem;
    border: 0;
    color: var(--color-text-primary);
    font-weight: 600;
  }

  .compare__table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
    border: 0;
    text-align: end;
  }

  .compare__table td::before {
    content: attr(data-label);
    color: var(--color-text-tertiary);
    font-size: 0.8125rem;
  }
}
