/*
 * «سوريا بالصور» (research 2026-11-17, E17; page-templates/gallery.php, parts/gallery/grid.php). Mobile first (390);
 * 3 columns from 768 px, 4 from 1024 px. On top of main.css, whose plain-page frame (.vs-main--plain, .vs-plain__title)
 * and chip (.vs-chip) it reuses; the chips row scrolls sideways below 768 px as the blog's does, and wraps above.
 * Enqueued by the template only. No movement without prefers-reduced-motion: no-preference.
 */

.vs-gallery__head {
	max-width: 820px;
}

.vs-gallery__title {
	margin-block-end: 12px;
}

.vs-gallery__intro {
	margin: 0 0 24px;
	color: var(--vs-secondary-text);
	font-size: 18px;
	line-height: 1.6;
}

/* Chips by governorate */

.vs-gallery-chips {
	display: flex;
	flex-wrap: nowrap;
	gap: 8px;
	margin: 0 -16px 16px;
	padding: 4px 16px;
	overflow-x: auto;
	scrollbar-width: none;
}

.vs-gallery-chips::-webkit-scrollbar {
	display: none;
}

.vs-gallery-chips .vs-chip {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 4px;
	min-height: 44px;
	text-decoration: none;
	box-shadow: inset 0 0 0 1px rgba(20, 88, 80, 0.4);
}

.vs-gallery-chips .vs-chip.is-active {
	padding-block: 12px;
	background: var(--wp--preset--color--bg-alt);
	box-shadow: none;
}

/* Review GAL-FE-02: the chip's border is a box-shadow, so the site's focus ring (main.css :focus-visible) is added to
   it here, as main.css does for .vs-btn--secondary. */
.vs-gallery-chips .vs-chip:focus-visible {
	box-shadow: inset 0 0 0 1px rgba(20, 88, 80, 0.4), var(--vs-focus);
}

.vs-gallery-chips .vs-chip.is-active:focus-visible {
	box-shadow: var(--vs-focus);
}

.vs-gallery-chips__count {
	color: var(--vs-secondary-text);
	font-size: 14px;
	font-weight: 400;
}

.vs-gallery__status,
.vs-gallery__notice {
	margin: 0 0 16px;
	color: var(--vs-secondary-text);
	font-size: 16px;
	line-height: 1.5;
}

.vs-gallery__notice {
	padding: 12px 16px;
	border-inline-start: 4px solid var(--vs-gold);
	border-radius: 8px;
	background: var(--vs-surface);
	color: var(--vs-dark-text);
}

/* Grid */

.vs-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 24px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Review GAL-FE-04: the list takes the focus after a chip link (#vs-gallery-list) so a screen reader starts there; no
   ring around the whole grid (as main.css does for .vs-main). */
.vs-gallery__grid:focus,
.vs-gallery__grid:focus-visible {
	outline: none;
	box-shadow: none;
}

/* Persona fixes C4 (2026-11-17, D1US-R2-17): a chip's link (#vs-gallery-list) stops with the chip row and the count line
   still in view above the grid, under the fixed header (html's scroll-padding): the row of chips and the line below it.
   gallery.js sets the exact distance when the chips wrap differently. */
.vs-gallery__grid {
	scroll-margin-top: 112px;
}

.vs-gallery__item {
	min-width: 0;
}

.vs-gallery__figure {
	display: grid;
	gap: 8px;
	margin: 0;
}

.vs-gallery__zoom {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius-md, 16px);
	background: var(--vs-img-placeholder);
	overflow: hidden;
	cursor: zoom-in;
}

.vs-gallery__zoom:focus-visible {
	box-shadow: var(--vs-focus);
}

.vs-gallery__zoom img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.vs-gallery__zoom img {
		transition: filter var(--vs-dur-fade-hover) var(--vs-ease-std);
	}

	.vs-gallery__zoom:hover img {
		filter: brightness(var(--vs-hover-dim));
	}
}

.vs-gallery__caption {
	display: grid;
	gap: 2px;
	min-width: 0;
}

.vs-gallery__name {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--vs-primary-text);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
	text-decoration: none;
	overflow-wrap: anywhere;
}

@media (hover: hover) {
	.vs-gallery__name:hover {
		text-decoration: underline;
		text-underline-offset: 4px;
	}
}

.vs-gallery__meta {
	color: var(--vs-secondary-text);
	font-size: 14px;
	line-height: 1.5;
}

.vs-gallery__caption .vs-photo-credit {
	display: block;
	margin: 2px 0 0;
	color: var(--vs-secondary-text);
	font-size: 12px;
	line-height: 1.6;
	overflow-wrap: anywhere;
}

.vs-gallery__caption .vs-photo-credit a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* Lightbox (a modal <dialog>: the browser traps focus inside it, Esc closes it, focus returns to the photo). */

.vs-lightbox {
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: auto;
	max-width: none;
	height: auto;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(0, 20, 18, 0.97); /* Persona fixes C (R2-P03-R3-S4-01): no page text ghosting behind the photo (was 0.94). */
	color: #fff;
	overflow: hidden;
}

/* Persona fixes C (2026-11-17, R2-P03-R3-S4-01, D1US-R3-S3-05): the page under an open photo does not scroll (the wheel
   moved it to the footer); the scrollbar's room is kept so nothing shifts sideways. gallery.js sets the class; :has()
   covers a dialog opened before the script ran its handler. */
html.vs-lightbox-open,
html:has(dialog.vs-lightbox[open]) {
	overflow: hidden;
	scrollbar-gutter: stable;
}

.vs-lightbox[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	grid-template-columns: minmax(0, 1fr);
}

.vs-lightbox::backdrop {
	background: rgba(0, 20, 18, 0.97);
}

.vs-lightbox__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 8px 16px;
}

.vs-lightbox__count {
	margin: 0;
	font-size: 16px;
	line-height: 1.4;
}

.vs-lightbox__btn {
	display: inline-grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	cursor: pointer;
}

.vs-lightbox__btn .vs-icon {
	width: 22px;
	height: 22px;
}

.vs-lightbox__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: none;
}

@media (hover: hover) {
	.vs-lightbox__btn:hover {
		background: rgba(255, 255, 255, 0.26);
	}
}

.vs-lightbox__figure {
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
	grid-template-columns: minmax(0, 1fr);
	gap: 12px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0 16px 88px; /* Room for the two navigation buttons under the photo on phones. */
	touch-action: pan-y pinch-zoom; /* A sideways swipe reaches gallery.js (next / previous); pinch-zoom stays. */
}

/* Review C5-FE-01: while the page is pinch-zoomed (gallery.js), a sideways move pans across the photo. */
.vs-lightbox.is-zoomed .vs-lightbox__figure {
	touch-action: auto;
}

.vs-lightbox__media {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
	place-items: center;
	min-width: 0;
	min-height: 0;
}

.vs-lightbox__media img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	border-radius: 8px;
	object-fit: contain;
}

.vs-lightbox__caption {
	display: grid;
	gap: 2px;
	max-width: 760px;
	margin-inline: auto;
	text-align: center;
}

.vs-lightbox__caption .vs-gallery__name,
.vs-lightbox__caption .vs-gallery__meta,
.vs-lightbox__caption .vs-photo-credit {
	justify-content: center;
	color: #fff;
}

.vs-lightbox__caption .vs-gallery__name {
	text-decoration: underline;
	text-underline-offset: 4px;
}

.vs-lightbox__caption .vs-gallery__meta,
.vs-lightbox__caption .vs-photo-credit {
	color: rgba(255, 255, 255, 0.86);
}

/* Review GAL-FE-01: the copied credit's links (author, licence) take the caption's light colour on the dark lightbox,
   not the site's link green; every link in the lightbox gets a white focus outline. */
.vs-lightbox__caption .vs-photo-credit a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.vs-lightbox a:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: none;
}

.vs-lightbox__nav {
	position: absolute;
	inset-block-end: 20px;
}

/* RTL: «السابقة» on the inline start (right), «التالية» on the inline end (left); the chevron points the way it goes. */
.vs-lightbox__nav--prev {
	inset-inline-start: 16px;
}

.vs-lightbox__nav--next {
	inset-inline-end: 16px;
}

.vs-lightbox__nav--prev .vs-icon {
	transform: scaleX(-1);
}

[dir="ltr"] .vs-lightbox__nav--prev .vs-icon {
	transform: none;
}

[dir="ltr"] .vs-lightbox__nav--next .vs-icon {
	transform: scaleX(-1);
}

@media (prefers-reduced-motion: no-preference) {
	.vs-lightbox[open] {
		animation: vs-lightbox-in var(--vs-dur-fast) var(--vs-ease-out);
	}
}

@keyframes vs-lightbox-in {
	from {
		opacity: 0;
	}
}

@media (forced-colors: active) {
	.vs-lightbox__btn {
		outline: 1px solid ButtonText;
	}
}

/* Tablet */

@media (min-width: 768px) {
	.vs-gallery-chips {
		flex-wrap: wrap;
		margin-inline: 0;
		padding-inline: 0;
		overflow: visible;
	}

	.vs-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 32px 24px;
		scroll-margin-top: 216px; /* Three rows of wrapped chips (C4, D1US-R2-17). */
	}
}

/* Desktop */

@media (min-width: 1024px) {
	.vs-gallery__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		scroll-margin-top: 168px; /* Two rows of chips (C4, D1US-R2-17). */
	}

	.vs-lightbox__figure {
		padding: 0 96px 32px;
	}

	.vs-lightbox__nav {
		inset-block-end: auto;
		inset-block-start: 50%;
		transform: translateY(-50%);
	}
}

/* Short screens (persona fix R2-P03-R1-11: a phone on its side, or 200 % zoom at 683 × 384): the photo takes most of
   the height. The counter and the close button share one compact row, the two arrows sit over the photo's edges
   (not under it), and the caption is one wrapped line of smaller text. */
@media (max-height: 500px) {
	.vs-lightbox__bar {
		padding: 4px 16px;
	}

	.vs-lightbox__count {
		font-size: 14px;
	}

	.vs-lightbox__figure {
		gap: 4px;
		padding: 0 16px 8px;
	}

	/* The visible height where the browser knows it (100dvh: without the phone's toolbars), so the caption below stays
	   in view; 108 px leaves the 44 px record link and the 12 px credit their full size (review C5-FE-02, C5-FE-03). */
	.vs-lightbox__media img {
		max-height: calc(100vh - 108px);
		max-height: calc(100dvh - 108px);
	}

	.vs-lightbox__caption {
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		justify-content: center;
		gap: 0 12px;
		max-width: none;
	}

	.vs-lightbox__caption .vs-gallery__name {
		min-height: 44px;
		font-size: 14px;
	}

	.vs-lightbox__caption .vs-gallery__meta {
		font-size: 13px;
	}

	.vs-lightbox__caption .vs-photo-credit {
		margin: 0;
		font-size: 12px;
	}

	/* The base light circle, with a dark ring so it shows over a light photo too (review C5-FE-06). */
	.vs-lightbox__nav {
		inset-block-end: auto;
		inset-block-start: 50%;
		transform: translateY(-50%);
		box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
	}

	.vs-lightbox__nav--prev {
		inset-inline-start: 8px;
	}

	.vs-lightbox__nav--next {
		inset-inline-end: 8px;
	}
}
