/* IG Feed Sync. Cores, espaços e tamanhos ajustáveis pelo tema através das variáveis. */
.igfs {
	--igfs-gap: 18px;
	--igfs-accent: #111;
	--igfs-accent-text: #fff;
	--igfs-muted: #666; /* 5,7:1 sobre branco (WCAG AA pede 4,5:1). */
	--igfs-card: #fff;
	width: 100%;
	max-width: var(--igfs-max-width, none);
	margin-inline: auto;
	font-size: 16px;
}

.igfs__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 24px;
	margin-bottom: 32px;
	color: inherit;
	text-decoration: none;
}

.igfs__avatar {
	flex: none;
	width: 96px;
	height: 96px;
	border-radius: 50%;
	object-fit: cover;
}

.igfs__avatar--icon {
	display: grid;
	place-items: center;
	background: var(--igfs-accent);
	color: var(--igfs-accent-text);
}

.igfs__avatar--icon svg {
	width: 34%;
	height: 34%;
	fill: currentColor;
}

.igfs__name {
	font-size: 1.375em;
	font-weight: 600;
}

.igfs__stat {
	font-size: 1em;
}

.igfs--cards .igfs__header {
	padding-bottom: 18px;
	border-bottom: 1px solid #ccc;
}

/* Linhas esticadas e imagens na mesma proporção: tudo alinhado, espaços iguais. */
.igfs .igfs__grid {
	display: grid;
	grid-template-columns: repeat(var(--igfs-cols, 4), minmax(0, 1fr));
	gap: var(--igfs-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.igfs .igfs__item {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
}

.igfs__media {
	position: relative;
	display: block;
	flex: 1;
	overflow: hidden;
}

.igfs__media img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--igfs-ratio, auto);
	object-fit: cover;
	transition: transform 0.4s ease;
}

.igfs__media:hover img,
.igfs__media:focus-visible img {
	transform: scale(1.03);
}

.igfs__icon {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 24px;
	height: 24px;
	fill: #fff;
	filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

/* Destaque: a publicação mais recente ocupa 2x2 e a imagem enche o espaço. */
.igfs--featured .igfs__item:first-child {
	grid-column: span 2;
	grid-row: span 2;
}

/*
 * Destaque alto: 1.ª coluna com a imagem quadrada; as outras com 2 publicações cada.
 * A largura da 1.ª coluna é calculada para o quadrado ter a altura exata das 2 linhas:
 * k = altura de 2 imagens em larguras de coluna (2 / proporção), w = largura das colunas pequenas.
 */
.igfs.igfs--featured-tall {
	--igfs-meta-h: 36px;
}

.igfs.igfs--featured-tall .igfs__grid {
	--igfs-k: calc(2 / (var(--igfs-ratio)));
	--igfs-w: calc((100% - var(--igfs-meta-h) - (var(--igfs-rest) + 1) * var(--igfs-gap)) / (var(--igfs-k) + var(--igfs-rest)));
	grid-template-columns: calc(var(--igfs-meta-h) + var(--igfs-gap) + var(--igfs-k) * var(--igfs-w)) repeat(var(--igfs-rest), var(--igfs-w));
}

.igfs--featured-tall .igfs__item:first-child .igfs__media img {
	object-position: top;
}

.igfs--featured-tall .igfs__item:first-child {
	grid-column: span 1;
}

.igfs--featured .igfs__item:first-child .igfs__media img {
	position: absolute;
	inset: 0;
	height: 100%;
	aspect-ratio: auto;
}

/* Layout "cards": cabeçalho por publicação. */
.igfs--cards .igfs__item {
	background: var(--igfs-card);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.igfs__meta {
	display: flex;
	box-sizing: border-box;
	align-items: center;
	gap: 8px;
	height: var(--igfs-meta-h, auto);
	padding: 10px;
}

.igfs__meta time {
	color: var(--igfs-muted);
	font-size: 0.8125em;
	font-weight: 400;
	line-height: 1;
}

.igfs__button {
	display: table;
	margin: 40px auto 0;
	padding: 12px 36px;
	background: var(--igfs-accent);
	color: var(--igfs-accent-text);
	text-decoration: none;
}

.igfs__button {
	border: 2px solid var(--igfs-accent);
	border-radius: var(--igfs-btn-radius, 0);
	transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.igfs__button:hover,
.igfs__button:focus-visible {
	opacity: 0.85;
}

.igfs--btn-outline .igfs__button {
	background: transparent;
	color: var(--igfs-accent);
}

.igfs--btn-outline .igfs__button:hover,
.igfs--btn-outline .igfs__button:focus-visible {
	background: var(--igfs-accent);
	color: var(--igfs-accent-text);
	opacity: 1;
}

.igfs--btn-upper .igfs__button {
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

@media (max-width: 767px) {
	.igfs {
		font-size: 14px;
	}

	.igfs .igfs__grid,
	.igfs.igfs--featured-tall .igfs__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		--igfs-gap: 10px;
	}

	.igfs__avatar {
		width: 64px;
		height: 64px;
	}

	.igfs__meta {
		padding: 8px;
	}

	/* Em 2 colunas o destaque ocupa a linha inteira e não há vizinhos para dar a altura. */
	.igfs--featured .igfs__item:first-child {
		grid-column: span 2;
		grid-row: auto;
	}

	.igfs--featured .igfs__item:first-child .igfs__media img {
		position: static;
		aspect-ratio: var(--igfs-ratio, auto);
	}

	.igfs--featured-tall .igfs__item:first-child .igfs__media img {
		aspect-ratio: 1;
	}

}

@media (prefers-reduced-motion: reduce) {
	.igfs__media img {
		transition: none;
	}

	.igfs-lb[open] {
		animation: none;
	}
}

/* Lightbox */
.igfs-lb-open {
	overflow: hidden;
}

.igfs-lb {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #111;
	font-family: inherit;
}

.igfs-lb::backdrop {
	background: rgba(0, 0, 0, 0.85);
}

.igfs-lb:focus {
	outline: none;
}

/* O atributo hidden tem de ganhar aos display das setas. */
.igfs-lb [hidden] {
	display: none !important;
}

.igfs-lb[open] {
	animation: igfs-lb-in 0.15s ease-out;
}

@keyframes igfs-lb-in {
	from {
		opacity: 0;
	}
}

.igfs-lb__status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.igfs-lb__caption a {
	color: inherit;
	text-decoration: underline;
	word-break: break-all;
}

.igfs-lb {
	/* Metade da largura da caixa: as setas ficam encostadas a ela, mesmo em ecrãs muito largos. */
	--igfs-lb-half: min(550px, calc(50% - 70px));
}

.igfs-lb__box {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	width: calc(var(--igfs-lb-half) * 2);
	max-height: 90vh;
	overflow: hidden;
	background: #fff;
	transform: translate(-50%, -50%);
}

.igfs-lb__media {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-width: 0;
	background: #000;
}

.igfs-lb__img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 90vh;
	object-fit: contain;
}

/* O embed do Instagram tem 54px de cabeçalho e o vídeo em 4:5: a largura segue a altura para o vídeo caber inteiro. */
.igfs-lb__video {
	--igfs-lb-vh: min(90vh, 760px);
	display: block;
	width: min(100%, max(240px, calc((var(--igfs-lb-vh) - 54px) * 0.8)));
	height: var(--igfs-lb-vh);
	border: 0;
	background: #fff;
}

.igfs-lb__side {
	display: flex;
	flex: 0 0 340px;
	flex-direction: column;
	gap: 12px;
	min-height: 0;
	padding: 16px;
	font-size: 14px;
}

.igfs-lb__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-right: 40px; /* Espaço para o botão fechar. */
	padding-bottom: 12px;
	border-bottom: 1px solid #e5e5e5;
}

.igfs-lb__avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
}

.igfs-lb__caption {
	flex: 1 1 auto;
	margin: 0;
	overflow-y: auto;
	line-height: 1.5;
	white-space: pre-line;
	overscroll-behavior: contain;
}

.igfs-lb__date {
	margin: 0;
	color: #666;
	font-size: 12px;
}

.igfs-lb__link {
	align-self: flex-start;
	padding: 10px 18px;
	border-radius: var(--igfs-btn-radius, 4px);
	background: var(--igfs-accent, #111);
	color: var(--igfs-accent-text, #fff);
	text-decoration: none;
}

.igfs-lb__link:hover,
.igfs-lb__link:focus-visible {
	opacity: 0.85;
}

.igfs-lb__close,
.igfs-lb__nav,
.igfs-lb__slide {
	position: absolute;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	cursor: pointer;
	line-height: 1;
}

.igfs-lb__close {
	z-index: 2;
	top: 8px;
	right: 8px;
	width: 40px;
	height: 40px;
	color: #111;
}

.igfs-lb__nav svg,
.igfs-lb__slide svg {
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.igfs-lb__slide svg {
	width: 18px;
	height: 18px;
	stroke-width: 2;
}

.igfs-lb__close svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
}

.igfs-lb button.igfs-lb__close:focus-visible {
	outline-color: #111;
	outline-offset: 0;
}

.igfs-lb__nav {
	top: 50%;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	transform: translateY(-50%);
	transition: background-color 0.2s ease;
}

.igfs-lb__nav:hover,
.igfs-lb__nav:focus-visible {
	background: rgba(255, 255, 255, 0.3);
}

.igfs-lb__nav--prev {
	left: calc(50% - var(--igfs-lb-half) - 60px);
}

.igfs-lb__nav--next {
	right: calc(50% - var(--igfs-lb-half) - 60px);
}

.igfs-lb__slide {
	top: 50%;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: #111;
	font-size: 28px;
	transform: translateY(-50%);
}

.igfs-lb__slide--prev {
	left: 10px;
}

.igfs-lb__slide--next {
	right: 10px;
}

/* Barra dos pontos: no computador fica por cima do fundo da imagem (a largura da imagem é a caixa menos o painel). */
.igfs-lb__bar {
	position: absolute;
	bottom: 4px;
	left: 0;
	display: flex;
	justify-content: center;
	width: calc(100% - 340px);
	pointer-events: none;
}

.igfs-lb__dots {
	display: flex;
	justify-content: center;
	pointer-events: auto;
}

/* As setas da barra só existem no telemóvel; no computador há as setas laterais. */
.igfs-lb__bar-btn {
	display: none;
}

/* Área de toque de 24 px (WCAG 2.5.8); o ponto visível é desenhado no centro. */
.igfs-lb__dot {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.igfs-lb__dot::before {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.5);
	content: "";
}

.igfs-lb__dot.is-active::before {
	background: #fff;
}

.igfs-lb__note {
	position: absolute;
	inset: auto 0 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 20px;
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
	text-align: center;
}

.igfs-lb__note p {
	margin: 0;
}

.igfs-lb__note .igfs-lb__link {
	align-self: center;
	background: #fff;
	color: #111;
}

.igfs-lb button:focus-visible,
.igfs-lb a:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.igfs-lb__side a:focus-visible {
	outline-color: #111;
}

/* Telemóvel: como no Instagram. Perfil em cima, imagem, pontos, legenda, data e botão. */
@media (max-width: 767px) {
	.igfs-lb__box {
		top: 0;
		left: 0;
		flex-direction: column;
		width: 100%;
		height: 100%;
		max-height: none;
		overflow: hidden; /* Só a legenda desliza: a imagem fica sempre inteira à vista. */
		transform: none;
	}

	/* Os filhos do painel passam a ser filhos da caixa, para se poderem ordenar. */
	.igfs-lb__side {
		display: contents;
	}

	.igfs-lb__head {
		order: 1;
		padding: 10px 52px 10px 12px;
		border-bottom: 0;
	}

	.igfs-lb__media {
		flex: 0 0 auto;
		flex-direction: column;
		order: 2;
		background: #fff;
	}

	/* Em ecrãs baixos a imagem encolhe, para sobrarem ~300px para perfil, setas, legenda e botão. */
	.igfs-lb__img {
		max-height: min(55vh, calc(100vh - 300px));
		max-height: min(55dvh, calc(100dvh - 300px));
	}

	.igfs-lb__video {
		--igfs-lb-vh: min(60vh, calc(100vh - 300px));
	}

	@supports (height: 1dvh) {
		.igfs-lb__video {
			--igfs-lb-vh: min(60dvh, calc(100dvh - 300px));
		}
	}

	.igfs-lb__bar {
		position: static;
		order: 3;
		justify-content: space-between;
		align-items: center;
		width: auto;
		padding: 0 4px;
		pointer-events: auto;
	}

	.igfs-lb__bar-btn {
		display: grid;
		place-items: center;
		width: 44px;
		height: 44px;
		padding: 0;
		border: 0;
		background: transparent;
		color: #111;
		cursor: pointer;
	}

	.igfs-lb__bar-btn svg {
		width: 22px;
		height: 22px;
		fill: none;
		stroke: currentColor;
		stroke-width: 1.5;
		stroke-linecap: round;
		stroke-linejoin: round;
	}

	.igfs-lb__bar-btn:focus-visible {
		outline-color: #111;
	}

	/* No telemóvel o carrossel passa-se a deslizar, como no Instagram. */
	.igfs-lb__slide {
		display: none;
	}

	.igfs-lb__dot::before {
		width: 6px;
		height: 6px;
		background: #c7c7c7;
	}

	.igfs-lb__dot.is-active::before {
		background: #0095f6;
	}

	.igfs-lb__slide {
		top: calc(50% - 10px);
	}

	.igfs-lb__caption {
		flex: 1 1 auto;
		order: 4;
		min-height: 3em;
		padding: 8px 12px 0;
	}

	.igfs-lb__date {
		order: 5;
		padding: 6px 12px 0;
		font-size: 11px;
		text-transform: uppercase;
	}

	.igfs-lb__link {
		order: 6;
		margin: 14px 12px 24px;
	}

	.igfs-lb__close {
		position: fixed;
		top: 6px;
		right: 6px;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.85); /* Visível também por cima de imagens escuras. */
	}

	.igfs-lb__nav {
		display: none;
	}
}
