/*
 * Quote form and the thank-you block (inc/quote-form.php), and the withdrawal function (inc/withdrawal.php,
 * the .dg-wd block at the end: it reuses the container, the fields, the alert and the honeypot below).
 * Composes the shared primitives from components.css (dg-field, dg-input, dg-chips, dg-btn, dg-steps, dg-specs)
 * and adds only the step layout, the model card and the inquiry summary.
 * Tokens only; the one literal colour is the error red already used in components.css.
 */

/* Container: a white card, so it reads the same on a light page and inside a dark warm section ---- */

.dg-quote {
	box-sizing: border-box;
	width: 100%;
	max-width: 760px;
	margin-inline: auto;
	padding: clamp(20px, 4vw, 36px);
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius-lg);
	background: var(--dg-white);
	color: var(--dg-text);
	font-size: 1rem;
}

/* Inside the page card (.dg-formcard, pages module) the form drops its own card: one border, one padding. */
.dg-formcard > .dg-quote,
.dg-formcard .dg-quote {
	max-width: none;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.dg-quote .dg-title,
.dg-quote .dg-quote__head {
	color: var(--dg-ink);
}

.dg-quote a:not(.dg-btn) {
	color: var(--dg-ink);
	text-decoration-color: var(--dg-accent);
	text-underline-offset: 3px;
}

.dg-quote__form {
	position: relative;
	display: grid;
	gap: var(--dg-space-6);
	counter-reset: dgq-step;
}

/* Form-level notice (expired form, too many inquiries, fields to check) --------------------------- */

.dg-quote__alert {
	padding: var(--dg-space-4);
	border-radius: var(--dg-radius);
	background: color-mix(in srgb, #b42318 8%, var(--dg-white));
	box-shadow: inset 4px 0 0 #b42318;
	color: var(--dg-ink);
	font-weight: 600;
}

.dg-quote__alert p {
	margin: 0;
}

.dg-quote__alert p + p {
	margin-block-start: var(--dg-space-2);
}

.dg-quote__alert a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

/* Steps ------------------------------------------------------------------------------------------ */

.dg-quote__step {
	display: grid;
	gap: var(--dg-space-5);
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.dg-quote__head {
	display: flex;
	align-items: center;
	gap: var(--dg-space-3);
	margin: 0;
	font-size: var(--dg-fs-lg);
	font-weight: 700;
	line-height: 1.25;
}

.dg-quote__head::before {
	content: counter(dgq-step);
	counter-increment: dgq-step;
	display: grid;
	flex: none;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--dg-accent);
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	font-weight: 700;
}

.dg-quote__row {
	display: grid;
	gap: var(--dg-space-5);
	align-items: start;
}

.dg-quote .dg-field {
	align-content: start;
}

@media (min-width: 560px) {
	.dg-quote__row--2 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Collapsible details ---------------------------------------------------------------------------- */

.dg-quote__more {
	display: block;
	border-block: 1px solid var(--dg-line);
}

.dg-quote__more > summary {
	position: relative;
	min-height: var(--dg-tap);
	padding: var(--dg-space-4) 44px var(--dg-space-4) 0;
	cursor: pointer;
	list-style: none;
}

.dg-quote__more > summary::-webkit-details-marker {
	display: none;
}

.dg-quote__more > summary::after {
	content: "";
	position: absolute;
	inset-inline-end: 4px;
	top: 50%;
	width: 24px;
	height: 24px;
	margin-top: -12px;
	border-radius: 50%;
	/* The plus sign is two gradient bars in the text colour, on a soft disc. */
	background:
		linear-gradient(currentcolor, currentcolor) center / 12px 2px no-repeat,
		linear-gradient(currentcolor, currentcolor) center / 2px 12px no-repeat,
		var(--dg-bg-soft);
	transition: transform 200ms var(--dg-ease);
}

.dg-quote__more[open] > summary::after {
	transform: rotate(45deg);
}

.dg-quote__more > summary:focus-visible {
	outline: none;
	border-radius: 6px;
	box-shadow: var(--dg-focus);
}

.dg-quote__more-body {
	display: grid;
	gap: var(--dg-space-5);
	padding-block: var(--dg-space-2) var(--dg-space-5);
}

/* Groups of chips -------------------------------------------------------------------------------- */

.dg-quote__group {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.dg-quote__group > legend {
	margin: 0 0 6px;
	padding: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	font-weight: 600;
}

.dg-quote .dg-req {
	color: var(--dg-accent-hover);
}

.dg-quote__group.is-invalid .dg-chip span {
	border-color: #b42318;
}

.dg-quote__group .dg-field__error,
.dg-quote .dg-field__error {
	display: block;
	margin-block-start: 6px;
	font-size: var(--dg-fs-sm);
}

/* An empty slot stays out of the layout (the display rule above would otherwise beat the hidden attribute). */
.dg-quote__group .dg-field__error[hidden],
.dg-quote .dg-field__error[hidden] {
	display: none;
}

.dg-quote .dg-field__hint {
	font-size: var(--dg-fs-sm);
}

/* The chips are tinted for dark sections in components.css; here they always sit on white. */
.dg-quote .dg-chip span {
	border-color: var(--dg-line);
	background: var(--dg-white);
	color: var(--dg-ink);
}

.dg-quote .dg-chip input:hover + span {
	border-color: var(--dg-ink);
}

.dg-quote .dg-chip input:checked + span {
	border-color: var(--dg-accent);
	background: color-mix(in srgb, var(--dg-accent) 14%, var(--dg-white));
}

/* Model card ------------------------------------------------------------------------------------- */

.dg-quote__model {
	display: flex;
	align-items: center;
	gap: var(--dg-space-3);
	padding: var(--dg-space-3);
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius);
	background: var(--dg-bg-soft);
}

.dg-quote__model img {
	flex: none;
	width: 64px;
	height: 64px;
	border-radius: 6px;
	background: var(--dg-white);
	object-fit: contain;
}

.dg-quote__model > div {
	display: grid;
	min-width: 0;
}

.dg-quote__model-label {
	color: var(--dg-muted);
	font-size: var(--dg-fs-sm);
}

.dg-quote__model strong {
	color: var(--dg-ink);
	font-size: var(--dg-fs-md);
	overflow-wrap: anywhere;
}

/* Consent and submit ----------------------------------------------------------------------------- */

.dg-quote .dg-check {
	min-height: 44px;
	padding-block: 6px;
	font-size: var(--dg-fs-sm);
}

/* The wrapper is a .dg-field, so components.css bolds its label: the consent sentence is body text. */
.dg-quote__consent > .dg-check {
	color: var(--dg-text);
	font-weight: 400;
}

.dg-quote__consent.is-invalid .dg-check input {
	outline: 2px solid #b42318;
	outline-offset: 2px;
}

/* The note sits beside the button only when the form itself has room for both (the form can be a narrow column). */
.dg-quote__submit {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--dg-space-3) var(--dg-space-5);
	margin-block-start: var(--dg-space-2);
}

.dg-quote__submit .dg-btn {
	width: 100%;
}

.dg-quote__note,
.dg-quote__legend {
	margin: 0;
	color: var(--dg-muted);
	font-size: var(--dg-fs-sm);
}

.dg-quote__submit .dg-quote__note {
	flex: 1 1 20ch;
}

@media (min-width: 560px) {
	.dg-quote__submit .dg-btn {
		width: auto;
	}
}

.dg-quote__form[aria-busy="true"] .dg-btn {
	opacity: 0.6;
	pointer-events: none;
}

/* Honeypot: out of sight for people and screen readers, present for bots ------------------------- */

.dg-quote__hp {
	position: absolute !important;
	inset-inline-start: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Thank-you block -------------------------------------------------------------------------------- */

.dg-quote-done {
	display: grid;
	gap: var(--dg-space-6);
	max-width: var(--dg-wrap);
}

.dg-quote-done__actions {
	display: grid;
	gap: var(--dg-space-3);
}

.dg-quote-done__actions .dg-btn {
	width: 100%;
}

@media (min-width: 560px) {
	.dg-quote-done__actions {
		grid-template-columns: repeat(2, max-content);
		gap: var(--dg-space-4);
	}

	.dg-quote-done__actions .dg-btn {
		width: auto;
	}
}

.dg-quote-done__summary {
	max-width: 560px;
}

.dg-quote-done--empty {
	justify-items: start;
}

.dg-quote-done .dg-icon {
	width: 20px;
	height: 20px;
}

/* Withdrawal function: the button, then a white panel with the form, the summary or the receipt ------ */

/* The button needs no card around it: the panel brings its own card. */
.dg-quote.dg-wd {
	max-width: none;
	margin-inline: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.dg-wd__open {
	display: block;
}

/* The native disclosure is the button; its marker is hidden in every engine. */
.dg-wd__toggle {
	box-sizing: border-box;
	width: 100%;
	list-style: none;
}

.dg-wd__toggle::-webkit-details-marker {
	display: none;
}

.dg-wd__panel {
	display: grid;
	gap: var(--dg-space-5);
	box-sizing: border-box;
	max-width: 760px;
	margin-block-start: var(--dg-space-5);
	padding: clamp(20px, 4vw, 36px);
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius-lg);
	background: var(--dg-white);
	color: var(--dg-text);
}

/* The summary and the receipt are the whole block: no gap above the panel. */
.dg-wd > .dg-wd__panel {
	margin-block-start: 0;
}

.dg-wd__panel p {
	margin: 0;
}

.dg-wd__panel .dg-card__title {
	margin: 0;
	color: var(--dg-ink);
}

/* Label above value: the name, the products and the reason are free text of any length. */
.dg-wd .dg-specs > div {
	grid-template-columns: minmax(0, 1fr);
	gap: 2px;
}

.dg-wd .dg-specs dd {
	text-align: start;
	overflow-wrap: anywhere;
}

/* The statement the customer is about to confirm, and the one that was received. */
.dg-wd__statement {
	padding: var(--dg-space-4);
	border-radius: var(--dg-radius);
	background: var(--dg-bg-soft);
	box-shadow: inset 4px 0 0 var(--dg-accent);
	color: var(--dg-ink);
	overflow-wrap: anywhere;
}

.dg-wd__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--dg-space-3) var(--dg-space-5);
}

.dg-wd__actions .dg-btn {
	width: 100%;
}

@media (min-width: 560px) {
	.dg-wd__toggle,
	.dg-wd__actions .dg-btn {
		width: auto;
	}
}

/* Reduced motion ---------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.dg-quote__more > summary::after {
		transition: none;
	}
}
