/**
 * AGSF donation form.
 *
 * Inherits the theme's type and colour tokens where they exist, with
 * fallbacks so the form is still legible if the plugin is used on a page
 * that does not load the AGSF theme stylesheet.
 */

.agsf-donate {
  --d-ink: var(--agsf-ink, #171018);
  --d-body: var(--agsf-secondary-ink, #3B3142);
  --d-muted: var(--agsf-muted, #6B6270);
  --d-plum: var(--agsf-plum, #43154E);
  --d-gold: var(--agsf-gold-solid, #F0B01F);
  --d-gold-ink: #7F5B0C;
  --d-lime: var(--agsf-lime, #9DBE1E);
  --d-cream: var(--agsf-cream, #FDF5E2);
  --d-line: var(--agsf-line, #E7E2DB);
  --d-card: #FFFFFF;

  color: var(--d-body);
  max-width: 760px;
}

.agsf-donate__title {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--d-ink);
  margin: 0 0 14px;
}

.agsf-donate__intro {
  font-size: 17px;
  line-height: 1.65;
  margin: 0 0 28px;
  max-width: 58ch;
}

.agsf-donate__fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 26px;
}

.agsf-donate__legend {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--d-ink);
  padding: 0;
  margin-bottom: 12px;
}

.agsf-donate__currency-note {
  font-weight: 500;
  font-size: 14.5px;
  color: var(--d-muted);
}

/* Frequency ------------------------------------------------------------ */

.agsf-donate__freq {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.agsf-donate__freq-option,
.agsf-donate__amount {
  position: relative;
  display: inline-flex;
}

.agsf-donate__freq-option input,
.agsf-donate__amount input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.agsf-donate__freq-option span,
.agsf-donate__amount span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  background: var(--d-card);
  border: 1px solid var(--d-line);
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--d-ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.agsf-donate__freq-option input:checked + span,
.agsf-donate__amount input:checked + span {
  border-color: var(--d-plum);
  box-shadow: inset 0 0 0 1px var(--d-plum);
  background: var(--d-cream);
}

/* Visible keyboard focus is essential here - these are custom controls. */
.agsf-donate__freq-option input:focus-visible + span,
.agsf-donate__amount input:focus-visible + span {
  outline: 3px solid var(--d-plum);
  outline-offset: 2px;
}

/* Amounts -------------------------------------------------------------- */

.agsf-donate__amounts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.agsf-donate__custom label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--d-ink);
  margin-bottom: 7px;
}

.agsf-donate__custom-field {
  display: flex;
  align-items: stretch;
  max-width: 260px;
  border: 1px solid var(--d-line);
  background: var(--d-card);
}

.agsf-donate__symbol {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--d-cream);
  border-right: 1px solid var(--d-line);
  font-weight: 700;
  color: var(--d-ink);
}

.agsf-donate__custom-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 13px 14px;
  font-size: 16px; /* 16px avoids the iOS zoom-on-focus jump */
  font-family: inherit;
  color: var(--d-ink);
  background: transparent;
}

.agsf-donate__custom-field:focus-within {
  outline: 3px solid var(--d-plum);
  outline-offset: 2px;
}

/* Summary and terms ---------------------------------------------------- */

.agsf-donate__summary {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--d-ink);
  margin-bottom: 18px;
  min-height: 1.4em;
}

.agsf-donate__terms {
  background: var(--d-cream);
  border-left: 4px solid var(--d-gold);
  padding: 18px 20px;
  margin-bottom: 24px;
}

.agsf-donate__terms h3 {
  font-family: Manrope, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--d-ink);
  margin: 0 0 10px;
}

.agsf-donate__terms ul {
  margin: 0;
  padding-left: 18px;
}

.agsf-donate__terms li {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 6px;
}

/* Payment methods ------------------------------------------------------ */

.agsf-donate__methods-label {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--d-ink);
  margin: 0 0 12px;
}

.agsf-donate__buttons {
  min-height: 52px;
}

.agsf-donate__loading {
  font-size: 15px;
  color: var(--d-muted);
  margin: 10px 0 0;
}

/* Messaging ------------------------------------------------------------ */

.agsf-donate__error {
  font-size: 15px;
  line-height: 1.55;
  color: #8A1C1C;
  margin: 10px 0 0;
  font-weight: 600;
}

.agsf-donate__status {
  margin-top: 20px;
  padding: 16px 18px;
  font-size: 16px;
  line-height: 1.6;
  border-left: 4px solid var(--d-line);
  background: var(--d-card);
}

.agsf-donate__status[data-kind="success"] {
  border-left-color: var(--d-lime);
  background: #F4F8E6;
  color: #2F3D06;
  font-weight: 600;
}

.agsf-donate__status[data-kind="error"] {
  border-left-color: #8A1C1C;
  background: #FCF0F0;
  color: #6E1414;
}

.agsf-donate__status[data-kind="cancelled"] {
  border-left-color: var(--d-gold);
  background: var(--d-cream);
  color: var(--d-ink);
}

.agsf-donate__status[data-kind="working"] {
  border-left-color: var(--d-plum);
  background: #F4F0FC;
  color: var(--d-plum);
}

.agsf-donate__notice {
  padding: 16px 18px;
  background: var(--d-cream);
  border-left: 4px solid var(--d-gold);
  margin-bottom: 24px;
}

.agsf-donate__notice p {
  margin: 0 0 6px;
}

.agsf-donate__notice p:last-child {
  margin-bottom: 0;
}

.agsf-donate__privacy {
  font-size: 14px;
  line-height: 1.6;
  color: var(--d-muted);
  margin-top: 22px;
}

/* Bank transfer -------------------------------------------------------- */

.agsf-donate__bank {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--d-line);
}

.agsf-donate__bank h3 {
  font-family: Manrope, system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--d-ink);
  margin: 0 0 10px;
}

.agsf-donate__bank p {
  font-size: 15.5px;
  line-height: 1.65;
  margin: 0 0 8px;
}

/* Small screens -------------------------------------------------------- */

@media (max-width: 560px) {
  .agsf-donate__amounts,
  .agsf-donate__freq {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .agsf-donate__freq-option span,
  .agsf-donate__amount span {
    width: 100%;
    padding: 0 12px;
  }

  .agsf-donate__custom-field {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agsf-donate__freq-option span,
  .agsf-donate__amount span {
    transition: none;
  }
}

/* Payment methods ------------------------------------------------------ */

/*
 * One row per eligible method, stacked in the order AGSF asked for:
 * Apple Pay, Google Pay, card, PayPal. The rows are created by the browser
 * only after eligibility passes, so an empty container is the correct
 * rendering when nothing is available.
 */

.agsf-donate__buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agsf-donate__method {
  min-height: 48px;
}

.agsf-donate__method--note {
  min-height: 0;
}

.agsf-donate__note {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--d-muted);
  margin: 0 0 2px;
}

/* Apple's own web component. Sized to match the other buttons; Apple
   controls everything inside it. */
.agsf-donate__method--applepay apple-pay-button {
  --apple-pay-button-width: 100%;
  --apple-pay-button-height: 48px;
  --apple-pay-button-border-radius: 8px;
  display: block;
  width: 100%;
}

/* Google's createButton() injects its own markup; we only size the host. */
.agsf-donate__method--googlepay > div,
.agsf-donate__method--googlepay button {
  width: 100%;
  min-height: 48px;
}

.agsf-donate__method--paypal paypal-button {
  display: block;
  width: 100%;
  --paypal-button-border-radius: 8px;
}

.agsf-donate__method--card paypal-basic-card-container {
  display: block;
  width: 100%;
}

.agsf-donate__method--card paypal-basic-card-button {
  display: block;
  width: 100%;
  min-height: 48px;
}

/*
 * One payment at a time. While a flow is running every button is visually
 * and functionally suppressed, which is the first of two defences against a
 * double charge — the server's idempotency keys are the second.
 */
.agsf-donate__buttons.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 560px) {
  .agsf-donate__method {
    min-height: 44px;
  }
}
