/**
 * Draper Landing Door Survey
 *
 * The blueprint has two layouts driven by one DOM. Above the breakpoint,
 * .dds-blueprint__fields is absolutely positioned over the drawing and each
 * input sits exactly on its callout box. Below it, the same fields become a
 * plain labelled list and the drawing turns into a scrollable reference.
 */

.dds {
	--dds-accent: #1f6fb2;
	--dds-line: #c9ccd1;
	--dds-ink: #1c1c1c;
	--dds-muted: #5b6067;
	--dds-fill: rgba(31, 111, 178, 0.12);
	--dds-err: #b32d2e;

	color: var(--dds-ink);
	max-width: 1080px;

	/* The landing pages suppress the theme's page title, which is what normally
	   opens up space under the header — without this the form title sits right
	   against it. */
	margin: clamp(1.75rem, 4vw, 3rem) auto 0;
}

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

.dds-title {
	margin: 0 0 0.15em;
	font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);
	line-height: 1.2;
}

.dds-code {
	display: inline-block;
	margin-left: 0.4em;
	padding: 0.1em 0.5em;
	border: 1px solid var(--dds-line);
	border-radius: 3px;
	font-size: 0.6em;
	vertical-align: middle;
	color: var(--dds-muted);
	letter-spacing: 0.08em;
}

.dds-sub {
	margin: 0 0 1.75rem;
	color: var(--dds-muted);
	text-transform: uppercase;
	letter-spacing: 0.09em;
	font-size: 0.78rem;
}

/* ------------------------------------------------------------- sections --- */

.dds-section {
	margin: 0 0 1.75rem;
	padding: 1.25rem 1.25rem 1.4rem;
	border: 1px solid var(--dds-line);
	border-radius: 5px;
}

.dds-section > legend {
	padding: 0 0.5em;
	margin-left: -0.5em;
	font-weight: 700;
	font-size: 1.02rem;
}

.dds-hint {
	margin: 0 0 1rem;
	color: var(--dds-muted);
	font-size: 0.9rem;
	line-height: 1.5;
}

.dds-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 1rem 1.25rem;
}

.dds-field {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.dds-field--wide,
.dds-field--textarea {
	grid-column: 1 / -1;
}

.dds-field label,
.dds-section > legend,
.dds-field > legend {
	font-weight: 600;
	font-size: 0.9rem;
}

.dds-desc {
	color: var(--dds-muted);
	font-size: 0.83rem;
	line-height: 1.45;
}

/*
 * The note under a radio group. Italic to match the paper sheet, which also
 * underlines "Note:" — not copied, because underlined text that is not a link
 * reads as a broken link on the web. Bold carries the same emphasis.
 */
.dds-desc--note {
	display: block;
	margin-top: 0.5rem;
	font-style: italic;
}

.dds-req {
	color: var(--dds-err);
}

.dds input[type="text"],
.dds input[type="email"],
.dds input[type="tel"],
.dds input[type="file"],
.dds textarea {
	width: 100%;
	padding: 0.55rem 0.65rem;
	border: 1px solid var(--dds-line);
	border-radius: 4px;
	font: inherit;
	font-size: 0.95rem;
	color: inherit;
	background: #fff;
}

.dds textarea {
	resize: vertical;
}

.dds input:focus-visible,
.dds textarea:focus-visible,
.dds button:focus-visible {
	outline: 3px solid var(--dds-accent);
	outline-offset: 1px;
}

/* --------------------------------------------------------------- radios --- */

.dds-field--radio {
	border: 0;
	padding: 0;
	margin: 0;
	grid-column: 1 / -1;
}

.dds-field--radio > legend {
	padding: 0;
	margin-bottom: 0.5rem;
}

.dds-opt {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.15rem 0.6rem;
	align-items: start;
	padding: 0.4rem 0;
	font-weight: 400;
	cursor: pointer;
}

.dds-opt input {
	margin-top: 0.2rem;
}

.dds-opt__label {
	font-weight: 600;
	font-size: 0.92rem;
}

.dds-opt__hint {
	grid-column: 2;
	color: var(--dds-muted);
	font-size: 0.83rem;
	line-height: 1.45;
}

.dds-modes {
	background: #fafbfc;
}

.dds-mode {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-right: 1.5rem;
	cursor: pointer;
	font-size: 0.95rem;
}

/* ------------------------------------------------------------ blueprint --- */

.dds-blueprint {
	position: relative;
	margin: 0 0 1rem;
}

.dds-blueprint__stage {
	aspect-ratio: var(--dds-ratio, 1.1);
	background: #fff;
	border: 1px solid var(--dds-line);
	border-radius: 4px;
	overflow: hidden;
}

.dds-blueprint__canvas {
	position: relative;
	width: 100%;
	height: 100%;
}

.dds-blueprint__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Reference letters, pinned to the drawing at every screen width. */
.dds-blueprint__markers {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.dds-marker {
	position: absolute;
	left: var(--l);
	top: var(--t);
	transform: translateY(-100%);
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	color: var(--dds-accent);
	background: #fff;
	padding: 1px 2px;
	border-radius: 2px;
}

.dds-blueprint__fields {
	position: absolute;
	inset: 0;
}

.dds-f {
	position: absolute;
	left: var(--l);
	top: var(--t);
	width: var(--w);
	height: var(--h);
	margin: 0;
}

.dds-f input[type="text"] {
	width: 100%;
	height: 100%;
	padding: 0 2px;
	border: 0;
	border-radius: 2px;
	background: var(--dds-fill);
	text-align: center;
	font-size: clamp(9px, 0.85vw, 13px);
	line-height: 1;
}

.dds-f--checkbox input {
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
	accent-color: var(--dds-accent);
}

/* The printed label is on the drawing already, so on desktop only the
   reference letter shows; the text stays for screen readers. */
.dds-f__text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* On the overlay the drawing's own marker layer shows the letter, so the copy
   carried in each label is for the list layout only. */
.dds-f__ref {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.dds-f:focus-within {
	z-index: 2;
}

.dds-f input[type="text"]:focus-visible {
	outline: 2px solid var(--dds-accent);
	outline-offset: 0;
	background: #fff;
}

/* ----------------------------------------------------------- drawing key -- */

.dds-legend {
	margin: 0 0 0.5rem;
	padding: 0.85rem 1rem;
	border: 1px solid var(--dds-line);
	border-radius: 4px;
	background: #fafbfc;
}

.dds-legend__title {
	margin: 0 0 0.5rem;
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--dds-muted);
}

.dds-legend dl {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 0.25rem 1.25rem;
	margin: 0;
}

.dds-legend__row {
	display: flex;
	gap: 0.5rem;
	font-size: 0.85rem;
}

.dds-legend dt {
	font-weight: 700;
	color: var(--dds-accent);
	min-width: 1.2em;
}

.dds-legend dd {
	margin: 0;
	color: var(--dds-muted);
}

/* -------------------------------------------------------------- notices --- */

.dds-notice {
	margin: 0 0 1.5rem;
	padding: 1rem 1.15rem;
	border-radius: 4px;
	border-left: 4px solid;
}

.dds-notice p {
	margin: 0;
}

.dds-notice ul {
	margin: 0.5rem 0 0;
	padding-left: 1.25rem;
}

.dds-notice--ok {
	border-color: #2b7a3d;
	background: #eef7f0;
}

.dds-notice--err {
	border-color: var(--dds-err);
	background: #fdf0f0;
}

.dds-error {
	color: var(--dds-err);
}

/* -------------------------------------------------------------- actions --- */

.dds-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
}

.dds-submit,
.dds-reset {
	font: inherit;
	font-weight: 700;
	padding: 0.7rem 1.6rem;
	border-radius: 4px;
	cursor: pointer;
	border: 1px solid var(--dds-accent);
}

.dds-submit {
	background: var(--dds-accent);
	color: #fff;
}

.dds-submit:hover {
	background: #185c95;
}

.dds-reset {
	background: transparent;
	color: var(--dds-accent);
}

.dds-reset:hover {
	background: var(--dds-fill);
}

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.dds-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ------------------------------------------------------------- narrow ----- */

@media (max-width: 900px) {
	.dds-blueprint__stage {
		aspect-ratio: auto;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	/* Wider than the viewport so the drawing stays legible; the stage scrolls.
	   The canvas matches, so the marker layer scrolls with the drawing and the
	   letters stay on their boxes. */
	.dds-blueprint__canvas {
		width: 720px;
		height: auto;
	}

	.dds-blueprint__img {
		width: 720px;
		max-width: none;
		height: auto;
	}

	.dds-marker {
		font-size: 11px;
	}

	.dds-blueprint__fields {
		position: static;
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
		gap: 0.85rem 1.25rem;
		margin-top: 1.25rem;
	}

	.dds-f {
		position: static;
		width: auto;
		height: auto;
		display: flex;
		flex-direction: column-reverse;
		gap: 0.3rem;
	}

	.dds-f input[type="text"] {
		height: auto;
		padding: 0.5rem 0.6rem;
		border: 1px solid var(--dds-line);
		background: #fff;
		text-align: left;
		font-size: 0.95rem;
	}

	.dds-f--checkbox {
		flex-direction: row-reverse;
		align-items: center;
		justify-content: flex-end;
		gap: 0.5rem;
	}

	.dds-f--checkbox input {
		width: 1.15rem;
		height: 1.15rem;
		flex: none;
	}

	/* In list mode the text label carries the meaning, so reveal it. */
	.dds-f__text {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		overflow: visible;
		clip: auto;
		clip-path: none;
		white-space: normal;
		font-weight: 600;
		font-size: 0.88rem;
	}

	/* Un-hide the letter in the list so it can be matched against the drawing. */
	.dds-f__ref {
		position: static;
		display: inline-block;
		width: auto;
		height: auto;
		padding: 0;
		margin: 0 0.35rem 0 0;
		overflow: visible;
		clip: auto;
		clip-path: none;
		white-space: nowrap;
		font-size: 0.78rem;
		font-weight: 700;
		color: var(--dds-accent);
	}

	.dds-f label {
		display: flex;
		align-items: baseline;
	}
}

@media print {
	.dds-actions,
	.dds-modes {
		display: none;
	}
}
