/*
 * consent.css — the cookie consent dialog.
 * Contents: 1 dialog shell · 2 header band · 3 body and text · 4 category
 * choices · 5 buttons · 6 phones · 7 print.
 *
 * Loaded by inc/assets.php as "synergi-consent", on every page, depending on
 * "synergi-base". Markup: parts/consent.php. Behaviour:
 * assets/js/parts/consent.js.
 */

/* ==========================================================================
   1. Dialog shell
   Modal, below centre (14 Sep, on request). The browser puts a
   modal dialog in the top layer, above the fixed header, so nothing here
   needs a z-index.
   ========================================================================== */

.syn-consent {
	/* 36rem is the narrowest width that keeps all three buttons on one row with
	   their labels unbroken. */
	inline-size: min(100% - 2 * var(--syn-gutter), 36rem);
	/* The user agent caps a dialog's size with its own margins; these replace
	   them with the theme's. */
	max-inline-size: none;
	/*
	 * Positioning that cannot stretch. The browser places a modal dialog with
	 * inset: 0 plus margin: auto, which only works while the engine also sizes
	 * it to its content. iPhone Safari did not (reported 14 Sep with a
	 * screenshot: the card ran almost the full screen height, and the spare
	 * height showed up as gaps between title, text and buttons). Desktop
	 * WebKit and Chrome both behaved, so no test here caught it.
	 *
	 * With the end inset auto, a fixed box's height can only come from its
	 * content. Its middle sits at 64% of the screen — below centre, as asked
	 * (58% on 14 Sep, then "a little bit lower") — and translate pulls it up
	 * by half its own height. The height cap is the matching 72%
	 * (64 + 72 / 2 = 100), so even the tallest state, with the choices open,
	 * never runs off the bottom edge; past that the body scrolls. Move the two
	 * numbers together. translate, not transform, so the entrance animation's
	 * transform composes with it instead of replacing it.
	 */
	inset-block: 64% auto;
	block-size: auto;
	/* dvh is the visible screen between Safari's bars; % is the fallback. */
	max-block-size: calc(72% - 2 * var(--syn-space-3));
	max-block-size: calc(72dvh - 2 * var(--syn-space-3));
	margin-block: 0;
	margin-inline: auto;
	translate: 0 -50%;
	padding: 0;
	/* Clips the header band to the rounded corners. The body scrolls, not this. */
	overflow: hidden;
	border: 0;
	border-radius: var(--syn-radius-lg);
	background-color: var(--syn-white);
	box-shadow: var(--syn-shadow-soft);
	color: var(--syn-text);
}

/*
 * display is set only while open. On the bare class it would beat the user
 * agent's dialog:not([open]) { display: none } and show the dialog to every
 * visitor with JavaScript off.
 */
.syn-consent[open] {
	display: flex;
	flex-direction: column;
	animation: syn-consent-in var(--syn-duration) var(--syn-ease-out);
}

/*
 * The dialog takes focus itself on a first visit (tabindex, see the part),
 * so a screen reader starts at the title. It is a container, not a control:
 * the focus ring belongs on the buttons and boxes inside it, which keep theirs
 * (CLAUDE.md §9).
 */
.syn-consent:focus-visible {
	outline: none;
}

/*
 * Older browsers do not pass custom properties into ::backdrop, so there the
 * page behind is simply not dimmed. The dialog still works.
 */
.syn-consent::backdrop {
	background-color: color-mix(in srgb, var(--syn-ink) 60%, transparent);
}

/* The page behind stays still while the dialog is open. Set by consent.js. */
.syn-consent-open {
	overflow: hidden;
}

/*
 * The hidden attribute loses to any display value set by a class, and the
 * fieldset and the buttons both set one. This gives hidden its meaning back
 * without !important.
 */
.syn-consent [hidden] {
	display: none;
}

@keyframes syn-consent-in {

	from {
		opacity: 0;
		transform: translateY(1rem);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   2. Header band
   Navy deep with a cyan rule beneath — the site's own footer and scrolled
   header colour, so the dialog reads as part of Synergi rather than a
   third-party widget. White on navy deep measures well above 4.5:1.
   ========================================================================== */

.syn-consent__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: var(--syn-space-2);
	padding-block: var(--syn-space-3);
	padding-inline: var(--syn-space-5);
	border-block-end: 3px solid var(--syn-cyan);
	background-color: var(--syn-navy-deep);
}

.syn-consent__icon {
	display: grid;
	flex: 0 0 auto;
	inline-size: 2.25rem;
	block-size: 2.25rem;
	place-items: center;
	border-radius: 50%;
	background-color: color-mix(in srgb, var(--syn-white) 12%, transparent);
	color: var(--syn-mint);
}

.syn-consent__icon svg {
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

.syn-consent__title {
	color: var(--syn-white);
	font-size: var(--syn-step-0);
	font-weight: 700;
	line-height: 1.3;
}

/* ==========================================================================
   3. Body and text
   ========================================================================== */

.syn-consent__body {
	display: grid;
	/* Rows packed at the top: a grid otherwise shares spare height out
	   between its rows, which is how gaps appear. */
	align-content: start;
	flex: 1 1 auto;
	gap: var(--syn-space-3);
	min-block-size: 0;
	padding: var(--syn-space-5);
	overflow-y: auto;
}

.syn-consent__text {
	font-size: var(--syn-step--1);
	line-height: 1.6;
}

.syn-consent__text a {
	color: var(--syn-navy);
	font-weight: 600;
}

/* ==========================================================================
   4. Category choices
   ========================================================================== */

.syn-consent__choices {
	display: grid;
	gap: var(--syn-space-2);
	margin: 0;
	padding: 0;
	border: 0;
}

.syn-consent__option {
	display: flex;
	align-items: flex-start;
	gap: var(--syn-space-2);
	padding: var(--syn-space-2) var(--syn-space-3);
	border-radius: var(--syn-radius-md);
	background-color: var(--syn-paper);
	font-size: var(--syn-step--1);
	line-height: 1.45;
}

.syn-consent__option input {
	flex: 0 0 auto;
	inline-size: 1.15rem;
	block-size: 1.15rem;
	margin-block: 0.15rem 0;
	margin-inline: 0;
	accent-color: var(--syn-navy);
}

.syn-consent__option label {
	display: grid;
	gap: 0.1rem;
}

.syn-consent__option strong {
	color: var(--syn-ink);
}

/* Text soft on paper measures above the 4.5:1 floor. */
.syn-consent__option span {
	color: var(--syn-text-soft);
}

/* ==========================================================================
   5. Buttons
   Plain rectangular buttons, not the brand's .syn-button (14 Sep, on request):
   a consent dialog should read as a standard question, not as a call to
   action. Every button shares one row and one width, so no choice looks like
   the expected one.
   ========================================================================== */

.syn-consent__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--syn-space-2);
	padding-block-start: var(--syn-space-1);
}

.syn-consent__button {
	display: inline-flex;
	flex: 1 1 8.5rem;
	min-block-size: 2.75rem;
	align-items: center;
	justify-content: center;
	padding-block: 0.6rem;
	padding-inline: var(--syn-space-2);
	border: 1px solid var(--syn-navy);
	border-radius: var(--syn-radius-sm);
	font-size: var(--syn-step--1);
	font-weight: 600;
	line-height: 1.2;
	/* A label never breaks inside its button; a button that no longer fits
	   moves to the next row whole, via the row's flex-wrap. */
	white-space: nowrap;
	cursor: pointer;
	transition:
		background-color var(--syn-duration-fast),
		border-color var(--syn-duration-fast),
		color var(--syn-duration-fast);
}

.syn-consent__button--solid {
	background-color: var(--syn-navy);
	color: var(--syn-white);
}

.syn-consent__button--solid:hover {
	border-color: var(--syn-navy-deep);
	background-color: var(--syn-navy-deep);
}

.syn-consent__button--outline {
	background-color: var(--syn-white);
	color: var(--syn-navy);
}

.syn-consent__button--outline:hover {
	background-color: var(--syn-paper-blue);
}

/* ==========================================================================
   6. Phones
   A compact card: less padding, tighter rows, and the buttons stacked at full
   width instead of two side by side with a third hanging below.

   Last in the file on purpose. These rules have the same specificity as the
   ones they adjust, so they only win by coming after them — placed earlier
   they lost, and flex: 1 1 8.5rem, which is a width in a row, became an
   8.5rem HEIGHT per button once the row turned into a column.
   ========================================================================== */

@media (max-width: 47.99rem) {

	.syn-consent {
		border-radius: var(--syn-radius-md);
	}

	.syn-consent__header {
		padding-block: var(--syn-space-2);
		padding-inline: var(--syn-space-3);
	}

	.syn-consent__icon {
		inline-size: 2rem;
		block-size: 2rem;
	}

	/* Text to buttons stays tight: this 0.5rem plus the actions row's own
	   0.5rem lead-in. */
	.syn-consent__body {
		gap: var(--syn-space-1);
		padding: var(--syn-space-3);
	}

	.syn-consent__text {
		line-height: 1.5;
	}

	.syn-consent__option {
		padding: var(--syn-space-1) var(--syn-space-2);
		line-height: 1.35;
	}

	.syn-consent__actions {
		flex-direction: column;
		gap: var(--syn-space-1);
	}

	.syn-consent__button {
		flex: 0 0 auto;
		min-block-size: 2.6rem;
	}
}

/* ==========================================================================
   7. Print
   ========================================================================== */

@media print {

	/* [open] to match the rule that shows it, or that rule wins on specificity. */
	.syn-consent[open] {
		display: none;
	}
}
