/* Pictures in a page body: the Gallery block and click to enlarge.

   Click to enlarge is WordPress's own (the Image block's "Enlarge on
   click"), turned on for every Image block in theme.json and for the event
   and project pictures by grunt-core (includes/images.php). Its overlay
   is a dialog that takes focus, closes on Escape and gives focus back.
   These rules only fit its look to the theme. The Gallery block is
   styled as a grid for any page, in place of the carousel Arlo asked for
   (Alanna, 2026-10-19: a grid is visible all at once, nothing moves, and
   each picture keeps its own alt text and caption). */

/* ---- Enlarge button ------------------------------------------------------- */

/* Core's button is 20px and shows on hover or focus. At 44px it meets the
   site's target size; solid ink behind the white icon keeps it legible on
   any picture (core's is a 25% grey). !important because core's own
   background rule carries three :not()s. */
.wp-lightbox-container button.lightbox-trigger {
	width: 44px;
	height: 44px;
	border-radius: 0;
	background-color: var(--wp--preset--color--text) !important;
	backdrop-filter: none;
}

.wp-lightbox-container button.lightbox-trigger svg {
	width: 16px;
	height: 16px;
}

/* The site's focus ring (style.css), in place of core's grey one. */
.wp-lightbox-container button.lightbox-trigger:focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* Closed with a pointer (a click or tap in the overlay): core gives focus
   back to the button, which then has no ring and shows only on hover, as
   before it was opened. grunt-core (assets/lightbox-focus.js) marks it
   until a key is pressed or focus moves on; a keyboard close keeps the
   ring. The button follows the picture in core's markup. */
.wp-lightbox-container button.lightbox-trigger[data-grunt-pointer-focus] {
	outline: none;
}

.wp-lightbox-container img:not(:hover) + button.lightbox-trigger[data-grunt-pointer-focus]:not(:hover) {
	opacity: 0;
}

/* ---- Overlay ---------------------------------------------------------- */

/* Core sizes the enlarged picture only inside an Image block's figure.
   The event and project pictures are Featured Image blocks, whose class
   the overlay copies, so the same rules are given to that figure. */
.wp-lightbox-overlay .wp-block-post-featured-image {
	position: relative;
	transform-origin: 0 0;
	display: flex;
	width: 100%;
	height: 100%;
	justify-content: center;
	align-items: center;
	box-sizing: border-box;
	z-index: 3000000;
	margin: 0;
}

.wp-lightbox-overlay .wp-block-post-featured-image img {
	min-width: var(--wp--lightbox-image-width);
	min-height: var(--wp--lightbox-image-height);
	width: var(--wp--lightbox-image-width);
	height: var(--wp--lightbox-image-height);
	max-width: none;
	max-height: none;
}

/* The overlay fades in and out (grunt-core takes off core's zoom; see
   grunt_lightbox_overlay_markup()). Core hides the picture on the page
   while the overlay is open and shows it again only once the zoom would
   have landed back on it, 0.4s after close. With a fade nothing lands
   there, so the picture would be missing under the fading overlay and
   then pop back: it stays drawn throughout. */
.wp-block-image.wp-lightbox-container img:is(.hide, .show) {
	visibility: visible;
	animation: none;
}

/* Solid white once open, nothing of the page behind showing through
   (Alanna, 2026-10-29). Core's scrim is the site background at 0.9
   opacity; the fade in and out is the overlay's own opacity (0 to 1 and
   back, or none with reduced motion), so the scrim at 1 keeps the fade
   and ends on full white. */
.wp-lightbox-overlay .scrim {
	opacity: 1;
}
/* Close, previous and next: 44px targets with the site's focus ring. */
.wp-lightbox-overlay :is(.wp-lightbox-close-button, .wp-lightbox-navigation-button) {
	min-width: 44px;
	min-height: 44px;
}

.wp-lightbox-overlay :is(.wp-lightbox-close-button, .wp-lightbox-navigation-button):focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* Larger, heavier icons in the text colour (Alanna, 2026-10-28: core's
   were small and thin). Core's icons are filled outlines, so the weight
   comes from the size, plus an outline stroke on the X. The X goes from
   20px to 40px, its arms from about 1.25px to 3px (1.5 units of its 24
   unit drawing, plus a 0.3 unit stroke, at 40/24px a unit). The arrows go
   from 28px to 48px, their arms from about 1.75px to 3px. */
.wp-lightbox-overlay .wp-lightbox-close-icon svg {
	width: 40px;
	height: 40px;
}

.wp-lightbox-overlay .wp-lightbox-close-icon svg path {
	stroke: var(--wp--preset--color--text);
	stroke-width: 0.3;
	stroke-linejoin: round;
}

.wp-lightbox-overlay .wp-lightbox-navigation-icon svg {
	width: 48px;
	height: 48px;
}

.wp-lightbox-overlay :is(.wp-lightbox-close-icon, .wp-lightbox-navigation-icon) svg {
	fill: var(--wp--preset--color--text);
}

/* ---- Gallery grid ------------------------------------------------------- */

/* The theme's gutter between pictures. Core reads this variable when a
   gallery has no spacing of its own and works the column widths out from
   it; a gap set on one gallery in the editor still wins. The gap itself
   follows the same variable: core takes it from the site's block gap
   (1.2rem), and a gap wider than the widths allow for wraps a row early
   (one picture per row on a phone). */
.wp-site-blocks,
.editor-styles-wrapper {
	--wp--style--gallery-gap-default: var(--wp--custom--gutter);
}

.wp-block-gallery.has-nested-images {
	gap: var(--wp--style--unstable-gallery-gap, var(--wp--custom--gutter));
}

/* Thumbnails, one size on every gallery (Alanna, 2026-11-04: "the same
   size across gallery blocks"). Core sizes each picture as a share of the
   gallery's width by its column setting (columns-N: 50% for two), so the
   size followed the setting and the column the gallery sat in: 588px in
   the full-width walkthrough stills, 360px for two columns in the 745px
   exhibition text, 384px for three on a page, and twice the front end's
   in the editor's wider column. Here a grid of fixed tracks takes the
   column setting's place: 216px pictures (nine gutters; 216 x 162 at
   4:3), as many to a row as fit, from the left. That is three in the
   745px text column of an exhibition or event and five in the 1200px
   page column, each row within a gutter of the full width. Where the
   gallery is too narrow for two of them and the gap between (a phone, a
   narrow Columns block), two share its width, smaller. A short last row
   keeps the width. The gap in the sum is the gallery's own (the gap rule
   above), so a gallery with a wider gap set in the editor still has two
   to a row on a phone. The editor loads this file too (functions.php
   add_editor_style), so a gallery is drawn there at the same size. */
.wp-block-gallery.has-nested-images {
	--grunt-gallery-tile: min(216px, calc((100% - var(--wp--style--unstable-gallery-gap, var(--wp--custom--gutter))) / 2));
}

/* [class] and the doubled class outrank core's flex layout for a gallery. */
.wp-block-gallery.has-nested-images.has-nested-images[class] {
	display: grid;
	grid-template-columns: repeat(auto-fill, var(--grunt-gallery-tile));
	justify-content: start;
	align-items: start;
}

/* Each picture fills its track. Core gives a picture a width by the column
   setting and, in the default columns from 600px, by the picture count
   (one: 100%; two: half each, which in a 216px track drew 96px pictures).
   Those count rules chain :first-child:nth-last-child(2) ~ figure on top
   of :not(#individual-image) and outrank any selector worth writing, so
   the width is !important: the track sets the size, and nothing else
   should. */
.wp-block-gallery.has-nested-images.has-nested-images[class] figure.wp-block-image:not(#individual-image) {
	width: auto !important;
	max-width: none;
	margin: 0;
}

/* The body's block gap (theme.json blockGap) above and below a gallery,
   where the body spaces its blocks with the flow gap (the exhibition and
   event bodies). The exhibition page zeroes figure margins
   (exhibitions.css .grunt-mosaic), which left a gallery flush under a
   video (2026-10-28) and its captions flush over the next paragraph,
   whose own margin is below it. Not in the page prose (.grunt-pg-prose,
   pages.css), whose blocks are 16px apart and a gallery already with
   them. Not before a first block or after a last one; beside another
   block's margin the two collapse. The walkthrough stills
   (.grunt-access__stills, a classic field, not a flow layout) get the
   same: a gallery there sat flush under the video's control bar
   (Falsework, 2026-11-04). */
:is(.is-layout-flow:not(.grunt-pg-prose), .grunt-access__stills) > .wp-block-gallery:not(:first-child) {
	margin-block-start: var(--wp--style--block-gap);
}

:is(.is-layout-flow:not(.grunt-pg-prose), .grunt-access__stills) > .wp-block-gallery:not(:last-child) {
	margin-block-end: var(--wp--style--block-gap);
}

/* A gallery takes the whole body column, also where text keeps to 66ch
   (events.css .grunt-prose). */
.grunt-tpl .grunt-prose > .wp-block-gallery {
	max-width: none;
}

/* Cropped (the default): every picture the same 4:3 box, so rows line up.
   Core crops each row to its tallest picture instead, which leaves rows
   of different heights. The whole picture opens on click: grunt-core
   (grunt_gallery_enlarge_whole()) has the overlay drawn at the picture's
   own shape, not the box's. */
.wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) {
	align-self: flex-start;
}

.wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) img {
	flex: none;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

/* The enlarge button in the box's top right corner, 16px in, where core
   puts it on a picture that fills its box. Told the picture is drawn
   whole (grunt_gallery_enlarge_whole()), core would place it at the
   corner of that smaller picture, inside the crop. Core sets the position
   inline, hence !important. */
.wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) button.lightbox-trigger {
	top: 16px !important;
	right: 16px !important;
}

/* Not cropped: each picture whole at its own ratio, tops aligned. */
.wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image:not(#individual-image) {
	align-self: flex-start;
}

/* Captions under the picture in the caption style (theme.json caption
   element), not white over a dark fade on the picture: that covered the
   artwork and its contrast depended on the photo. */
.wp-block-gallery.has-nested-images figure.wp-block-image figcaption.wp-element-caption {
	position: static;
	max-height: none;
	overflow: visible;
	margin: 8px 0 0;
	padding: 0;
	background: none;
	color: inherit;
	font-size: var(--wp--preset--font-size--body-s);
	line-height: 1.5;
	text-align: left;
	text-shadow: none;
}

.wp-block-gallery.has-nested-images figure.wp-block-image:has(figcaption)::before {
	content: none;
}

.wp-block-gallery > figcaption.blocks-gallery-caption {
	grid-column: 1 / -1;
	flex-basis: 100%;
	margin: 0;
	font-size: var(--wp--preset--font-size--body-s);
	line-height: 1.5;
	text-align: left;
}
