/**
 * Fattoria Pupo — Instagram Feed Section
 *
 * Palette coerente con main.css:
 *   #8b5e3c  brown primario
 *   #2c2415  dark text
 *   #f5ede4  brown chiaro (sfondo sezione)
 *
 * @package FattoriaPupo
 */

/* ── Section wrapper ──────────────────────────────────────────────────────── */

.section-instagram {
	padding-block: clamp(4rem, 8vw, 7rem);
	background-color: #faf7f3;
}

.section-instagram .section__header {
	text-align: center;
	margin-bottom: 2.5rem;
}

/* ── Profile link ─────────────────────────────────────────────────────────── */

.ig-profile-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #8b5e3c;
	font-weight: 700;
	font-size: 0.9375rem;
	text-decoration: none;
	margin-top: 0.5rem;
	transition: color 150ms ease, opacity 150ms ease;
}

.ig-profile-link:hover {
	color: #6d4a2d;
	opacity: 0.85;
}

.ig-profile-link svg {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

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

.ig-feed-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 6px;
}

@media (max-width: 900px) {
	.ig-feed-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 560px) {
	.ig-feed-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 4px;
	}
}

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

.ig-feed-item {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: 4px;
	background: #ede8e1;
}

.ig-feed-item__inner {
	display: block;
	width: 100%;
	height: 100%;
	position: relative;
	cursor: pointer;
	text-decoration: none;
}

.ig-feed-item__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 400ms ease;
}

.ig-feed-item__inner:hover .ig-feed-item__img,
.ig-feed-item__inner:focus-visible .ig-feed-item__img {
	transform: scale(1.06);
}

/* ── Hover overlay ────────────────────────────────────────────────────────── */

.ig-feed-item__overlay {
	position: absolute;
	inset: 0;
	background: rgba(44, 36, 21, 0.52);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	opacity: 0;
	transition: opacity 280ms ease;
	padding: 12px;
}

.ig-feed-item__inner:hover .ig-feed-item__overlay,
.ig-feed-item__inner:focus-visible .ig-feed-item__overlay {
	opacity: 1;
}

.ig-feed-item__overlay-icon {
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ig-feed-item__overlay-icon svg {
	width: 28px;
	height: 28px;
	filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

.ig-feed-item__overlay-caption {
	color: rgba(255, 255, 255, 0.92);
	font-size: 0.75rem;
	line-height: 1.4;
	text-align: center;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ── Video badge ──────────────────────────────────────────────────────────── */

.ig-feed-item__video-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 4px;
	padding: 3px 5px;
	display: flex;
	align-items: center;
	color: #fff;
}

.ig-feed-item__video-badge svg {
	width: 14px;
	height: 14px;
}

/* ── Album badge ──────────────────────────────────────────────────────────── */

.ig-feed-item__album-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 4px;
	padding: 3px 5px;
	display: flex;
	align-items: center;
	color: #fff;
}

.ig-feed-item__album-badge svg {
	width: 14px;
	height: 14px;
}

/* ── Skeleton loader ──────────────────────────────────────────────────────── */

.ig-feed-item--skeleton .ig-feed-item__inner {
	background: linear-gradient(
		90deg,
		#ede8e1 25%,
		#e4ddd5 50%,
		#ede8e1 75%
	);
	background-size: 200% 100%;
	animation: ig-skeleton-shimmer 1.5s infinite ease-in-out;
	cursor: default;
}

@keyframes ig-skeleton-shimmer {
	0%   { background-position: 200% center; }
	100% { background-position: -200% center; }
}

/* ── Reveal animation ─────────────────────────────────────────────────────── */

.ig-feed-item--loaded {
	animation: ig-item-reveal 350ms ease forwards;
}

@keyframes ig-item-reveal {
	from { opacity: 0; transform: scale(0.95); }
	to   { opacity: 1; transform: scale(1); }
}

/* ── Focus visible ────────────────────────────────────────────────────────── */

.ig-feed-item__inner:focus-visible {
	outline: 3px solid #8b5e3c;
	outline-offset: 2px;
}

/* ── Error state ──────────────────────────────────────────────────────────── */

.ig-feed-error {
	text-align: center;
	color: #8b5e3c;
	font-size: 0.9375rem;
	margin-top: 1.5rem;
	opacity: 0.75;
}

/* ── CTA ──────────────────────────────────────────────────────────────────── */

.ig-feed-cta {
	margin-top: 2.5rem;
	text-align: center;
}

.btn--instagram {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.btn--instagram svg {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.ig-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.ig-lightbox[hidden] {
	display: none;
}

.ig-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(20, 15, 8, 0.88);
	cursor: pointer;
}

.ig-lightbox__content {
	position: relative;
	z-index: 1;
	max-width: min(560px, calc(100vw - 100px));
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
}

.ig-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 160px);
	object-fit: contain;
	border-radius: 6px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ig-lightbox__caption {
	color: rgba(255, 255, 255, 0.88);
	font-size: 0.875rem;
	line-height: 1.5;
	text-align: center;
	max-width: 480px;
	max-height: 80px;
	overflow: hidden;
}

.ig-lightbox__ig-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: rgba(255, 255, 255, 0.75);
	font-size: 0.8125rem;
	text-decoration: none;
	transition: color 150ms ease;
}

.ig-lightbox__ig-link:hover {
	color: #fff;
}

.ig-lightbox__ig-link svg {
	width: 16px;
	height: 16px;
}

.ig-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 150ms ease;
}

.ig-lightbox__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.ig-lightbox__close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.8);
	outline-offset: 2px;
}

.ig-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #fff;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 150ms ease, opacity 150ms ease;
}

.ig-lightbox__prev { left: 12px; }
.ig-lightbox__next { right: 12px; }

.ig-lightbox__nav:hover {
	background: rgba(255, 255, 255, 0.25);
}

.ig-lightbox__nav:disabled {
	opacity: 0.25;
	cursor: not-allowed;
}

.ig-lightbox__nav:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.8);
	outline-offset: 2px;
}

/* ── Lightbox animazione ──────────────────────────────────────────────────── */

.ig-lightbox {
	animation: ig-lb-in 220ms ease;
}

@keyframes ig-lb-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ── Responsive lightbox ──────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.ig-lightbox__content {
		max-width: calc(100vw - 40px);
	}

	.ig-lightbox__nav {
		width: 36px;
		height: 36px;
	}

	.ig-lightbox__prev { left: 4px; }
	.ig-lightbox__next { right: 4px; }
}

/* ── Riduzione movimento ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.ig-feed-item__img,
	.ig-feed-item__overlay,
	.ig-feed-item--loaded,
	.ig-lightbox,
	.ig-feed-item--skeleton .ig-feed-item__inner {
		transition: none;
		animation: none;
	}
}
