/*
 * Donation form.
 *
 * Two shapes from one stylesheet: a split panel with an image beside the
 * fields (for a donate page or modal), and a plain stack when there is no
 * image or the container is narrow.
 *
 * The accent colour arrives as the --w4h-accent custom property set inline on
 * the panel, so it is configurable in the admin without generating stylesheets.
 */

.w4h-panel {
    --w4h-accent: #4a9cab;
    --w4h-ink: #1f2937;
    --w4h-muted: #6b7280;
    --w4h-line: #d6dae0;
    --w4h-field-bg: #f7f8f9;

    box-sizing: border-box;
    max-width: 62rem;
    margin: 0 auto;
    color: var(--w4h-ink);
}

.w4h-panel *,
.w4h-panel *::before,
.w4h-panel *::after { box-sizing: inherit; }

.w4h-panel__title {
    margin: 0 0 1.75rem;
    font-size: clamp(1.6rem, 3vw, 2.15rem);
    font-weight: 400;
    letter-spacing: .01em;
}

.w4h-panel__body { display: block; }

/* Image and fields side by side, image slightly narrower so the form leads. */
.w4h-panel--split .w4h-panel__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(1.5rem, 5vw, 4.5rem);
    align-items: start;
}

.w4h-panel__media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 2px;
}

.w4h-intro {
    margin: 0 0 2rem;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--w4h-muted);
}

.w4h-field { margin: 0 0 1.5rem; border: 0; padding: 0; }

.w4h-label {
    display: block;
    margin: 0 0 .55rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--w4h-muted);
}

.w4h-req { color: #d94f4f; margin-left: .15rem; }

.w4h-hint { margin: .4rem 0 0; font-size: .8125rem; color: var(--w4h-muted); }

.w4h-row { display: flex; gap: 1rem; }
.w4h-row .w4h-field { flex: 1; }

/* --- Inputs ------------------------------------------------------------- */

.w4h-form input[type="text"],
.w4h-form input[type="email"],
.w4h-form input[type="number"],
.w4h-form textarea {
    width: 100%;
    padding: .95rem 1rem;
    border: 1px solid var(--w4h-line);
    border-radius: 2px;
    background: var(--w4h-field-bg);
    color: inherit;
    font: inherit;
    /* 16px minimum stops iOS Safari zooming in on focus, which throws the
       page layout sideways mid-donation. */
    font-size: max(1rem, 16px);
    transition: border-color .15s, box-shadow .15s;
}

.w4h-form input:focus,
.w4h-form textarea:focus {
    outline: none;
    border-color: var(--w4h-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--w4h-accent) 25%, transparent);
}

/* Currency symbol sits inside the field so the donor is never guessing which
   currency they are typing in. */
.w4h-amount-input { position: relative; display: flex; align-items: center; }

.w4h-amount-input__symbol {
    position: absolute;
    left: 1rem;
    font-size: max(1.15rem, 18px);
    font-weight: 700;
    line-height: 1;
    color: var(--w4h-muted);
    pointer-events: none;
    /* Never swallow a click aimed at the field. */
    user-select: none;
}

/* The type-attribute selector above is more specific than a bare class, and
   its `padding` shorthand would otherwise reset this back to 1rem — leaving
   the typed amount sitting underneath the currency symbol. Matching on the
   attribute here keeps it winning. */
.w4h-form input[type="number"].w4h-amount-input__field,
.w4h-form input[type="text"].w4h-amount-input__field {
    padding-left: 2.4rem;
    font-size: max(1.15rem, 18px);
    font-weight: 700;
}

/* Hide the spinner arrows: they invite click-click-click on an amount field
   and add nothing on a donation form. */
.w4h-amount-input__field::-webkit-outer-spin-button,
.w4h-amount-input__field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.w4h-amount-input__field { -moz-appearance: textfield; appearance: textfield; }

/* --- Choice chips (frequency, optional preset amounts) ------------------- */

.w4h-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.w4h-choices--amounts { margin-bottom: .75rem; }

.w4h-choice { position: relative; flex: 1 1 auto; }

/* Visually hidden, not display:none — the radio must stay focusable so the
   form is usable by keyboard and screen reader. */
.w4h-choice input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.w4h-choice span {
    display: block;
    padding: .7rem 1rem;
    text-align: center;
    border: 1px solid var(--w4h-line);
    border-radius: 2px;
    background: var(--w4h-field-bg);
    font-weight: 600;
    transition: border-color .15s, background-color .15s, color .15s;
}

.w4h-choice input:checked + span {
    border-color: var(--w4h-accent);
    background: color-mix(in srgb, var(--w4h-accent) 12%, transparent);
    color: color-mix(in srgb, var(--w4h-accent) 75%, black);
}

.w4h-choice input:focus-visible + span { outline: 2px solid var(--w4h-accent); outline-offset: 2px; }

.w4h-choices--amounts .w4h-choice { flex: 1 1 5.5rem; }

/* --- Actions ------------------------------------------------------------- */

.w4h-checkbox { display: flex; gap: .55rem; align-items: center; margin: 0 0 1.5rem; }
.w4h-checkbox input { width: 1.1rem; height: 1.1rem; accent-color: var(--w4h-accent); }

.w4h-submit {
    padding: 1.05rem 2.75rem;
    border: 0;
    border-radius: 2px;
    background: var(--w4h-accent);
    color: #fff;
    font: inherit;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter .15s;
}

.w4h-submit:hover { filter: brightness(.92); }
.w4h-submit:focus-visible { outline: 3px solid var(--w4h-accent); outline-offset: 3px; }
.w4h-submit[disabled] { opacity: .6; cursor: progress; }

.w4h-secure { margin: 1rem 0 0; font-size: .8125rem; color: var(--w4h-muted); }

.w4h-error {
    margin: 0 0 1.5rem;
    padding: .85rem 1rem;
    border-radius: 2px;
    background: #fcf0f1;
    border: 1px solid #d63638;
    color: #8a1f22;
}

/* Honeypot: off-screen rather than hidden, because some bots skip
   display:none fields. */
.w4h-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Narrow screens ------------------------------------------------------ */

@media (max-width: 782px) {
    /* Image above the fields rather than beside them. It stays because it is
       doing real persuasive work, but it must not push the form below the fold
       on a phone, so it is capped. */
    .w4h-panel--split .w4h-panel__body { grid-template-columns: 1fr; gap: 1.5rem; }
    .w4h-panel__media img { max-height: 15rem; object-fit: cover; }
    .w4h-row { flex-direction: column; gap: 0; }
    .w4h-submit { width: 100%; }
}
