/* Montgomery Systems */

:root {
	color-scheme: light;

	--paper: #F5F0E6;
	--paper-2: #FBF8F1;
	--ink: #1F1A17;
	--ink-2: #5C534B;
	--brand: #A3201E;
	--brand-dark: #7E1816;
	--accent: #34508F;
	--line: #E4DCCB;
	--field: #CFC5B3;
	--highlight: #F3D9A4;
	--focus: var(--accent);

	--serif: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, Georgia, serif;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	--step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
	--step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
	--step-1: clamp(1.2rem, 1.1rem + 0.5vw, 1.45rem);
	--step-2: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
	--step-3: clamp(1.75rem, 1.4rem + 1.75vw, 2.6rem);
	--step-4: clamp(2rem, 1.5rem + 2.5vw, 3.25rem);
	--step-5: clamp(2.25rem, 1.5rem + 3.75vw, 4.25rem);

	--content: 72rem;
	--gutter: clamp(1rem, 4vw, 2.5rem);
	--bleed: max(var(--gutter), (100% - var(--content)) / 2);
	--section-gap: clamp(3rem, 8vw, 6rem);
	--radius: 0.5rem;
}

/* Base */

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

html {
	text-size-adjust: 100%;
	-webkit-text-size-adjust: 100%;
	scroll-padding-block-start: 7rem;

	@media (prefers-reduced-motion: no-preference) {
		scroll-behavior: smooth;
	}
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--sans);
	font-size: var(--step-0);
	line-height: 1.6;
}

:where(h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote, details, address) {
	margin: 0;
}

/* Vertical rhythm inside page content; containers tune it with --flow. */
:where(main) :where(section, li, details, hgroup, figure, div) > * + * {
	margin-block-start: var(--flow, 1em);
}

:where(main section) > :is(h2, h3):not(:first-child) {
	margin-block-start: 1.75em;
}

h1, h2, h3 {
	font-family: var(--serif);
	font-weight: 700;
	line-height: 1.15;
	text-wrap: balance;

	b {
		color: var(--brand);
	}
}

h1 {
	font-size: var(--step-5);
}

h2 {
	font-size: var(--step-3);
}

h3 {
	font-size: var(--step-1);
}

p, li {
	text-wrap: pretty;
}

a {
	color: var(--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;

	&:hover {
		color: var(--brand);
		text-decoration-thickness: 2px;
	}
}

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

img {
	max-inline-size: 100%;
	block-size: auto;
}

u {
	text-decoration-color: var(--brand);
	text-decoration-thickness: 0.12em;
	text-underline-offset: 0.12em;
	text-decoration-skip-ink: none;
}

mark {
	padding-inline: 0.2em;
	border-radius: 0.2em;
	background: var(--highlight);
	color: inherit;
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
}

small, figcaption {
	color: var(--ink-2);
	font-size: var(--step--1);
}

dfn {
	font-style: normal;
	font-weight: 700;
}

details {
	padding-inline: 1.25rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--paper-2);
	--flow: 0.75em;

	& + details {
		margin-block-start: 0.75rem;
	}

	&[open] {
		padding-block-end: 1.25rem;

		summary::after {
			rotate: 45deg;
		}
	}

	> a {
		display: inline-block;
		margin-block-start: 0.75em;
	}

	summary {
		display: flex;
		justify-content: space-between;
		align-items: center;
		gap: 1rem;
		padding-block: 1rem;
		font-family: var(--serif);
		font-size: var(--step-1);
		font-weight: 700;
		list-style: none;
		cursor: pointer;

		&::-webkit-details-marker {
			display: none;
		}

		&::after {
			content: "+" / "";
			color: var(--brand);
			font-size: 1.5em;
			line-height: 1;
			transition: rotate 0.2s;
		}
	}
}

:is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="hidden"]), select, textarea) {
	inline-size: 100%;
	padding: 0.7em 0.9em;
	border: 1px solid var(--field);
	border-radius: 0.375rem;
	background: #fff;
	color: var(--ink);
	font: inherit;

	&::placeholder {
		color: var(--ink-2);
		opacity: 1;
	}

	&:focus-visible {
		border-color: var(--accent);
		outline-offset: 0;
	}
}

textarea {
	min-block-size: 8rem;
	resize: vertical;
}

input[type="checkbox"] {
	inline-size: 1.1em;
	block-size: 1.1em;
	margin: 0 0.4em 0 0;
	vertical-align: -0.15em;
	accent-color: var(--brand);
}

label:has(+ :is(input, select, textarea)) {
	display: block;
	margin-block-end: 0.35em;
	font-weight: 600;
}

fieldset {
	margin: 0;
	padding: 1rem 1.25rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);

	legend {
		padding-inline: 0.4em;
		font-weight: 600;
	}

	p + p {
		margin-block-start: 0.5em;
	}
}

.go-online-nav, [type="submit"], main button {
	display: inline-block;
	padding: 0.65em 1.3em;
	border: 0;
	border-radius: 0.375rem;
	background: var(--brand);
	color: var(--paper);
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.15s;

	&:hover {
		background: var(--brand-dark);
		color: var(--paper);
	}

	&[hidden] {
		display: none;
	}
}

.pilot-promo {
	display: inline-block;
	margin-inline-end: 0.4em;
	padding: 0.15em 0.65em;
	border-radius: 999px;
	background: var(--brand);
	color: var(--paper);
	font-size: 0.75em;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	vertical-align: 0.1em;
}

/* Promo banner */

#banner-promo {
	position: static;
	inline-size: auto;
	max-inline-size: none;
	margin: 0;
	padding: 0.6rem var(--bleed);
	border: 0;
	background: var(--ink);
	color: var(--paper);
	font-size: var(--step--1);
	--focus: var(--paper);

	&[open] {
		display: flex;
		align-items: center;
		gap: 1rem;
	}

	p {
		flex: 1;
		text-align: center;
	}

	a {
		display: block;
		inline-size: fit-content;
		margin-inline: auto;
		color: inherit;
		font-weight: 600;
	}

	button {
		padding: 0.1em 0.45em;
		border: 0;
		border-radius: 0.25rem;
		background: none;
		color: inherit;
		font-size: 1.5rem;
		line-height: 1;
		cursor: pointer;

		&:hover {
			background: rgb(255 255 255 / 0.12);
		}
	}
}

/* Site header */

body > header {
	position: sticky;
	inset-block-start: 0;
	z-index: 10;
	border-block-end: 1px solid var(--line);
	background: color-mix(in srgb, var(--paper) 92%, transparent);
	backdrop-filter: blur(8px);

	> div {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 0.75rem 2rem;
		padding: 0.75rem var(--bleed);
	}

	img {
		display: block;
		inline-size: auto;
		block-size: clamp(2.25rem, 1.75rem + 2vw, 3rem);
	}

	nav {
		margin-inline-start: auto;
	}

	ul {
		display: flex;
		gap: clamp(1rem, 2.5vw, 2rem);
		margin: 0;
		padding: 0;
		list-style: none;
	}

	nav a {
		color: var(--ink);
		font-weight: 500;
		text-decoration: none;

		&:hover, &[aria-current="page"] {
			color: var(--brand);
		}

		&[aria-current="page"] {
			text-decoration: underline 2px;
			text-underline-offset: 0.4em;
		}
	}

	@media (width < 56rem) {
		.go-online-nav {
			margin-inline-start: auto;
		}

		nav {
			order: 1;
			flex-basis: calc(100% + 2 * var(--gutter));
			margin-inline: calc(var(--gutter) * -1);
			padding: 0.5rem var(--gutter) 0;
			overflow-x: auto;
			border-block-start: 1px solid var(--line);
		}
	}
}

/* Page layout: a centred content column with an optional full-bleed track. */

main {
	display: grid;
	grid-template-columns:
		[full-start] minmax(var(--gutter), 1fr)
		[content-start] min(var(--content), 100% - 2 * var(--gutter))
		[content-end] minmax(var(--gutter), 1fr) [full-end];
	row-gap: var(--section-gap);
	padding-block: clamp(2.5rem, 6vw, 5rem) var(--section-gap);

	> * {
		grid-column: content;
	}

	/* Sections read at a comfortable measure unless they opt out. */
	> section {
		justify-self: center;
		inline-size: 100%;
		max-inline-size: 48rem;
	}

	/* A list whose items carry headings is a set of cards. */
	ul:has(> li > :is(h2, h3)) {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
		gap: 1.25rem;
		padding: 0;
		list-style: none;

		> li {
			padding: 1.5rem;
			border: 1px solid var(--line);
			border-block-start: 4px solid var(--brand);
			border-radius: var(--radius);
			background: var(--paper-2);
			transition: transform 0.2s, box-shadow 0.2s;
			--flow: 0.5em;

			/* transform, not translate, so the hover lift composes with the reveal animations. */
			&:hover {
				transform: translateY(-3px);
				box-shadow: 0 0.75rem 1.5rem -0.75rem rgb(31 26 23 / 0.25);
			}
		}

		p {
			color: var(--ink-2);
		}

		h2 {
			font-size: var(--step-2);
		}
	}

	form {
		display: grid;
		gap: 1rem;

		> * {
			margin: 0;
		}

		> [type="submit"] {
			justify-self: start;
		}
	}
}

#hero, #testimonials, #about-andrew, #subscribe {
	max-inline-size: none;
}

hgroup {
	--flow: 0.4em;

	> p {
		color: var(--ink-2);
		font-size: var(--step-1);
	}
}

main > hgroup {
	justify-self: center;
	max-inline-size: 56rem;
	text-align: center;
	--flow: 0.75em;

	> p {
		max-inline-size: 40rem;
		margin-inline: auto;
	}
}

#hero {
	grid-column: full;
	display: grid;
	grid-template-columns: subgrid;
	row-gap: clamp(2rem, 5vw, 3rem);
	margin-block-start: calc(var(--section-gap) * -0.4);

	> * {
		grid-column: content;
		margin-block: 0;
	}

	/* Offer band: the pilot promo and the primary CTA share one full-bleed strip. */
	> div {
		grid-column: full;
		display: grid;
		justify-items: center;
		gap: clamp(1.25rem, 3vw, 2rem);
		padding: clamp(2rem, 6vw, 3.5rem) var(--gutter);
		border-block: 4px double rgb(245 240 230 / 0.35);
		background: var(--brand);
		color: var(--paper);
		text-align: center;
		--focus: var(--paper);

		> * {
			margin: 0;
		}

		p {
			max-inline-size: 44rem;
			font-size: var(--step-1);
			line-height: 1.5;
		}

		.pilot-promo {
			display: table;
			margin: 0 auto 0.75rem;
			background: var(--paper);
			color: var(--brand);
		}

		p a {
			color: inherit;
			font-weight: 600;
		}
	}

	.go-online-button {
		display: inline-block;
		padding: 0.45em 1.2em;
		border-radius: var(--radius);
		background: var(--paper);
		box-shadow: 0 0.3rem 0 var(--brand-dark);
		color: var(--brand);
		font-family: var(--serif);
		font-size: min(var(--step-4), 7.5vw);
		font-weight: 700;
		line-height: 1.1;
		text-decoration: none;
		white-space: nowrap;
		transition: background-color 0.15s, translate 0.15s, box-shadow 0.15s;

		&::after {
			content: "\2192" / "";
			display: inline-block;
			margin-inline-start: 0.35em;
			transition: translate 0.2s;
		}

		&:hover {
			background: #fff;
			color: var(--brand);

			&::after {
				translate: 0.25em 0;
			}
		}

		&:active {
			translate: 0 0.2rem;
			box-shadow: 0 0.1rem 0 var(--brand-dark);
		}
	}
}

#promise {
	display: grid;
	gap: clamp(2rem, 4vw, 3rem);

	> * {
		margin-block: 0;
	}

	> * + * {
		padding-block-start: clamp(2rem, 4vw, 3rem);
		border-block-start: 1px solid var(--line);
	}

	hgroup > p {
		color: var(--brand);
		font-family: var(--serif);
		font-size: var(--step-2);
		font-style: italic;
		line-height: 1.25;
	}
}

#audit {
	justify-self: center;
	max-inline-size: 48rem;
	padding: clamp(1.5rem, 5vw, 3rem);
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--paper);
	text-align: center;
	--flow: 0.5em;
	--focus: var(--paper);

	h2 {
		color: inherit;
		font-size: var(--step-2);
	}

	a {
		color: inherit;
		font-weight: 600;
	}
}

#how-this-works {
	ol {
		margin-block: 2rem 0;
		padding: 0;
		list-style: none;
		counter-reset: step;
	}

	ol > li {
		position: relative;
		padding-inline-start: 4rem;
		padding-block-end: 2rem;
		counter-increment: step;
		--flow: 0.4em;

		&::before {
			content: counter(step);
			position: absolute;
			inset-inline-start: 0;
			inset-block-start: 0;
			display: grid;
			place-items: center;
			inline-size: 2.75rem;
			aspect-ratio: 1;
			border: 2px solid var(--accent);
			border-radius: 50%;
			background: var(--paper);
			color: var(--accent);
			font-family: var(--serif);
			font-size: var(--step-1);
			font-weight: 700;
		}

		&:not(:last-child)::after {
			content: "";
			position: absolute;
			inset-inline-start: calc(1.375rem - 1px);
			inset-block: 3.25rem 0.5rem;
			border-inline-start: 2px dotted var(--accent);
			opacity: 0.4;
		}
	}

	h3 {
		padding-block-start: 0.4rem;
	}

	mark {
		margin-inline-end: 0.3em;
		font-size: 0.75em;
		font-weight: 700;
		letter-spacing: 0.05em;
		text-transform: uppercase;
	}

	details:first-of-type {
		margin-block-start: 2rem;
	}
}

#testimonials {
	display: grid;
	justify-items: center;
	gap: 1.5rem clamp(2rem, 5vw, 4rem);
	padding: clamp(1.5rem, 5vw, 3.5rem);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--paper-2);

	> * {
		margin-block: 0;
	}

	h2 {
		grid-column: 1 / -1;
	}

	figure {
		--flow: 0.75em;
	}

	img {
		display: block;
		inline-size: clamp(8rem, 18vw, 12.5rem);
		aspect-ratio: 1;
		margin-inline: auto;
		border-radius: 50%;
		object-fit: cover;
		box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 5px var(--accent);
	}

	#eric {
		text-align: center;
	}

	blockquote {
		font-family: var(--serif);
		font-size: var(--step-2);
		line-height: 1.35;

		&::before {
			content: "\201C" / "";
			display: block;
			block-size: 0.5em;
			color: var(--brand);
			font-size: 3em;
			line-height: 1;
		}
	}

	@media (width >= 48rem) {
		grid-template-columns: auto 1fr;
		align-items: center;
		justify-items: start;
	}
}

#guarantee {
	padding: clamp(1.5rem, 5vw, 3rem);
	border: 4px double var(--accent);
	background: var(--paper-2);
	outline: 1px solid var(--accent);
	outline-offset: 6px;

	> h2 {
		text-align: center;
	}

	ul {
		padding-inline-start: 1.25rem;
	}

	li {
		margin-block-start: 0.4em;

		&::marker {
			color: var(--brand);
		}
	}
}

#about-andrew {
	display: grid;
	gap: 2rem clamp(2rem, 5vw, 4rem);
	align-items: center;

	> * {
		margin-block: 0;
	}

	figure {
		justify-self: center;
		max-inline-size: 18rem;
		text-align: center;
		--flow: 0.75em;
	}

	img {
		display: block;
		inline-size: 100%;
		border-radius: var(--radius);
	}

	@media (width >= 48rem) {
		grid-template-columns: 18rem 1fr;
	}
}

#subscribe {
	padding: clamp(1.5rem, 5vw, 3rem);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--paper-2);

	form > div {
		display: grid;
		gap: 1rem;

		> * {
			margin-block: 0;
		}

		@media (width >= 48rem) {
			grid-template-columns: 1fr 1fr auto;

			> :is(hgroup, p:has([type="checkbox"])) {
				grid-column: 1 / -1;
			}

			> p:has([type="checkbox"]) {
				order: 1;
			}
		}
	}

	hgroup {
		--flow: 0.3em;

		> p {
			font-size: var(--step-0);
		}

		> p:first-child {
			color: var(--brand);
			font-size: var(--step--1);
			font-weight: 700;
			letter-spacing: 0.1em;
			text-transform: uppercase;
		}
	}

	h2 {
		font-size: var(--step-3);
	}
}

#qualify ul {
	padding-inline-start: 1.75rem;
	list-style: "\2713\00A0\00A0";
	font-size: var(--step-1);

	li + li {
		margin-block-start: 0.4em;
	}

	li::marker {
		color: var(--brand);
		font-weight: 700;
	}
}

/* Site footer */

body > footer {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2.5rem 2rem;
	padding: clamp(3rem, 8vw, 5rem) var(--bleed) 2rem;
	background: var(--ink);
	color: #D9D1C3;
	font-size: var(--step--1);
	--focus: var(--paper);

	> div:first-child {
		grid-column: 1 / -1;

		> * + * {
			margin-block-start: 1.25rem;
		}

		img {
			display: block;
			inline-size: auto;
			block-size: 3.5rem;
		}

		p {
			max-inline-size: 24rem;
		}

		ul {
			display: flex;
			gap: 1.25rem;
		}
	}

	> div:last-child {
		grid-column: 1 / -1;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		align-items: center;
		gap: 1rem 2rem;
		padding-block-start: 2rem;
		border-block-start: 1px solid rgb(255 255 255 / 0.12);

		ul {
			display: flex;
			flex-wrap: wrap;
			gap: 0.5rem 1.5rem;
		}
	}

	h3 {
		margin-block-end: 1rem;
		color: #A99F90;
		font-family: var(--sans);
		font-size: 0.8rem;
		letter-spacing: 0.12em;
		text-transform: uppercase;
	}

	ul {
		display: grid;
		gap: 0.65rem;
		padding: 0;
		list-style: none;
	}

	a {
		color: var(--paper);
		text-decoration: none;

		&:hover {
			color: #E9685B;
			text-decoration: underline;
		}
	}

	address {
		font-style: normal;
	}

	dt {
		color: #A99F90;
		font-size: 0.8em;
	}

	dd + dt {
		margin-block-start: 0.65rem;
	}

	small {
		color: #A99F90;
		font-size: inherit;
	}

	> section:has(address) {
		grid-column: 1 / -1;
	}

	@media (width >= 48rem) {
		grid-template-columns: repeat(3, minmax(0, 1fr)) auto;

		> section:has(address) {
			grid-column: auto;
		}
	}

	@media (width >= 72rem) {
		grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)) auto;
		column-gap: 2.5rem;

		> div:first-child {
			grid-column: auto;
		}
	}
}

/* Motion */

@keyframes drop-in {
	from {
		opacity: 0;
		translate: 0 -1.25rem;
	}
}

@keyframes rise-in {
	from {
		opacity: 0;
		translate: 0 1.5rem;
	}
}

@media (prefers-reduced-motion: no-preference) {
	:root {
		interpolate-size: allow-keywords;
	}

	/*
	 * On load: the hero cards and offer band drop in, one after another. The banner, header, and
	 * headline paint immediately: if everything on the first screen starts transparent, Lighthouse
	 * and other crawlers can record no paint at all (NO_FCP) and score the page 0.
	 */
	#hero li, #hero > div {
		animation: drop-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) var(--delay, 0s) both;
	}

	#hero li {
		--delay: 0.1s;

		&:nth-child(2) {
			--delay: 0.2s;
		}

		&:nth-child(3) {
			--delay: 0.3s;
		}
	}

	#hero > div {
		--delay: 0.45s;
	}

	/* On scroll: everything below the fold rises in as it enters the viewport. */
	@supports (animation-timeline: view()) {
		main > section:not(#hero) > :not(ul:has(> li > :is(h2, h3))),
		main > section:not(#hero) ul:has(> li > :is(h2, h3)) > li {
			animation: rise-in linear both;
			animation-timeline: view();
			animation-range: entry 0% entry 60%;
		}

		main > section:not(#hero) ul:has(> li > :is(h2, h3)) > li {
			&:nth-child(3n + 2) {
				animation-range: entry 10% entry 70%;
			}

			&:nth-child(3n) {
				animation-range: entry 20% entry 80%;
			}
		}
	}

	details {
		&::details-content {
			block-size: 0;
			overflow: clip;
			transition: block-size 0.3s ease, content-visibility 0.3s allow-discrete;
		}

		&[open]::details-content {
			block-size: auto;
		}
	}
}
