/**
 * HyperKit Photo Fan.
 *
 * Every photo is absolutely positioned in the middle of the stage and moved
 * out from there. PHP hands each one two numbers — a centred index in
 * --hk-pf-i and the same value normalised to -1…1 in --hk-pf-t — and the
 * single transform below turns them into the spread, the arc and the tilt.
 *
 * The stage keeps its own height and width so the page does not reflow when
 * the fan opens; only transforms animate, never layout.
 */

.hk-pf {
	--hk-pf-w: 210px;
	--hk-pf-ratio: 1.25;
	--hk-pf-h: calc(var(--hk-pf-w) * var(--hk-pf-ratio));
	--hk-pf-radius: 14px;
	--hk-pf-pad: 0px;
	--hk-pf-frame: #ffffff;

	--hk-pf-spread: 168px;
	--hk-pf-arc: 46px;
	--hk-pf-tilt: 11deg;
	--hk-pf-closed-scale: 0.88;
	--hk-pf-speed: 720ms;
	--hk-pf-stagger: 55ms;

	--hk-pf-note-bg-all: #ffd400;
	--hk-pf-note-color: #111111;
	--hk-pf-note-rot: -6deg;

	--hk-pf-lb-bg: rgba(8, 8, 8, 0.86);
	--hk-pf-lb-color: #ffffff;
	--hk-pf-lb-radius: 12px;

	position: relative;
}

.hk-pf--empty {
	padding: 24px;
	border: 1px dashed rgba(17, 17, 17, 0.3);
	border-radius: 10px;
	font-style: italic;
	text-align: center;
}

.hk-pf__stage {
	position: relative;
	/* Room for the open fan: the photos either side of the middle, plus the
	 * arc and the tilt's overhang. Reserved up front so opening the fan never
	 * moves the rest of the page. */
	width: calc(var(--hk-pf-spread) * (var(--hk-pf-count) - 1) + var(--hk-pf-w) * 1.2);
	max-width: 100%;
	height: calc(var(--hk-pf-h) + max(var(--hk-pf-arc), 0px) + 40px);
	margin: 0 auto;
}

.hk-pf__photo {
	position: absolute;
	left: 50%;
	top: 20px;
	z-index: var(--hk-pf-z, 1);
	display: block;
	width: var(--hk-pf-w);
	height: var(--hk-pf-h);
	margin: 0;
	padding: var(--hk-pf-pad);
	border-radius: var(--hk-pf-radius);
	background: var(--hk-pf-frame);
	/* Closed: a neat pile, each photo turned a little more than the last. */
	transform:
		translateX(-50%)
		translateX(calc(var(--hk-pf-i, 0) * 6px))
		scale(var(--hk-pf-closed-scale))
		rotate(calc(var(--hk-pf-t, 0) * 3deg + var(--hk-pf-extra-rot, 0deg)));
	transition:
		transform var(--hk-pf-speed) cubic-bezier(0.22, 1, 0.32, 1),
		box-shadow 0.3s ease;
	transition-delay: calc(var(--hk-pf-n, 0) * var(--hk-pf-stagger));
	cursor: default;
}

.hk-pf--lightbox .hk-pf__photo {
	cursor: zoom-in;
}

/* Scoped with the root class on purpose. Elementor's frontend stylesheet
 * carries `.elementor img { height: auto; border-radius: 0; }` at specificity
 * (0,1,1), which beats a bare `.hk-xx__img` (0,1,0) — so the image ignores its
 * height and its radius, sizes to its own aspect ratio, and leaves the card's
 * background showing as a polaroid border nobody asked for. Two classes wins. */
.hk-pf .hk-pf__img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: calc(var(--hk-pf-radius) - var(--hk-pf-pad));
	object-fit: cover;
}

/* --- open --------------------------------------------------------------- */
.hk-pf--always .hk-pf__photo,
.hk-pf.is-open .hk-pf__photo,
.hk-pf--hover .hk-pf__stage:hover .hk-pf__photo {
	transform:
		translateX(-50%)
		translateX(calc(var(--hk-pf-i, 0) * var(--hk-pf-spread)))
		translateY(calc(var(--hk-pf-t, 0) * var(--hk-pf-t, 0) * var(--hk-pf-arc) + var(--hk-pf-nudge, 0px)))
		rotate(calc(var(--hk-pf-t, 0) * var(--hk-pf-tilt) + var(--hk-pf-extra-rot, 0deg)));
}

/* The lifted photo has to win over the neighbours it is overlapping, so the
 * z-index goes up with it. */
.hk-pf--lift .hk-pf__photo:hover,
.hk-pf--lift .hk-pf__photo:focus-visible {
	z-index: 99;
}

.hk-pf--lift.hk-pf--always .hk-pf__photo:hover,
.hk-pf--lift.hk-pf.is-open .hk-pf__photo:hover,
.hk-pf--lift.hk-pf--hover .hk-pf__stage:hover .hk-pf__photo:hover {
	transform:
		translateX(-50%)
		translateX(calc(var(--hk-pf-i, 0) * var(--hk-pf-spread)))
		translateY(calc(var(--hk-pf-t, 0) * var(--hk-pf-t, 0) * var(--hk-pf-arc) + var(--hk-pf-nudge, 0px) - 18px))
		rotate(calc(var(--hk-pf-t, 0) * var(--hk-pf-tilt) * 0.4 + var(--hk-pf-extra-rot, 0deg)))
		scale(1.04);
	transition-delay: 0ms;
}

/* --- sticky notes ------------------------------------------------------- */
.hk-pf__note {
	position: absolute;
	z-index: 2;
	padding: 6px 11px;
	border-radius: 10px;
	background: var(--hk-pf-note-bg, var(--hk-pf-note-bg-all));
	color: var(--hk-pf-note-color);
	font-size: 13px;
	line-height: 1.2;
	white-space: nowrap;
	box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
	transform: rotate(var(--hk-pf-note-rot));
}

/* The tail. Drawn as a rotated square rather than a border triangle so it
 * inherits the note's colour, including a per-photo override. */
.hk-pf__note::after {
	content: "";
	position: absolute;
	width: 9px;
	height: 9px;
	background: inherit;
	transform: rotate(45deg);
}

.hk-pf__note--tl { left: -12px; top: -14px; }
.hk-pf__note--tr { right: -12px; top: -14px; }
.hk-pf__note--bl { left: -12px; bottom: -14px; }
.hk-pf__note--br { right: -12px; bottom: -14px; }

.hk-pf__note--tl::after { left: 16px; bottom: -4px; }
.hk-pf__note--tr::after { right: 16px; bottom: -4px; }
.hk-pf__note--bl::after { left: 16px; top: -4px; }
.hk-pf__note--br::after { right: 16px; top: -4px; }

/* --- lightbox ----------------------------------------------------------- */
.hk-pf__lb {
	position: fixed;
	inset: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hk-pf__lb[hidden] {
	display: none;
}

.hk-pf__lb-backdrop {
	position: absolute;
	inset: 0;
	background: var(--hk-pf-lb-bg);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.hk-pf__lb.is-open .hk-pf__lb-backdrop {
	opacity: 1;
}

.hk-pf__lb-inner {
	position: relative;
	display: flex;
	gap: 12px;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 5vmin;
	color: var(--hk-pf-lb-color);
	opacity: 0;
	scale: 0.97;
	transition: opacity 0.3s ease, scale 0.35s cubic-bezier(0.22, 1, 0.32, 1);
}

.hk-pf__lb-inner:focus {
	outline: none;
}

.hk-pf__lb.is-open .hk-pf__lb-inner {
	opacity: 1;
	scale: 1;
}

.hk-pf__lb-figure {
	display: flex;
	flex-direction: column;
	gap: 14px;
	align-items: center;
	margin: 0;
	min-width: 0;
}

.hk-pf .hk-pf__lb-img {
	max-width: min(1100px, 86vw);
	max-height: 78vh;
	border-radius: var(--hk-pf-lb-radius);
	object-fit: contain;
}

.hk-pf__lb-caption {
	font-size: 14px;
	opacity: 0.8;
	text-align: center;
}

.hk-pf__lb-close,
.hk-pf__lb-nav {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: inherit;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.hk-pf__lb-close:hover,
.hk-pf__lb-nav:hover {
	background: rgba(255, 255, 255, 0.24);
}

.hk-pf__lb-close {
	position: absolute;
	top: 4vmin;
	right: 4vmin;
	z-index: 2;
}

.hk-pf__lb-close svg,
.hk-pf__lb-nav svg {
	width: 20px;
	height: 20px;
}

.hk-pf__lb-count {
	position: absolute;
	left: 50%;
	bottom: 3vmin;
	translate: -50% 0;
	font-size: 13px;
	letter-spacing: 0.08em;
	opacity: 0.7;
}

/* --- small screens ------------------------------------------------------ */
@media (max-width: 767px) {
	.hk-pf__note {
		font-size: 11px;
		padding: 5px 9px;
	}

	.hk-pf__lb-nav {
		position: absolute;
		bottom: 6vmin;
	}

	.hk-pf__lb-nav--prev { left: 6vmin; }
	.hk-pf__lb-nav--next { right: 6vmin; }
}

@media (prefers-reduced-motion: reduce) {
	.hk-pf__photo,
	.hk-pf__lb-inner,
	.hk-pf__lb-backdrop {
		transition-duration: 0.001ms;
	}
}
