/*
 * Portfolio wall (Gallery block → Styles → Portfolio wall)
 * Rows of equal height; each photo keeps its own shape; no captions.
 * Change the look here:
 *   --btc-row  how tall each row is (phone / tablet / desktop below)
 *   --btc-gap  space between photos
 */
.wp-block-gallery.is-style-btc-portfolio {
	--btc-row: 150px;
	--btc-gap: 6px;
	display: flex !important;
	flex-wrap: wrap !important;
	gap: var(--btc-gap) !important;
	margin: 0 !important;
	/* Always use the full width available, even inside a Row/Stack group (which would otherwise shrink it). */
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100% !important;
	align-self: stretch !important;
	flex: 1 1 100%;
	float: none !important;      /* Ignore Align left / Align right, which would shrink the wall. */
	clear: both;
	margin-inline: 0 !important;
}
@media (min-width: 600px) {
	.wp-block-gallery.is-style-btc-portfolio { --btc-row: 230px; --btc-gap: 8px; }
}
@media (min-width: 1024px) {
	.wp-block-gallery.is-style-btc-portfolio { --btc-row: 320px; --btc-gap: 10px; }
}

/* Each photo: starts at row height, then grows in proportion to its shape so the row fills exactly. */
.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image:not(#individual-image) {
	/* Grow in proportion to shape (×100 so a single photo on its own row still fills it). */
	flex: calc(var(--btc-r, 1) * 100) 1 calc(var(--btc-row) * var(--btc-r, 1)) !important;
	width: auto !important;
	max-width: 100% !important;
	aspect-ratio: var(--btc-r, 1);
	margin: 0 !important;
	overflow: hidden;
	background: rgba(28, 23, 20, 0.06);
}
.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image img,
.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image > a,
.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image > div {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	object-fit: cover;
	flex: none !important;
}

/* The last row stays at row height instead of stretching a few photos huge. */
.wp-block-gallery.is-style-btc-portfolio::after {
	content: "";
	flex-grow: 100000000;
}

/* No text on the wall. */
.wp-block-gallery.is-style-btc-portfolio figcaption,
.wp-block-gallery.is-style-btc-portfolio .blocks-gallery-caption { display: none !important; }

/* Gentle hover when photos open larger. */
.wp-block-gallery.is-style-btc-portfolio figure a img,
.wp-block-gallery.is-style-btc-portfolio figure .wp-lightbox-container img { transition: transform 0.6s ease, opacity 0.3s ease; }
.wp-block-gallery.is-style-btc-portfolio figure a:hover img,
.wp-block-gallery.is-style-btc-portfolio figure .wp-lightbox-container:hover img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery.is-style-btc-portfolio figure img { transition: none !important; transform: none !important; }
}

/* ===== Phones: three tidy columns, same order, tap a photo to see it whole =====
 * Rows of mixed shapes get too small on a phone, so below 600px the wall becomes
 * a 3-column grid of even portrait tiles (3:4, the shape of a magazine cover).
 * Landscape photos that start a row span the full width at their own shape.
 */
@media (max-width: 599px) {
	.wp-block-gallery.is-style-btc-portfolio {
		--btc-gap: 3px;
		display: grid !important;
		width: 100% !important;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--btc-gap) !important;
	}
	.wp-block-gallery.is-style-btc-portfolio::after { display: none; }
	.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image:not(#individual-image) {
		flex: none !important;
		width: auto !important;
		aspect-ratio: 3 / 4;
	}
	/* Keep the top of each photo (magazine titles, faces) when a little has to be trimmed. */
	.wp-block-gallery.is-style-btc-portfolio figure img { object-position: 50% 20%; }
	.wp-block-gallery.has-nested-images.is-style-btc-portfolio figure.wp-block-image.btc-wide:not(#individual-image) {
		grid-column: 1 / -1;
		aspect-ratio: var(--btc-rw, 1.5);
	}
	/* No zoom-on-hover on touch screens. */
	.wp-block-gallery.is-style-btc-portfolio figure img { transform: none !important; }
}

/* ===== When the wall sits inside a Columns block =====
 * (e.g. the About page's "Selected work" grid, which shows columns two-across on
 * phones and tablets) the column holding the wall takes the full width instead.
 */
.wp-block-columns:not(#btc-portfolio) > .wp-block-column:has(.is-style-btc-portfolio) {
	flex: 1 1 100% !important;
	width: 100% !important;
	max-width: 100% !important;
}
.wp-block-column > .btc-portfolio-page { padding-top: 0 !important; }

/* Phones: the wall runs almost edge to edge (8px either side), whatever page padding it sits in. */
@media (max-width: 599px) {
	.btc-portfolio-page:has(.is-style-btc-portfolio) {
		width: calc(100vw - 16px) !important;
		max-width: none !important;
		margin-left: calc(50% - 50vw + 8px) !important;
		margin-right: 0 !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
}

/* Editor: shapes aren't known while editing, so photos show as even tiles there. */
.editor-styles-wrapper .wp-block-gallery.is-style-btc-portfolio figure.wp-block-image { aspect-ratio: auto; height: var(--btc-row); }
