/*
 * Office map ([platinum_office_map], mu-plugins/platinum-office-map.php). Loaded only where the map renders.
 * Same component as the XPT Specialty office map. Colours follow the old MapSVG map 4: dark grey states,
 * Platinum blue where there is an office, white labels; pins and accents in Platinum purple.
 */

.office-map {
	--office-map-base: #666;
	--office-map-active: #50649f;
	--office-map-stroke: #fff;
	--office-map-label: #fff;
	--office-map-ink: #000;
	--office-map-pin: #250e62;
	--office-map-link: #250e62;
	--office-map-accent: #250e62;
	--office-map-card: #f4f4f8;
	--office-map-text: #333;
	--office-map-font: "IBM Plex Sans", sans-serif;
	--office-map-ease: cubic-bezier(.32, .72, 0, 1);
	--zoom: 1;
	position: relative;
	margin: 24px 0;
	color: var(--office-map-ink);
	font-family: var(--office-map-font);
}

.office-map__stage {
	position: relative;
}

.office-map__viewport {
	position: relative;
	overflow: hidden;
	touch-action: none;
}

.office-map__canvas {
	position: relative;
	transform-origin: 0 0;
	transition: transform .5s var(--office-map-ease);
}

.office-map.is-zoomed .office-map__canvas { cursor: grab; }
.office-map.is-dragging .office-map__canvas { cursor: grabbing; transition: none; }

/* Elementor and theme button styles would otherwise apply to the map controls. */
.office-map .office-map__pin,
.office-map .office-map__zoom button,
.office-map .office-map__close {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
}

.office-map__svg {
	display: block;
	width: 100%;
	height: auto;
}

.office-map__states path {
	fill: var(--office-map-base);
	stroke: var(--office-map-stroke);
	stroke-width: .6;
	stroke-linejoin: round;
	vector-effect: non-scaling-stroke;
}

.office-map__labels text {
	font: 700 5px/1 var(--office-map-font);
	fill: var(--office-map-label);
	text-anchor: middle;
	dominant-baseline: middle;
	pointer-events: none;
}

/* Pins keep their on-screen size at any zoom level. */
.office-map .office-map__pin {
	position: absolute;
	z-index: 1;
	width: 24px;
	height: 32px;
	transform: translate(-50%, -100%) scale(calc(1 / var(--zoom)));
	transform-origin: 50% 100%;
	transition: transform .3s var(--office-map-ease);
}

.office-map__pin svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

.office-map__pin path { fill: var(--office-map-pin); stroke: #fff; stroke-width: 1.5; }
.office-map__pin circle { fill: #fff; }

.office-map .office-map__pin:hover,
.office-map .office-map__pin:focus-visible,
.office-map .office-map__pin[aria-expanded="true"] {
	z-index: 3;
	transform: translate(-50%, -100%) scale(calc(1.2 / var(--zoom)));
}

.office-map__pin[aria-expanded="true"] path { fill: #000; }

.office-map .office-map__pin:focus-visible {
	outline: 3px solid #000;
	outline-offset: 2px;
	border-radius: 4px;
}

.office-map__tip {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 6px);
	padding: 4px 8px;
	background: #000;
	color: #fff;
	font-size: 14px;
	line-height: 20px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transform: translateX(-50%);
	transition: opacity .2s var(--office-map-ease);
}

.office-map__pin:hover .office-map__tip,
.office-map__pin:focus-visible .office-map__tip { opacity: 1; }

.office-map__zoom {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 4;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.office-map .office-map__zoom button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: 1px solid #9b9b9b;
	background: #fff;
	color: #000;
	font-size: 20px;
	line-height: 1;
	transition: background-color .3s var(--office-map-ease), color .3s var(--office-map-ease);
}

.office-map .office-map__zoom button:hover {
	border-color: var(--office-map-link);
	background: var(--office-map-link);
	color: #fff;
}

.office-map .office-map__zoom button:focus-visible,
.office-map .office-map__close:focus-visible {
	outline: 3px solid #000;
	outline-offset: 2px;
}

.office-map__details {
	position: absolute;
	z-index: 5;
	left: 8px;
	bottom: 8px;
	width: min(340px, calc(100% - 16px));
	max-height: calc(100% - 16px);
	overflow: auto;
	padding: 24px 24px 16px;
	border-top: 4px solid var(--office-map-accent);
	background: #fff;
	box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}

.office-map .office-map__close {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	color: #000;
	font-size: 26px;
	line-height: 1;
}

.office-map__office + .office-map__office {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid #ddd;
}

.office-map .office-map__office :is(h3, h4) {
	margin: 0 0 8px;
	padding-right: 24px;
	color: #000;
	font: 700 20px/28px var(--office-map-font);
}

.office-map .office-map__office :is(p, address) {
	margin: 0 0 4px;
	color: var(--office-map-text);
	font-size: 16px;
	font-style: normal;
	line-height: 26px;
}

/* !important: Elementor's global link colour would otherwise win. */
.office-map .office-map__office a {
	color: var(--office-map-link) !important;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.office-map .office-map__office a:hover {
	color: #000 !important;
}

/* list="toggle" */
.office-map__list {
	margin-top: 16px;
}

.office-map__list summary {
	cursor: pointer;
	font-weight: 700;
}

.office-map__states-list {
	columns: 3 240px;
	column-gap: 32px;
	margin-top: 16px;
}

.office-map__states-list section {
	margin-bottom: 20px;
	break-inside: avoid;
}

/* list="open": every office as a card under the map. */
.office-map__list--open {
	margin-top: 48px;
}

.office-map .office-map__list-title {
	margin: 0 0 24px;
	color: #000;
	font: 700 28px/36px var(--office-map-font);
}

.office-map__cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.office-map__card {
	position: relative;
	margin: 0;
	padding: 24px 24px 20px;
	border-top: 4px solid var(--office-map-accent);
	background: var(--office-map-card);
}

.office-map__state {
	position: absolute;
	top: 20px;
	right: 20px;
	padding: 2px 8px;
	background: var(--office-map-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	line-height: 20px;
	letter-spacing: .04em;
}

.office-map__card .office-map__office {
	padding-right: 40px;
}

/* Phones: the map is too small to hold the card, so it sits below the map. */
@media (max-width: 639px) {
	/* Smaller pin drawing, but the button keeps a 24px target (WCAG 2.5.8). */
	.office-map .office-map__pin {
		width: 24px;
		height: 24px;
	}

	.office-map__pin svg {
		width: 16px;
		height: 22px;
		margin: 2px auto 0;
	}

	.office-map__details {
		position: relative;
		left: auto;
		bottom: auto;
		width: 100%;
		max-height: none;
		margin-top: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.office-map__canvas,
	.office-map__tip,
	.office-map .office-map__pin {
		transition: none;
	}
}
