/*
 * Pricing/module cards — the one card system for every surface that shows what
 * a practice books: the onboarding wizard, the studio's financial panel and the
 * public marketing site. Colours come from the custom properties below, so a
 * consumer with its own palette (the marketing site, with its dark theme) only
 * overrides the variables instead of restyling the cards.
 * Mobile-first; cards sit side-by-side from ~640px up.
 */

:root {
  --pc-bg: #fff;
  --pc-fg: #1f2a37;
  --pc-muted: #5a6675;
  --pc-faint: #8a94a1;
  --pc-border: #dbe2ea;
  --pc-input-border: #c4ccd6;
  /* The accent marks what is included/selected — booked modules, the chosen
     plan, the highlighted offer. */
  --pc-accent: #3a6ea5;
  --pc-accent-bg: #e9f1fa;
  --pc-accent-ring: rgba(58, 110, 165, 0.18);
  --pc-accent-soft: rgba(58, 110, 165, 0.12);
  --pc-off-bg: #f8fafc;
  --pc-off-input: #f1f4f8;
  --pc-chip-bg: #eef2f7;
  --pc-chip-fg: #46566a;
  --pc-total-bg: #f4f7fa;
  --pc-danger: #d63939;
  --pc-radius: 14px;
}

.pricing-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

@media (min-width: 640px) {
  .pricing-cards {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

.pricing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem;
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-radius);
  background: var(--pc-bg);
}

/* ── PWYW opt-in cards (onboarding): whole card selects a module ───────── */

/* Alpine x-cloak: keep toggled affordances hidden until Alpine initialises. */
[x-cloak] {
  display: none !important;
}

.pricing-card--selectable {
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}

.pricing-card--on {
  border-color: var(--pc-accent);
  box-shadow: 0 0 0 2px var(--pc-accent-ring);
  /* Light accent tint so included modules stand apart from the unselected. */
  background: var(--pc-accent-bg);
}

.pricing-card--on .pricing-card__price input {
  background: var(--pc-bg);
}

.pricing-card--off {
  border-style: dashed;
  background: var(--pc-off-bg);
}

/* An unselected card reads as an offer, not as content: its text steps back so
   the row's included modules carry the contrast. */
.pricing-card--off .pricing-card__title,
.pricing-card--off .pricing-card__desc {
  color: var(--pc-faint);
}

.pricing-card--off:hover {
  border-color: var(--pc-accent);
  box-shadow: 0 0 0 2px var(--pc-accent-soft);
}

.pricing-card--off .pricing-card__img {
  filter: grayscale(1);
  opacity: 0.55;
}

/* ── The switch: one mark per card, always in the same corner ──────────────
   A real checkbox, so the keyboard and screen readers get the module's state
   for free; the card around it is a second, larger hit area for the mouse.
   Off it is a dashed ring with a plus, on it is a filled ring with a tick —
   the row can be read without reading a single label. */
.pricing-card__check {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.65rem;
  height: 1.65rem;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 2px dashed var(--pc-input-border);
  border-radius: 999px;
  background: var(--pc-bg);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

.pricing-card__check::before,
.pricing-card__check::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--pc-accent);
}

.pricing-card__check::before {
  width: 0.68rem;
  height: 2px;
  transform: translate(-50%, -50%);
}

.pricing-card__check::after {
  width: 2px;
  height: 0.68rem;
  transform: translate(-50%, -50%);
}

.pricing-card__check:checked,
.pricing-card__check--fixed {
  border-style: solid;
  border-color: var(--pc-accent);
  background: var(--pc-accent);
}

.pricing-card__check:checked::before,
.pricing-card__check--fixed::before {
  display: none;
}

/* The tick: two borders of an empty box, turned 45°. */
.pricing-card__check:checked::after,
.pricing-card__check--fixed::after {
  width: 0.34rem;
  height: 0.62rem;
  background: none;
  border: solid var(--pc-bg);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.pricing-card__check:focus-visible {
  outline: 2px solid var(--pc-accent);
  outline-offset: 2px;
}

/* The homepage is included by definition — it wears the mark, but nothing
   about it can be switched. */
.pricing-card__check--fixed {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.65rem;
  height: 1.65rem;
  border: 2px solid var(--pc-accent);
  border-radius: 999px;
}

.pricing-card__badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  background: var(--pc-accent-soft);
  color: var(--pc-accent);
}

/* Fixed-height slot where Add/Remove swap in place (empty on the homepage
   card) — keeps the card content from shifting when a module is toggled. */
.pricing-card__action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
}

/* A deselected card's price row is inert as a whole, so a click anywhere on it
   falls through to the card and adds the module. Hide the "0.00" placeholder
   there — the reserved field must read as truly empty. */
.pricing-card--off .pricing-card__price {
  pointer-events: none;
}

.pricing-card--off .pricing-card__price input:disabled {
  background: var(--pc-off-input);
}

.pricing-card--off .pricing-card__price input:disabled::placeholder {
  color: transparent;
}

/* Add and Remove name what the next click does. They look like buttons because
   they behave like one; the card carries the click, so neither is a control of
   its own (nothing to tab to twice, nothing to announce twice). */
.pricing-card__add,
.pricing-card__remove {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.9rem;
  border: 1px solid;
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1.2;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.pricing-card__add {
  border-color: var(--pc-accent);
  background: var(--pc-bg);
  font-weight: 600;
  color: var(--pc-accent);
}

.pricing-card--off:hover .pricing-card__add {
  background: var(--pc-accent);
  color: var(--pc-bg);
}

.pricing-card__remove {
  border-color: var(--pc-border);
  background: var(--pc-bg);
  color: var(--pc-muted);
}

.pricing-card--on:hover .pricing-card__remove {
  border-color: var(--pc-danger);
  color: var(--pc-danger);
}

/* ── Manage mode: group headings, cancel + recommended-price affordances ── */

.pricing-group__title {
  margin: 1.25rem 0 0.25rem;
  font-size: 1rem;
}

.pricing-group__hint {
  margin: 0 0 0.25rem;
  font-size: 0.86rem;
  color: var(--pc-faint);
}

/* Cancelling a module removes it — an × in the card corner, not a wastebasket
   (which reads like "delete my content"). Muted until hovered so the card does
   not shout "danger" at rest. */
.pricing-card__cancel {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pc-faint);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.pricing-card__cancel:hover:not(:disabled) {
  background: color-mix(in srgb, var(--pc-danger) 12%, transparent);
  color: var(--pc-danger);
}

.pricing-card__cancel:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* The × asks once: the second click is the one that cancels. Preferred over a
   modal — a dialog that always says the same thing is dismissed unread, while
   a button that visibly changed its mind is not. */
.pricing-card__cancel--asking,
.pricing-card__cancel--asking:hover:not(:disabled) {
  background: var(--pc-danger);
  color: #fff;
}

.pricing-card__recommend {
  margin-top: 0.25rem;
}

.pricing-card--fixed {
  justify-content: center;
}

.pricing-card__img {
  width: 76px;
  height: 76px;
}

.pricing-card__title {
  font-weight: 700;
  font-size: 1.05rem;
}

.pricing-card__desc {
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--pc-muted);
  flex: 1;
}

/* ── PWYW: per-module price input ─────────────────────────────────────── */

.pricing-card__price {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.pricing-card__currency {
  font-weight: 600;
  color: var(--pc-muted);
}

.pricing-card__price input {
  width: 6.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--pc-input-border);
  border-radius: 9px;
  font-size: 1rem;
  text-align: right;
}

.pricing-card__price input:focus-visible {
  outline: 2px solid var(--pc-accent);
  outline-offset: 1px;
}

.pricing-card__per {
  font-size: 0.8rem;
  color: var(--pc-faint);
}

/* ── fixed mode: selectable plan card ─────────────────────────────────── */

.pricing-card--plan {
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.pricing-card--plan:has(input:checked) {
  border-color: var(--pc-accent);
  box-shadow: 0 0 0 2px var(--pc-accent-ring);
}

.pricing-card__radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pricing-card__amount {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--pc-fg);
}

.pricing-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.pricing-card__chip {
  font-size: 0.72rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--pc-chip-bg);
  color: var(--pc-chip-fg);
}

/* ── running total (PWYW) ─────────────────────────────────────────────── */

.pricing-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  border-radius: 11px;
  background: var(--pc-total-bg);
  font-size: 1.05rem;
}

.pricing-total__sum {
  font-weight: 800;
  font-size: 1.25rem;
}

/* billing-period selector — keep it narrow next to the cards */
.pricing-period {
  max-width: 16rem;
}

/* Hide the number-spinner arrows on price inputs — they get in the way; the
   value is validated as a number server-side regardless. */
.pricing-input::-webkit-outer-spin-button,
.pricing-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pricing-input {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* coffee-fund donation row (Financial tab) */
.coffee-fund__row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.coffee-fund__presets,
.coffee-fund__custom {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.coffee-fund__amount {
  width: 9rem;
}

/* top-up + refund rows (Financial tab) */
.deposit__presets {
  display: flex;
  gap: 0.5rem;
}

.deposit__row,
.refund__form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.deposit__amount,
.refund__amount {
  width: 9rem;
}

.refund__iban {
  width: 16rem;
}

/* PWYW "hosting costs money" appeal — warm note under the price cards */
.pricing-explanation {
  margin: 1rem 0 1.25rem;
  max-width: 44rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--tblr-secondary, #626976);
}

.pricing-explanation p:last-child {
  margin-bottom: 0;
}


/* ── subscription status (studio financial panel) ─────────────────────── */

/* The panel opens with the plain answer to "what am I on right now?" — the
   status colours the card, the amount is the headline. */
.billing-status {
  --bs-tone: var(--pc-accent);
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--bs-tone) 35%, var(--pc-border));
  border-left: 4px solid var(--bs-tone);
  border-radius: var(--pc-radius);
  background: color-mix(in srgb, var(--bs-tone) 7%, var(--pc-bg));
}

.billing-status--trial { --bs-tone: #4299e1; }
.billing-status--active { --bs-tone: #2fb344; }
.billing-status--past_due { --bs-tone: #f76707; }
.billing-status--cancelled,
.billing-status--none { --bs-tone: var(--pc-faint); }

.billing-status__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.billing-status__badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bs-tone) 18%, transparent);
  color: color-mix(in srgb, var(--bs-tone) 75%, #000);
}

.billing-status__amount {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--pc-fg);
}

.billing-status__per {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--pc-muted);
}

.billing-status__meta {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--pc-muted);
}

.billing-status__hint {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--pc-fg);
}

/* ── top-up QR code ───────────────────────────────────────────────────── */

.deposit-qr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin: 0.75rem 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-radius);
  background: var(--pc-bg);
}

.deposit-qr__code {
  margin: 0;
  text-align: center;
}

.deposit-qr__code img {
  display: block;
  border-radius: 8px;
}

.deposit-qr--example .deposit-qr__code img {
  opacity: 0.45;
  filter: grayscale(1);
}

.deposit-qr__note {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--pc-faint);
}

.deposit-qr__details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.75rem;
  margin: 0;
  font-size: 0.88rem;
}

.deposit-qr__details dt {
  font-weight: 500;
  color: var(--pc-muted);
}

.deposit-qr__details dd {
  margin: 0;
  color: var(--pc-fg);
}

/* The module's colour as a dot before its name — same hue as in the studio and
   on the marketing site (core.feature_toggles.MODULE_COLORS). A dot, not a
   filled card: the card's own on/off state already owns its background. */
.pricing-card__module {
  display: inline-block;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  margin-right: .45em;
  vertical-align: baseline;
}

/* Nothing here needs motion to be understood — the state is carried by the
   mark, the border and the label. */
@media (prefers-reduced-motion: reduce) {
  .pricing-card--selectable,
  .pricing-card__check,
  .pricing-card__add,
  .pricing-card__remove {
    transition: none;
  }
}

/* ── the operator's pencil ─────────────────────────────────────────────
   The module descriptions and the pay-what-you-want note are content the
   operator writes, so each carries a pencil into its form — drawn only for
   them (billing/_edit_pencil.html). It lives here rather than in the marketing
   site's CSS because the cards are rendered on three surfaces (wizard, studio
   panel, marketing site) and only one of those loads marketing.css: without
   this the raw SVG would blow up to its intrinsic size in the studio. */
.pricing-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid var(--pc-border);
  border-radius: 8px;
  color: var(--pc-muted);
  background: var(--pc-bg);
  opacity: 0.55;
  transition: opacity 0.15s;
}

.pricing-edit:hover,
.pricing-edit:focus {
  opacity: 1;
  color: var(--pc-fg);
  text-decoration: none;
}

.pricing-edit svg {
  width: 1rem;
  height: 1rem;
}

/* The card's top right corner is the module's on/off mark, so the pencil takes
   the left one. */
.pricing-card > .pricing-edit {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
}

.pricing-explanation {
  position: relative;
}

.pricing-explanation > .pricing-edit {
  float: right;
  margin-left: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .pricing-edit { transition: none; }
}
