/**
 * Create Fundraiser Form — styles.
 *
 * Covers both frontend form rendering and the editor block preview.
 * Colour and typography are driven by WordPress block supports (declared in
 * block.json). WordPress injects text/background/link colours and typography
 * settings directly on the block wrapper via get_block_wrapper_attributes(),
 * so this stylesheet only defines structural and accent-colour tokens.
 *
 * @package AmbassadorHub\Fundraisers\Blocks\CreateFundraiserForm
 */

/* ── Theme token aliases ────────────────────────────────────────────── */
/*
 * --ambh-accent  : link/primary colour from WP Global Styles or theme preset.
 * --ambh-border / --ambh-surface: derived from currentColor, so they always
 *   adapt to whichever text colour WordPress injects on the wrapper.
 */
.ambh-create-fundraiser-form {
	/* Appearance settings → WP Global Styles → fallback. All purely
	   currentColor-based tokens (border, surface) adapt automatically to
	   whatever text colour WordPress / the theme injects on the wrapper. */
	--ambh-accent:        var(--ambh-color-primary, var(--wp--style--color--link, var(--wp--preset--color--primary, #0073aa)));
	--ambh-accent-hover:  var(--ambh-color-primary-hover, var(--wp--preset--color--primary, #005177));
	--ambh-border:        color-mix(in srgb, currentColor 18%, transparent);
	--ambh-border-hover:  color-mix(in srgb, currentColor 35%, transparent);
	--ambh-surface:       color-mix(in srgb, currentColor  4%, transparent);
	--ambh-surface-hover: color-mix(in srgb, currentColor  7%, transparent);
	--ambh-radius:        var(--wp--custom--border-radius, 4px);
}

/* ── Outer wrapper ──────────────────────────────────────────────────── */

.ambh-create-fundraiser-form {
	/* colour and background-color are set by WordPress via get_block_wrapper_attributes();
	   we only ensure font-family cascades from the theme. */
	font-family: inherit;
}

/* ── Step visibility ────────────────────────────────────────────────── */

.ambh-cff-step {
	display: none;
}

.ambh-cff-step.is-active {
	display: block;
}

/* ── Step title ─────────────────────────────────────────────────────── */

.ambh-cff-step-title {
	margin-top: 0;
	margin-bottom: 20px;
	font-size: 1.25em;
}

/* ── Context info banner ─────────────────────────────────────────────── */

.ambh-cff-context-info {
	display: none;
	flex-wrap: wrap;
	gap: 4px 20px;
	padding: 10px 14px;
	margin-bottom: 20px;
	background: var(--ambh-surface);
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	font-size: 0.875em;
	line-height: 1.4;
}

.ambh-cff-context-info.is-visible {
	display: flex;
}

.ambh-cff-context-info__label {
	font-weight: 600;
	margin-right: 4px;
}

.ambh-cff-context-info__parent:empty {
	display: none;
}

/* ── Campaign list (step 1) ─────────────────────────────────────────── */

.ambh-cff-campaign-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ambh-cff-campaign-item {
	margin: 0;
	padding: 0;
}

.ambh-cff-campaign-option {
	display: block;
	width: 100%;
	padding: 14px 18px;
	text-align: left;
	background: var(--ambh-surface);
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	cursor: pointer;
	font-size: 1em;
	font-family: inherit;
	color: inherit;
	line-height: 1.4;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.ambh-cff-campaign-option:hover,
.ambh-cff-campaign-option:focus-visible {
	background: var(--ambh-surface-hover);
	border-color: var(--ambh-border-hover);
	color: inherit;
	outline: none;
}

/* ── Type list (individual / team step) ────────────────────────────── */

.ambh-cff-type-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ambh-cff-type-item {
	margin: 0;
	padding: 0;
}

.ambh-cff-type-option {
	position: relative;
	display: block;
	width: 100%;
	padding: 14px 44px 14px 18px;
	text-align: left;
	background: var(--ambh-surface);
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	cursor: pointer;
	font-size: 1em;
	font-family: inherit;
	color: inherit;
	line-height: 1.4;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.ambh-cff-type-option::after {
	content: '›';
	position: absolute;
	right: 18px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 1.5em;
	line-height: 1;
	opacity: 0.4;
	transition: opacity 0.15s ease, right 0.15s ease;
}

.ambh-cff-type-option:hover,
.ambh-cff-type-option:focus-visible {
	background: var(--ambh-surface-hover);
	border-color: var(--ambh-border-hover);
	color: inherit; /* prevent theme button:hover from changing text colour, which breaks currentColor-based tokens */
	outline: none;
}

.ambh-cff-type-option:hover::after,
.ambh-cff-type-option:focus-visible::after {
	opacity: 1;
	right: 14px;
}

.ambh-cff-type-option__label {
	display: block;
}

.ambh-cff-type-option__description {
	display: block;
	margin-top: 2px;
	font-size: 0.875em;
	opacity: 0.7;
}

/* ── Form fields (step 2) ───────────────────────────────────────────── */

.ambh-cff-field {
	margin-bottom: 20px;
}

.ambh-cff-field label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.ambh-cff-field input[type="text"],
.ambh-cff-field input[type="number"],
.ambh-cff-field input[type="email"],
.ambh-cff-field input[type="url"],
.ambh-cff-field input[type="datetime-local"],
.ambh-cff-field textarea,
.ambh-cff-field select {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	font-size: 1em;
	font-family: inherit;
	color: inherit;
	background-color: transparent;
	line-height: 1.5;
	box-sizing: border-box;
	transition: border-color 0.15s ease;
}

.ambh-cff-field input:focus,
.ambh-cff-field textarea:focus,
.ambh-cff-field select:focus {
	border-color: var(--ambh-accent);
	outline: none;
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--ambh-accent) 25%, transparent);
}

.ambh-cff-field__error {
	display: block;
	min-height: 1.2em;
	margin-top: 4px;
	color: var(--wp--preset--color--vivid-red, #cc1818);
	font-size: 0.875em;
	line-height: 1.3;
}

/* ── Actions row ────────────────────────────────────────────────────── */

.ambh-cff-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	margin-top: 28px;
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.ambh-cff-submit,
.ambh-cff-back {
	padding: 11px 22px;
	border-radius: var(--ambh-radius);
	font-size: 1em;
	font-family: inherit;
	cursor: pointer;
	line-height: 1.4;
	margin-top:15px;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ambh-cff-submit {
	background: var(--ambh-accent);
	color: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--ambh-accent);
}

.ambh-cff-submit:hover {
	background: var(--ambh-accent-hover);
	border-color: var(--ambh-accent-hover);
}

.ambh-cff-submit:focus-visible {
	outline: 2px solid var(--ambh-accent);
	outline-offset: 2px;
}

.ambh-cff-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.ambh-cff-back {
	background: transparent;
	color: inherit;
	border: 1px solid var(--ambh-border);
}

.ambh-cff-back:hover {
	background: var(--ambh-surface-hover);
	border-color: var(--ambh-border-hover);
	color: inherit;
}

/* ── Button utility classes (ambh-button--primary / --secondary / --link) ── */

.ambh-button {
	padding: 11px 22px;
	border-radius: var(--ambh-radius);
	font-size: 1em;
	font-family: inherit;
	cursor: pointer;
	line-height: 1.4;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ambh-button--primary {
	background: var(--ambh-accent);
	color: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--ambh-accent);
}

.ambh-button--primary:hover {
	background: var(--ambh-accent-hover);
	border-color: var(--ambh-accent-hover);
}

.ambh-button--primary:focus-visible {
	outline: 2px solid var(--ambh-accent);
	outline-offset: 2px;
}

.ambh-button--primary:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.ambh-button--secondary {
	background: transparent;
	color: inherit;
	border: 1px solid var(--ambh-border);
}

.ambh-button--secondary:hover {
	background: var(--ambh-surface-hover);
	border-color: var(--ambh-border-hover);
	color: inherit;
}

.ambh-button--link {
	background: transparent;
	border: none;
	padding: 0;
	color: var(--ambh-accent);
	text-decoration: underline;
	font-family: inherit;
	font-size: 1em;
	cursor: pointer;
}

.ambh-button--link:hover {
	color: var(--ambh-accent-hover);
}

/* ── Status message ─────────────────────────────────────────────────── */

.ambh-cff-status {
	margin-top: 14px;
	font-style: italic;
	color: var(--ambh-accent);
	min-height: 1.4em;
}

/* ── Login prompt ───────────────────────────────────────────────────── */

.ambh-cff-login-prompt {
	font-style: italic;
}

/* ── Empty-campaigns notice ─────────────────────────────────────────── */

.ambh-cff-notice {
	font-style: italic;
	opacity: 0.7;
}

/* ── Image picker (dropzone) ────────────────────────────────────────── */

.ambh-cff-image-drop {
	position: relative;
	padding: 28px 20px;
	border: 2px dashed var(--ambh-border);
	border-radius: var(--ambh-radius);
	background: var(--ambh-surface);
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.ambh-cff-image-drop:hover,
.ambh-cff-image-drop:focus-visible,
.ambh-cff-image-drop.is-drag-over {
	border-color: var(--ambh-accent);
	background: var(--ambh-surface-hover);
	outline: none;
}

.ambh-cff-image-drop .ambh-cff-image-input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.ambh-cff-image-drop-prompt {
	opacity: 0.7;
	font-size: 0.95em;
}

/* ── Cropper ────────────────────────────────────────────────────────── */

.ambh-cff-crop-viewport {
	position: relative;
	overflow: hidden;
	border-radius: var(--ambh-radius);
	border: 1px solid var(--ambh-border);
	cursor: grab;
	aspect-ratio: 16 / 9;
	background: #1a1a1a;
	-webkit-user-select: none;
	user-select: none;
	touch-action: none;
}

.ambh-cff-crop-viewport.is-dragging {
	cursor: grabbing;
}

.ambh-cff-crop-viewport .ambh-cff-crop-img {
	position: absolute;
	max-width: none;
	max-height: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
	pointer-events: none;
}

.ambh-cff-crop-viewport::after {
	content: '';
	position: absolute;
	inset: 0;
	border: 3px solid rgba(255, 255, 255, 0.5);
	pointer-events: none;
	box-sizing: border-box;
	border-radius: var(--ambh-radius);
}

.ambh-cff-crop-hint {
	margin: 6px 0 10px;
	font-size: 0.85em;
	opacity: 0.6;
	font-style: italic;
}

.ambh-cff-image-change {
	margin-top: 8px;
	background: transparent;
	color: var(--ambh-accent);
	border: none;
	padding: 0;
	cursor: pointer;
	font-size: 0.9em;
	font-family: inherit;
	text-decoration: underline;
	display: inline-block;
}

.ambh-cff-image-change:hover {
	color: var(--ambh-accent-hover);
}

/* ── Root fundraiser selection (card grid) ──────────────────────────── */

.ambh-cff-root-grid {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 1rem;
	margin-bottom: 20px;
}

@media ( max-width: 768px ) {
	.ambh-cff-root-grid {
		grid-template-columns: repeat( 2, 1fr );
	}
}

@media ( max-width: 480px ) {
	.ambh-cff-root-grid {
		grid-template-columns: 1fr;
	}
}

.ambh-cff-root-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	overflow: hidden;
	background: var(--ambh-surface);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.ambh-cff-root-card:hover {
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.08 );
	transform: translateY( -2px );
}

.ambh-cff-root-card__image img,
.ambh-cff-root-card__placeholder {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

.ambh-cff-root-card__placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--ambh-surface-hover);
	color: var(--ambh-border-hover);
}

.ambh-cff-root-card__placeholder svg {
	width: 2.5rem;
	height: 2.5rem;
}

.ambh-cff-root-card__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 0.875rem;
	gap: 0.625rem;
}

.ambh-cff-root-card__title {
	margin: 0;
	font-size: 0.9375em;
	font-weight: 600;
	line-height: 1.4;
}

.ambh-cff-root-card__actions {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin-top: auto;
}

.ambh-cff-root-card__btn {
	display: block;
	width: 100%;
	padding: 8px 14px;
	border-radius: var(--ambh-radius);
	font-size: 0.875em;
	font-family: inherit;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	line-height: 1.4;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	/* primary — filled accent */
	background: var(--ambh-accent);
	color: var(--wp--preset--color--base, #fff);
	border: 1.5px solid var(--ambh-accent);
}

.ambh-cff-root-card__btn:hover,
.ambh-cff-root-card__btn:focus-visible {
	background: var(--ambh-accent-hover);
	border-color: var(--ambh-accent-hover);
	outline: none;
}

.ambh-cff-root-card__btn--secondary {
	background: transparent;
	color: inherit;
	border-color: var(--ambh-border-hover);
}

.ambh-cff-root-card__btn--secondary:hover,
.ambh-cff-root-card__btn--secondary:focus-visible {
	background: var(--ambh-surface);
	border-color: var(--ambh-accent);
	color: var(--ambh-accent);
}

.ambh-cff-root-card__btn--tertiary {
	background: transparent;
	color: var(--ambh-muted);
	border-color: var(--ambh-border);
	font-weight: 500;
}

.ambh-cff-root-card__btn--tertiary:hover,
.ambh-cff-root-card__btn--tertiary:focus-visible {
	background: var(--ambh-surface);
	color: inherit;
	border-color: var(--ambh-border-hover);
	outline: none;
}

.ambh-cff-create-root-wrap {
	margin-top: 12px;
	text-align: center;
}

.ambh-cff-create-root-btn {
	display: inline-block;
	padding: 10px 20px;
	background: transparent;
	color: var(--ambh-accent);
	border: 1px dashed var(--ambh-border-hover);
	border-radius: var(--ambh-radius);
	font-size: 0.9375em;
	font-family: inherit;
	cursor: pointer;
	line-height: 1.4;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ambh-cff-create-root-btn:hover,
.ambh-cff-create-root-btn:focus-visible {
	background: var(--ambh-surface);
	border-color: var(--ambh-accent);
	outline: none;
}

/* ── Inline auth prompt (login / register) ──────────────────────────── */

.ambh-cff-auth {
	font-family: inherit;
}

.ambh-cff-auth__intro {
	margin-top: 0;
	margin-bottom: 24px;
	font-size: 1.05em;
}

.ambh-cff-auth__columns {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}

@media ( max-width: 600px ) {
	.ambh-cff-auth__columns {
		grid-template-columns: 1fr;
	}

	.ambh-cff-auth__box:first-child {
		padding-right: 0;
		padding-bottom: 28px;
	}

	.ambh-cff-auth__box + .ambh-cff-auth__box {
		padding-left: 0;
		padding-top: 28px;
		border-left: none;
		border-top: 1px solid var(--ambh-border);
	}
}

.ambh-cff-auth__box:first-child {
	padding-right: 40px;
}

.ambh-cff-auth__box + .ambh-cff-auth__box {
	padding-left: 40px;
	border-left: 1px solid var(--ambh-border);
}

.ambh-cff-auth__box h3 {
	margin-top: 0;
	margin-bottom: 20px;
	font-size: 1.125em;
}

.ambh-cff-auth__box p {
	margin: 0 0 14px;
}

.ambh-cff-auth__box label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
	font-size: 0.9375em;
}

.ambh-cff-auth__box input[type="text"],
.ambh-cff-auth__box input[type="email"],
.ambh-cff-auth__box input[type="password"] {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	font-size: 1em;
	font-family: inherit;
	color: inherit;
	background-color: transparent;
	line-height: 1.5;
	box-sizing: border-box;
	transition: border-color 0.15s ease;
}

.ambh-cff-auth__box input:focus {
	border-color: var(--ambh-accent);
	outline: none;
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--ambh-accent) 25%, transparent);
}

.ambh-cff-auth__error {
	padding: 0.55em 0.8em;
	margin-bottom: 16px;
	background: #fef2f2;
	border: 1px solid #fca5a5;
	border-radius: var(--ambh-radius);
	color: #b91c1c;
	font-size: 0.875em;
}

.ambh-cff-auth__button {
	display: block;
	width: 100%;
	padding: 10px 18px;
	border-radius: var(--ambh-radius);
	font-size: 1em;
	font-family: inherit;
	cursor: pointer;
	line-height: 1.4;
	box-sizing: border-box;
	border: 1px solid var(--ambh-border);
	background: transparent;
	color: inherit;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.ambh-cff-auth__button--primary {
	background: var(--ambh-accent);
	color: var(--wp--preset--color--base, #fff);
	border-color: var(--ambh-accent);
	font-weight: 600;
}

.ambh-cff-auth__button--primary:hover {
	background: var(--ambh-accent-hover);
	border-color: var(--ambh-accent-hover);
}

.ambh-cff-auth__button:not(.ambh-cff-auth__button--primary):hover {
	background: var(--ambh-surface-hover);
	border-color: var(--ambh-border-hover);
}

/* ── Editor block preview ───────────────────────────────────────────── */

.ambh-block-preview--create-fundraiser {
	padding: 20px;
	background: var(--ambh-surface);
	border: 1px solid var(--ambh-border);
	border-radius: var(--ambh-radius);
	text-align: center;
	font-style: italic;
	opacity: 0.7;
}
