/* Rabin Craft — Hover Preview List. Needs core.css.
   Image position: --follow (hover-list.js sets --fx/--fy, pointer px within the list, and --tilt, deg, on the
   floating frame, .is-showing on the list), --side (the frame sits beside the list) or --inline (CSS only: the
   row's thumbnail opens beside its title). The script sets .is-active on the current row's image and .is-prev
   on the one it replaces. Touch screens get a thumbnail in each row instead; with --tap the script adds
   .is-tap and the thumbnail becomes a button that opens the image under the row (.is-open).
   Image shape: --shape-square | portrait | wide | circle (landscape without a class). */

.mkit-hlist {
	--_ratio: 4/3;
	--_radius: var(--mkit-card-radius, 14px);
	position: relative;
	width: 100%;
	color: var(--mkit-muted);
}

.mkit-hlist--shape-square {
	--_ratio: 1;
}

.mkit-hlist--shape-portrait {
	--_ratio: 3/4;
}

.mkit-hlist--shape-wide {
	--_ratio: 16/9;
}

.mkit-hlist--shape-circle {
	--_ratio: 1;
	--_radius: 50%;
}

.mkit-hlist__rows {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--mkit-line);
}

.mkit-hlist__row {
	margin: 0;
	border-bottom: 1px solid var(--mkit-line);
}

.mkit-hlist__link {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	align-items: center;
	gap: clamp(1rem, 3vw, 2.5rem);
	padding: clamp(1.1rem, 2.6vw, 2rem) .25rem;
	color: inherit;
	text-decoration: none;
	transition: opacity .35s var(--mkit-ease);
}

.mkit-hlist--numbered .mkit-hlist__link {
	grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.mkit-hlist__num {
	min-width: 2ch;
	color: var(--mkit-accent-soft);
	font-family: var(--mkit-font-mono);
	font-size: .8125rem;
	letter-spacing: .08em;
}

.mkit-hlist__title {
	color: var(--mkit-text);
	font-size: clamp(1.75rem, 1.1rem + 2.8vw, 4rem);
	font-weight: 600;
	line-height: 1.05;
	letter-spacing: -.035em;
	transition: translate .45s var(--mkit-ease), color .35s var(--mkit-ease);
}

.mkit-hlist__meta {
	font-size: .9375rem;
	text-align: right;
}

.mkit-hlist__arrow {
	width: clamp(1.5rem, 2.5vw, 2.25rem);
	height: auto;
	color: var(--mkit-text);
	rotate: -45deg;
	transition: rotate .45s var(--mkit-ease), color .35s var(--mkit-ease);
}

.mkit-hlist__thumb {
	display: none;
}

.mkit-hlist__rows:has(.mkit-hlist__link:is(:hover, :focus-visible)) .mkit-hlist__link:not(:hover, :focus-visible) {
	opacity: .32;
}

.mkit-hlist__link:is(:hover, :focus-visible) .mkit-hlist__title {
	translate: clamp(.5rem, 1.5vw, 1.25rem) 0;
}

.mkit-hlist__link:is(:hover, :focus-visible) .mkit-hlist__arrow {
	rotate: 0deg;
	color: var(--mkit-accent-soft);
}

.mkit-hlist__link:focus-visible {
	outline: 2px solid var(--mkit-accent-soft);
	outline-offset: -2px;
}

/* The floating frame (mouse and trackpad) */
.mkit-hlist__float {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 5;
	width: var(--mkit-float-w, clamp(200px, 22vw, 320px));
	aspect-ratio: var(--mkit-float-ratio, var(--_ratio));
	translate: calc(var(--fx, 0) * 1px + 32px) calc(var(--fy, 0) * 1px - 50%); /* right of the pointer */
	rotate: calc(var(--tilt, 0) * 1deg);
	scale: .6;
	opacity: 0;
	pointer-events: none;
	transition: opacity .35s var(--mkit-ease), scale .5s var(--mkit-spring);
}

.mkit-hlist.is-showing .mkit-hlist__float {
	opacity: 1;
	scale: 1;
}

.mkit-hlist__frame {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border-radius: var(--_radius);
	box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6);
}

.mkit-hlist__img {
	position: absolute;
	inset: 0;
	clip-path: inset(100% 0 0 0);
	transition: clip-path .55s cubic-bezier(.7, 0, .2, 1);
}

.mkit-hlist__img.is-active {
	z-index: 1;
	clip-path: inset(0 0 0 0);
}

.mkit-hlist__img.is-prev {
	clip-path: inset(0 0 0 0);
	transition: none;
}

.mkit-hlist__img > img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	scale: 1.15;
	transition: scale .8s var(--mkit-ease);
}

.mkit-hlist__img.is-active > img {
	scale: 1;
}

/* Fixed side: the frame stays beside the list and only its image changes */
.mkit-hlist--side {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--mkit-float-w, clamp(220px, 30vw, 420px));
	align-items: start;
	gap: clamp(1.5rem, 4vw, 4rem);
}

.mkit-hlist--side .mkit-hlist__float {
	position: sticky;
	top: calc(var(--mkit-sticky-top, 0px) + 12vh);
	width: auto;
	translate: none;
	rotate: none;
	scale: 1;
	opacity: 1;
}

/* Inline: the row's own image opens beside its title. Its space is always there (the middle of a row
   is empty), so opening it moves nothing. */
@media (hover: hover) and (pointer: fine) and (min-width: 601px) {
	.mkit-hlist--inline .mkit-hlist__link {
		display: flex;
	}
	.mkit-hlist--inline .mkit-hlist__title {
		min-width: 0;
	}
	.mkit-hlist--inline .mkit-hlist__meta {
		order: 1;
		margin-inline-start: auto;
	}
	.mkit-hlist--inline .mkit-hlist__arrow {
		order: 2;
	}
	.mkit-hlist--inline .mkit-hlist__arrow {
		margin-inline-start: auto;
	}
	.mkit-hlist--inline .mkit-hlist__meta ~ .mkit-hlist__arrow {
		margin-inline-start: 0;
	}
	.mkit-hlist--inline .mkit-hlist__thumb {
		position: relative;
		display: block;
		flex: none;
		height: var(--mkit-inline-h, clamp(3rem, 2rem + 3.6vw, 5.5rem));
		aspect-ratio: var(--mkit-float-ratio, var(--_ratio));
		margin-block: -.75rem;
		overflow: hidden;
		border-radius: var(--_radius);
		clip-path: inset(0 100% 0 0 round var(--_radius));
		opacity: 0;
		translate: -.5rem 0;
		transition: clip-path .55s cubic-bezier(.7, 0, .2, 1), opacity .3s var(--mkit-ease), translate .45s var(--mkit-ease);
	}
	.mkit-hlist--inline .mkit-hlist__thumb > img {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.mkit-hlist--inline .mkit-hlist__link:is(:hover, :focus-visible) .mkit-hlist__thumb {
		clip-path: inset(0 0 0 0 round var(--_radius));
		opacity: 1;
		translate: clamp(.5rem, 1.5vw, 1.25rem) 0; /* moves with the title */
	}
}

/* Tap mode's button and panel exist only once the script has turned it on (touch screens) */
.mkit-hlist__toggle {
	display: none;
}

/* The side frame needs room: narrow lists get the thumbnails */
@media (max-width: 767px) {
	.mkit-hlist--side {
		display: block;
	}
}

@media (hover: none), (pointer: coarse), (max-width: 767px) {
	.mkit-hlist--side .mkit-hlist__float {
		display: none;
	}
	.mkit-hlist--side .mkit-hlist__thumb {
		position: relative;
		display: block;
		width: clamp(48px, 12vw, 72px);
		aspect-ratio: 1;
		overflow: hidden;
		border-radius: min(var(--_radius), 10px);
	}
	.mkit-hlist--side.mkit-hlist--shape-circle .mkit-hlist__thumb {
		border-radius: 50%;
	}
	.mkit-hlist--side .mkit-hlist__thumb > :is(img, .mkit-ph) {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.mkit-hlist--side .mkit-hlist__arrow {
		display: none;
	}
}

@media (hover: none), (pointer: coarse) {
	.mkit-hlist--side {
		display: block;
	}
	.mkit-hlist__float {
		display: none;
	}
	.mkit-hlist__thumb {
		position: relative;
		display: block;
		width: clamp(48px, 12vw, 72px);
		aspect-ratio: 1;
		overflow: hidden;
		border-radius: 10px;
	}
	.mkit-hlist--shape-circle .mkit-hlist__thumb {
		border-radius: 50%;
	}

	/* Tap mode: the thumbnail is a button beside the link; its image opens under the row */
	.mkit-hlist.is-tap .mkit-hlist__row {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		column-gap: clamp(.75rem, 3vw, 1.5rem);
	}
	.mkit-hlist.is-tap .mkit-hlist__link .mkit-hlist__thumb {
		display: none; /* the button carries it */
	}
	.mkit-hlist.is-tap .mkit-hlist__toggle {
		position: relative;
		display: block;
		margin: 0 .25rem 0 0;
		padding: 0;
		border: 0;
		border-radius: 12px;
		background: none;
		color: inherit;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		touch-action: manipulation;
	}
	.mkit-hlist.is-tap .mkit-hlist__thumb {
		width: clamp(56px, 14vw, 76px); /* a comfortable tap target */
	}
	/* a small + that turns into × while the image is open */
	.mkit-hlist.is-tap .mkit-hlist__toggle::after {
		content: "";
		position: absolute;
		right: -6px;
		bottom: -6px;
		width: 22px;
		height: 22px;
		border-radius: 50%;
		background:
			linear-gradient(currentColor, currentColor) center / 10px 1.5px no-repeat,
			linear-gradient(currentColor, currentColor) center / 1.5px 10px no-repeat,
			var(--mkit-surface);
		box-shadow: 0 0 0 1px var(--mkit-line);
		color: var(--mkit-text);
		transition: rotate .35s var(--mkit-ease);
	}
	.mkit-hlist.is-tap .mkit-hlist__toggle[aria-expanded="true"]::after {
		rotate: 45deg;
	}
	.mkit-hlist.is-tap .mkit-hlist__toggle:focus-visible {
		outline: 2px solid var(--mkit-accent-soft);
		outline-offset: 3px;
	}
	.mkit-hlist__peek {
		position: relative;
		grid-column: 1 / -1;
		width: min(100%, 26rem);
		aspect-ratio: var(--mkit-float-ratio, var(--_ratio));
		margin: 0 .25rem clamp(1.1rem, 2.6vw, 2rem);
		overflow: hidden;
		border-radius: var(--_radius);
		animation: mkit-hlist-peek .5s cubic-bezier(.7, 0, .2, 1) both;
	}
	.mkit-hlist--shape-circle .mkit-hlist__peek {
		width: min(70%, 16rem);
	}
	.mkit-hlist__peek > img {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.mkit-hlist__thumb > :is(img, .mkit-ph) {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.mkit-hlist__thumb .mkit-ph span {
		font-size: 1rem;
	}
	.mkit-hlist__arrow {
		display: none;
	}
}

.mkit-hlist__peek[hidden] {
	display: none;
}

@keyframes mkit-hlist-peek {
	from {
		clip-path: inset(0 0 100% 0);
		opacity: 0;
	}
	to {
		clip-path: inset(0 0 0 0);
		opacity: 1;
	}
}

@media (max-width: 600px) {
	.mkit-hlist__link,
	.mkit-hlist--numbered .mkit-hlist__link {
		grid-template-columns: auto minmax(0, 1fr) auto;
		row-gap: .25rem;
	}
	.mkit-hlist:not(.mkit-hlist--numbered) .mkit-hlist__link {
		grid-template-columns: minmax(0, 1fr) auto;
	}
	.mkit-hlist__meta {
		grid-column: 1 / -1;
		font-size: .875rem;
		text-align: left;
	}
	.mkit-hlist--numbered .mkit-hlist__meta {
		grid-column: 2 / -1;
		grid-row: 2;
	}
	/* without numbers: the text stacks on the left, the thumbnail or arrow stays on the right */
	.mkit-hlist:not(.mkit-hlist--numbered) .mkit-hlist__meta {
		grid-column: 1;
		grid-row: 2;
	}
	.mkit-hlist:not(.mkit-hlist--numbered) :is(.mkit-hlist__thumb, .mkit-hlist__arrow) {
		grid-column: 2;
		grid-row: 1 / span 2;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mkit-hlist:not(.mkit-hlist--side) .mkit-hlist__float {
		display: none;
	}
	.mkit-hlist__title,
	.mkit-hlist__arrow,
	.mkit-hlist__img,
	.mkit-hlist__img > img,
	.mkit-hlist__thumb,
	.mkit-hlist__toggle::after {
		transition: none !important;
	}
	.mkit-hlist__peek {
		animation: none;
	}
}
