/* Custom Photo Collage Widget — frontend styles
   Everything is scoped under .cpc-collage / .cpc-tile so it never leaks
   into the rest of the theme. */

.cpc-gallery {
	display: block;
	width: 100%;
}

.cpc-collage {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-auto-rows: 140px;
	grid-auto-flow: dense;
	gap: 10px;
	width: 100%;
}

/* Exact reference collage layout — 6 tracks so the two small middle
   photos can sit side-by-side inside the visual "middle column". */
.cpc-collage.cpc-pattern-reference {
	grid-template-columns: repeat(6, 1fr);
}

.cpc-tile {
	position: relative !important;
	margin: 0 !important;
	overflow: hidden;
	border-radius: 10px;
	background: #ffffff;
	padding: 4px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
	box-sizing: border-box !important;
	/* Force every tile to actually fill its grid cell — some themes set
	   min-width/min-height on figure/img that otherwise fights the grid
	   and makes equally-sized cells LOOK different once real photos
	   (with different aspect ratios) are dropped in. */
	width: 100% !important;
	height: 100% !important;
	min-width: 0 !important;
	min-height: 0 !important;
	align-self: stretch;
	justify-self: stretch;
}

.cpc-tile-link {
	display: block;
	position: relative;
	width: 100% !important;
	height: 100% !important;
	overflow: hidden;
	border-radius: 6px;
	cursor: pointer;
}

.cpc-tile img,
.cpc-collage img.cpc-tile-img {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	object-fit: cover !important;
	object-position: center !important;
	transition: transform 0.35s ease;
	margin: 0 !important;
}

.cpc-collage.cpc-zoom .cpc-tile-link:hover img {
	transform: scale(1.08);
}

.cpc-tile-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: 12px;
	background-color: rgba(0, 0, 0, 0.35);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.cpc-tile-link:hover .cpc-tile-overlay {
	opacity: 1;
}

.cpc-tile-caption {
	color: #ffffff;
	font-size: 14px;
	line-height: 1.3;
	font-weight: 500;
}

.cpc-empty-notice {
	padding: 24px;
	border: 1px dashed #c3c3c3;
	border-radius: 8px;
	text-align: center;
	color: #6d6d6d;
	font-size: 14px;
}

/* ---------- Pagination ---------- */
.cpc-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
}

.cpc-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: 1.5px solid #d9d9d9;
	background-color: transparent;
	color: #333333;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	box-sizing: border-box;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

/* Numbered page buttons — perfect circles, like the reference design.
   Deliberately not user-adjustable via a radius slider so they can never
   accidentally stop being circular. */
.cpc-page-btn.cpc-page-number {
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 50% !important;
}

/* Prev / Next — pill-shaped buttons with an arrow + label, matching the
   reference ("Next →" on the right, "← Prev" on the left). */
.cpc-page-btn.cpc-page-prev,
.cpc-page-btn.cpc-page-next {
	height: 36px;
	padding: 0 16px;
	border-radius: 999px !important;
}

.cpc-arrow {
	font-size: 15px;
	line-height: 1;
}

.cpc-page-btn:hover:not(.is-disabled):not(.is-active) {
	background-color: #f5f5f5;
	border-color: #bfbfbf;
}

.cpc-page-btn:active:not(.is-disabled) {
	transform: scale(0.96);
}

.cpc-page-number.is-active {
	background-color: #22b14c;
	border-color: #22b14c;
	color: #ffffff;
	cursor: default;
}

.cpc-page-btn.is-disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* ---------- Responsive breakpoints ---------- */

/* Tablet: the reference layout keeps its exact 3-photo top row but the
   6-track grid gets tight, so we scale row height down a touch. */
@media (max-width: 1024px) {
	.cpc-collage {
		grid-auto-rows: 110px;
	}

	.cpc-collage:not(.cpc-pattern-reference) {
		grid-template-columns: repeat(2, 1fr);
		grid-auto-rows: 120px;
	}
}

/* Mobile: every pattern collapses to a single clean column. The
   reference layout uses explicit grid-line numbers (not span:N), so we
   reset those to "auto" rather than "span 1" or the browser would try
   to honour the original line numbers and leave empty gaps. */
@media (max-width: 640px) {
	.cpc-collage,
	.cpc-collage.cpc-pattern-reference {
		grid-template-columns: 1fr;
		grid-auto-rows: 220px;
		gap: 8px;
	}

	.cpc-collage .cpc-tile {
		grid-column: auto !important;
		grid-row: auto !important;
	}
}
