/*
 * Interactive Masterplan
 *
 * Structure and neutral defaults only. Everything site-specific (colours, type,
 * buttons, legend and popup styling) is set per widget from its Style tab, which
 * writes either the custom properties below or the element's own properties.
 * Defaults lean on the four Elementor system globals every kit has.
 *
 * The lot popup is a native <dialog> opened with showModal(). It renders in the top
 * layer (so no ancestor overflow or transform clips it) but stays inside the widget
 * in the DOM, so {{WRAPPER}} selectors and the custom properties below still reach it.
 */

.interactive-masterplan {
	--im-primary: var(--e-global-color-primary, #333333);
	--im-text: var(--e-global-color-text, #333333);
	--im-inset: 10px;

	/* stage view panel and legend */
	--im-panel-bg: #ffffff;
	--im-legend-bg: #ffffff;
	--im-swatch-size: 1.25em;
	--im-legend-gap: 1.25em;

	/* status overlays drawn over the plan artwork */
	--im-fill-available-hover: rgba(46, 160, 67, .45);
	--im-fill-sold: rgba(200, 60, 50, .5);
	--im-fill-contract: rgba(235, 160, 50, .45);
	--im-fill-future: rgba(51, 51, 51, .45);

	/* legend swatches - set these to what the overlays look like on the plan */
	--im-swatch-available: #8fbf8a;
	--im-swatch-sold: #c8645a;
	--im-swatch-contract: #e0b35c;
	--im-swatch-future: #7a7a7a;

	/* masterplan stage shapes */
	--im-outline-color: #ffffff;
	--im-outline-width: 2px;
	--im-label-box: #ffffff;
	--im-label-text: var(--im-primary);

	overflow: hidden;
}

.lot-popup-information {
	--bl: 26px;
	--im-popup-bg: #ffffff;
	--im-popup-text: var(--e-global-color-text, #333333);
	--im-popup-heading: var(--e-global-color-primary, #333333);
	--im-popup-divider: var(--e-global-color-accent, currentColor);
	--im-popup-divider-width: 190px;
	--im-popup-divider-max-width: 70%; /* % of the lot name's width */
	--im-popup-close: var(--e-global-color-primary, #333333);
	--im-popup-close-hover: var(--e-global-color-accent, #333333);
	--im-popup-backdrop: rgba(0, 0, 0, .7);
	--im-popup-image-height: 220px;
	--im-popup-gap: calc(var(--bl) * 1.5); /* between the info and form columns, stacked or side by side */
	/* info column: the space below each item, and around the divider under the lot name */
	--im-popup-image-space: var(--bl);
	--im-popup-header-space: var(--bl);
	--im-popup-divider-above: 15px;
	--im-popup-divider-below: 15px;
	--im-popup-stat-space: 0px;
	/* where the divider sits; the Alignment control moves it with the text */
	--im-popup-divider-left: 50%;
	--im-popup-divider-shift: -50%;
}

@media (min-width: 1025px) {
	.interactive-masterplan {
		--im-inset: 20px;
	}
	.lot-popup-information {
		--im-popup-image-height: 260px;
	}
}


/* Layout */

.interactive-masterplan__inner {
	position: relative;
}

.interactive-masterplan .stage {
	position: relative;
	z-index: 2;
}

.interactive-masterplan .stage--stage {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 2;
	display: none;
	background-color: var(--im-panel-bg);
}
.interactive-masterplan[data-single-stage] .stage--stage {
	display: block;
	position: relative;
}

.interactive-masterplan .stage--masterplan {
	z-index: 1;
}

.interactive-masterplan .stage__inner {
	position: relative;
	z-index: 1;
}


/* Back to masterplan button - inherits the kit's button style unless the widget sets one */

.interactive-masterplan .back-to-master {
	position: absolute;
	z-index: 2;
	top: var(--im-inset);
	left: var(--im-inset);
}
.interactive-masterplan[data-single-stage] .back-to-master {
	display: none;
}

.interactive-masterplan .back-to-master .elementor-button {
	display: inline-flex;
	align-items: center;
	padding: 8px 16px;
	font-size: 13px;
	line-height: 1;
}
.interactive-masterplan .back-to-master .elementor-button-content-wrapper {
	display: inline-flex;
	align-items: center;
	gap: .4em;
}
.interactive-masterplan .back-to-master .elementor-button-icon svg {
	display: block;
}


/* Stage heading */

.interactive-masterplan .stage__heading {
	position: absolute;
	z-index: 2;
	top: var(--im-inset);
	right: var(--im-inset);
	margin: 0;
	padding: 6px 16px;
	text-align: center;
	background-color: #ffffff;
	color: var(--im-primary);
	font-family: var(--e-global-typography-primary-font-family), sans-serif;
	font-size: 18px;
	line-height: 1.2;
}

@media (min-width: 1025px) {
	.interactive-masterplan .stage__heading {
		right: auto;
		left: 50%;
		transform: translateX(-50%);
		padding: 8px 24px;
		font-size: 24px;
	}
}


/* Legend - placement (Top / Bottom / Absolute / None) comes from the widget's
   Content tab per view and breakpoint; Bottom is the fallback. Absolute reads
   the --im-legend-* edges, which the Vertical / Horizontal controls rewrite. */

.interactive-masterplan .legend {
	--im-legend-x: var(--im-inset);
	--im-legend-y: var(--im-inset);
	--im-legend-top: auto;
	--im-legend-bottom: var(--im-legend-y);
	--im-legend-left: var(--im-legend-x);
	--im-legend-right: auto;
	--im-legend-transform: none;

	position: relative;
	order: 1;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	row-gap: .5em;
	column-gap: var(--im-legend-gap);
	padding: 10px;
	background-color: var(--im-legend-bg);
	color: var(--im-text);
	z-index: 99;
	font-family: var(--e-global-typography-text-font-family), sans-serif;
	font-size: 11px;
	line-height: 1.2;
	text-transform: uppercase;
	letter-spacing: .05em;
}

@media (min-width: 768px) {
	.interactive-masterplan .legend {
		padding: 8px 14px;
		font-size: 12px;
	}
}
@media (min-width: 1025px) {
	.interactive-masterplan .legend {
		padding: 12px 18px;
		font-size: 14px;
	}
}

.interactive-masterplan .legend__item {
	display: inline-flex;
	align-items: center;
}

.interactive-masterplan .legend__item--color::before {
	content: '';
	display: inline-block;
	flex: 0 0 auto;
	width: var(--im-swatch-size);
	height: var(--im-swatch-size);
	margin-right: .5em;
	border-radius: 100px;
	background-color: currentColor;
}

.interactive-masterplan .legend__item--available::before { background-color: var(--im-swatch-available); }
.interactive-masterplan .legend__item--contract::before { background-color: var(--im-swatch-contract); }
.interactive-masterplan .legend__item--sold::before { background-color: var(--im-swatch-sold); }
.interactive-masterplan .legend__item--future::before { background-color: var(--im-swatch-future); }


/* Map - a column so the legend can sit above (order -1) or below (order 1) the plan */

.interactive-masterplan .stage__map {
	position: relative;
	display: flex;
	flex-direction: column;
}

.interactive-masterplan .stage__map__inner {
	/* space around the plan, e.g. to leave room for an absolute legend; the widget's
	   Map › Padding controls set these per view */
	--im-map-pad-top: 0px;
	--im-map-pad-right: 0px;
	--im-map-pad-bottom: 0px;
	--im-map-pad-left: 0px;

	position: relative;
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: var(--im-map-pad-top) var(--im-map-pad-right) var(--im-map-pad-bottom) var(--im-map-pad-left);
}

.interactive-masterplan .stage__map__image {
	position: relative;
	z-index: 1;
}
.interactive-masterplan .stage__map__image img {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
}

/* the overlay sits exactly over the image, inside the padding */
.interactive-masterplan .stage__map__svg {
	position: absolute;
	top: var(--im-map-pad-top);
	left: var(--im-map-pad-left);
	width: calc(100% - var(--im-map-pad-left) - var(--im-map-pad-right));
	height: calc(100% - var(--im-map-pad-top) - var(--im-map-pad-bottom));
	z-index: 2;
}

.interactive-masterplan .stage__map__svg svg {
	width: 100%;
	height: 100%;
	fill: transparent;
}

.interactive-masterplan .stage__map__svg g {
	fill: transparent;
}
.interactive-masterplan .stage__map__svg g:focus {
	outline: none;
}

.interactive-masterplan .stage__map__svg .lot-outlines,
.interactive-masterplan .stage__map__svg .stage-outlines {
	fill: transparent;
	transition: fill .3s;
}

.interactive-masterplan .stage__map__svg .stage-outlines,
.interactive-masterplan .stage__map__svg .stage-line {
	stroke: var(--im-outline-color);
	stroke-width: var(--im-outline-width);
}

.interactive-masterplan .stage__map__svg .stage-name-box {
	fill: var(--im-label-box);
}
.interactive-masterplan .stage__map__svg .stage-name-text {
	fill: var(--im-label-text);
}

.interactive-masterplan .stage__map__svg g[data-status="available"] {
	cursor: pointer;
}

.interactive-masterplan .stage__map__svg g[data-status="available"]:hover .lot-outlines,
.interactive-masterplan .stage__map__svg g[data-status="available"]:hover .stage-outlines {
	fill: var(--im-fill-available-hover);
}

.interactive-masterplan .stage__map__svg g[data-status="sold"] .lot-outlines,
.interactive-masterplan .stage__map__svg g[data-status="sold"] .stage-outlines {
	fill: var(--im-fill-sold);
}

.interactive-masterplan .stage__map__svg g[data-status="contract"] .lot-outlines,
.interactive-masterplan .stage__map__svg g[data-status="contract"] .stage-outlines {
	fill: var(--im-fill-contract);
}

.interactive-masterplan .stage__map__svg g[data-status="future"] .lot-outlines,
.interactive-masterplan .stage__map__svg g[data-status="future"] .stage-outlines {
	fill: var(--im-fill-future);
}

/* Lot shapes with no matching lot post are hidden */
.interactive-masterplan .stage--stage .stage__map__svg g:not([data-status]) {
	display: none;
}

/* Stage shapes with no matching stage post (yet) show as future */
.interactive-masterplan .stage--masterplan .stage__map__svg g:not([data-status]) .stage-outlines {
	fill: var(--im-fill-future);
}

/* A future stage is indicative only, so it carries no name label - covers both an
   explicit "future" status and a shape whose stage post does not exist yet, since
   the rule above already renders those the same way. */
.interactive-masterplan .stage__map__svg g[data-status="future"] .stage-name-box,
.interactive-masterplan .stage__map__svg g[data-status="future"] .stage-name-text,
.interactive-masterplan .stage--masterplan .stage__map__svg g:not([data-status]) .stage-name-box,
.interactive-masterplan .stage--masterplan .stage__map__svg g:not([data-status]) .stage-name-text {
	display: none;
}


/* Lot popup - lot details alongside the enquiry form */

/* Padding lives on __inner, not the dialog, so a click that lands on the dialog
   element itself can only be a backdrop click (see ic_im_widget.js). */
.lot-popup-information {
	position: fixed;
	width: 440px;
	max-width: calc(100vw - 32px);
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: none;
	overflow: auto;
	overscroll-behavior: contain;
	background-color: var(--im-popup-bg);
	color: var(--im-popup-text);
	box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.lot-popup-information[open] {
	animation: im-popup-in .25s ease-out;
}
.lot-popup-information::backdrop {
	background-color: var(--im-popup-backdrop);
	animation: im-popup-fade .25s ease-out;
}

@keyframes im-popup-in {
	from { opacity: 0; transform: translateY(12px); }
}
@keyframes im-popup-fade {
	from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.lot-popup-information[open],
	.lot-popup-information::backdrop {
		animation: none;
	}
}

/* no page scroll behind the open popup */
html:has(.lot-popup-information[open]) {
	overflow: hidden;
}

.lot-popup-information .lot-popup-information__inner {
	padding: calc(var(--bl) * 1.5) var(--bl) var(--bl);
}

.lot-popup-information .lot-popup-information__close {
	position: absolute;
	z-index: 2;
	top: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 8px;
	border: none;
	border-radius: 0;
	background-color: transparent;
	color: var(--im-popup-close);
	cursor: pointer;
	transition: color .3s;
}
.lot-popup-information .lot-popup-information__close:hover,
.lot-popup-information .lot-popup-information__close:focus-visible {
	color: var(--im-popup-close-hover);
	background-color: transparent;
}
.lot-popup-information .lot-popup-information__close svg {
	display: block;
	width: 100%;
	height: 100%;
}

.lot-popup-information .lot-popup-information__details {
	text-align: center;
	margin-bottom: var(--im-popup-gap);
}

.lot-popup-information .lot-popup-information__image:empty {
	display: none;
}
.lot-popup-information .lot-popup-information__image {
	margin-bottom: var(--im-popup-image-space);
}
.lot-popup-information .lot-popup-information__image img {
	display: inline-block;
	vertical-align: middle;
	width: auto;
	max-width: 100%;
	max-height: var(--im-popup-image-height);
	object-fit: contain;
}

.lot-popup-information .lot-popup-information__header {
	margin-bottom: var(--im-popup-header-space);
}

/* no trailing space under whichever info item comes last */
.lot-popup-information .lot-popup-information__details > :last-child {
	margin-bottom: 0;
}

.lot-popup-information .lot-popup-information__heading {
	position: relative;
	margin-bottom: var(--im-popup-divider-below);
	padding-bottom: var(--im-popup-divider-above);
	color: var(--im-popup-heading);
	font-family: var(--e-global-typography-primary-font-family), serif;
	font-size: 36px;
	line-height: 1.2;
}
.lot-popup-information .lot-popup-information__heading::after {
	content: '';
	display: block;
	position: absolute;
	bottom: 0;
	left: var(--im-popup-divider-left);
	transform: translateX(var(--im-popup-divider-shift));
	width: var(--im-popup-divider-width);
	max-width: var(--im-popup-divider-max-width);
	height: 0;
	border-top: 1px solid var(--im-popup-divider);
}

.lot-popup-information .lot-popup-information__heading:last-child {
	margin-bottom: 0;
}

.lot-popup-information .lot-popup-information__sub-heading {
	margin-bottom: 0;
	color: var(--im-popup-text);
	font-family: var(--e-global-typography-secondary-font-family), sans-serif;
	font-size: 16px;
	line-height: 1.2;
	text-transform: uppercase;
	letter-spacing: .05em;
}

.lot-popup-information .lot-popup-information__details__stats {
	display: flex;
	flex-direction: column;
	gap: var(--im-popup-stat-space);
	margin-bottom: 0;
}
.lot-popup-information .lot-popup-information__details__stats .stat {
	margin: 0;
	color: var(--im-popup-text);
	font-family: var(--e-global-typography-text-font-family), sans-serif;
	font-size: 22px;
	line-height: 1.4;
}


/* Enquiry form - inherits the site's Gravity Forms styling; only the popup-specific bits here */

.lot-popup-information__form .gform_heading,
.lot-popup-information__form .gform_required_legend,
.lot-popup-information__form .gform_validation_errors {
	display: none;
}

.lot-popup-information__form .gform_wrapper .gfield textarea {
	height: 110px !important;
}

.lot-popup-information__form .gform_wrapper .gfield_validation_message {
	background: transparent;
	border: none;
	padding: 0;
	margin: 4px 0 0;
	font-size: 12px;
}

.lot-popup-information__form .gform_wrapper .gform_footer {
	margin: var(--bl) 0 0;
	padding: 0;
	justify-content: center;
}

.lot-popup-information__form .gform_wrapper .gform_button {
	margin: 0;
	cursor: pointer;
	transition: background-color .3s, color .3s, border-color .3s;
}

.lot-popup-information__form .gform_confirmation_message {
	text-align: center;
	font-size: 18px;
	padding: var(--bl) 0;
}

/* Mobile - tighten the vertical rhythm so more of the form fits on screen */
@media (max-width: 767px) {
	.lot-popup-information {
		--im-popup-image-height: 140px;
		--im-popup-gap: calc(var(--bl) * .75);
		--im-popup-image-space: calc(var(--bl) * .5);
		--im-popup-header-space: calc(var(--bl) * .5);
		--im-popup-divider-above: 8px;
		--im-popup-divider-below: 8px;
	}
	.lot-popup-information .lot-popup-information__inner {
		padding: var(--bl) calc(var(--bl) * .75) calc(var(--bl) * .75);
	}
	.lot-popup-information .lot-popup-information__heading {
		font-size: 28px;
	}
	.lot-popup-information .lot-popup-information__details__stats .stat {
		font-size: 18px;
		line-height: 1.3;
	}
	.lot-popup-information__form .gform_wrapper {
		--field-row-gap: 12px;
	}
	.lot-popup-information__form .gform_wrapper .gfield textarea {
		height: 80px !important;
	}
	.lot-popup-information__form .gform_wrapper .gform_footer {
		margin-top: calc(var(--bl) * .6);
	}
}

/* By default the popup's side padding and the column gap share one gutter, so the centred
   details have equal space on either side. The Column Gap and Info Column Width controls
   override --im-popup-gap and --im-popup-info-width. */
@media (min-width: 768px) {
	.lot-popup-information {
		--popup-gutter: calc(var(--bl) * 2);
		--im-popup-gap: var(--popup-gutter);
		--im-popup-info-width: 240px;
		width: 760px;
	}
	.lot-popup-information .lot-popup-information__inner {
		padding: var(--popup-gutter);
		display: flex;
		align-items: center;
		gap: var(--im-popup-gap);
	}
	/* Info Column Position sets the order: 0 puts the details left of the form, 2 right */
	.lot-popup-information .lot-popup-information__details {
		flex: 0 0 var(--im-popup-info-width);
		min-width: 0;
		order: var(--im-popup-info-order, 0);
		margin-bottom: 0;
	}
	.lot-popup-information .lot-popup-information__form {
		flex: 1 1 auto;
		order: 1;
		min-width: 0;
	}
}

@media (min-width: 1025px) {
	.lot-popup-information {
		--popup-gutter: calc(var(--bl) * 2.5);
		--im-popup-info-width: 280px;
		width: 940px;
	}
	.lot-popup-information .lot-popup-information__inner {
		padding: var(--popup-gutter) var(--popup-gutter) calc(var(--bl) * 2);
	}
	.lot-popup-information .lot-popup-information__close {
		width: 48px;
		height: 48px;
		padding: 10px;
	}
}


/* Only one of the info and form columns is shown: a narrower popup, the column at full width.
   The Width style control still overrides this. */
.lot-popup-information.lot-popup-information--single .lot-popup-information__details {
	margin-bottom: 0;
}
@media (min-width: 768px) {
	.lot-popup-information:where(.lot-popup-information--single) {
		width: 480px;
	}
	.lot-popup-information.lot-popup-information--single .lot-popup-information__inner {
		display: block;
	}
}
