/*
 * Alloggio Instagram Feed
 * Inherits your theme's fonts and text colour. Override these in your theme:
 *   .aif { --aif-radius: 0; --aif-button-bg: #fff; }
 */

.aif {
	--aif-radius: 6px;
	--aif-tile-bg: rgba(127, 127, 127, 0.12);
	--aif-button-bg: #ffffff;
	--aif-button-fg: #1a1a1a;
	--aif-focus: currentColor;
	--aif-lb-bg: rgba(12, 12, 14, 0.94);
	--aif-lb-fg: #f3f3f1;
	--aif-lb-panel: #1b1b1e;

	--_pv: var(--aif-pv, 4);
	position: relative;
	margin-block: 1.5em;
}

@media (max-width: 1024px) {
	.aif { --_pv: var(--aif-pv-t, 3); }
}

@media (max-width: 640px) {
	.aif { --_pv: var(--aif-pv-m, 1.5); }
}

/* Header ----------------------------------------------------------- */

.aif__header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.25em 1em;
	margin-bottom: 0.9em;
}

.aif__title {
	margin: 0;
}

.aif__handle {
	font-weight: 600;
	text-decoration: none;
	color: inherit;
}

.aif__handle:hover,
.aif__handle:focus-visible {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* Track ------------------------------------------------------------ */

.aif__viewport {
	position: relative;
}

.aif .aif__track {
	display: flex;
	gap: var(--aif-gap, 12px);
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.aif .aif__track::-webkit-scrollbar {
	display: none;
}

.aif .aif__track:focus-visible {
	outline: 2px solid var(--aif-focus);
	outline-offset: 4px;
}

.aif--dragging .aif__track {
	scroll-snap-type: none;
	cursor: grabbing;
	user-select: none;
}

.aif .aif__slide {
	flex: 0 0 calc((100% - (var(--_pv) - 1) * var(--aif-gap, 12px)) / var(--_pv));
	min-width: 0;
	margin: 0;
	padding: 0;
	scroll-snap-align: start;
}

.aif__slide::before,
.aif__slide::marker {
	content: none;
}

/* Tiles ------------------------------------------------------------ */

.aif .aif__item {
	position: relative;
	display: block;
	aspect-ratio: var(--aif-ratio, 1/1);
	overflow: hidden;
	border-radius: var(--aif-radius);
	background: var(--aif-tile-bg);
	color: #fff;
	text-decoration: none;
	cursor: zoom-in;
}

.aif .aif__item img,
.aif .aif__item video {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: transform 0.5s ease, filter 0.3s ease;
	pointer-events: none;
}

.aif .aif__item:hover img,
.aif .aif__item:hover video {
	transform: scale(1.035);
	filter: brightness(0.9);
}

.aif .aif__item:focus-visible {
	outline: 2px solid var(--aif-focus);
	outline-offset: 3px;
}

.aif__badge {
	position: absolute;
	top: 10px;
	right: 10px;
	display: flex;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
	pointer-events: none;
}

/* Arrows ----------------------------------------------------------- */

.aif .aif__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--aif-button-bg);
	color: var(--aif-button-fg);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	transform: translateY(-50%);
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.aif .aif__nav svg {
	width: 20px;
	height: 20px;
}

.aif .aif__nav--prev { left: 10px; }
.aif .aif__nav--next { right: 10px; }

[dir="rtl"] .aif .aif__nav--prev,
.aif[dir="rtl"] .aif__nav--prev { left: auto; right: 10px; transform: translateY(-50%) scaleX(-1); }
[dir="rtl"] .aif .aif__nav--next,
.aif[dir="rtl"] .aif__nav--next { right: auto; left: 10px; transform: translateY(-50%) scaleX(-1); }

.aif .aif__nav:disabled {
	opacity: 0;
	pointer-events: none;
}

.aif .aif__nav:focus-visible {
	outline: 2px solid var(--aif-button-fg);
	outline-offset: 2px;
}

.aif--static .aif__nav {
	display: none;
}

@media (hover: none) and (max-width: 640px) {
	.aif .aif__nav { display: none; }
}

/* Lightbox --------------------------------------------------------- */

html.aif-lock {
	overflow: hidden;
}

.aif-lb {
	--aif-lb-bg: rgba(12, 12, 14, 0.94);
	--aif-lb-fg: #f3f3f1;
	--aif-lb-panel: #1b1b1e;

	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--aif-lb-bg);
	color: var(--aif-lb-fg);
	font: inherit;
	z-index: 100000;
}

.aif-lb::backdrop {
	background: transparent;
}

.aif-lb[open] {
	animation: aif-fade 0.2s ease-out;
}

@keyframes aif-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.aif-lb__inner {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
	width: 100%;
	height: 100%;
}

.aif-lb__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 56px 72px;
	touch-action: pan-y;
}

.aif-lb__media {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	min-height: 0;
}

.aif-lb__asset {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.aif-lb__asset.is-ready {
	opacity: 1;
}

video.aif-lb__asset {
	background: #000;
	opacity: 1;
}

.aif-lb button {
	margin: 0;
	padding: 0;
	border: 0;
	font: inherit;
	cursor: pointer;
}

.aif-lb__nav,
.aif-lb__close {
	position: absolute;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: var(--aif-lb-fg);
	transition: background-color 0.2s ease;
}

.aif-lb__nav svg,
.aif-lb__close svg {
	width: 22px;
	height: 22px;
}

.aif-lb__nav:hover,
.aif-lb__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.aif-lb__nav:focus-visible,
.aif-lb__close:focus-visible,
.aif-lb__link:focus-visible {
	outline: 2px solid var(--aif-lb-fg);
	outline-offset: 2px;
}

.aif-lb__nav {
	top: 50%;
	transform: translateY(-50%);
}

.aif-lb__nav--prev { left: 16px; }
.aif-lb__nav--next { right: 16px; }

.aif-lb__close {
	top: 12px;
	right: 12px;
	z-index: 3;
}

.aif-lb__dots {
	position: absolute;
	bottom: 22px;
	left: 50%;
	display: flex;
	gap: 6px;
	transform: translateX(-50%);
}

.aif-lb__dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.35);
	transition: background-color 0.2s ease;
}

.aif-lb__dots span.is-active {
	background: var(--aif-lb-fg);
}

.aif-lb__panel {
	display: flex;
	flex-direction: column;
	gap: 1em;
	min-height: 0;
	padding: 64px 28px 28px;
	overflow-y: auto;
	background: var(--aif-lb-panel);
	font-size: 0.95rem;
	line-height: 1.55;
}

.aif-lb__meta {
	display: flex;
	justify-content: space-between;
	gap: 1em;
	opacity: 0.7;
	font-size: 0.875em;
}

.aif-lb__caption {
	margin: 0;
	white-space: pre-line;
	overflow-wrap: anywhere;
}

.aif-lb__link {
	align-self: flex-start;
	margin-top: auto;
	padding: 0.6em 1.1em;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 999px;
	color: var(--aif-lb-fg);
	font-weight: 600;
	font-size: 0.9em;
	text-decoration: none;
	transition: background-color 0.2s ease;
}

.aif-lb__link:hover {
	background: rgba(255, 255, 255, 0.1);
	color: var(--aif-lb-fg);
}

@media (max-width: 860px) {
	.aif-lb__inner {
		grid-template-columns: 1fr;
		grid-template-rows: minmax(0, 1fr) auto;
	}

	.aif-lb__stage {
		padding: 60px 12px 40px;
	}

	.aif-lb__nav {
		width: 38px;
		height: 38px;
		background: rgba(0, 0, 0, 0.35);
	}

	.aif-lb__nav--prev { left: 8px; }
	.aif-lb__nav--next { right: 8px; }

	.aif-lb__dots { bottom: 14px; }

	.aif-lb__panel {
		max-height: 38vh;
		padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.aif .aif__item img,
	.aif .aif__item video,
	.aif-lb__asset,
	.aif-lb[open] {
		transition: none;
		animation: none;
	}

	.aif .aif__item:hover img,
	.aif .aif__item:hover video {
		transform: none;
	}
}
