/*
 * Project Showcase Map – frontend.
 * Defaults follow the OCI design (navy #001338, orange #F8781B, Poppins).
 * Every value is a custom property that the widget's Style tab can override.
 */

.psm-map {
	--psm-font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
	--psm-map-max-width: 100%;
	--psm-map-bg: transparent;

	--psm-state-fill: #e6ebf2;
	--psm-state-fill-hover: var(--psm-state-fill);
	--psm-state-stroke: #8193aa;
	--psm-state-stroke-width: 0.8px;

	--psm-pin-size: 34px;
	--psm-pin-icon-size: 18px;
	--psm-pin-border-width: 2px;
	--psm-pin-bg: #f8781b;
	--psm-pin-color: #fff;
	--psm-pin-border-color: #fff;
	--psm-pin-bg-active: #001338;
	--psm-pin-color-active: #fff;
	--psm-pin-border-color-active: #fff;
	--psm-pin-halo: rgba(248, 120, 27, 0.35);

	--psm-card-width: 264px;
	--psm-card-gap: 12px;
	--psm-card-bg: #001338;
	--psm-card-radius: 16px;
	--psm-card-align: center;
	--psm-card-justify: center;
	--psm-card-title: #fff;
	--psm-card-image-height: 140px;
	--psm-card-image-radius: 10px;
	--psm-card-location: rgba(255, 255, 255, 0.72);

	--psm-button-radius: 10px;
	--psm-button-color: #fff;
	--psm-button-bg: #f8781b;
	--psm-button-color-hover: #001338;
	--psm-button-bg-hover: #fff;

	--psm-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--psm-duration: 220ms;

	position: relative;
	background: var(--psm-map-bg);
	font-family: var(--psm-font);
}

/* ---------- Elementor container sizing ---------- */

/*
 * Same pattern Elementor uses for its own full-width widgets (Accordion, Toggle).
 * Without a definite width, a wrapping flex container (Elementor's tablet/mobile
 * default) measures the widget before stretching it; the map's height is then
 * computed from a fallback width and the next section overlaps the map.
 * Respects the widget's Advanced › Width setting via the same variables.
 */
.e-con-inner > .elementor-widget-psm-projects-map,
.e-con > .elementor-widget-psm-projects-map {
	width: var(--container-widget-width);
	/* Row containers with Align Items set resolve the width above to 0%;
	   keep the map visible next to long text. */
	min-width: min(100%, 280px);
	--flex-grow: var(--container-widget-flex-grow);
}

/* ---------- Map ---------- */

.psm-map__canvas {
	position: relative;
	max-width: var(--psm-map-max-width);
	margin: 0 auto;
}

.psm-map__svg {
	display: block;
	width: 100%;
	height: auto;
	/* Clip the Aleutian tail that falls outside the viewBox (would overflow the page). */
	overflow: hidden;
}

.psm-map .psm-state {
	fill: var(--psm-state-fill);
	stroke: var(--psm-state-stroke);
	stroke-width: var(--psm-state-stroke-width);
	stroke-linejoin: round;
	vector-effect: non-scaling-stroke;
	transition: fill var(--psm-duration) ease;
}

.psm-map .psm-state:hover {
	fill: var(--psm-state-fill-hover);
}

/* ---------- Pins ---------- */

.psm-map .psm-map__pins {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	pointer-events: none;
}

.psm-map .psm-pin {
	position: absolute;
	z-index: 1;
	width: 0;
	height: 0;
	margin: 0;
	padding: 0;
	/* Offsets set by frontend.js to separate overlapping pins. */
	transform: translate(var(--psm-pin-dx, 0px), var(--psm-pin-dy, 0px));
}

.psm-map .psm-pin:hover,
.psm-map .psm-pin:focus-within,
.psm-map .psm-pin.is-open {
	z-index: 30;
}

.psm-map .psm-pin__halo {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--psm-pin-size);
	height: var(--psm-pin-size);
	margin: calc(var(--psm-pin-size) / -2) 0 0 calc(var(--psm-pin-size) / -2);
	border-radius: 50%;
	background: var(--psm-pin-halo);
	opacity: 0;
	pointer-events: none;
}

.psm-pulse-yes .psm-map .psm-pin__halo {
	animation: psm-pulse 2.6s var(--psm-ease) infinite;
}

.psm-pulse-yes .psm-map .psm-pin:nth-child(3n + 2) .psm-pin__halo {
	animation-delay: 0.85s;
}

.psm-pulse-yes .psm-map .psm-pin:nth-child(3n + 3) .psm-pin__halo {
	animation-delay: 1.7s;
}

@keyframes psm-pulse {
	0% {
		transform: scale(1);
		opacity: 0.9;
	}

	70%,
	100% {
		transform: scale(2);
		opacity: 0;
	}
}

/* Extra specificity: beats theme / Elementor kit `button` and `[type=button]` resets. */
.psm-map .psm-pin .psm-pin__button {
	position: absolute;
	top: 0;
	left: 0;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: var(--psm-pin-size);
	height: var(--psm-pin-size);
	min-height: 0;
	margin: 0;
	padding: 0;
	border: var(--psm-pin-border-width) solid var(--psm-pin-border-color);
	border-radius: 50%;
	background: var(--psm-pin-bg);
	color: var(--psm-pin-color);
	line-height: 0;
	box-shadow: 0 6px 14px -4px rgba(0, 19, 56, 0.45);
	transform: translate(-50%, -50%);
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
	transition:
		background-color var(--psm-duration) ease,
		color var(--psm-duration) ease,
		border-color var(--psm-duration) ease,
		transform var(--psm-duration) var(--psm-ease);
}

.psm-map .psm-pin:hover .psm-pin__button,
.psm-map .psm-pin.is-open .psm-pin__button,
.psm-map .psm-pin .psm-pin__button:focus-visible {
	background: var(--psm-pin-bg-active);
	color: var(--psm-pin-color-active);
	border-color: var(--psm-pin-border-color-active);
	transform: translate(-50%, -50%) scale(1.12);
}

.psm-map .psm-pin .psm-pin__button:focus {
	outline: none;
}

.psm-map .psm-pin .psm-pin__button:focus-visible {
	outline: 2px solid var(--psm-pin-bg);
	outline-offset: 3px;
}

.psm-map .psm-pin__icon {
	display: grid;
	place-items: center;
	width: var(--psm-pin-icon-size);
	height: var(--psm-pin-icon-size);
	font-size: var(--psm-pin-icon-size);
	line-height: 1;
}

.psm-map .psm-pin__icon svg {
	display: block;
	width: 100%;
	height: 100%;
	fill: currentColor;
}

/* ---------- Card ---------- */

.psm-map .psm-card {
	--psm-card-shift: 0px;
	--psm-card-offset: calc(var(--psm-pin-size) / 2 + var(--psm-card-gap));
	position: absolute;
	bottom: var(--psm-card-offset);
	/* Sideways shift via left (not animated) so it applies instantly on open. */
	left: var(--psm-card-shift);
	z-index: 2;
	width: var(--psm-card-width);
	max-width: calc(100vw - 24px);
	/* display:none (not visibility) so closed cards near the screen edge never
	   widen the page on mobile. allow-discrete keeps the fade in modern
	   browsers; older ones simply show/hide without animating. */
	display: none;
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, 8px);
	transition-property: opacity, transform, display;
	transition-duration: var(--psm-duration);
	transition-timing-function: ease, var(--psm-ease), linear;
	transition-behavior: allow-discrete;
}

/* Invisible bridge across the gap so the pointer can travel from the pin to the
   card. Spans only the gap: overlapping the pin would swallow its clicks. */
.psm-map .psm-card::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	height: var(--psm-card-gap);
}

.psm-map .psm-pin--below .psm-card {
	top: var(--psm-card-offset);
	bottom: auto;
	transform: translate(-50%, -8px);
}

.psm-map .psm-pin--below .psm-card::after {
	top: auto;
	bottom: 100%;
}

.psm-map--trigger-hover .psm-pin:hover .psm-card,
.psm-map--trigger-hover .psm-pin:focus-within .psm-card,
.psm-map .psm-pin.is-open .psm-card {
	display: block;
	opacity: 1;
	pointer-events: auto;
	transform: translate(-50%, 0);
}

/* Entry animation start point (cards come from display:none). */
@starting-style {
	.psm-map--trigger-hover .psm-pin:hover .psm-card,
	.psm-map--trigger-hover .psm-pin:focus-within .psm-card,
	.psm-map .psm-pin.is-open .psm-card {
		opacity: 0;
		transform: translate(-50%, 8px);
	}

	.psm-map--trigger-hover .psm-pin--below:hover .psm-card,
	.psm-map--trigger-hover .psm-pin--below:focus-within .psm-card,
	.psm-map .psm-pin--below.is-open .psm-card {
		transform: translate(-50%, -8px);
	}
}

.psm-map .psm-pin.is-dismissed .psm-card {
	display: none;
	opacity: 0;
	pointer-events: none;
}

.psm-map .psm-card__inner {
	display: flex;
	flex-direction: column;
	gap: 10px;
	box-sizing: border-box;
	padding: 16px 16px 18px;
	border-radius: var(--psm-card-radius);
	background: var(--psm-card-bg);
	box-shadow: 0 22px 44px -14px rgba(0, 19, 56, 0.55);
	text-align: var(--psm-card-align);
}

.psm-map .psm-card__title {
	margin: 0;
	padding: 0;
	color: var(--psm-card-title);
	font-family: var(--psm-font);
	font-size: 17px;
	font-weight: 600;
	line-height: 1.3;
}

.psm-map .psm-card__media {
	height: var(--psm-card-image-height);
	overflow: hidden;
	border-radius: var(--psm-card-image-radius);
	background: rgba(255, 255, 255, 0.08);
}

.psm-map .psm-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	border-radius: 0;
	object-fit: cover;
}

.psm-map .psm-card__location {
	margin: 0;
	padding: 0;
	color: var(--psm-card-location);
	font-family: var(--psm-font);
	font-size: 14px;
	line-height: 1.4;
}

.psm-map .psm-card .psm-card__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: var(--psm-card-justify);
	margin-top: 2px;
	padding: 10px 22px;
	border: 0;
	border-radius: var(--psm-button-radius);
	background: var(--psm-button-bg);
	color: var(--psm-button-color);
	font-family: var(--psm-font);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.3px;
	line-height: 1.2;
	text-decoration: none;
	transition:
		background-color var(--psm-duration) ease,
		color var(--psm-duration) ease;
}

.psm-map .psm-card .psm-card__button:hover,
.psm-map .psm-card .psm-card__button:focus-visible {
	background: var(--psm-button-bg-hover);
	color: var(--psm-button-color-hover);
	text-decoration: none;
}

.psm-map .psm-card .psm-card__button:focus-visible {
	outline: 2px solid var(--psm-button-bg);
	outline-offset: 2px;
}

/* ---------- Tablets (Elementor tablet breakpoint) ---------- */

@media (max-width: 1024px) {
	.psm-map {
		--psm-pin-size: 30px;
		--psm-pin-icon-size: 16px;
		--psm-card-width: 248px;
		--psm-card-image-height: 128px;
	}
}

/* ---------- Small screens (Elementor mobile breakpoint) ---------- */

@media (max-width: 767px) {
	.psm-map {
		--psm-pin-size: 24px;
		--psm-pin-icon-size: 13px;
		--psm-pin-border-width: 1.5px;
		--psm-card-width: 232px;
		--psm-card-gap: 8px;
		--psm-card-image-height: 112px;
	}

	.psm-map .psm-card__inner {
		gap: 8px;
		padding: 14px 14px 16px;
	}

	.psm-map .psm-card__title {
		font-size: 15px;
	}
}

/* ---------- Editor-only hints ---------- */

.psm-map__notice {
	margin: 12px 0 0;
	padding: 10px 14px 10px 30px;
	border-left: 3px solid #f8781b;
	border-radius: 6px;
	background: #fff7f0;
	color: #5a3d28;
	font-size: 13px;
	line-height: 1.5;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
	.psm-pulse-yes .psm-map .psm-pin__halo {
		animation: none;
	}

	.psm-map .psm-state,
	.psm-map .psm-pin .psm-pin__button,
	.psm-map .psm-card,
	.psm-map .psm-card .psm-card__button {
		transition: none;
	}
}
