/* Reels on space listings: inc/space-reels.php, assets/js/space-reels.js. Loaded only on listings that have reels. */

/* Row: two or more reels, above Overview */
.sn-reels__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
}
.space-content__item.sn-reels .sn-reels__head h3 { margin: 0; }
.sn-reels__arrows { display: flex; flex: none; gap: 8px; }
.sn-reels__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid #dcdee4;
	border-radius: 50%;
	background: #fff;
	color: #0f0f0f;
	cursor: pointer;
}
.sn-reels__arrow svg { width: 14px; height: 14px; }
.sn-reels__arrow--prev svg { transform: rotate(180deg); }
.sn-reels__arrow:disabled { opacity: 0.35; cursor: default; }
.sn-reels__track {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}
.sn-reels__track::-webkit-scrollbar { display: none; }

/* Tile */
.sn-reels__tile {
	position: relative;
	display: block;
	flex: 0 0 calc((100% - 36px) / 4);
	aspect-ratio: 9 / 16;
	overflow: hidden;
	border-radius: 14px;
	background: #111;
	color: #fff;
	text-decoration: none;
	scroll-snap-align: start;
}
/* Beats the theme's green .space-content__item a:not(.button) */
.space-content__item a.sn-reels__tile:not(.button),
.space-content__item a.sn-reels__tile:not(.button):hover,
.space-content__item a.sn-reels__tile:not(.button):focus { color: #fff; font-weight: 400; text-decoration: none; }
.sn-reels__tile:focus-visible { outline: 3px solid #197845; outline-offset: 3px; }
.sn-reels__tile img,
.sn-reels__tile video {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: transform 0.35s ease;
}
.sn-reels__tile:hover img,
.sn-reels__tile:hover video { transform: scale(1.03); }
.sn-reels__shade {
	position: absolute;
	inset: auto 0 0;
	height: 46%;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
	pointer-events: none;
}
.sn-reels__play {
	position: absolute;
	top: 10px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.42);
}
.sn-reels__play svg { width: 11px; height: 11px; margin-left: 2px; }
.sn-reels__label {
	position: absolute;
	right: 12px;
	bottom: 12px;
	left: 12px;
	display: grid;
	gap: 1px;
}
.sn-reels__label b { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sn-reels__label span {
	overflow: hidden;
	font-size: 12.5px;
	line-height: 1.35;
	white-space: nowrap;
	text-overflow: ellipsis;
	opacity: 0.85;
}

/* One reel: the tile sits to the left of the Overview text */
.sn-reels-solo {
	display: grid;
	grid-template-columns: 240px minmax(0, 1fr);
	gap: 32px;
	align-items: start;
}
.sn-reels-solo__reel { position: sticky; top: 24px; }
.sn-reels-solo__reel .sn-reels__tile { width: 100%; }
.sn-reels-solo__text { min-width: 0; }

@media (max-width: 767px) {
	.sn-reels__arrows { display: none; }
	.sn-reels__track { gap: 10px; margin-right: -15px; padding-right: 15px; }
	.sn-reels__tile { flex-basis: 44%; }
	.sn-reels-solo { display: block; }
	.sn-reels-solo__reel { position: static; width: 60%; margin-bottom: 24px; }
}

/* Modal */
html.sn-reels-open { overflow: hidden; }
.sn-reels-modal {
	--sn-rh: min(calc(100vh - 172px), 1100px);
	--sn-rw: min(calc(var(--sn-rh) * 9 / 16), calc(100vw - 240px));
	position: fixed;
	inset: 0;
	z-index: 100001;
	background: rgba(9, 9, 9, 0.96);
	color: #fff;
	font-family: GroteskNeue, sans-serif;
}
@supports (height: 100dvh) {
	.sn-reels-modal { --sn-rh: min(calc(100dvh - 172px), 1100px); }
}
.sn-reels-modal[hidden] { display: none; }
.sn-reels-modal button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}
.sn-reels-modal button:focus-visible,
.sn-reels-modal a:focus-visible { outline: 3px solid #6adc91; outline-offset: 2px; }
.sn-reels-modal__close {
	position: absolute;
	z-index: 3;
	top: 22px;
	right: 26px;
	width: 44px;
	height: 44px;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
}
.sn-reels-modal__close svg { width: 16px; height: 16px; }
.sn-reels-modal__count {
	position: absolute;
	z-index: 3;
	top: 32px;
	left: 32px;
	font-size: 15px;
	font-weight: 500;
	opacity: 0.8;
}
.sn-reels-modal__nav {
	position: absolute;
	z-index: 3;
	top: calc(36px + var(--sn-rh) / 2 - 24px);
	width: 48px;
	height: 48px;
	background: #fff;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
	color: #0f0f0f;
}
.sn-reels-modal__nav svg { width: 15px; height: 15px; }
.sn-reels-modal__nav--prev { left: calc(50% - var(--sn-rw) / 2 - 74px); }
.sn-reels-modal__nav--prev svg { transform: rotate(180deg); }
.sn-reels-modal__nav--next { right: calc(50% - var(--sn-rw) / 2 - 74px); }
.sn-reels-modal__nav:disabled { opacity: 0; pointer-events: none; }
.sn-reels-modal__track {
	position: absolute;
	top: 36px;
	right: 0;
	left: 0;
	display: flex;
	gap: 26px;
	height: var(--sn-rh);
	padding-inline: calc(50% - var(--sn-rw) / 2);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	touch-action: pan-x;
	cursor: grab;
	-webkit-overflow-scrolling: touch;
}
.sn-reels-modal__track::-webkit-scrollbar { display: none; }
.sn-reels-modal__track.is-drag { cursor: grabbing; user-select: none; }
.sn-reels-modal__slide {
	flex: 0 0 var(--sn-rw);
	height: 100%;
	scroll-snap-align: center;
	scroll-snap-stop: always;
}
.sn-reels-modal__reel {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border-radius: 16px;
	background: #111;
	transition: opacity 0.25s, transform 0.25s;
}
.sn-reels-modal__slide:not(.is-current) .sn-reels-modal__reel { opacity: 0.32; transform: scale(0.9); cursor: pointer; }
.sn-reels-modal__reel video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}
.sn-reels-modal__sound {
	position: absolute;
	z-index: 2;
	top: 12px;
	right: 12px;
	width: 38px;
	height: 38px;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
}
.sn-reels-modal__sound svg { width: 18px; height: 18px; }
.sn-reels-modal__slide:not(.is-current) .sn-reels-modal__sound { visibility: hidden; }
.sn-reels-modal__bar {
	position: absolute;
	z-index: 2;
	right: 0;
	bottom: 0;
	left: 0;
	height: 3px;
	background: rgba(255, 255, 255, 0.25);
}
.sn-reels-modal__bar i { display: block; width: 0; height: 100%; background: #fff; }
.sn-reels-modal__cap {
	position: absolute;
	right: 0;
	bottom: 24px;
	left: 0;
	display: grid;
	gap: 3px;
	padding: 0 24px;
	text-align: center;
}
.sn-reels-modal__cap b { font-size: 21px; font-weight: 700; line-height: 1.2; }
.sn-reels-modal__cap span { font-size: 15px; color: rgba(255, 255, 255, 0.75); }
.sn-reels-modal__cap a { color: #fff; text-decoration: underline; }

/* On a phone, or a phone on its side, each reel fills the screen. Nothing is cropped: a taller screen shows black above and below. */
@media (max-width: 767px), (max-height: 520px) {
	.sn-reels-modal { --sn-rh: 100vh; --sn-rw: 100vw; background: #000; }
	@supports (height: 100dvh) {
		.sn-reels-modal { --sn-rh: 100dvh; }
	}
	.sn-reels-modal__track { top: 0; gap: 0; padding-inline: 0; }
	.sn-reels-modal__reel { border-radius: 0; }
	.sn-reels-modal__slide:not(.is-current) .sn-reels-modal__reel { opacity: 1; transform: none; }
	.sn-reels-modal__nav { display: none !important; }
	.sn-reels-modal__close { top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; background: rgba(0, 0, 0, 0.45); }
	.sn-reels-modal__count { top: calc(26px + env(safe-area-inset-top, 0px)); left: 16px; opacity: 1; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
	.sn-reels-modal__sound { top: calc(68px + env(safe-area-inset-top, 0px)); right: 17px; }
	.sn-reels-modal__cap {
		z-index: 2;
		bottom: 0;
		padding: 60px 16px calc(22px + env(safe-area-inset-bottom, 0px));
		background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
		text-align: left;
		pointer-events: none;
	}
	.sn-reels-modal__cap a { pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
	.sn-reels__tile img,
	.sn-reels__tile video,
	.sn-reels-modal__reel { transition: none; }
}
