/*
 * Enquiry drawer (inc/enquiry.php, assets/js/enquiry.js). It slides in from the left edge, full
 * height: the burgundy column with the shield, title and phone on the left, the form on cream on the
 * right. As it opens, the gold thread draws down its right edge, the burgundy side's lines come in one
 * after the other, then the fields; a soft light follows the cursor over the burgundy. Under 900px
 * the burgundy goes on top. The fields themselves are styled in contact.css, shared with the Contact
 * section.
 */

.kl-enquiry {
	--kl-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	--kl-pad: clamp(24px, 4vw, 56px);
	--kl-w: min(100%, 1120px);
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--fg);
	overflow: hidden;
}
.kl-enquiry:not([open]) { display: none; }

.kl-enquiry::backdrop {
	background: rgb(35 31 32 / 0.6);
	backdrop-filter: blur(0);
	opacity: 0;
	transition: opacity 0.5s ease, backdrop-filter 0.6s ease;
}
.kl-enquiry.is-shown::backdrop { opacity: 1; backdrop-filter: blur(4px); }

.kl-enquiry__panel {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	/* Rows as tall as their content: the clipped burgundy side would otherwise be squeezed */
	grid-auto-rows: max-content;
	align-content: start;
	width: var(--kl-w);
	height: 100%;
	background: var(--bg-alt);
	box-shadow: 30px 0 80px -30px rgb(35 31 32 / 0.55);
	overflow-y: auto;
	overscroll-behavior: contain;
	translate: -100% 0;
	transition: translate 0.7s var(--kl-ease);
}
.kl-enquiry.is-shown .kl-enquiry__panel { translate: 0 0; }
.kl-enquiry__panel:focus { outline: none; }
.kl-enquiry:not(.is-shown) .kl-enquiry__panel { transition-duration: 0.5s; }

/* The thread: a gold line down the drawer's right edge, beside the panel so it never scrolls away */
.kl-enquiry__thread {
	position: absolute;
	top: 0;
	left: calc(var(--kl-w) - 3px);
	width: 3px;
	height: 100%;
	background: var(--gold);
	transform: scaleY(0);
	transform-origin: 50% 0;
	translate: calc(-1 * var(--kl-w)) 0;
	transition: translate 0.7s var(--kl-ease), transform 1.1s var(--kl-ease) 0.4s;
	pointer-events: none;
}
.kl-enquiry.is-shown .kl-enquiry__thread { translate: 0 0; transform: scaleY(1); }
.kl-enquiry:not(.is-shown) .kl-enquiry__thread { transition: translate 0.5s var(--kl-ease), transform 0.2s ease; }

/* ---------- Burgundy column ---------- */

.kl-enquiry__aside {
	position: relative;
	overflow: hidden;
	padding: var(--kl-pad);
	padding-top: calc(var(--kl-pad) + 12px);
	isolation: isolate;
}

/* A soft light that follows the cursor (position set by enquiry.js) */
.kl-enquiry__light {
	position: absolute;
	z-index: -1;
	inset: 0;
	background: radial-gradient(420px circle at var(--mx, 30%) var(--my, 25%), rgb(217 168 117 / 0.16), transparent 65%);
	opacity: 0;
	transition: opacity 0.8s ease 0.5s;
	pointer-events: none;
}
.kl-enquiry.is-shown .kl-enquiry__light { opacity: 1; }

/* The shield, large and faint, rising into the corner */
.kl-enquiry__mark {
	position: absolute;
	z-index: -1;
	right: -70px;
	bottom: -60px;
	width: 300px;
	height: auto;
	opacity: 0;
	filter: grayscale(1) brightness(2);
	translate: 0 60px;
	rotate: -6deg;
	transition: opacity 1.2s ease 0.5s, translate 1.6s var(--kl-ease) 0.4s;
	pointer-events: none;
}
.kl-enquiry.is-shown .kl-enquiry__mark { opacity: 0.04; translate: 0 0; }

.kl-enquiry__intro { display: flex; flex-direction: column; gap: var(--space-3); }
.kl-enquiry__shield { width: 52px; height: auto; margin-bottom: var(--space-3); }
.kl-enquiry__eyebrow {
	margin: 0;
	color: var(--eyebrow);
	font-size: var(--type-eyebrow-size);
	line-height: var(--type-eyebrow-line);
	font-weight: var(--type-eyebrow-weight);
	letter-spacing: var(--type-eyebrow-tracking);
	text-transform: uppercase;
}
/* Doubled up against the Elementor Kit's h2, a and button colours */
.kl-enquiry .kl-enquiry__title {
	margin: 0;
	color: var(--heading);
	font-size: clamp(30px, 3.4vw, 44px);
	line-height: 1.08;
}
.kl-enquiry__lead { margin: 0; max-width: 34ch; color: var(--fg); font-size: 18px; line-height: 1.55; }
.kl-enquiry__alt {
	display: grid;
	gap: 2px;
	margin: auto 0 0;
	padding-top: var(--space-5);
	color: var(--fg-muted);
	font-size: var(--type-caption-size);
	line-height: 1.5;
}
.kl-enquiry .kl-enquiry__alt a {
	justify-self: start;
	background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
	color: var(--accent);
	font-size: 24px;
	text-decoration: none;
	transition: background-size 0.45s var(--kl-ease);
}
.kl-enquiry .kl-enquiry__alt a:hover { background-size: 100% 1px; color: var(--accent); }

/* The burgundy side's lines come in one after another */
.kl-enquiry__intro > * {
	opacity: 0;
	translate: -14px 0;
	transition: opacity 0.6s ease, translate 0.8s var(--kl-ease);
}
.kl-enquiry.is-shown .kl-enquiry__intro > * { opacity: 1; translate: 0 0; }
.kl-enquiry.is-shown .kl-enquiry__intro > :nth-child(1) { transition-delay: 0.3s; }
.kl-enquiry.is-shown .kl-enquiry__intro > :nth-child(2) { transition-delay: 0.38s; }
.kl-enquiry.is-shown .kl-enquiry__intro > :nth-child(3) { transition-delay: 0.46s; }
.kl-enquiry.is-shown .kl-enquiry__intro > :nth-child(4) { transition-delay: 0.54s; }
.kl-enquiry.is-shown .kl-enquiry__intro > :nth-child(5) { transition-delay: 0.7s; }

/* The title's short gold rule draws out after the title */
.kl-enquiry .kl-enquiry__title::after { transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.8s var(--kl-ease); }
.kl-enquiry.is-shown .kl-enquiry__title::after { transform: scaleX(1); transition-delay: 0.75s; }

/* ---------- Close: a word and a thin cross ---------- */

.kl-enquiry .kl-enquiry__close {
	position: absolute;
	z-index: 3;
	top: 16px;
	right: 20px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 0 8px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--gold);
	font-family: var(--font-serif);
	font-size: var(--type-eyebrow-size);
	font-weight: var(--type-eyebrow-weight);
	letter-spacing: var(--type-eyebrow-tracking);
	text-transform: uppercase;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.4s ease;
}
.kl-enquiry.is-shown .kl-enquiry__close { opacity: 1; transition-delay: 0.5s; }
.kl-enquiry__close-text {
	background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
	padding-bottom: 2px;
	transition: background-size 0.4s var(--kl-ease);
}
.kl-enquiry__close-x { position: relative; width: 16px; height: 16px; transition: rotate 0.5s var(--kl-ease); }
.kl-enquiry__close-x::before,
.kl-enquiry__close-x::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	width: 100%;
	height: 1px;
	background: currentColor;
	rotate: 45deg;
}
.kl-enquiry__close-x::after { rotate: -45deg; }
.kl-enquiry .kl-enquiry__close:hover,
.kl-enquiry .kl-enquiry__close:focus-visible { background: transparent; color: var(--gold); }
.kl-enquiry .kl-enquiry__close:hover .kl-enquiry__close-text,
.kl-enquiry .kl-enquiry__close:focus-visible .kl-enquiry__close-text { background-size: 100% 1px; }
.kl-enquiry .kl-enquiry__close:hover .kl-enquiry__close-x { rotate: 90deg; }
.kl-enquiry .kl-enquiry__close:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }

/* ---------- Form ---------- */

.kl-enquiry__body { padding: var(--kl-pad); padding-top: calc(var(--kl-pad) + 36px); }
.kl-enquiry__body .e-con { --padding-top: 0; --padding-right: 0; --padding-bottom: 0; --padding-left: 0; }
.kl-enquiry .elementor-field-textual::placeholder { color: var(--fg-muted); opacity: 0.7; font-size: 17px; }

/* The fields rise in one after another (--i set by enquiry.js) */
.kl-enquiry .elementor-form .elementor-field-group {
	opacity: 0;
	translate: 0 16px;
	transition: opacity 0.5s ease, translate 0.7s var(--kl-ease);
}
.kl-enquiry.is-shown .elementor-form .elementor-field-group {
	opacity: 1;
	translate: 0 0;
	transition-delay: calc(0.45s + var(--i, 0) * 50ms);
}

/* "I am writing as": three choices side by side, the chosen one filled from the left like the buttons */
.kl-enquiry .elementor-field-type-radio .elementor-field-subgroup { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.kl-enquiry .elementor-field-type-radio .elementor-field-option { position: relative; margin: 0; }
.kl-enquiry .elementor-field-type-radio input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}
.kl-enquiry.kl-enquiry .elementor-field-type-radio .elementor-field-option label {
	display: inline-block;
	margin: 0;
	padding: 8px 16px;
	border: 1px solid var(--border-strong);
	background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 0 / 0 100%;
	color: var(--fg);
	font-family: var(--font-serif);
	font-size: 17px;
	line-height: 1.3;
	transition: background-size 0.45s var(--kl-ease), color 0.3s ease, border-color 0.3s ease;
}
.kl-enquiry.kl-enquiry .elementor-field-type-radio .elementor-field-option input:hover + label { border-color: var(--accent); }
.kl-enquiry.kl-enquiry .elementor-field-type-radio .elementor-field-option input:checked + label { background-size: 100% 100%; border-color: var(--accent); color: var(--on-accent); }
.kl-enquiry.kl-enquiry .elementor-field-type-radio .elementor-field-option input:focus-visible + label { outline: 1px solid var(--accent); outline-offset: 3px; }

/* Page behind the drawer stays put */
html:has(.kl-enquiry[open]) { overflow: hidden; }

/* ---------- Side by side from 900px ---------- */

@media (min-width: 900px) {
	.kl-enquiry__panel { grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.5fr); }
	/* The burgundy column stays in place while the form scrolls */
	.kl-enquiry__aside { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; }
	.kl-enquiry__intro { height: 100%; }
	.kl-enquiry .kl-enquiry__close { color: var(--accent); }
	.kl-enquiry .kl-enquiry__close:hover,
	.kl-enquiry .kl-enquiry__close:focus-visible { color: var(--accent); }
}

@media (max-width: 899px) {
	.kl-enquiry__aside { padding-top: 64px; }
	.kl-enquiry__shield { display: none; }
	.kl-enquiry__mark { width: 200px; right: -50px; bottom: -80px; }
	.kl-enquiry__alt { padding-top: var(--space-2); }
	.kl-enquiry__body { padding-top: var(--kl-pad); }
}
@media (max-width: 599px) {
	.kl-enquiry__thread { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.kl-enquiry::backdrop,
	.kl-enquiry *,
	.kl-enquiry *::after { transition: none !important; }
}
