/*
 * Donation form styles.
 *
 * No build step, no framework: this file is enqueued as-is. Layout and
 * spacing are opinionated; typography and colour are left to inherit from the
 * theme wherever a reasonable value exists, so the form does not look like a
 * plugin bolted onto the page.
 */

/*
 * The [hidden] attribute must actually hide things. This rule is not belt and
 * braces -- without it the form is broken.
 *
 * form.js shows and hides every state in this component by toggling the
 * `hidden` property: the details block when checkout mounts over it, the fee
 * row, the summary, the error line. `hidden` works because the UA stylesheet
 * carries `[hidden] { display: none }` -- but author styles outrank the UA
 * stylesheet regardless of specificity, so every `display: flex` below silently
 * defeats it. The symptom is the whole donation form still sitting on screen
 * underneath Stripe's mounted checkout iframe, with a live Donate button.
 *
 * Scoped under the component class so it wins on specificity (0,2,0 against
 * 0,1,0) rather than with !important, which this project does not use.
 *
 * The status component below has exactly the same shape -- one flex panel per
 * state, all shipping `hidden`, revealed one at a time by status.js -- so it is
 * covered here too. Without it the thank-you page shows every outcome at once:
 * "your gift is complete" stacked on "your payment failed".
 */
.ncd-donation-form [hidden],
.ncd-donation-form[hidden],
.ncd-donation-status [hidden],
.ncd-donation-status[hidden] {
	display: none;
}

.ncd-donation-form {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	font-family: inherit;
	color: inherit;
    background-color: #fafafa;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    max-width: 480px; 
    margin: 0 auto; 
	overflow: hidden;
}

/* Force native browser checkbox and strip out theme-injected icon fonts */
.ncd-donation-form__cover-fees input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: auto !important;
}

.ncd-donation-form__cover-fees input[type="checkbox"]::before,
.ncd-donation-form__cover-fees input[type="checkbox"]::after {
    display: none !important;
    content: none !important;
}

.ncd-donation-form__title {
	font-family: inherit;
	color: inherit;
	margin: 0;
}

.ncd-donation-form__details {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	padding: 30px;
}

.ncd-donation-form__field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.ncd-donation-form__field label {
	font-weight: 600;
}

.ncd-donation-form input[type="text"],
.ncd-donation-form input[type="email"] {
    padding: 15px 20px !important;
    border: 1px solid #b5b5b5 !important;
    border-radius: 4px !important;
    font-size: 1.2em !important;
    background: #ffffff !important;
}

.ncd-donation-form input[type="text"]:focus,
.ncd-donation-form input[type="email"]:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ncd-donation-form__presets {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
}

.ncd-donation-form__preset {
    font: inherit;
    color: #ffffff !important;
    background-color: #2b8cca !important;
    border: 2px solid #2b8cca !important;
    border-radius: 4px !important;
    padding: 15px 10px !important;
    cursor: pointer;
    font-size: 1.2em !important;
    font-weight: 600 !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Container that acts as the visual input box */
.ncd-donation-form__amount-wrapper {
    display: flex;
    align-items: stretch;
    border: 1px solid #b5b5b5;
    border-radius: 4px;
    background: #ffffff;
    overflow: hidden;
    height: 70px;
}

/* Add a focus ring to the wrapper when the input is clicked */
.ncd-donation-form__amount-wrapper:focus-within {
    outline: 2px solid #2b8cca;
    outline-offset: 1px;
}

/* The dollar sign and dotted border */
.ncd-donation-form__currency-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    font-size: 1.2em;
    color: #555;
    border-right: 1px dotted #b5b5b5;
    background: transparent;
}

/* The actual input field, stripped of its native borders */
#ncd-donation-amount {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    padding-left: 20px !important;
    font-size: 2.2em !important;
    font-weight: 600 !important;
    color: #333 !important;
    width: 100%;
}

/*
 * CanvasText/Canvas rather than currentColor for the inverted state.
 *
 * `background-color: currentColor` resolves against the element's OWN color,
 * and these rules set `color: Canvas` on that same element -- so both
 * properties compute to Canvas and the button becomes invisible: matching text
 * on a matching background, with only the border left. The selected preset
 * silently disappeared from the row.
 *
 * The system colors carry no such self-reference, and they track the user's
 * light/dark preference and forced-colors mode for free, which a hard-coded
 * pair of hex values would not.
 */
.ncd-donation-form__preset:hover,
.ncd-donation-form__preset[aria-pressed="true"],
.ncd-donation-form__preset.is-selected {
    background-color: #ffffff !important;
    color: #2b8cca !important;
}

.ncd-donation-form__cover-fees {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    padding: 15px 20px;
}

.ncd-donation-form__cover-fees label {
    font-weight: 400 !important;
    color: #555555;
}

.ncd-donation-form__cover-fees input[type="checkbox"] {
	margin-top: 0.2em;
}

.ncd-donation-form__summary {
	border: 1px solid currentColor;
	border-radius: 0.25rem;
	padding: 0.75rem 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.ncd-donation-form__summary-row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}

.ncd-donation-form__summary-row--total {
	font-weight: 700;
	border-top: 1px solid currentColor;
	padding-top: 0.35rem;
}

.ncd-donation-form__error {
	margin: 0;
	padding: 0.6em 0.75em;
	border: 1px solid #b32d2e;
	border-radius: 0.25rem;
	color: #b32d2e;
}

.ncd-donation-form__submit {
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	align-self: flex-start;
	transition: opacity 0.15s ease;
	background-color: #2b8cca;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 15px 20px;
    font-size: 1.2em;
    width: 100%;
    margin-top: 10px;
}

.ncd-donation-form__submit:hover {
    background-color: #1f6fa3; /* Slightly darker blue on hover */
}

.ncd-donation-form__submit[aria-busy="true"] {
	cursor: progress;
	opacity: 0.7;
}

.ncd-donation-form__submit:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.ncd-donation-form__checkout {
	min-height: 25rem;
	margin: 0;
	padding: 0;
}

/*
 * Off-screen, not display:none: some bot heuristics specifically look for
 * display:none / visibility:hidden and skip those fields, defeating the
 * honeypot. Clipping it to a 1px box that is moved off the visible canvas
 * keeps the field present, focusable by a script, and invisible to a human,
 * without tripping that heuristic. aria-hidden on the wrapper (see form.php)
 * is what keeps it out of assistive tech.
 */
.ncd-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.ncd-donation-form__preset,
	.ncd-donation-form__submit {
		transition: none;
	}
}

/*
 * Donation status (thank-you page) styles.
 */

.ncd-donation-status {
	max-width: 32rem;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	font-family: inherit;
	color: inherit;
}

.ncd-donation-status__title {
	font-family: inherit;
	color: inherit;
	margin: 0;
}

.ncd-donation-status__error {
	margin: 0;
	padding: 0.6em 0.75em;
	border: 1px solid #b32d2e;
	border-radius: 0.25rem;
	color: #b32d2e;
}

.ncd-donation-status__state {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.ncd-donation-status__state--loading {
	flex-direction: row;
	align-items: center;
	gap: 0.75rem;
}

.ncd-donation-status__state--failed p:first-child,
.ncd-donation-status__state--expired p:first-child {
	padding: 0.6em 0.75em;
	border: 1px solid #b32d2e;
	border-radius: 0.25rem;
	color: #b32d2e;
	margin: 0;
}

.ncd-donation-status__row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	border: 1px solid currentColor;
	border-radius: 0.25rem;
	padding: 0.5rem 1rem;
}

.ncd-donation-status__note {
	opacity: 0.85;
}

/*
 * CSS-only spinner. A 2px ring with one quadrant coloured, rotating -- no
 * image, no JS-driven animation loop.
 */
.ncd-donation-status__spinner {
	display: inline-block;
	width: 1.5rem;
	height: 1.5rem;
	flex-shrink: 0;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	opacity: 0.6;
	animation: ncd-donation-status-spin 0.8s linear infinite;
}

@keyframes ncd-donation-status-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ncd-donation-status__spinner {
		/*
		 * Not display:none: the spinner still communicates "this is loading"
		 * to a sighted user who has asked for less motion, just as a static
		 * ring rather than a spin. The accessible loading text next to it
		 * carries the meaning either way.
		 */
		animation: none;
	}
}
