/*
 * Lef Creative Instagram Feed — front-end and editor canvas.
 *
 * Deliberately small and dependency-free: it is enqueued unconditionally
 * (builder patterns make has_block() unreliable), so its weight is its budget.
 * Colours and radii come from the theme's CSS variables, with literal
 * fallbacks so the block still looks intentional outside leflite.
 */

.lef-ig-feed {
	--lef-ig-gap: 16px;
	--lef-ig-cols-desktop: 4;
	--lef-ig-cols-tablet: 3;
	--lef-ig-cols-mobile: 2;
	--lef-ig-radius: var(--general-border-radius, 10px);
}

/* ── Grid ────────────────────────────────────────────────────────────────── */

.lef-ig-feed.lef-ig-layout-grid {
	display: grid;
	grid-template-columns: repeat(var(--lef-ig-cols-mobile), minmax(0, 1fr));
	gap: var(--lef-ig-gap);
}

@media (min-width: 768px) {
	.lef-ig-feed.lef-ig-layout-grid {
		grid-template-columns: repeat(var(--lef-ig-cols-tablet), minmax(0, 1fr));
	}
}

@media (min-width: 992px) {
	.lef-ig-feed.lef-ig-layout-grid {
		grid-template-columns: repeat(var(--lef-ig-cols-desktop), minmax(0, 1fr));
	}
}

/* ── Carousel ────────────────────────────────────────────────────────────── */

/*
 * Before Tiny Slider initialises, the items are still plain children. Laying
 * them out as a row keeps the block from flashing as a tall stack, and doubles
 * as the finished look for the scroll-snap fallback below.
 */
.lef-ig-feed.lef-ig-layout-carousel {
	display: flex;
	gap: var(--lef-ig-gap);
}

.lef-ig-feed.lef-ig-layout-carousel > .lef-ig-item {
	flex: 0 0 calc((100% - (var(--lef-ig-cols-mobile) - 1) * var(--lef-ig-gap)) / var(--lef-ig-cols-mobile));
}

@media (min-width: 768px) {
	.lef-ig-feed.lef-ig-layout-carousel > .lef-ig-item {
		flex-basis: calc((100% - (var(--lef-ig-cols-tablet) - 1) * var(--lef-ig-gap)) / var(--lef-ig-cols-tablet));
	}
}

@media (min-width: 992px) {
	.lef-ig-feed.lef-ig-layout-carousel > .lef-ig-item {
		flex-basis: calc((100% - (var(--lef-ig-cols-desktop) - 1) * var(--lef-ig-gap)) / var(--lef-ig-cols-desktop));
	}
}

/*
 * Once Tiny Slider takes over it manages widths itself through inline styles,
 * so the flex sizing has to get out of the way.
 */
.lef-ig-feed.slider-initialized {
	display: block;
}

.lef-ig-feed.slider-initialized > .lef-ig-item {
	flex: none;
}

/* Fallback when the theme's slider is unavailable (non-leflite theme, or
 * theme_object missing). A snap-scrolling row is a perfectly good Instagram
 * strip and needs no JavaScript at all. */
.lef-ig-feed.lef-ig-scroll-fallback {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.lef-ig-feed.lef-ig-scroll-fallback > .lef-ig-item {
	scroll-snap-align: start;
}

/* ── Item ────────────────────────────────────────────────────────────────── */

.lef-ig-item {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	background: rgba(0, 0, 0, .04);
	line-height: 0;
}

.lef-ig-feed.is-rounded .lef-ig-item {
	border-radius: var(--lef-ig-radius);
}

.lef-ig-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .35s ease;
}

.lef-ig-item:hover img,
.lef-ig-item:focus-visible img {
	transform: scale(1.04);
}

.lef-ig-item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Type indicator for videos/Reels and albums. */
.lef-ig-item .lef-ig-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .45);
	color: #fff;
	pointer-events: none;
}

.lef-ig-item .lef-ig-badge .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* ── Editor-only ─────────────────────────────────────────────────────────── */

.lef-ig-placeholder {
	padding: 28px 24px;
	border: 1px dashed rgba(0, 0, 0, .2);
	border-radius: 8px;
	text-align: center;
	color: #50575e;
	background: rgba(0, 0, 0, .015);
}

.lef-ig-placeholder .dashicons {
	font-size: 28px;
	width: 28px;
	height: 28px;
	margin-bottom: 8px;
	color: #2271b1;
}

.lef-ig-placeholder strong {
	display: block;
	font-size: 14px;
	margin-bottom: 4px;
	color: #1e1e1e;
}

.lef-ig-placeholder p {
	margin: 0;
	font-size: 13px;
}

.lef-ig-preview-note {
	margin: 0 0 10px;
	font-size: 12px;
	color: #787c82;
	font-style: italic;
}
