/* Download Button Popup – front end. Inherits the theme's fonts and primary color. */

.dbp-modal {
	--dbp-accent: var(--wp--preset--color--primary, var(--wp--preset--color--contrast, #1e1e1e));
	--dbp-accent-text: #fff;
	--dbp-bg: #fff;
	--dbp-text: #1e1e1e;
	--dbp-muted: #5f6368;
	--dbp-border: rgba(0, 0, 0, 0.18);
	--dbp-error: #c62828;
	--dbp-radius: 12px;

	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	font-family: inherit;
	line-height: 1.5;
	opacity: 0;
	transition: opacity 0.18s ease;
}

.dbp-modal[hidden] {
	display: none;
}

.dbp-modal.is-visible {
	opacity: 1;
}

html.dbp-open {
	overflow: hidden;
}

.dbp-overlay {
	position: absolute;
	inset: 0;
	background: rgba(17, 17, 20, 0.55);
}

.dbp-dialog {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 36px 32px 32px;
	background: var(--dbp-bg);
	color: var(--dbp-text);
	border-radius: var(--dbp-radius);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
	transform: translateY(8px);
	transition: transform 0.18s ease;
	outline: none;
}

.dbp-modal.is-visible .dbp-dialog {
	transform: none;
}

.dbp-dialog *,
.dbp-dialog *::before,
.dbp-dialog *::after {
	box-sizing: border-box;
}

.dbp-close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--dbp-muted);
	cursor: pointer;
	box-shadow: none;
}

.dbp-close:hover,
.dbp-close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
	color: var(--dbp-text);
}

.dbp-head {
	margin-bottom: 20px;
	padding-right: 24px;
}

.dbp-dialog .dbp-title {
	margin: 0 0 6px;
	padding: 0;
	font-family: inherit;
	font-size: 1.4em;
	font-weight: 600;
	line-height: 1.25;
	color: inherit;
}

.dbp-dialog .dbp-desc {
	margin: 0;
	color: var(--dbp-muted);
	font-size: 0.95em;
}

.dbp-fields {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px 16px;
}

.dbp-field {
	grid-column: 1 / -1;
	min-width: 0;
}

.dbp-field.dbp-w-half {
	grid-column: span 1;
}

.dbp-dialog .dbp-label {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-size: 0.9em;
	font-weight: 500;
	color: inherit;
}

.dbp-req {
	color: var(--dbp-error);
}

.dbp-dialog .dbp-input {
	display: block;
	width: 100%;
	max-width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 12px;
	font: inherit;
	font-size: 16px; /* Stops iOS zooming into the field. */
	color: var(--dbp-text);
	background: #fff;
	border: 1px solid var(--dbp-border);
	border-radius: 8px;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dbp-dialog textarea.dbp-input {
	min-height: 88px;
	resize: vertical;
}

.dbp-dialog .dbp-input:focus {
	outline: none;
	border-color: var(--dbp-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--dbp-accent) 22%, transparent);
}

.dbp-field.has-error .dbp-input {
	border-color: var(--dbp-error);
}

.dbp-choices {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.dbp-dialog .dbp-choice {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 0 0 6px;
	font-size: 0.95em;
	font-weight: 400;
	cursor: pointer;
}

.dbp-choice input {
	flex: none;
	width: 18px;
	height: 18px;
	margin: 2px 0 0;
	accent-color: var(--dbp-accent);
}

.dbp-field--consent {
	margin-top: 16px;
	font-size: 0.9em;
}

.dbp-field--consent a {
	color: inherit;
	text-decoration: underline;
}

.dbp-error,
.dbp-form-error {
	margin: 6px 0 0;
	font-size: 0.85em;
	color: var(--dbp-error);
}

.dbp-error[hidden],
.dbp-form-error[hidden] {
	display: none;
}

.dbp-form-error {
	margin-top: 16px;
}

/* Honeypot: off-screen, not display:none, so simple bots still fill it in. */
.dbp-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.dbp-dialog .dbp-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	margin: 20px 0 0;
	padding: 12px 24px;
	font: inherit;
	font-weight: 600;
	color: var(--dbp-accent-text);
	background: var(--dbp-accent);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.05s ease;
}

.dbp-dialog .dbp-submit:hover {
	opacity: 0.9;
}

.dbp-dialog .dbp-submit:active {
	transform: translateY(1px);
}

.dbp-dialog .dbp-submit:disabled {
	opacity: 0.6;
	cursor: wait;
}

.dbp-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	min-height: 160px;
	color: var(--dbp-muted);
}

.dbp-spinner {
	width: 22px;
	height: 22px;
	border: 2px solid var(--dbp-border);
	border-top-color: var(--dbp-accent);
	border-radius: 50%;
	animation: dbp-spin 0.7s linear infinite;
}

@keyframes dbp-spin {
	to {
		transform: rotate(360deg);
	}
}

.dbp-success {
	padding: 12px 0 4px;
	text-align: center;
}

.dbp-success-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin-bottom: 16px;
	border-radius: 50%;
	color: var(--dbp-accent-text);
	background: var(--dbp-accent);
}

.dbp-success .dbp-desc {
	margin-bottom: 18px;
}

.dbp-dialog .dbp-backup {
	color: var(--dbp-accent);
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.dbp-message {
	padding: 24px 8px 8px;
	text-align: center;
}

@media (max-width: 600px) {
	.dbp-modal {
		align-items: flex-end;
		padding: 0;
	}

	.dbp-dialog {
		max-height: 92vh;
		padding: 32px 20px 24px;
		border-radius: var(--dbp-radius) var(--dbp-radius) 0 0;
	}

	.dbp-fields {
		grid-template-columns: 1fr;
	}

	.dbp-field.dbp-w-half {
		grid-column: 1 / -1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dbp-modal,
	.dbp-dialog {
		transition: none;
	}

	.dbp-spinner {
		animation-duration: 1.6s;
	}
}
