/* donate.css — donate form, pay modal, bank-transfer panel, thank-you opt-in and supporter
   wall. Loaded only on /support-us/ and /thank-you/ via the page's `extraCss` front matter
   (see layouts/base.njk). Design tokens live in main.css, which is always loaded first. */

/* ---- Donate form ---- */
.donate-form {
  --cur-sym: "$";
  --box-pad: clamp(1.25rem, 4vw, 1.75rem);
  /* the box inset (form padding + the 1rem fieldset margin it used to have) */
  --box-inset: calc(1rem + var(--box-pad));
  display: grid;
  gap: 0;
  margin: 1.5rem auto;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
}

/* Header band: palm teal, like the homepage impact strip, so the box has an anchor */
.donate-head {
  background: var(--brand);
  padding: 1.25rem var(--box-inset);
}

.donate-title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  color: #fff;
  margin: 0 0 .2rem;
}

.donate-head p:not(.donate-title) {
  margin: 0;
  color: var(--ink-on-brand);
  font-size: .9rem;
}

/* Preset amount tiles (amount + optional impact caption) */
.donate-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
}


.donate-preset {
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .45rem .5rem;
  border-radius: 999px;
  border: 2px solid var(--brand);
  background: transparent;
  color: var(--brand-dark);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.donate-preset:hover {
  background: var(--brand);
  color: #fff;
}

.donate-preset[aria-pressed="true"] {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.donate-preset-amt {
  font-weight: 700;
}

.donate-preset-cap {
  font-size: .72rem;
  line-height: 1.2;
  font-weight: 400;
  opacity: .85;
  text-align: center;
}

/* Custom amount: narrow, centred, with leading currency symbol */
.donate-amount {
  display: grid;
  gap: .35rem;
  justify-items: center;
  /* Balances the air below, which carries the reserved (usually empty) error line */
  margin-top: 2rem;
}

.donate-amount-label {
  font-size: .85rem;
  color: var(--muted);
}

.donate-amount-field {
  position: relative;
  display: inline-block;
}

.donate-amount-field::before {
  content: var(--cur-sym);
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand-dark);
  font-size: 1.25rem;
  font-weight: 600;
  pointer-events: none;
}

/* The amount is the point of the box: big, brand-dark, brand frame */
.donate-amount input {
  font: inherit;
  font-size: 2rem;
  font-weight: 600;
  color: var(--brand-dark);
  width: 13rem;
  max-width: 100%;
  text-align: center;
  padding: .35rem 3rem .35rem 2rem;
  border: 2px solid var(--brand);
  border-radius: 12px;
  background: var(--surface);
}

/* Currency code inside the field: "$" alone is ambiguous across dollar currencies */
.donate-amount-code {
  position: absolute;
  right: .8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--brand-dark);
  pointer-events: none;
}

.donate-amount input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.donate-error {
  margin: -.2rem 0 0;
  text-align: center;
  color: var(--ink);
  font-weight: 600;
  font-size: .9rem;
}

/* ponytail: no reserved line for the (usually empty) error; a one-line shift when an
   error appears beats permanent dead air under the amount field. */
.donate-error:empty {
  display: none;
}

/* Per-transaction cap hint under the amount field: muted by default, terracotta when over/just-snapped */
.donate-cap-hint {
  margin: -.1rem auto .1rem;
  max-width: 36ch;
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.donate-cap-hint.is-warn {
  color: var(--accent);
  font-weight: 600;
}

.donate-cap-hint.is-flash {
  color: var(--accent);
  font-weight: 600;
  animation: cap-flash .45s ease;
}

@keyframes cap-flash {

  0%,
  100% {
    transform: none;
  }

  35% {
    transform: scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .donate-cap-hint.is-flash {
    animation: none;
  }
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* dim any disabled button (payment methods, opt-in Save) so "disabled" reads as disabled */

/* ---- Payment methods, per ABA's Merchant Integration Guideline v2.11. Annotated minimums:
   logo-to-label >= 10px (we use 12), title-to-description >= 4px, description grey #697386,
   logos never restyled. Row metrics from the guideline's "payment method on web" component
   (node 26283:2835): padding 10px, radius 8, 8px between rows, shadow 0 1px 4px, title 600,
   20px chevron tile #F2F3F7, brand tiles 24x14. Type scaled up from the component's 12/11px
   for legibility; ratios and spacing are the bank's. */
.donate-amount-set,
.pay-methods-list {
  border: 0;
  padding: 0;
  margin: 0 var(--box-inset); /* inset the wide buttons (and their legends) from the box frame */
  min-width: 0;
  display: grid;
}

/* Sand band under the amount step: depth by tone, the two steps read as two steps.
   On a div, not the fieldset: a fieldset's background starts at the middle of its legend. */
.donate-amount-band {
  background: var(--sand);
  padding: var(--box-pad) var(--box-inset);
}

.donate-amount-set {
  gap: .85rem;
  margin: 0;
}

/* Turnstile: invisible in interaction-only mode; when a challenge does show, give it room. */
.donate-form .cf-turnstile:not(:empty) {
  margin: .5rem var(--box-inset) 0;
}

.pay-methods-list {
  /* 1.9rem + the hint's .1rem bottom margin + the band's padding: about the same air the
     amount field has above it. */
  margin-top: 1.9rem;
  gap: 8px;
}

.donate-amount-set legend,
.pay-methods-list legend {
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
  margin-bottom: .5rem;
}

.pay-method {
  font: inherit;
  cursor: pointer;
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr 20px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(183, 190, 203, .36);
  transition: border-color .15s ease;
}

.pay-method:hover:not(:disabled) {
  border-color: var(--brand);
}

.pay-method:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.pay-method > img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.pay-method-text {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.pay-method-title {
  font-weight: 600;
  font-size: .875rem;
  line-height: 1.2;
}

.pay-method-desc {
  color: #697386;
  font-size: .8rem;
  line-height: 1.25;
}

.pay-method .pay-method-logos {
  display: block;
  height: 14px;
  width: auto;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.pay-method-chevron {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: #F2F3F7;
  position: relative;
}

.pay-method-chevron::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 6px;
  width: 5px;
  height: 5px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(-45deg);
}

.donate-smallprint {
  font-size: .82rem;
  color: var(--muted);
  text-align: center;
  max-width: 42ch;
  margin: .85rem auto var(--box-pad);
  padding-inline: var(--box-pad);
  line-height: 1.5;
}

.donate-smallprint a {
  white-space: nowrap;
}

/* keep multi-word policy links (e.g. "Donation & Refund Policy") whole, not split across lines */
.donate-nojs {
  color: var(--ink);
  font-weight: 600;
  text-align: center;
}

/* ---- Pay modal (native dialog) ---- */
.pay-modal,
.policy-modal {
  border: 0;
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  max-width: 40rem;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
  color: var(--ink);
  background: var(--surface);
}

.pay-modal::backdrop,
.policy-modal::backdrop {
  background: rgba(36, 31, 27, .5);
}

.pay-modal-spinner {
  width: 2.2rem;
  height: 2.2rem;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

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

@media (prefers-reduced-motion: reduce) {
  .pay-modal-spinner {
    animation: none;
  }
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  font: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
}

.pay-modal {
  text-align: center;
}

/* centre heading, body text and action buttons; close × still floats right */

/* ---- Donate section: bank-transfer alternative (collapsible) ---- */
.give-alt {
  margin: 1.6rem 0;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.give-alt summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}

.give-alt[open] summary {
  margin-bottom: .8rem;
}

/* "What a gift can provide" ladder — collapsed by default; a magnitude bar per tier (log scale).
   Alignment mirrors .give-alt so the two stacked disclosures read as siblings. */
.impact-ladder {
  margin: 1.6rem 0;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.impact-ladder summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}

.impact-ladder[open] summary {
  margin-bottom: .4rem;
}

.impact-ladder-list {
  margin: 0;
}

.impact-row {
  padding: .65rem 0;
  border-top: 1px solid var(--line);
}

.impact-row:first-child {
  border-top: 0;
}

.impact-row dt {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.impact-amt {
  font-weight: 700;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  min-width: 4.5rem;
}

.impact-bar {
  flex: 1;
  height: .5rem;
  background: var(--sand);
  border-radius: 999px;
  overflow: hidden;
}

.impact-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--bar, 0);
  background: var(--brand);
  border-radius: 999px;
}

.impact-row dd {
  margin: .3rem 0 0;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.45;
}

.impact-note {
  font-size: .8rem;
  color: var(--muted);
  margin: .8rem 0 0;
}

/* ---- Thank-you opt-in form ---- */
.optin-form {
  display: grid;
  gap: 1.1rem;
  max-width: 32rem;
  margin: 1rem 0;
}

.optin-actions:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  margin-top: .7rem;
}

/* Save above, note under; both centred. :not([hidden]) so the JS hidden attr can hide it */
.optin-note {
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
}

.optin-check {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  font-weight: 600;
}

/* Fixed-size box so the field indent below lines up exactly with the label text;
   small top nudge sits it on the first line (labels can wrap to two lines). */
/* Centre on the first text line: 17px text × lh 1.65 ≈ 28px line box, box is 1.1rem ≈ 17.6px,
   so ~5px centres the box; nudged to .38rem to sit on the text's optical centre (cap-height sits
   below the line-box centre). flex-start keeps it on line 1 when the label wraps. */
.optin-check input[type="checkbox"] {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: .38rem;
  accent-color: var(--brand);
}

.optin-fields:not([hidden]) {
  display: grid;
  gap: .6rem;
  padding-left: 1.65rem;
}

/* = checkbox 1.1rem + gap .55rem; :not([hidden]) so the JS-toggled hidden attr wins */
.optin-fields label {
  display: grid;
  gap: .25rem;
  font-weight: 600;
}

.optin-optional {
  font-weight: 400;
  color: var(--muted);
  font-size: .85em;
}

.optin-fields input,
.optin-fields select {
  font: inherit;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}

.optin-done {
  color: var(--brand);
  font-weight: 600;
  text-align: center;
}

/* Save failed: a boxed callout, not a coloured line, so it reads as "nothing was saved" at a
   glance. Body text stays ink for contrast; the tint + border carry the warning. */
.optin-error {
  margin: .75rem 0 0;
  padding: .7rem .9rem;
  border: 1.5px solid var(--accent-dark);
  border-radius: 8px;
  background: #fff1e6;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.5;
}

.optin-error strong {
  color: var(--accent-dark);
}

/* Name + country share a row; stack on very narrow screens (slow-mobile audience). */
.optin-row {
  display: flex;
  gap: .6rem;
}

.optin-row>label {
  flex: 1 1 0;
  min-width: 0;
}

@media (max-width: 380px) {
  .optin-row {
    flex-wrap: wrap;
  }

  .optin-row>label {
    flex-basis: 100%;
  }
}

/* Live preview: label centred on its own line (fixed text = never shifts), pill centred
   under it so it grows symmetrically from the centre — no horizontal jiggle while typing. */
.optin-preview:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  margin-top: .5rem;
}

/* :not([hidden]) so the empty pill stays hidden until a name is typed */
.optin-preview .supporter-wall {
  margin: 0;
}

/* the shared pill wrapper carries a 1.25rem margin — kill it here so label + pill stay together */
.optin-preview-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
}

/* Email field: greyed placeholder + live valid check (green border + ✓), error hint on blur. */
.optin-email-field {
  position: relative;
  display: block;
}

.optin-email-field input {
  padding-right: 2rem;
}

.optin-email-field.is-valid input {
  border-color: var(--brand);
}

.optin-email-check {
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}

.optin-email-field.is-valid .optin-email-check {
  opacity: 1;
}

.optin-email-error {
  color: var(--accent-dark);
  font-size: .8rem;
  font-weight: 600;
  margin: .1rem 0 0;
}

/* ---- Supporter wall (donate page) — pills under the markdown "## Our supporters" heading ---- */
.supporter-wall {
  margin: 1.25rem 0;
}

/* Flexible height, capped ~ the donation box; scroll inside when it overflows. */
.supporter-wall .supporter-pills {
  list-style: none;
  margin: 0;
  padding: .2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  max-height: 34rem;
  overflow-y: auto;
  /* ~ the donation box height; scrolls past that */
}

.supporter-wall .supporter-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

.supporter-name {
  white-space: nowrap;
}

/* Flag sized to the text; hairline ink ring so white-field flags (JP, DK, FR) keep an edge on the white pill.
   Selector must beat `.page-body img` (0,0,1,1) — otherwise the flag inherits its 1.5rem margin (which
   inflated pill height), 14px radius (round flags) and card shadow. */
.supporter-pill .supporter-flag {
  height: 1em;
  width: auto;
  aspect-ratio: 4 / 3;
  margin: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(36, 31, 27, .16);
  flex: none;
}

/* Quiet "be the first" note — shown only while .supporter-pills is empty (build with no
   supporters, or a live fetch that comes back empty). Hidden by default so a populated
   wall never shows both. */
.supporter-wall-empty {
  display: none;
  margin: .2rem;
  color: var(--muted);
  font-size: .82rem;
  font-style: italic;
}

.supporter-pills:empty + .supporter-wall-empty {
  display: block;
}