/*
 * Image hotspots: markers on a photo at x/y percent; each marker opens its card as a popover (popovertarget, no JS).
 * Wide screens anchor the card above its marker (CSS anchor positioning, flipped when there is no room; browsers
 * without it centre the card on the screen). Phones (37.5rem and under) show it as a bottom sheet with a close button.
 * The original theme: rtthemes/image-hotspots + rtthemes/hotspot with their own original-theme-only CSS (the card is a core/group there).
 */
.rt-image-hotspots {
	--rt-image-hotspots-marker-size: 2.25rem;
	--rt-image-hotspots-ring: color-mix(in srgb, var(--rt-color-accent) 35%, transparent);
	position: relative;
	counter-reset: rt-hotspot;
}

.rt-image-hotspots .rt-image-hotspots__image {
	margin: 0;
}

.rt-image-hotspots .rt-image-hotspots__image img {
	display: block;
	width: 100%;
	height: auto;
}

.rt-image-hotspots__spot {
	position: absolute;
	top: calc(var(--rt-hotspot-y) * 1%);
	left: calc(var(--rt-hotspot-x) * 1%);
	width: 0;
	height: 0;
	counter-increment: rt-hotspot;
	anchor-scope: --rt-hotspot;
}

.rt-image-hotspots__marker {
	position: absolute;
	top: 0;
	left: 0;
	display: grid;
	place-content: center;
	box-sizing: border-box;
	width: var(--rt-image-hotspots-marker-size);
	height: var(--rt-image-hotspots-marker-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--rt-color-accent);
	box-shadow: 0 0 0 calc(var(--rt-image-hotspots-marker-size) / 6) var(--rt-image-hotspots-ring);
	color: var(--rt-color-on-accent);
	font-family: inherit;
	font-size: calc(var(--rt-image-hotspots-marker-size) * 0.42);
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	translate: -50% -50%;
	transition: scale 0.2s ease;
	anchor-name: --rt-hotspot;
}

.rt-image-hotspots__marker:hover,
.rt-image-hotspots__marker:focus-visible,
.rt-image-hotspots__spot:has(> :popover-open) > .rt-image-hotspots__marker {
	scale: 1.12;
}

.rt-image-hotspots__marker:focus-visible {
	outline: 2px solid var(--rt-color-accent);
	outline-offset: calc(var(--rt-image-hotspots-marker-size) / 6 + 2px);
}

.rt-image-hotspots--plus .rt-image-hotspots__marker::before,
.rt-image-hotspots--plus .rt-image-hotspots__marker::after {
	content: "";
	grid-area: 1 / 1;
	width: 0.875em;
	height: 0.125em;
	border-radius: 1px;
	background-color: currentColor;
	transition: rotate 0.2s ease;
}

.rt-image-hotspots--plus .rt-image-hotspots__marker::after {
	rotate: 90deg;
}

.rt-image-hotspots--plus .rt-image-hotspots__spot:has(> :popover-open) > .rt-image-hotspots__marker::before {
	rotate: 45deg;
}

.rt-image-hotspots--plus .rt-image-hotspots__spot:has(> :popover-open) > .rt-image-hotspots__marker::after {
	rotate: 135deg;
}

.rt-image-hotspots--number .rt-image-hotspots__marker::before {
	content: counter(rt-hotspot);
	font-variant-numeric: tabular-nums;
}

.rt-image-hotspots--dot .rt-image-hotspots__marker {
	background-color: var(--rt-image-hotspots-ring);
	box-shadow: none;
}

.rt-image-hotspots--dot .rt-image-hotspots__marker::before {
	content: "";
	/* Sized from the marker: a percentage would resolve against the content-sized grid track */
	width: calc(var(--rt-image-hotspots-marker-size) * 0.4);
	height: calc(var(--rt-image-hotspots-marker-size) * 0.4);
	box-sizing: border-box;
	border: 2px solid currentColor;
	border-radius: 50%;
	background-color: var(--rt-color-accent);
}

.rt-image-hotspots--pulse .rt-image-hotspots__marker {
	animation: rt-image-hotspots-pulse 2s ease-out infinite;
}

@keyframes rt-image-hotspots-pulse {
	0% {
		box-shadow: 0 0 0 0 var(--rt-image-hotspots-ring);
	}

	70% {
		box-shadow: 0 0 0 calc(var(--rt-image-hotspots-marker-size) / 2.5) transparent;
	}

	100% {
		box-shadow: 0 0 0 calc(var(--rt-image-hotspots-marker-size) / 2.5) transparent;
	}
}

.rt-image-hotspots__card {
	box-sizing: border-box;
	width: min(18rem, 100vw - 2rem);
	max-height: calc(100dvh - 2rem);
	overflow: auto;
	padding: var(--rt-spacing-30) var(--rt-spacing-40);
	border: 0;
	border-radius: 0.3125rem;
	background-color: var(--rt-color-base);
	box-shadow: 0 2px 25px rgb(0 0 0 / 22%);
	color: var(--rt-color-contrast);
	opacity: 0;
	translate: 0 0.5rem;
	transition: opacity 0.2s ease, translate 0.2s ease, display 0.2s allow-discrete, overlay 0.2s allow-discrete;
}

.rt-image-hotspots__card:popover-open {
	display: flex;
	flex-direction: column;
	gap: var(--rt-spacing-20);
	opacity: 1;
	translate: 0 0;
}

@starting-style {
	.rt-image-hotspots__card:popover-open {
		opacity: 0;
		translate: 0 0.5rem;
	}
}

.rt-image-hotspots .rt-image-hotspots__title {
	margin: 0;
	font-size: var(--rt-font-size-base-plus);
	font-weight: 700;
}

.rt-image-hotspots .rt-image-hotspots__text,
.rt-image-hotspots .rt-image-hotspots__link {
	margin: 0;
	font-size: var(--rt-font-size-small);
}

.rt-image-hotspots .rt-image-hotspots__link {
	font-weight: 700;
}

.rt-image-hotspots__link a {
	color: inherit;
}

.rt-image-hotspots__close {
	display: none;
}

@supports (position-area: top) {
	@media (width > 37.5rem) {
		.rt-image-hotspots__card {
			inset: auto;
			margin: 0.75rem;
			position-anchor: --rt-hotspot;
			position-area: top;
			position-try-fallbacks: flip-block, right, left;
		}
	}
}

@media (width <= 37.5rem) {
	.rt-image-hotspots .rt-image-hotspots__card {
		inset: auto 0 0;
		width: auto;
		max-width: none;
		max-height: 75dvh;
		margin: 0;
		border-end-start-radius: 0;
		border-end-end-radius: 0;
		translate: 0 100%;
	}

	.rt-image-hotspots .rt-image-hotspots__card:popover-open {
		translate: 0 0;
	}

	@starting-style {
		.rt-image-hotspots .rt-image-hotspots__card:popover-open {
			translate: 0 100%;
		}
	}

	.rt-image-hotspots__card::backdrop {
		background-color: rgb(0 0 0 / 35%);
	}

	.rt-image-hotspots__close {
		position: absolute;
		top: 0.25rem;
		right: 0.25rem;
		display: grid;
		place-content: center;
		width: 2.5rem;
		height: 2.5rem;
		margin: 0;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: none;
		color: inherit;
		cursor: pointer;
	}

	.rt-image-hotspots__close::before,
	.rt-image-hotspots__close::after {
		content: "";
		grid-area: 1 / 1;
		width: 1.125rem;
		height: 2px;
		background-color: currentColor;
		rotate: 45deg;
	}

	.rt-image-hotspots__close::after {
		rotate: -45deg;
	}

	.rt-image-hotspots__close:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: -4px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rt-image-hotspots .rt-image-hotspots__marker,
	.rt-image-hotspots .rt-image-hotspots__marker::before,
	.rt-image-hotspots .rt-image-hotspots__marker::after,
	.rt-image-hotspots .rt-image-hotspots__card {
		transition: none;
		animation: none;
	}
}
