/**
 * Diania Consent — front-end styles.
 *
 * Self-hosted only: no remote fonts, no remote images, no external requests.
 *
 * Appearance is customised by redefining the custom properties below, which
 * is why the templates themselves are not overridable. Example:
 *
 *   :root { --dc-accent: #123456; --dc-radius: 0; }
 *
 * These must be declared on :root, not repeated on .dc-banner/.dc-modal/
 * .dc-embed themselves: a custom property SET on an element by a matching
 * rule always wins over one merely INHERITED from an ancestor such as
 * :root, regardless of which rule appears later in the file or which
 * selector is more specific - that is how CSS custom property inheritance
 * works, not a bug specific to this file, but declaring the defaults here
 * a second time on .dc-banner &c. would still have silently defeated every
 * :root override this comment promises. Confirmed live: an admin-set
 * --dc-bg landed in the page as written and still changed nothing, until
 * the second declaration below was removed.
 */

:root {
	--dc-bg: #ffffff;
	--dc-fg: #1f2327;
	--dc-muted: #5b6470;
	--dc-border: #d7dce2;
	--dc-accent: #1f5c46;
	--dc-accent-hover: #17452f;
	--dc-accent-fg: #ffffff;
	--dc-radius: 4px;
	--dc-gap: 16px;
	--dc-max-width: 1120px;
	--dc-shadow: 0 -2px 16px rgba( 0, 0, 0, 0.12 );
}

.dc-banner,
.dc-modal,
.dc-embed {
	box-sizing: border-box;
	color: var( --dc-fg );
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

.dc-banner *,
.dc-modal *,
.dc-embed *,
.dc-banner *::before,
.dc-modal *::before,
.dc-embed *::before,
.dc-banner *::after,
.dc-modal *::after,
.dc-embed *::after {
	box-sizing: inherit;
}

/* --------------------------------------------------------------------- *
 * Visibility
 *
 * The banner is always in the markup and hidden by default. The inline
 * bootstrap script stamps the html element during head parsing, so visitors
 * who already decided never see it appear and disappear.
 * --------------------------------------------------------------------- */

.dc-banner {
	display: none;
}

.dc-consent-undecided .dc-banner {
	display: block;
	position: fixed;
	z-index: 999998;
	right: 0;
	bottom: 0;
	left: 0;
	background: var( --dc-bg );
	border-top: 1px solid var( --dc-border );
	box-shadow: var( --dc-shadow );
	max-height: 90vh;
	overflow-y: auto;
}

.dc-banner__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var( --dc-gap );
	max-width: var( --dc-max-width );
	margin: 0 auto;
	padding: 20px;
}

.dc-banner__content {
	flex: 1 1 380px;
	min-width: 0;
}

.dc-banner__title {
	margin: 0 0 6px;
	padding: 0;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.3;
	color: var( --dc-fg );
}

.dc-banner__text p {
	margin: 0 0 6px;
	color: var( --dc-muted );
}

.dc-banner__text p:last-child {
	margin-bottom: 0;
}

.dc-banner__text a {
	color: var( --dc-accent );
}

.dc-banner__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	flex: 0 1 auto;
}

/* --------------------------------------------------------------------- *
 * Buttons
 *
 * Accepting and refusing share one style. Refusal is never smaller, paler
 * or further away than acceptance.
 * --------------------------------------------------------------------- */

.dc-button {
	display: inline-block;
	margin: 0;
	padding: 10px 18px;
	border: 1px solid transparent;
	border-radius: var( --dc-radius );
	background: transparent;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.dc-button--primary {
	background: var( --dc-accent );
	border-color: var( --dc-accent );
	color: var( --dc-accent-fg );
}

.dc-button--primary:hover,
.dc-button--primary:focus {
	background: var( --dc-accent-hover );
	border-color: var( --dc-accent-hover );
	color: var( --dc-accent-fg );
}

.dc-button--secondary {
	background: transparent;
	border-color: var( --dc-border );
	color: var( --dc-fg );
}

.dc-button--secondary:hover,
.dc-button--secondary:focus {
	border-color: var( --dc-accent );
	color: var( --dc-accent );
}

/*
 * Accept/reject/preferences colours, configurable per role. Each falls
 * back to the shared --dc-accent(-fg)/--dc-fg pair above when not
 * configured, so a site that sets none of these looks byte-identical to
 * one that predates this feature. Deliberately layered ON TOP of
 * .dc-button--primary/--secondary rather than replacing them: those two
 * classes are what keeps Accept and Reject the same size, weight and
 * position (CLAUDE.md section 44 - refusal never smaller, paler or
 * further away than acceptance). Colour is the only thing this layer can
 * change; an administrator cannot use it to make Reject less prominent.
 */
.dc-button--accept {
	background: var( --dc-accept-bg, var( --dc-accent ) );
	border-color: var( --dc-accept-bg, var( --dc-accent ) );
	color: var( --dc-accept-fg, var( --dc-accent-fg ) );
}

.dc-button--reject {
	background: var( --dc-reject-bg, var( --dc-accent ) );
	border-color: var( --dc-reject-bg, var( --dc-accent ) );
	color: var( --dc-reject-fg, var( --dc-accent-fg ) );
}

.dc-button--preferences {
	background: var( --dc-prefs-bg, transparent );
	color: var( --dc-prefs-fg, var( --dc-fg ) );
}

.dc-inline-button {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.dc-banner :focus-visible,
.dc-modal :focus-visible,
.dc-embed :focus-visible,
.dc-inline-button:focus-visible {
	outline: 2px solid var( --dc-accent, #1f5c46 );
	outline-offset: 2px;
}

/* --------------------------------------------------------------------- *
 * Preferences dialog
 * --------------------------------------------------------------------- */

.dc-modal {
	display: none;
}

.dc-modal.is-open {
	display: flex;
	position: fixed;
	z-index: 999999;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.dc-modal__backdrop {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba( 15, 20, 25, 0.55 );
}

.dc-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 620px;
	max-height: 86vh;
	background: var( --dc-bg );
	border-radius: var( --dc-radius );
	box-shadow: 0 8px 40px rgba( 0, 0, 0, 0.3 );
	overflow: hidden;
}

.dc-modal__dialog:focus {
	outline: none;
}

.dc-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var( --dc-gap );
	padding: 18px 20px;
	border-bottom: 1px solid var( --dc-border );
}

.dc-modal__title {
	margin: 0;
	padding: 0;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
}

.dc-modal__close {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var( --dc-radius );
	background: transparent;
	color: var( --dc-muted );
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.dc-modal__close:hover,
.dc-modal__close:focus {
	border-color: var( --dc-border );
	color: var( --dc-fg );
}

.dc-modal__body {
	padding: 20px;
	overflow-y: auto;
}

.dc-modal__intro {
	margin: 0 0 18px;
	color: var( --dc-muted );
}

.dc-category {
	padding: 14px 0;
	border-bottom: 1px solid var( --dc-border );
}

.dc-category:first-of-type {
	padding-top: 0;
}

.dc-category__row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	cursor: pointer;
}

.dc-category--required .dc-category__row {
	justify-content: space-between;
	cursor: default;
}

.dc-category__input {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin: 0;
	cursor: pointer;
}

.dc-category__name {
	font-weight: 600;
}

.dc-category__state {
	color: var( --dc-muted );
	font-size: 13px;
}

.dc-category__description {
	margin: 6px 0 0;
	color: var( --dc-muted );
	font-size: 14px;
}

.dc-modal__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding-top: 20px;
}

.dc-modal-open {
	overflow: hidden;
}

/* --------------------------------------------------------------------- *
 * Blocked embed placeholder
 *
 * Stands in for a third-party iframe that has not been consented to. It
 * borrows the original width and height where the markup declared them, so
 * replacing it with the real embed moves the page as little as possible.
 * --------------------------------------------------------------------- */

.dc-embed {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 180px;
	padding: 20px;
	border: 1px solid var( --dc-border );
	border-radius: var( --dc-radius );
	background: #f4f6f8;
	text-align: center;
}

.dc-embed__inner {
	max-width: 28rem;
}

.dc-embed__title {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 600;
	color: var( --dc-fg );
}

.dc-embed__text {
	margin: 0 0 14px;
	font-size: 14px;
	color: var( --dc-muted );
}

.dc-embed__note {
	margin: 10px 0 0;
	font-size: 12px;
	color: var( --dc-muted );
}

/* --------------------------------------------------------------------- *
 * Small screens
 * --------------------------------------------------------------------- */

@media screen and ( max-width: 640px ) {
	.dc-banner__inner {
		flex-direction: column;
		align-items: stretch;
		padding: 16px;
	}

	/*
	 * The flex basis above is a width for the row layout. Once the banner
	 * stacks it would be read as a height and leave a large empty gap, so it
	 * is reset here.
	 */
	.dc-banner__content {
		flex: 0 1 auto;
	}

	.dc-banner__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.dc-button {
		width: 100%;
	}

	.dc-modal.is-open {
		padding: 0;
		align-items: flex-end;
	}

	.dc-modal__dialog {
		max-width: none;
		max-height: 92vh;
		border-radius: var( --dc-radius ) var( --dc-radius ) 0 0;
	}

	.dc-modal__actions {
		flex-direction: column;
	}

	.dc-embed {
		min-height: 150px;
		padding: 16px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.dc-banner,
	.dc-modal,
	.dc-embed,
	.dc-banner *,
	.dc-modal *,
	.dc-embed * {
		animation: none !important;
		transition: none !important;
	}
}
