/*
 * Contact section: the Contact widget (inc/elementor/contact-widget.php) and Elementor Pro's Form widget
 * in one container with the class kl-contact-band. From 1024px the two share one grid cell: the widget
 * fills it with the ground and the map, and the form panel lies over its right side. Below that they
 * stack, with the map between the channels and the form.
 *
 * Without .is-ready (no JavaScript) the map is fully drawn and the pin in place.
 * The form panel takes its colours from the page's light tokens, as it is outside the widget's data-theme.
 * Selectors are multiplied where the Elementor Kit styles headings, links, fields and buttons.
 */

.kl-contact-band {
	/* Height of the clear stretch of map at the foot of the section */
	--kl-band: clamp(320px, 30vw, 480px);
	background: var(--burgundy);
}
.kl-contact-band:has(.kl-contact[data-theme="dark"]) { background: var(--ink); }
.kl-contact-band:has(.kl-contact--tint) { background: var(--bg-alt); }

.kl-contact {
	--kl-rail: 32px;
	--kl-rail-x: 8px;
	--kl-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	--kl-ground: var(--bg);
	--kl-map: var(--rule);
	position: relative;
	height: 100%;
	padding: var(--space-7) 0 var(--kl-band, 320px);
	overflow: clip;
	container-type: inline-size;
	background: var(--kl-ground);
	color: var(--fg);
}
/* Warm tint: paper ground, the map in burgundy, the form panel in white */
.kl-contact--tint[data-theme] { --kl-ground: var(--bg-alt); --kl-map: var(--accent); --rule: var(--eyebrow); background: var(--kl-ground); }
.kl-contact-band:has(.kl-contact--tint) .elementor-widget-form { background: var(--bg); }

.kl-contact__inner {
	position: relative;
	z-index: 2;
	max-width: var(--wrap-max);
	margin-inline: auto;
	padding-inline: var(--gutter);
}
.kl-contact__aside { padding-left: var(--kl-rail); }

/* ---------- The map ---------- */

.kl-contact__map,
.kl-contact__pin { --kl-plan-w: max(100cqw, 1100px); }

.kl-contact__map {
	position: absolute;
	inset: 0;
	pointer-events: none;
	/* Clear at the foot, barely there behind the text */
	-webkit-mask-image: linear-gradient(to top, #000 var(--kl-band, 320px), rgba(0, 0, 0, 0.08) calc(var(--kl-band, 320px) + 200px));
	mask-image: linear-gradient(to top, #000 var(--kl-band, 320px), rgba(0, 0, 0, 0.08) calc(var(--kl-band, 320px) + 200px));
}
.kl-contact__plan {
	position: absolute;
	left: 50%;
	bottom: 0;
	display: block;
	width: var(--kl-plan-w);
	max-width: none;
	height: auto;
	transform: translateX(-50%);
	overflow: visible;
}

.kl-contact__road { fill: none; stroke: var(--kl-map); stroke-linecap: round; stroke-linejoin: round; }
.kl-contact__road--minor { stroke-width: 1; stroke-opacity: 0.42; }
.kl-contact__road--major { stroke-width: 2; stroke-opacity: 0.8; }
.kl-contact__road--coast { stroke-width: 2.5; stroke-opacity: 0.7; }

/* The plan engraves itself, the main roads first */
.kl-contact.is-ready .kl-contact__road { stroke-dasharray: 1; stroke-dashoffset: 1; }
.kl-contact.is-drawn .kl-contact__road { stroke-dashoffset: 0; transition: stroke-dashoffset 3.2s var(--kl-ease); }
.kl-contact.is-drawn .kl-contact__road--minor { transition-duration: 4s; transition-delay: 0.4s; }

.kl-contact__street {
	fill: var(--fg);
	font-family: var(--font-serif);
	font-size: 17px;
	font-weight: 600;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	stroke: var(--kl-ground);
	stroke-width: 6px;
	stroke-linejoin: round;
	paint-order: stroke;
}
.kl-contact.is-ready .kl-contact__street { opacity: 0; }
.kl-contact.is-drawn .kl-contact__street { opacity: 0.85; transition: opacity 1.4s ease 1.6s; }

/* The light: a soft glow with the buildings inside it, only where the pointer is */
.kl-contact__buildings { fill: var(--kl-map); fill-opacity: 0.55; }
.kl-contact__plan--light { opacity: 0.35; }
.kl-contact.is-ready .kl-contact__plan--light {
	opacity: 0;
	background: radial-gradient(circle 240px at var(--kl-lx, 50%) var(--kl-ly, 50%), color-mix(in srgb, var(--kl-map) 20%, transparent), transparent);
	-webkit-mask-image: radial-gradient(circle 240px at var(--kl-lx, 50%) var(--kl-ly, 50%), #000 35%, transparent);
	mask-image: radial-gradient(circle 240px at var(--kl-lx, 50%) var(--kl-ly, 50%), #000 35%, transparent);
	transition: opacity 0.5s ease;
}
.kl-contact.is-ready .kl-contact__plan--light.is-on { opacity: 1; }
@media (hover: none) {
	.kl-contact.is-ready.is-drawn .kl-contact__plan--light { opacity: 0.35; background: none; -webkit-mask-image: none; mask-image: none; transition: opacity 2s ease 2s; }
}

/* ---------- The pin ---------- */

.kl-contact__pin {
	position: absolute;
	z-index: 3;
	left: 50%;
	bottom: calc(var(--kl-plan-w) * 0.15); /* (1000 - 760) / 1600 of the plan: see scripts/build-contact-plan.mjs */
	width: 0;
	height: 0;
}
.kl-contact__mark { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; transform: rotate(45deg); }
.kl-contact__mark i { position: absolute; inset: 0; }
.kl-contact__mark i:first-child { background: var(--accent); }
.kl-contact__mark i:last-child { border: 1.5px solid var(--accent); }

.kl-contact.is-ready:not(.is-arrived) .kl-contact__mark { transform: rotate(45deg) scale(0); }
.kl-contact.is-ready .kl-contact__mark { transition: transform 0.7s cubic-bezier(0.34, 1.7, 0.64, 1); }
.kl-contact.is-arrived .kl-contact__mark i:last-child { animation: kl-contact-ping 2.8s ease-out 0.6s infinite; }
@keyframes kl-contact-ping {
	from { transform: scale(1); opacity: 0.9; }
	to { transform: scale(3.4); opacity: 0; }
}

/* The name flag rises from the pin when the thread lands on it */
.kl-contact.kl-contact .kl-contact__flag {
	position: absolute;
	left: 0;
	bottom: 26px;
	display: grid;
	gap: 2px;
	width: max-content;
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--rule);
	background: var(--kl-ground);
	color: var(--fg);
	font-size: var(--type-caption-size);
	line-height: 1.3;
	text-decoration: none;
	transform: translateX(-50%);
	transition: background 0.3s ease, color 0.3s ease, opacity 0.8s ease 0.3s, translate 0.8s var(--kl-ease) 0.3s;
}
.kl-contact.is-ready:not(.is-arrived) .kl-contact__flag { opacity: 0; translate: 0 12px; pointer-events: none; }
.kl-contact.kl-contact .kl-contact__flag:hover,
.kl-contact.kl-contact .kl-contact__flag:focus-visible { background: var(--accent); color: var(--on-accent); }
.kl-contact__flag strong { font-size: 17px; font-weight: 500; }
.kl-contact__flag span {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}
.kl-contact__flag svg { width: 14px; height: 14px; }

.kl-contact .kl-contact__credit {
	position: absolute;
	z-index: 3;
	right: var(--space-3);
	bottom: var(--space-2);
	margin: 0;
	color: var(--fg-muted);
	font-size: 12px;
}
.kl-contact.kl-contact .kl-contact__credit a { color: inherit; }

/* ---------- Thread ---------- */

.kl-contact__thread { display: none; }
.kl-contact.is-ready .kl-contact__thread {
	display: block;
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
	max-width: none;
	overflow: visible;
	pointer-events: none;
}
.kl-contact__line { fill: none; stroke-width: 2; }
.kl-contact__node { fill: var(--kl-ground); stroke: var(--rule); stroke-width: 1.5; transition: fill 0.4s linear; }
.kl-contact__node.is-passed { fill: var(--rule); }
.kl-contact__tip { fill: var(--accent); }

/* ---------- Head and channels ---------- */

.kl-contact .kl-contact__eyebrow {
	margin: 0 0 var(--space-3);
	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;
}
.kl-contact .kl-contact__title {
	max-width: 12em;
	margin: 0;
	color: var(--heading);
	font-family: var(--font-serif);
	font-size: clamp(34px, 4.4vw, 60px);
	line-height: 1.06;
}
.kl-contact .kl-contact__text { max-width: 28em; margin: var(--space-4) 0 0; color: var(--fg); }

.kl-contact__channels { margin: var(--space-5) 0 0; padding: 0; list-style: none; }
.kl-contact__channel {
	display: grid;
	gap: var(--space-1);
	justify-items: start;
	padding: var(--space-3) 0;
}
.kl-contact .kl-contact__label {
	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;
}
.kl-contact .kl-contact__value {
	margin: 0;
	color: var(--fg);
	font-family: var(--font-serif);
	font-size: clamp(21px, 2vw, 26px);
	font-style: normal;
	font-weight: 500;
	line-height: 1.25;
	font-variant-numeric: lining-nums;
	overflow-wrap: anywhere;
	transition: opacity 0.8s linear, translate 0.8s var(--kl-ease);
}
.kl-contact .kl-contact__value--big { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.1; }
/* A row comes up to full strength when the thread reaches it */
.kl-contact.is-ready .kl-contact__channel:not(.is-passed) .kl-contact__value { opacity: 0.45; translate: 8px 0; }

.kl-contact.kl-contact .kl-contact__link {
	color: var(--fg);
	text-decoration: none;
	background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 0 1px;
	transition: background-size 0.45s var(--kl-ease), color 0.3s ease, opacity 0.8s linear, translate 0.8s var(--kl-ease);
}
.kl-contact.kl-contact .kl-contact__link:hover,
.kl-contact.kl-contact .kl-contact__link:focus-visible { color: var(--accent-hover); background-size: 100% 1px; }

.kl-contact .kl-contact__clock {
	position: relative;
	margin: 0;
	padding-left: 16px;
	color: var(--fg-muted);
	font-size: var(--type-caption-size);
	line-height: var(--type-caption-line);
	font-variant-numeric: lining-nums tabular-nums;
}
.kl-contact__clock:empty { display: none; }
/* A filled diamond when the office is open, an empty one when it is not */
.kl-contact__clock::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.5em;
	width: 7px;
	height: 7px;
	border: 1.5px solid var(--accent);
	transform: rotate(45deg);
}
.kl-contact__clock[data-open="1"]::before { background: var(--accent); }

/* Social: square icons that fill from the left, like the buttons */
.kl-contact__social { display: flex; gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.kl-contact.kl-contact .kl-contact__icon {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--border-strong);
	/* A ground of its own, so the streets of the map do not run through the icons */
	background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 0 / 0 100%, var(--kl-ground);
	color: var(--accent);
	transition: background-size 0.45s var(--kl-ease), color 0.3s ease;
}
.kl-contact.kl-contact .kl-contact__icon:hover,
.kl-contact.kl-contact .kl-contact__icon:focus-visible { background-size: 100% 100%, auto; color: var(--on-accent); }

/* ---------- The form panel: Elementor Pro's Form widget ---------- */

.kl-contact-band.kl-contact-band .elementor-widget-form {
	position: relative;
	z-index: 2;
	margin: var(--space-3) var(--space-4) var(--space-7) calc(var(--space-3) + 32px);
	padding: clamp(28px, 4vw, 52px);
	background: var(--bg-alt);
	color: var(--fg);
}
/* The double frame of the shield */
.kl-contact-band .elementor-widget-form::before,
.kl-contact-band .elementor-widget-form::after {
	content: "";
	position: absolute;
	border: 1px solid var(--rule);
	pointer-events: none;
}
.kl-contact-band .elementor-widget-form::before { inset: 8px; }
.kl-contact-band .elementor-widget-form::after { inset: -9px; }

/* The fields, consent, button and messages also dress the enquiry dialog's form (enquiry.css).
   Tripled so they beat Elementor's form CSS whichever loads first. */
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-label {
	margin-bottom: var(--space-1);
	color: var(--eyebrow);
	font-family: var(--font-serif);
	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;
}
/* A line, and a darker one that draws across it on focus */
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-textual {
	min-height: 0;
	padding: 6px 0 8px;
	border: 0;
	border-bottom: 1px solid var(--border-strong);
	border-radius: var(--radius-none);
	background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 0 2px;
	background-color: transparent !important; /* Over the white the Form widget sets in its own styles */
	box-shadow: none;
	color: var(--fg);
	font-family: var(--font-serif);
	font-size: 19px;
	line-height: 1.4;
	transition: background-size 0.5s var(--kl-ease);
}
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-textual:focus {
	background-size: 100% 2px;
	/* The drawn line is the focus mark; no box around the field */
	outline: none;
	box-shadow: none;
}
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) textarea.elementor-field-textual { resize: vertical; }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-select-wrapper { background: transparent; }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-select-wrapper::before { color: var(--accent); font-size: 14px; }

/* The consent field's label is for the email only; the visitor reads the sentence beside the box */
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-type-acceptance > .elementor-field-label { display: none; }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-type-acceptance .elementor-field-option { display: flex; gap: var(--space-2); align-items: flex-start; }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-type-acceptance input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-field-type-acceptance label {
	margin: 0;
	color: var(--fg-muted);
	font-family: var(--font-serif);
	font-size: var(--type-caption-size);
	line-height: 1.5;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

/* The site's one button style (base.css, .btn), with the arrow */
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-3);
	min-height: 54px;
	padding: 0 28px;
	border: 2px solid var(--accent);
	border-radius: var(--radius-none);
	background: var(--accent) linear-gradient(var(--accent-hover), var(--accent-hover)) no-repeat 0 0 / 0 100%;
	color: var(--on-accent);
	font-family: var(--font-serif);
	font-size: var(--type-button-size);
	line-height: var(--type-button-line);
	font-weight: var(--type-button-weight);
	letter-spacing: var(--type-button-tracking);
	text-transform: uppercase;
	cursor: pointer;
	transition: background-size 0.45s var(--kl-ease), border-color 0.3s ease;
}
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-button:hover,
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-button:focus-visible { background-size: 100% 100%; border-color: var(--accent-hover); color: var(--on-accent); }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-button::after {
	content: "";
	width: 18px;
	height: 18px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h15m-5-5 5 5-5 5' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h15m-5-5 5 5-5 5' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 0.3s ease;
}
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-button:hover::after { transform: translateX(4px); }

:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-message { margin-top: var(--space-3); font-family: var(--font-serif); font-size: 17px; }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-message-success { color: var(--heading); }
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-message-danger,
:is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry):is(.kl-contact-band, .kl-enquiry) .elementor-error .elementor-message { color: var(--accent); }

/* ---------- From 1024px: one cell, with the form over the right side ---------- */

@media (min-width: 1024px) {
	.kl-contact-band.kl-contact-band { display: grid; grid-template-columns: minmax(0, 1fr); }
	.kl-contact-band > .elementor-widget-katslaw-contact { grid-area: 1 / 1; width: 100%; height: 100%; align-self: stretch; }
	.kl-contact-band.kl-contact-band > .elementor-widget-form {
		grid-area: 1 / 1;
		justify-self: end;
		align-self: start;
		width: min(47%, 640px);
		/* The foot of the form stays clear of the map; a taller form makes the section taller */
		margin: var(--space-8) max(var(--gutter), calc((100% - var(--wrap-max)) / 2 + var(--gutter))) calc(var(--kl-band) + var(--space-3)) 0;
	}
	.kl-contact { --kl-rail: 48px; --kl-rail-x: 10px; padding-top: var(--space-8); }
	.kl-contact__aside { max-width: 46%; }
	.kl-contact .kl-contact__credit { right: var(--gutter); }
}

@media (prefers-reduced-motion: reduce) {
	.kl-contact *,
	.kl-contact *::before,
	.kl-contact *::after {
		animation-duration: 0.01ms !important;
		animation-delay: 0s !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		transition-delay: 0s !important;
	}
}
