/* The Donate page and its pay pages, linked only by their templates (extra_css in
   base.html), so other pages don't download these styles. Colours, radius and fonts come
   from the tokens in charity.css, which every page loads first. */

/* How paying works, above the form, and what became of a payment, on the pay page. */
.payment-notice,
.payment-message {
    margin-block: 1.5rem;
    padding: 1rem 1.25rem;
    border-left: 6px solid var(--colour-accent);
    border-radius: var(--radius);
    background: var(--colour-surface);
}

.payment-message.is-problem {
    border-left-color: var(--colour-error);
}

.payment-notice > :first-child,
.payment-message > :first-child {
    margin-top: 0;
}

.payment-notice > :last-child,
.payment-message > :last-child {
    margin-bottom: 0;
}

/* The wait's countdown (#226): figures of one width, so the time doesn't shift each second. */
.countdown {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* One column on phones; as many 14rem cards as fit on wider screens, with no breakpoint. */
.amount-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    gap: 0.75rem;
}

.amount-options legend,
.amount-options .errorlist,
.amount-options .other-amount {
    grid-column: 1 / -1;
}

.form-page main .amount-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.1rem 0.75rem;
    align-content: start;
    min-height: 2.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--colour-border);
    border-radius: var(--radius);
    font-weight: 400;
    cursor: pointer;
}

.amount-option:has(input:checked) {
    border-color: var(--colour-primary);
    background: var(--colour-surface);
}

.amount-option:has(input:focus-visible) {
    outline: 3px solid var(--colour-focus);
    outline-offset: 2px;
}

/* The card's ring stands in for the radio's. A browser without :has() drops this rule too,
   so the radio keeps its own ring there. */
.amount-option:has(input:focus-visible) input {
    outline: none;
}

.amount-figure {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--colour-primary-dark);
}

.amount-impact {
    grid-column: 2;
    color: var(--colour-muted);
    font-size: 0.9375rem;
}

.amount-options .other-amount {
    margin: 0.25rem 0 0;
}

/* "Your own amount" appears once "Other amount" is chosen. CSS only, so it works without
   JavaScript; browsers without :has() simply always show it. */
.amount-options:not(:has(input[value="other"]:checked)) .other-amount:not(.is-shown) {
    display: none;
}

.amount-options .other-amount input {
    max-width: 14rem;
}

/* The mobile number is only for monthly reminders, so it appears once Monthly is chosen. */
.giving-frequency:not(:has(input[value="monthly"]:checked)) .phone-field {
    display: none;
}

.pledge-form + * {
    margin-top: 2.5rem;
}

/* Pay pages: the gift, then the ways to pay, one under another on a phone. */
.gift-summary {
    margin-block: 1.5rem;
}

.gift-summary dt {
    color: var(--colour-muted);
    font-size: 0.9375rem;
}

.gift-summary dd {
    margin: 0 0 0.75rem;
    color: var(--colour-primary-dark);
    font-size: 1.25rem;
    font-weight: 700;
}

.pay-page section {
    margin-top: 2rem;
}

/* "I didn't pay": the pay buttons and the other ways, folded while an attempt may already be
   paid. Its summary is a 44px tap target, in link colour so it reads as something to open. */
.pay-again {
    margin-block: 1.5rem;
}

.pay-again summary,
.qr-how summary {
    min-height: 2.75rem;
    padding-block: 0.625rem;
    color: var(--colour-primary);
    font-weight: 600;
    cursor: pointer;
}

.pay-again[open] > section:first-of-type {
    margin-top: 0.5rem;
}

/* A button for each provider, one under another: full width on a phone, then no wider than 24rem,
   so on a wide screen they're a short column lined up with the text. No breakpoint. */
.payment-options {
    display: grid;
    gap: 0.75rem;
    max-width: 24rem;
}

.payment-options .button {
    width: 100%;
}

/* A provider's button (#201): its logo, then "Pay with …", on white with a border in the brand
   colour. The logos sit on the white they were drawn for (eSewa's guidelines ask for it), the
   buttons read as equal choices rather than two main actions, and the text keeps the page's own
   colour, so it reads as well on every charity's site. */
.pay-provider {
    justify-content: flex-start;
    gap: 0.5rem;
    padding-inline: 1rem;
    border: 2px solid var(--colour-primary);
    background: var(--colour-background);
    color: var(--colour-text);
    text-align: start;
}

.pay-provider:hover {
    background: var(--colour-surface);
}

/* Every logo in the same box, so each "Pay with …" starts at the same place. The logo keeps its
   proportions inside it (contain), against the left. 2rem tall: the providers' files carry their
   own clear space, so the mark itself is smaller. */
.pay-provider img {
    flex: none;
    width: 5.25rem;
    height: 2rem;
    object-fit: contain;
    object-position: left center;
}

/* The ways to pay, and "Pay another way": a full-width row for each, drawn like the amount cards,
   with the way's name, a muted line on how, and an arrow. The text wraps, so a longer Nepali
   line fits at 320px with no breakpoint. */
.pay-ways {
    display: grid;
    gap: 0.75rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.pay-way {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.1rem 0.75rem;
    min-height: 2.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--colour-border);
    border-radius: var(--radius);
    color: var(--colour-text);
    text-decoration: none;
}

.pay-way:hover {
    border-color: var(--colour-primary);
    background: var(--colour-surface);
}

.pay-way strong {
    color: var(--colour-primary-dark);
}

.pay-way span {
    grid-column: 1;
    color: var(--colour-muted);
    font-size: 0.9375rem;
}

.pay-way .pay-way-arrow {
    grid-column: 2;
    grid-row: 1 / span 2;
    color: var(--colour-primary);
    font-size: 1.5rem;
    line-height: 1;
}

/* A row with no line under its name ("Pay another way") centres the arrow on the name. */
.pay-way strong + .pay-way-arrow {
    grid-row: 1;
}

/* Paying in person: what to do at the counter, a step at a time. */
.pay-steps li + li {
    margin-top: 0.75rem;
}

.pay-steps address {
    font-style: normal;
}

/* A phone number to call is a 44px tap target, as is a link on a line of its own. */
.pay-steps a[href^="tel:"],
.share-gift a[href^="tel:"],
.payment-message p > a:only-child:not(.button) {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
}

/* Scan our QR code: the details to copy, the app to pay with, the QR card, then "I've paid". The
   page also carries the form-page class, so its field, radio and card rules apply. */
.qr-details {
    margin-block: 1.5rem;
}

.qr-details > div + div {
    margin-top: 0.75rem;
}

.qr-details dt {
    color: var(--colour-muted);
    font-size: 0.9375rem;
}

.qr-details dd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: var(--colour-primary-dark);
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.qr-help {
    color: var(--colour-muted);
    font-size: 0.9375rem;
}

/* "Copied", straight under the value that was copied. No height of its own until it speaks. */
.qr-details dd.copy-status {
    min-height: 0;
    margin: 0;
    color: var(--colour-muted);
    font-size: 0.9375rem;
    font-weight: 400;
}

/* Icon only, so a row never wraps at 320px; its spoken name is its aria-label. */
.copy-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 2px solid var(--colour-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--colour-primary);
    cursor: pointer;
}

.copy-icon-button .copy-tick,
.copy-icon-button.is-copied .copy-icon {
    display: none;
}

.copy-icon-button.is-copied .copy-tick {
    display: block;
}

/* The QR card as uploaded: no border or frame added, smoothly scaled, never wider than 24rem. */
.qr-card img {
    display: block;
    width: min(100%, 24rem);
    height: auto;
    margin-block: 1rem;
}

.qr-card h3 {
    margin-bottom: 0;
}

.form-page main .qr-card p > .button {
    align-self: flex-start;
}

/* The two steps of paying by QR, each its own page: a numbered row that links to the other
   page. The step you're on has a filled circle in the brand colour (the same pair the filled
   buttons use, so the brand contrast check covers it), the other an outline in the link colour.
   Then the step itself, divided by a line. */
.qr-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.qr-progress-step {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    font-weight: 600;
}

span.qr-progress-step {
    color: var(--colour-primary-dark);
}

.qr-progress-number {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--colour-primary);
    border-radius: 50%;
    background: transparent;
    color: var(--colour-primary);
    font-weight: 700;
}

.is-current .qr-progress-number {
    background: var(--colour-primary);
    color: var(--colour-on-dark);
}

.pay-page .qr-step {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--colour-border);
    scroll-margin-top: 1rem;
}

.qr-step > h2 {
    margin-top: 0;
}

.pay-page .qr-card {
    margin-top: 1rem;
}

/* "Pay another way", at the bottom of every way's page: set apart from the way above it by a
   line, as the QR steps are. */
.pay-page .other-ways {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--colour-border);
}

.other-ways > h2 {
    margin-top: 0;
}

/* "Can't scan?": the account to pay instead, set apart from the QR code's own help. */
.qr-fallback {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--colour-border);
}

.qr-fallback h4 {
    margin: 0;
    font-size: 1.0625rem;
}

.qr-fallback .qr-details {
    margin-block: 0.75rem 0;
}

ol.qr-help {
    margin: 0;
    padding-left: 1.5rem;
}

/* From 48rem there's room beside the QR code for its help and the account to pay instead:
   the code on the left at a size that scans, the rest on the right. The source order is the
   same, so the keyboard and screen reader order doesn't change. */
@media (min-width: 48rem) {
    .qr-card {
        display: grid;
        grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
        column-gap: 2rem;
        align-items: start;
    }

    .qr-card h3 {
        grid-column: 1 / -1;
    }
}

/* With 2 or more QR codes, only the chosen one shows. CSS only, so it works without
   JavaScript; browsers without :has() show every code, each under its name. Each rule pairs
   the nth app with the nth card (up to eight; any more are always shown). */
.qr-pay:has(.qr-choice label:nth-of-type(1) input:checked) .qr-card:not(:nth-of-type(1)),
.qr-pay:has(.qr-choice label:nth-of-type(2) input:checked) .qr-card:not(:nth-of-type(2)),
.qr-pay:has(.qr-choice label:nth-of-type(3) input:checked) .qr-card:not(:nth-of-type(3)),
.qr-pay:has(.qr-choice label:nth-of-type(4) input:checked) .qr-card:not(:nth-of-type(4)),
.qr-pay:has(.qr-choice label:nth-of-type(5) input:checked) .qr-card:not(:nth-of-type(5)),
.qr-pay:has(.qr-choice label:nth-of-type(6) input:checked) .qr-card:not(:nth-of-type(6)),
.qr-pay:has(.qr-choice label:nth-of-type(7) input:checked) .qr-card:not(:nth-of-type(7)),
.qr-pay:has(.qr-choice label:nth-of-type(8) input:checked) .qr-card:not(:nth-of-type(8)) {
    display: none;
}

/* Sharing that they've given (#100): the Show my gift box with Save under it, then Tell your
   friends, then the other ways as a row of text links that wraps, each a 44px tap target. One
   column at every width; a wider screen only lets the links sit on one line. */
.show-gift {
    margin-block: 1rem 1.5rem;
}

.show-gift .button {
    margin-top: 0.5rem;
}

.share-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.share-links a,
.share-links .link-button {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    font-weight: 700;
}
