/**
 * Stile del feed IG Feed Builder.
 * Tutte le classi sono prefissate igfb per non entrare in conflitto con il tema o Divi.
 * Il numero di colonne arriva da variabili CSS impostate inline sul contenitore.
 */

.igfb-wrapper {
	margin: 0;
}

/* Testata del profilo in cima al feed. */
.igfb-header {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 20px;
}

.igfb-avatar {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	display: block;
	padding: 2px;
	background: #fff;
	box-shadow: 0 0 0 2px #dbdbdb;
}

.igfb-header-info {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.igfb-username {
	font-weight: 600;
	font-size: 1.05em;
	line-height: 1.2;
	color: var(--igfb-username-color, #262626);
	text-decoration: none;
}

a.igfb-username:hover {
	text-decoration: underline;
}

.igfb-avatar-link {
	display: block;
	flex-shrink: 0;
}

.igfb-description {
	font-size: 0.9em;
	line-height: 1.45;
	color: var(--igfb-description-color, #8e8e8e);
}

/* Griglia dei post. */
.igfb-feed {
	display: grid;
	grid-template-columns: repeat(var(--igfb-cols-d, 3), 1fr);
	gap: var(--igfb-gap, 20px);
	margin: 0;
	padding: 0;
}

.igfb-item {
	display: flex;
	flex-direction: column;
	height: 100%;
	margin: 0;
}

.igfb-media {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--igfb-radius, 12px);
	aspect-ratio: 1 / 1;
	background: #efefef;
}

.igfb-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.igfb-media:hover img {
	transform: scale(1.05);
}

/* Overlay in stile Instagram al passaggio del mouse. */
.igfb-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0);
	opacity: 0;
	transition: background 0.35s ease, opacity 0.35s ease;
	pointer-events: none;
}

.igfb-media:hover .igfb-overlay {
	opacity: 1;
	background: rgba(0, 0, 0, 0.4);
}

.igfb-overlay svg {
	width: 42px;
	height: 42px;
	color: #ffffff;
	transform: scale(0.8);
	transition: transform 0.35s ease;
}

.igfb-media:hover .igfb-overlay svg {
	transform: scale(1);
}

/* Caption. */
.igfb-caption {
	margin-top: 10px;
	margin-bottom: 12px;
	font-size: 0.9em;
	line-height: 1.45;
	color: var(--igfb-caption-color, #262626);
	word-wrap: break-word;
}

/* Button. */
.igfb-button {
	display: inline-block;
	text-align: center;
	margin-top: auto;
	padding: 11px 18px;
	background: var(--igfb-btn-bg, #0095f6);
	color: var(--igfb-btn-color, #ffffff);
	text-decoration: none;
	border-radius: var(--igfb-btn-radius, 10px);
	font-weight: 600;
	font-size: 0.95em;
	line-height: 1.2;
	transition: filter 0.2s ease, transform 0.1s ease;
}

.igfb-button:hover {
	filter: brightness(0.94);
	color: var(--igfb-btn-color, #ffffff);
}

.igfb-button:active {
	transform: translateY(1px);
}

/* Indicatore del tipo di post (carosello o video) in alto a destra sulla foto. */
.igfb-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 22px;
	height: 22px;
	color: #ffffff;
	pointer-events: none;
	z-index: 2;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.igfb-badge svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* Riga del nome utente con eventuale icona Instagram accanto. */
.igfb-username-row {
	display: flex;
	align-items: center;
	gap: 5px;
}

.igfb-header-icon {
	width: 16px;
	height: 16px;
	display: inline-block;
	color: var(--igfb-username-color, #262626);
}

.igfb-header-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* Pulsante Segui in stile Instagram. */
.igfb-follow {
	margin-left: auto;
	align-self: center;
	padding: 7px 16px;
	background: var(--igfb-btn-bg, #0095f6);
	color: #ffffff;
	text-decoration: none;
	border-radius: 8px;
	font-weight: 600;
	font-size: 0.9em;
	line-height: 1.2;
	white-space: nowrap;
	transition: filter 0.2s ease;
}

.igfb-follow:hover {
	filter: brightness(0.94);
	color: #ffffff;
}

/* Layout griglia Instagram: foto attaccate e squadrate, senza extra. */
.igfb-layout-grid .igfb-media {
	border-radius: 0;
}

.igfb-layout-grid .igfb-item {
	height: auto;
}

/* Con la lightbox attiva le foto sono cliccabili. */
.igfb-lightbox .igfb-media {
	cursor: pointer;
}

/* Animazione allo scroll: i post entrano con dissolvenza e leggera salita. */
.igfb-animate .igfb-item {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.6s ease, transform 0.6s ease;
}

.igfb-animate .igfb-item.igfb-in {
	opacity: 1;
	transform: none;
}

/* Rispetto la preferenza di sistema per la riduzione dei movimenti. */
@media (prefers-reduced-motion: reduce) {
	.igfb-animate .igfb-item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}

/* Tablet, sotto 980px. */
@media (max-width: 980px) {
	.igfb-feed {
		grid-template-columns: repeat(var(--igfb-cols-t, 2), 1fr);
	}
}

/* Mobile, sotto 600px. */
@media (max-width: 600px) {
	.igfb-feed {
		grid-template-columns: repeat(var(--igfb-cols-m, 1), 1fr);
	}
}

/* Messaggio mostrato quando non ci sono post da visualizzare. */
.igfb-empty {
	padding: 16px;
	color: #8e8e8e;
	font-style: italic;
}

/* Lightbox. */
.igfb-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.85);
	padding: 20px;
	box-sizing: border-box;
}

.igfb-lb-content {
	display: flex;
	background: #fff;
	border-radius: 12px;
	overflow: hidden;
	max-width: 92vw;
	max-height: 88vh;
}

.igfb-lb-media {
	flex: 0 1 auto;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
}

.igfb-lb-media img {
	display: block;
	width: auto;
	height: auto;
	max-height: 88vh;
	max-width: calc(92vw - 340px);
	object-fit: contain;
	transition: opacity 0.25s ease;
}

.igfb-lb-info {
	flex: 0 0 340px;
	padding: 24px;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	max-height: 88vh;
	box-sizing: border-box;
}

.igfb-lb-caption {
	font-size: 0.95em;
	line-height: 1.5;
	color: #262626;
	white-space: pre-wrap;
	word-wrap: break-word;
	margin-bottom: 14px;
}

.igfb-lb-date {
	font-size: 0.82em;
	color: #8e8e8e;
	margin-bottom: 20px;
}

.igfb-lb-actions {
	margin-top: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.igfb-lb-button {
	display: inline-block;
	text-align: center;
	padding: 12px 18px;
	background: var(--igfb-btn-bg, #0095f6);
	color: #fff;
	text-decoration: none;
	border-radius: 10px;
	font-weight: 600;
	transition: filter 0.2s ease;
}

.igfb-lb-button:hover {
	filter: brightness(0.94);
	color: #fff;
}

.igfb-lb-link {
	text-align: center;
	color: #8e8e8e;
	text-decoration: none;
	font-size: 0.88em;
}

.igfb-lb-link:hover {
	color: #262626;
	text-decoration: underline;
}

.igfb-lb-close,
.igfb-lb-nav {
	position: absolute;
	background: rgba(0, 0, 0, 0.25);
	color: #fff;
	border: none;
	cursor: pointer;
	border-radius: 50%;
	width: 34px;
	height: 34px;
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.igfb-lb-close:hover,
.igfb-lb-nav:hover {
	background: rgba(0, 0, 0, 0.45);
}

.igfb-lb-close {
	top: 20px;
	right: 20px;
}

.igfb-lb-prev {
	left: 20px;
	top: 50%;
	transform: translateY(-50%);
}

.igfb-lb-next {
	right: 20px;
	top: 50%;
	transform: translateY(-50%);
}

/* Lightbox responsive: su schermi piccoli impilo immagine e testo. */
@media (max-width: 780px) {
	.igfb-lb-content {
		flex-direction: column;
		width: 92vw;
		max-width: 420px;
		max-height: 92vh;
	}

	/* Cornice bianca attorno alla foto, staccata dall'alto e con angoli morbidi. */
	.igfb-lb-media {
		padding: 14px 14px 0;
		box-sizing: border-box;
	}

	.igfb-lb-media img {
		max-width: 100%;
		max-height: 52vh;
		margin: 0 auto;
		border-radius: 10px;
	}

	.igfb-lb-info {
		flex: 1 1 auto;
		max-height: 40vh;
		padding: 16px 20px 22px;
	}

	/* Su mobile navigo con lo swipe, quindi nascondo le frecce. */
	.igfb-lb-nav {
		display: none;
	}
}

/* Rispetto la riduzione dei movimenti anche nella lightbox. */
@media (prefers-reduced-motion: reduce) {
	.igfb-lb-media img {
		transition: none;
	}
}
