/*
 * Digital Download front end.
 *
 * Everything is wrapped in :where(), which has no weight of its own, so ANY rule from the theme, Elementor, the block
 * editor's Global Styles or a Customizer "Additional CSS" box overrides these without needing !important.
 * Colours and fonts come from the site: Elementor's global colours first, then the block theme's, then plain text colour.
 */
:where(.dd) {
	--dd-accent: var(--e-global-color-accent, var(--e-global-color-primary, var(--wp--preset--color--primary, currentColor)));
	--dd-border: color-mix(in srgb, currentColor 18%, transparent);
	--dd-soft: color-mix(in srgb, currentColor 6%, transparent);
	--dd-radius: 4px;
	--dd-gap: 0.75rem;
	color: inherit;
	font: inherit;
}

:where(.dd) table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 1.25rem;
}

:where(.dd) th,
:where(.dd) td {
	padding: 0.6rem 0.75rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--dd-border);
}

:where(.dd) thead th {
	font-weight: 600;
	border-bottom-width: 2px;
}

:where(.dd) h3 {
	margin: 1.5rem 0 0.5rem;
}

:where(.dd) code {
	word-break: break-all;
}

:where(.dd) .dd-button {
	font: inherit;
	cursor: pointer;
}

:where(.dd) .dd-link {
	appearance: none;
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	font: inherit;
	color: var(--dd-accent);
	text-decoration: underline;
	cursor: pointer;
}

:where(.dd) .dd-inline {
	display: inline;
}

:where(.dd) .dd-buy {
	margin: 0;
}

:where(.dd) .dd-notice {
	margin: 0 0 1rem;
	padding: 0.75rem 1rem;
	border-left: 4px solid var(--dd-accent);
	background: var(--dd-soft);
	border-radius: var(--dd-radius);
}

:where(.dd) .dd-code {
	display: flex;
	flex-wrap: wrap;
	gap: var(--dd-gap);
	margin: 0 0 1rem;
}

:where(.dd) .dd-code input[type="text"],
:where(.dd) input[type="email"],
:where(.dd) input[type="text"] {
	font: inherit;
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--dd-border);
	border-radius: var(--dd-radius);
	background: transparent;
	color: inherit;
}

:where(.dd) .dd-summary {
	font-weight: 600;
}

:where(.dd) .dd-confirmation {
	margin: 0 0 1.25rem;
	padding: 1rem;
	border: 1px solid var(--dd-border);
	border-radius: var(--dd-radius);
	background: var(--dd-soft);
}

:where(.dd) #dd-payment-element {
	margin: 0 0 1rem;
}

/* Narrow screens: tables become stacked cards so nothing scrolls sideways. */
@media (max-width: 640px) {
	:where(.dd) table,
	:where(.dd) tbody,
	:where(.dd) thead,
	:where(.dd) tr,
	:where(.dd) th,
	:where(.dd) td {
		display: block;
		width: auto;
	}

	:where(.dd) thead {
		position: absolute;
		left: -9999px;
	}

	:where(.dd) tr {
		margin: 0 0 1rem;
		border: 1px solid var(--dd-border);
		border-radius: var(--dd-radius);
	}

	:where(.dd) td {
		border-bottom: 0;
		padding: 0.4rem 0.75rem;
	}

	/* The header row is hidden here, so each value carries its column name. */
	:where(.dd) td[data-label]::before {
		content: attr(data-label) ": ";
		font-weight: 600;
	}
}
