/*
 * Store map (home-1 "Store Locations"): world map image with pins; each pin opens a card.
 * Pure CSS: a card shows on marker hover/focus; the open pin's card is visible until another marker is active.
 * Pins sit in the root's coordinate space (container query units), so they follow the map at any width.
 * The original theme: rtthemes/store-map (core/image + rtthemes/store-pin blocks; card content is heading + paragraph).
 */
.rt-store-map {
	/* Map height as a share of its width (1189×539) */
	--rt-store-map-ratio: 0.4533;
	--rt-store-map-marker-width: 2.25rem;
	--rt-store-map-marker-height: 2.75rem;
	--rt-store-map-card-gap: 1.4375rem;
	position: relative;
	container-type: inline-size;
}

.rt-store-map .rt-store-map__image {
	margin: 0;
}

.rt-store-map .rt-store-map__image img {
	display: block;
	width: 100%;
	height: auto;
	filter: drop-shadow(0 4px 4px var(--rt-store-map-shadow));
}

/* The pin wrapper only groups marker + card; both are positioned against the root */
.rt-store-map__pin {
	display: contents;
}

.rt-store-map__marker {
	position: absolute;
	z-index: 1;
	top: calc(var(--rt-pin-y) * var(--rt-store-map-ratio) * 1cqw);
	left: calc(var(--rt-pin-x) * 1cqw);
	width: var(--rt-store-map-marker-width);
	height: var(--rt-store-map-marker-height);
	margin: 0;
	padding: 0;
	border: 0;
	background-color: var(--rt-color-accent);
	cursor: pointer;
	translate: -50% -100%;
	transition: scale 0.2s ease;
	transform-origin: 50% 100%;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 44'%3E%3Cpath d='M18 0C8.075 0 0 7.993 0 17.818C0 21.873 1.342 25.691 3.881 28.86C7.169 32.964 16.73 42.707 17.136 43.12L18 44L18.864 43.12C19.27 42.707 28.834 32.961 32.122 28.856C34.659 25.69 36 21.873 36 17.818C36 7.993 27.925 0 18 0ZM30.233 27.373C27.586 30.678 20.477 38.029 18 40.571C15.524 38.029 8.417 30.68 5.771 27.377C3.573 24.634 2.411 21.329 2.411 17.818C2.411 9.309 9.404 2.387 18 2.387C26.596 2.387 33.589 9.309 33.589 17.818C33.589 21.329 32.428 24.633 30.233 27.373Z'/%3E%3Cpath d='M17.5 7C11.71 7 7 11.71 7 17.5C7 23.29 11.71 28 17.5 28C23.29 28 28 23.29 28 17.5C28 11.71 23.29 7 17.5 7ZM17.5 25.624C13.021 25.624 9.376 21.979 9.376 17.5C9.376 13.021 13.021 9.376 17.5 9.376C21.979 9.376 25.624 13.021 25.624 17.5C25.624 21.979 21.979 25.624 17.5 25.624Z'/%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 36 44'%3E%3Cpath d='M18 0C8.075 0 0 7.993 0 17.818C0 21.873 1.342 25.691 3.881 28.86C7.169 32.964 16.73 42.707 17.136 43.12L18 44L18.864 43.12C19.27 42.707 28.834 32.961 32.122 28.856C34.659 25.69 36 21.873 36 17.818C36 7.993 27.925 0 18 0ZM30.233 27.373C27.586 30.678 20.477 38.029 18 40.571C15.524 38.029 8.417 30.68 5.771 27.377C3.573 24.634 2.411 21.329 2.411 17.818C2.411 9.309 9.404 2.387 18 2.387C26.596 2.387 33.589 9.309 33.589 17.818C33.589 21.329 32.428 24.633 30.233 27.373Z'/%3E%3Cpath d='M17.5 7C11.71 7 7 11.71 7 17.5C7 23.29 11.71 28 17.5 28C23.29 28 28 23.29 28 17.5C28 11.71 23.29 7 17.5 7ZM17.5 25.624C13.021 25.624 9.376 21.979 9.376 17.5C9.376 13.021 13.021 9.376 17.5 9.376C21.979 9.376 25.624 13.021 25.624 17.5C25.624 21.979 21.979 25.624 17.5 25.624Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.rt-store-map__marker:focus-visible {
	outline: 2px solid var(--rt-color-body);
	outline-offset: 2px;
}

/* Card: 259px wide, centred above the marker with a 23px gap */
.rt-store-map__card {
	position: absolute;
	z-index: 2;
	top: calc(var(--rt-pin-y) * var(--rt-store-map-ratio) * 1cqw);
	left: calc(var(--rt-pin-x) * 1cqw);
	box-sizing: border-box;
	width: 16.1875rem;
	max-width: calc(100cqw - 2rem);
	padding: 0.6875rem var(--rt-spacing-30) 1.0625rem;
	border-radius: 0.3125rem;
	background-color: var(--rt-color-base);
	box-shadow: 0 0 5px var(--rt-store-map-card-shadow);
	color: var(--rt-color-body);
	text-align: center;
	opacity: 0;
	visibility: hidden;
	translate: -50% calc(-100% - var(--rt-store-map-marker-height) - var(--rt-store-map-card-gap) + 0.5rem);
	/* Hiding waits a moment, so the pointer can travel from the marker to the card */
	transition: opacity 0.2s ease 0.15s, translate 0.2s ease 0.15s, visibility 0s linear 0.35s;
}

.rt-store-map .rt-store-map__title {
	margin: 0;
	color: var(--rt-color-body);
	font-family: var(--rt-font-family-body);
	font-size: var(--rt-font-size-base);
	font-weight: var(--rt-font-weight-bold);
	line-height: 2.25;
}

.rt-store-map .rt-store-map__text {
	margin: 0;
	font-size: var(--rt-font-size-small);
	line-height: 1.05;
}

.rt-store-map__card a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.rt-store-map__card a:hover,
.rt-store-map__card a:focus-visible {
	color: var(--rt-color-contrast);
}

/* JS controls (narrow screens only) */
.rt-store-map__arrow {
	display: none;
}

/*
 * Wide screens: a pin is active while its marker or its card is hovered or focused, so links in the card can be
 * clicked. The open pin's card shows until another pin becomes active.
 */
@media (width > 37.5rem) {
	.rt-store-map__marker:hover,
	.rt-store-map__marker:focus-visible {
		scale: 1.1;
	}

	/* Invisible bridge over the gap between the card and the marker */
	.rt-store-map__card::after {
		content: "";
		position: absolute;
		top: 100%;
		left: 50%;
		width: var(--rt-store-map-marker-width);
		height: var(--rt-store-map-card-gap);
		translate: -50% 0;
	}

	.rt-store-map__pin > .rt-store-map__marker:hover + .rt-store-map__card,
	.rt-store-map__pin > .rt-store-map__marker:focus-visible + .rt-store-map__card,
	.rt-store-map__pin > .rt-store-map__card:hover,
	.rt-store-map__pin > .rt-store-map__card:focus-within,
	.rt-store-map__pin--open > .rt-store-map__card {
		opacity: 1;
		visibility: visible;
		translate: -50% calc(-100% - var(--rt-store-map-marker-height) - var(--rt-store-map-card-gap));
		transition-delay: 0s;
	}

	.rt-store-map:has(.rt-store-map__pin:not(.rt-store-map__pin--open) > :is(.rt-store-map__marker:hover, .rt-store-map__marker:focus-visible, .rt-store-map__card:hover, .rt-store-map__card:focus-within)) .rt-store-map__pin--open > .rt-store-map__card {
		opacity: 0;
		visibility: hidden;
		transition-delay: 0s, 0s, 0.2s;
	}
}

/* Narrow screens without JS: markers stay on the map, cards are listed below it */
@media (max-width: 37.5rem) {
	.rt-store-map {
		--rt-store-map-marker-width: 1.5rem;
		--rt-store-map-marker-height: 1.8333rem;
		display: grid;
		gap: var(--rt-spacing-30);
	}

	.rt-store-map .rt-store-map__card {
		position: static;
		width: auto;
		max-width: none;
		opacity: 1;
		visibility: visible;
		translate: none;
		transition: none;
	}

	.rt-store-map .rt-store-map__text {
		line-height: 1.4;
	}

	/* Map only: no cards on narrow screens */
	.rt-store-map--mobile-map-only .rt-store-map__card {
		display: none;
	}

	/*
	 * With JS: one card at a time between previous/next arrows. The active pin's marker keeps its size and grows in
	 * when it becomes active; the other markers shrink.
	 */
	.rt-store-map[data-rt-ready]:not(.rt-store-map--mobile-map-only) {
		grid-template-columns: auto minmax(0, 1fr) auto;
		grid-template-areas:
			"map map map"
			"prev card next";
		align-items: center;
		column-gap: var(--rt-spacing-20);
	}

	.rt-store-map[data-rt-ready] .rt-store-map__image {
		grid-area: map;
	}

	.rt-store-map[data-rt-ready] .rt-store-map__card {
		grid-area: card;
		align-self: stretch;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.25s ease, visibility 0s linear 0.25s;
	}

	.rt-store-map[data-rt-ready] .rt-store-map__pin--active > .rt-store-map__card {
		opacity: 1;
		visibility: visible;
		transition-delay: 0s;
	}

	.rt-store-map[data-rt-ready]:not(.rt-store-map--mobile-map-only) .rt-store-map__marker {
		scale: 0.65;
		transition: scale 0.25s ease;
	}

	.rt-store-map[data-rt-ready]:not(.rt-store-map--mobile-map-only) .rt-store-map__pin--active > .rt-store-map__marker {
		z-index: 2;
		scale: 1;
		animation: rt-store-map-grow 0.4s ease-out;
	}

	.rt-store-map[data-rt-ready]:not(.rt-store-map--mobile-map-only) .rt-store-map__arrow {
		display: block;
		position: relative;
		width: 2.75rem;
		height: 2.75rem;
		margin: 0;
		padding: 0;
		border: 2px solid var(--rt-color-accent);
		border-radius: 50%;
		background: none;
		color: var(--rt-color-contrast);
		cursor: pointer;
	}

	.rt-store-map__arrow--prev {
		grid-area: prev;
	}

	.rt-store-map__arrow--next {
		grid-area: next;
	}

	.rt-store-map__arrow::before {
		content: "";
		position: absolute;
		inset: 0;
		background-color: currentColor;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 17'%3E%3Cpath d='M1.5 1.5l7 7-7 7' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 50% 50% / 0.5rem 0.875rem no-repeat;
		mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 17'%3E%3Cpath d='M1.5 1.5l7 7-7 7' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 50% 50% / 0.5rem 0.875rem no-repeat;
	}

	.rt-store-map__arrow--prev::before {
		scale: -1 1;
	}

	.rt-store-map__arrow:hover {
		background-color: var(--rt-color-accent);
	}

	.rt-store-map__arrow:focus-visible {
		outline: 2px solid var(--rt-color-accent);
		outline-offset: 3px;
	}
}

@keyframes rt-store-map-grow {
	0% {
		scale: 0.65;
	}

	60% {
		scale: 1.2;
	}

	100% {
		scale: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rt-store-map .rt-store-map__marker,
	.rt-store-map .rt-store-map__card {
		transition: none !important;
		animation: none !important;
	}
}
