/*
 * Theme hooks: override these on `.mkl-pc-hotspots-overlay` (or a parent) to
 * restyle every hotspot without touching the rules below.
 */
.mkl-pc-hotspots-overlay {
	--mkl-pc-hotspot-size: 26px;
	--mkl-pc-hotspot-color: rgba(17, 24, 39, 0.92);
	--mkl-pc-hotspot-icon-color: #fff;
	--mkl-pc-hotspot-ring: #fff;
	--mkl-pc-hotspot-label-bg: #fff;
	--mkl-pc-hotspot-label-color: #111827;
	--mkl-pc-hotspot-label-gap: 8px;
	--mkl-pc-hotspot-focus: #3b82f6;
	position: absolute;
	inset: 0;
	pointer-events: none;
	overflow: hidden;
	z-index: 5;
	opacity: 1;
	transition: opacity 0.4s ease;
}

/*
 * Held back while the viewer's orbit hint is still moving, so the opening frame
 * carries one message instead of two. Lifted when the hint settles, or sooner if
 * the customer rotates the model. See _wait_for_orbit_hint in fe-hotspots.js —
 * the pins are only ever hidden when the host confirms a hint is coming.
 *
 * visibility, not just opacity: a fading-in pin must not be clickable before it
 * can be seen, and the individual hotspots switch pointer-events back on.
 */
.mkl-pc-hotspots-overlay.is-awaiting-hint {
	opacity: 0;
	visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.mkl-pc-hotspots-overlay {
		transition: none;
	}
}

/*
 * A hotspot is a zero-size button sitting exactly on the projected point; the
 * marker is centred on it and the label hangs beside it. Nothing inside is in
 * flow, so the button's own box never moves the point.
 */
.mkl-pc-hotspot {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: auto;
	border: 0;
	padding: 0;
	margin: 0;
	background: transparent;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
	opacity: 1;
	will-change: transform, opacity;
	transition: opacity 0.35s ease;
}

.mkl-pc-hotspot:focus, .mkl-pc-hotspot:hover {
	outline: none;
	z-index: 2;
}

.mkl-pc-hotspot[data-in_view="false"] {
	opacity: 0.15;
	pointer-events: none;
	.mkl-pc-hotspot__content-container {
		display: none;
	}
}

/*
 * A keyboard user can still Tab to a pin on the far side, and a focus stop that
 * is barely visible fails them. Shown in full while focused: the pin really is
 * there, behind the model. Taking these out of the tab order instead would make
 * the sequence change as the model turns, and hide the far side's information
 * from anyone who cannot see it to rotate towards it.
 */
.mkl-pc-hotspot[data-in_view="false"]:focus-visible {
	opacity: 1;
	.mkl-pc-hotspot__content-container {
		display: flex;
	}
}

/* Behind the camera there is no meaningful screen position; fe-hotspots.js also drops these from the tab order. */
.mkl-pc-hotspot[data-behind="true"] {
	opacity: 0;
	pointer-events: none;
}

/*
 * Dark disc, light ring. The model can be any colour and so can the backdrop,
 * and a single-tone marker vanishes against one of them: the old white dot
 * disappeared on a light studio backdrop or a white part. The ring carries it
 * on dark surfaces, the disc on light ones.
 */
.mkl-pc-hotspot__icon {
	position: absolute;
	top: 0;
	left: 0;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--mkl-pc-hotspot-size);
	height: var(--mkl-pc-hotspot-size);
	border: 2px solid var(--mkl-pc-hotspot-ring);
	border-radius: 50%;
	background: var(--mkl-pc-hotspot-color);
	color: var(--mkl-pc-hotspot-icon-color);
	box-shadow: 0 2px 8px rgba(17, 24, 39, 0.35);
	transform: translate(-50%, -50%);
	transition: transform 0.15s ease;
	svg {
		display: block;
		width: 16px;
		height: 16px;
	}
}

/* The dot icon is the disc itself, with a small centre so it still reads as a target. */
.mkl-pc-hotspot--icon-dot .mkl-pc-hotspot__icon::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--mkl-pc-hotspot-icon-color);
}

/*
 * A few slow pulses to draw the eye when the pins arrive, then still: a model
 * covered in permanently throbbing pins is noise. Held while the overlay waits
 * for the orbit hint, so the pulses start when the pins can actually be seen.
 */
.mkl-pc-hotspot__icon::after {
	content: '';
	position: absolute;
	inset: -2px;
	border-radius: 50%;
	border: 2px solid var(--mkl-pc-hotspot-ring);
	box-shadow: 0 0 0 1px var(--mkl-pc-hotspot-color);
	opacity: 0;
	animation: mkl-pc-hotspot-pulse 2s ease-out 3;
	pointer-events: none;
}

.mkl-pc-hotspots-overlay.is-awaiting-hint .mkl-pc-hotspot__icon::after {
	animation: none;
}

@keyframes mkl-pc-hotspot-pulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	100% {
		transform: scale(1.9);
		opacity: 0;
	}
}

.mkl-pc-hotspot:hover .mkl-pc-hotspot__icon,
.mkl-pc-hotspot:focus-visible .mkl-pc-hotspot__icon {
	transform: translate(-50%, -50%) scale(1.12);
}

.mkl-pc-hotspot:focus-visible .mkl-pc-hotspot__icon {
	box-shadow: 0 0 0 3px var(--mkl-pc-hotspot-focus);
}

@media (prefers-reduced-motion: reduce) {
	.mkl-pc-hotspot__icon {
		transition: none;
	}
	.mkl-pc-hotspot__icon::after {
		animation: none;
	}
}

/*
 * The label sits beside the marker, its first line level with the marker's
 * centre: the container starts half a marker above the point and the label is
 * exactly one marker tall. It used to hang from the point's lower right corner,
 * half under the icon. `data-side` is set by fe-hotspots.js, which flips the
 * label to the left when it would run off the viewer's right edge.
 *
 * max-content: the button is zero-wide, so an absolutely positioned child
 * would otherwise shrink to its narrowest and wrap annotation text word by word.
 */
.mkl-pc-hotspot__content-container {
	position: absolute;
	top: calc(var(--mkl-pc-hotspot-size) / -2);
	left: calc(var(--mkl-pc-hotspot-size) / 2 + var(--mkl-pc-hotspot-label-gap));
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	width: max-content;
	max-width: 260px;
}

.mkl-pc-hotspot[data-side="left"] .mkl-pc-hotspot__content-container {
	left: auto;
	right: calc(var(--mkl-pc-hotspot-size) / 2 + var(--mkl-pc-hotspot-label-gap));
	align-items: flex-end;
}

/* No marker: centre the label on the point itself. */
.mkl-pc-hotspot--icon-none .mkl-pc-hotspot__content-container,
.mkl-pc-hotspot--icon-none[data-side="left"] .mkl-pc-hotspot__content-container {
	left: 0;
	right: auto;
	align-items: center;
	transform: translateX(-50%);
}

.mkl-pc-hotspot__label {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	min-height: var(--mkl-pc-hotspot-size);
	padding: 4px 12px;
	border-radius: calc(var(--mkl-pc-hotspot-size) / 2);
	background: var(--mkl-pc-hotspot-label-bg);
	color: var(--mkl-pc-hotspot-label-color);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
	box-shadow: 0 2px 8px rgba(17, 24, 39, 0.2);
}

/*
 * Pin: the label is kept until asked for, and then the marker seems to stretch
 * into a pill holding it. The pill starts at the marker's left edge with the
 * same height, colours and ring, and sits under it, so the marker becomes the
 * pill's rounded end. The marker does not grow on hover here: it would no
 * longer line up with that end.
 *
 * clip-path rather than display: the label stays laid out, so fe-hotspots.js
 * can measure it to pick a side before it is ever shown.
 */
.mkl-pc-hotspot--pin .mkl-pc-hotspot__icon {
	z-index: 1;
}

.mkl-pc-hotspot--pin.mkl-pc-hotspot--has-label:hover .mkl-pc-hotspot__icon,
.mkl-pc-hotspot--pin.mkl-pc-hotspot--has-label:focus-visible .mkl-pc-hotspot__icon {
	transform: translate(-50%, -50%);
	border-color: transparent;
	background-color: transparent;
}

.mkl-pc-hotspot--pin .mkl-pc-hotspot__content-container {
	left: calc(var(--mkl-pc-hotspot-size) / -2);
	pointer-events: none;
	/* A box-shadow would be cut off by the clip; a filter follows its shape. */
	filter: drop-shadow(0 2px 6px rgba(17, 24, 39, 0.3));
}

/* Once open, the pill is part of the hotspot: moving onto it keeps it open, and it can be clicked. */
.mkl-pc-hotspot--pin:hover .mkl-pc-hotspot__content-container {
	pointer-events: auto;
}

.mkl-pc-hotspot--pin[data-side="left"] .mkl-pc-hotspot__content-container {
	left: auto;
	right: calc(var(--mkl-pc-hotspot-size) / -2);
}

.mkl-pc-hotspot--pin .mkl-pc-hotspot__label {
	border: 2px solid var(--mkl-pc-hotspot-ring);
	/* No vertical padding: with the ring, it would make the pill taller than the marker. */
	padding: 0 12px 0 calc(var(--mkl-pc-hotspot-size) + 2px);
	background: var(--mkl-pc-hotspot-color);
	color: var(--mkl-pc-hotspot-icon-color);
	white-space: nowrap;
	box-shadow: none;
	clip-path: inset(0 100% 0 0 round calc(var(--mkl-pc-hotspot-size) / 2));
	transition: clip-path 0.2s ease;
}

.mkl-pc-hotspot--pin[data-side="left"] .mkl-pc-hotspot__label {
	padding: 0 calc(var(--mkl-pc-hotspot-size) + 2px) 0 12px;
	clip-path: inset(0 0 0 100% round calc(var(--mkl-pc-hotspot-size) / 2));
}

.mkl-pc-hotspot--pin:hover .mkl-pc-hotspot__label,
.mkl-pc-hotspot--pin:focus-visible .mkl-pc-hotspot__label {
	clip-path: inset(0 0 0 0 round calc(var(--mkl-pc-hotspot-size) / 2));
}

@media (prefers-reduced-motion: reduce) {
	.mkl-pc-hotspot--pin .mkl-pc-hotspot__label {
		transition: none;
	}
}

.mkl-pc-hotspot__body {
	display: none;
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--mkl-pc-hotspot-label-bg);
	color: var(--mkl-pc-hotspot-label-color);
	font-size: 13px;
	line-height: 1.45;
	box-shadow: 0 4px 16px rgba(17, 24, 39, 0.18);
	img {
		display: block;
		max-width: 100%;
		height: auto;
		margin-top: 8px;
		border-radius: 4px;
	}
}

.mkl-pc-hotspot--annotation:hover .mkl-pc-hotspot__body,
.mkl-pc-hotspot--annotation:focus-visible .mkl-pc-hotspot__body {
	display: block;
}

.mkl-pc-hotspot-description-panel {
	position: fixed;
	inset: 0;
	z-index: 100020;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.45);
}

.mkl-pc-hotspot-description-panel__inner {
	position: relative;
	background: #fff;
	border-radius: 8px;
	padding: 20px 24px;
	max-width: 520px;
	width: calc(100% - 32px);
	max-height: 80vh;
	overflow: auto;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.mkl-pc-hotspot-description-panel__close {
	position: absolute;
	top: 8px;
	right: 10px;
	border: 0;
	background: transparent;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #6b7280;
}

.mkl-pc-hotspot-description-panel__title {
	margin: 0 0 12px;
	font-size: 18px;
}

.mkl-pc-hotspot-description-panel__body {
	font-size: 14px;
	line-height: 1.5;
}

.mkl-pc-hotspot-description-panel__body p:first-child {
	margin-top: 0;
}

.mkl-pc-hotspot-description-panel__body p:last-child {
	margin-bottom: 0;
}
