/* CP Flickr Gallery — CityPubli
   Cores ajustáveis no tema: --cpfg-accent, --cpfg-text, --cpfg-muted, --cpfg-radius */
.cpfg {
	--cpfg-accent: #1f4b8f;
	--cpfg-text: #1e293b;
	--cpfg-muted: #64748b;
	--cpfg-radius: 10px;
	--cpfg-gap: 6px;
	color: var(--cpfg-text);
	margin: 0 0 1.5em;
	container-type: inline-size;
	scroll-margin-top: 120px;
}
.cpfg *, .cpfg *::before, .cpfg *::after { box-sizing: border-box; }

/* ---------- Página de álbuns ---------- */
/* No máximo N colunas (atributo colunas), e cada card com pelo menos 240px: em espaços estreitos cai para menos colunas sozinho. */
.cpfg-albums {
	--cpfg-cols: 3; --cpfg-agap: 24px;
	display: grid; gap: var(--cpfg-agap);
	grid-template-columns: repeat(auto-fill, minmax(max(240px, calc((100% - (var(--cpfg-cols) - 1) * var(--cpfg-agap)) / var(--cpfg-cols))), 1fr));
}
.cpfg-cols-2 { --cpfg-cols: 2; }
.cpfg-cols-4 { --cpfg-cols: 4; }
@container (max-width: 520px) { .cpfg-albums { --cpfg-agap: 16px; grid-template-columns: 1fr; } }

.cpfg-album-card {
	position: relative; display: block; overflow: hidden; border-radius: var(--cpfg-radius);
	aspect-ratio: 4 / 3; background: #0f172a; text-decoration: none !important; color: #fff !important;
	box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 8px 24px -12px rgba(15, 23, 42, .35);
	transition: transform .35s ease, box-shadow .35s ease;
}
.cpfg-album-card::before { /* pilha de fotos, como um álbum */
	content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
	border-top: 3px solid rgba(255, 255, 255, .55); border-radius: var(--cpfg-radius);
}
.cpfg-album-cover, .cpfg-album-cover img { position: absolute; inset: 0; width: 100%; height: 100%; }
.cpfg-album-cover img { object-fit: cover; transition: transform .6s ease; max-width: none; }
.cpfg-album-cover::after {
	content: ""; position: absolute; inset: 0;
	background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.78) 100%);
}
.cpfg-album-info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.cpfg-album-title { font-size: clamp(16px, 1.05rem, 20px); font-weight: 700; line-height: 1.25; text-wrap: balance; }
.cpfg-album-meta { font-size: 13px; opacity: .85; display: inline-flex; align-items: center; gap: 6px; }
.cpfg-album-meta::before { content: ""; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--cpfg-icon-photo) center/contain no-repeat; mask: var(--cpfg-icon-photo) center/contain no-repeat; }
.cpfg { --cpfg-icon-photo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h3l2-2h6l2 2h3a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zm8 3.5A4.5 4.5 0 1 0 12 17.5 4.5 4.5 0 0 0 12 8.5zm0 2a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5z'/%3E%3C/svg%3E"); }
.cpfg-album-card:hover, .cpfg-album-card:focus-visible { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(15,23,42,.1), 0 18px 36px -14px rgba(15,23,42,.45); }
.cpfg-album-card:hover img, .cpfg-album-card:focus-visible img { transform: scale(1.05); }
.cpfg-album-card:focus-visible { outline: 3px solid var(--cpfg-accent); outline-offset: 3px; }

/* ---------- Álbum ---------- */
.cpfg-back {
	display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; padding: 8px 14px;
	border-radius: 999px; background: #f1f5f9; color: var(--cpfg-text) !important; font-weight: 600; font-size: .9em; text-decoration: none !important;
}
.cpfg-back:hover { background: #e2e8f0; }
.cpfg-album-head { margin-bottom: 18px; }
.cpfg-album-name { margin: 0 0 6px !important; padding: 0 !important; line-height: 1.2; text-wrap: balance; }
.cpfg-album-sub { margin: 0 !important; padding: 0 !important; color: var(--cpfg-muted); font-size: .92em; }
.cpfg-album-sub a { color: var(--cpfg-accent); }
.cpfg-album-desc { margin: 10px 0 0 !important; max-width: 70ch; color: var(--cpfg-muted); }

/* Grade justificada só com CSS: cada foto cresce na proporção dela, as linhas ficam com a mesma altura
   e a última linha não é esticada. Funciona sem JavaScript e se ajusta sozinha à largura. */
.cpfg-justified { display: flex; flex-wrap: wrap; gap: var(--cpfg-gap); }
.cpfg-justified::after { content: ""; flex-grow: 999999; }
.cpfg-item {
	position: relative; display: block; overflow: hidden; border-radius: 4px; background: #e2e8f0;
	flex-grow: calc(var(--w) / var(--h) * 100);
	width: calc(var(--w) / var(--h) * var(--cpfg-row, 240px));
	aspect-ratio: var(--w) / var(--h);
	cursor: zoom-in;
}
.cpfg-item img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; transition: transform .5s ease, filter .3s ease; }
.cpfg-item:hover img { transform: scale(1.04); }
.cpfg-item:focus-visible { outline: 3px solid var(--cpfg-accent); outline-offset: 2px; }
.cpfg-item.is-new { animation: cpfg-in .45s ease both; }
@keyframes cpfg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Linhas mais baixas quando o espaço da galeria é estreito (coluna do Divi, tablet, celular). */
@container (max-width: 760px) { .cpfg-item { width: calc(var(--w) / var(--h) * var(--cpfg-row, 240px) * .7); } }
@container (max-width: 480px) {
	.cpfg-justified { --cpfg-gap: 4px; }
	.cpfg-item { width: calc(var(--w) / var(--h) * var(--cpfg-row, 240px) * .5); }
}

.cpfg-more-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 24px; }
.cpfg-more {
	appearance: none; border: 0; cursor: pointer; padding: 12px 26px; border-radius: 999px;
	background: var(--cpfg-accent); color: #fff; font: inherit; font-weight: 600;
	transition: filter .2s ease, transform .2s ease;
}
.cpfg-more:hover { filter: brightness(1.12); transform: translateY(-1px); }
.cpfg-more[disabled] { opacity: .6; cursor: wait; transform: none; }
.cpfg-progress { font-size: .85em; color: var(--cpfg-muted); }
.cpfg-credit-pt { display: block; font-style: italic; }
.cpfg-credit.is-dup { display: none; }
.cpfg-credit { margin: 18px 0 0 !important; padding: 0 !important; font-size: 11px !important; line-height: 1.4; color: #94a3b8; }
.cpfg-admin-notice { padding: 12px 16px; border-left: 4px solid #d63638; background: #fcf0f1; color: #50575e; font-size: 14px; margin: 1em 0; }

/* ---------- Lightbox ---------- */
.cpfg-lb {
	position: fixed; inset: 0; z-index: 999999; display: flex; flex-direction: column;
	background: rgba(8, 10, 15, .97); color: #fff; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s;
	padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
	font-family: inherit; -webkit-user-select: none; user-select: none; touch-action: pan-y;
}
.cpfg-lb.is-open { opacity: 1; visibility: visible; }
.cpfg-lb-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; font-size: 14px; }
.cpfg-lb-count { opacity: .8; font-variant-numeric: tabular-nums; }
.cpfg-lb-actions { display: flex; align-items: center; gap: 8px; }
.cpfg-lb-link { color: #fff !important; text-decoration: none !important; padding: 8px 14px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; font-size: 13px; }
.cpfg-lb-link:hover { background: rgba(255,255,255,.12); }
.cpfg-lb-btn {
	appearance: none; border: 0; cursor: pointer; width: 44px; height: 44px; border-radius: 50%;
	display: inline-grid; place-items: center; background: rgba(255,255,255,.1); color: #fff; padding: 0;
	transition: background .2s ease;
}
.cpfg-lb-btn:hover, .cpfg-lb-btn:focus-visible { background: rgba(255,255,255,.22); outline: none; }
.cpfg-lb-btn svg { width: 22px; height: 22px; }
.cpfg-lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 72px; }
.cpfg-lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.5); transition: opacity .25s ease; }
.cpfg-lb-img.is-loading { opacity: .25; }
.cpfg-lb-spin { position: absolute; width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: cpfg-spin .8s linear infinite; display: none; }
.cpfg-lb.is-busy .cpfg-lb-spin { display: block; }
@keyframes cpfg-spin { to { transform: rotate(360deg); } }
.cpfg-lb-prev, .cpfg-lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; }
.cpfg-lb-prev { left: 12px; }
.cpfg-lb-next { right: 12px; }
.cpfg-lb-prev[hidden], .cpfg-lb-next[hidden] { display: none; }
.cpfg-lb-caption { padding: 14px 20px 20px; text-align: center; min-height: 56px; }
.cpfg-lb-title { font-weight: 600; font-size: 15px; }
.cpfg-lb-desc { margin-top: 4px; font-size: 13px; opacity: .75; max-width: 80ch; margin-left: auto; margin-right: auto; }
@media (max-width: 700px) {
	.cpfg-lb-stage { padding: 0 8px; }
	.cpfg-lb-prev, .cpfg-lb-next { width: 42px; height: 42px; background: rgba(0,0,0,.35); }
	.cpfg-lb-prev { left: 6px; } .cpfg-lb-next { right: 6px; }
	.cpfg-lb-link span { display: none; }
}
html.cpfg-locked, html.cpfg-locked body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
	.cpfg-album-card, .cpfg-album-cover img, .cpfg-item img, .cpfg-lb, .cpfg-lb-img, .cpfg-more { transition: none; }
	.cpfg-item.is-new { animation: none; }
}
