/**
 * Lightbox — the full-screen photograph viewer.
 *
 * Built by assets/js/gallery.js, styled entirely here. Lives in its own file
 * because more than one page uses it: the Gallery grid, and the per-category
 * photographs on Facilities and Amenities. Enqueued wherever gallery.js is (see
 * bananchal_assets()). Depends on the tokens in assets/css/style.css.
 *
 * Look: a near-black scrim with a polaroid-style white frame around the
 * photograph — the image reads as a printed photo pinned to a dark surface.
 * Caption sits inside the white card in dark text; counter is a gold accent
 * line underneath. Controls are small charcoal circles that flip to gold on
 * hover. No rgba() token substitutions — the scrim and button shades live as
 * literals because hex tokens cannot be used inside rgba() without channel
 * variants, and the same handful of values appear across the rest of the theme.
 *
 * 1. Sheet
 * 2. Photograph — the polaroid frame
 * 3. Caption and counter
 * 4. Controls — solid charcoal circles
 * 5. Responsive
 * 6. Reduced motion
 */

/* ==========================================================================
   1. Sheet
   ========================================================================== */

/* Scroll lock while the viewer is open. */
.bf-scroll-lock,
.bf-scroll-lock body {
	overflow: hidden;
}

.bf-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1080;
	display: flex;
	align-items: center;
	justify-content: center;
	/*
	 * Tight sheet padding so the photograph fills the viewport. The polaroid
	 * frame carries its own breathing room, so the dark scrim only needs to
	 * peek past the corners.
	 */
	padding: clamp(0.5rem, 1.5vw, 1rem);
	overflow: hidden;
	background-color: rgba(0, 0, 0, 0.92);
	-webkit-backdrop-filter: blur(18px) saturate(120%);
	backdrop-filter: blur(18px) saturate(120%);
	opacity: 0;
	visibility: hidden;
	/* Belt and braces: visibility is still in its fade-out delay for a moment after
	   the class goes, and a full-screen sheet must never eat a click while it is. */
	pointer-events: none;
	transition: opacity 0.3s var(--bf-ease), visibility 0s linear 0.3s;
}

.bf-lightbox.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity 0.3s var(--bf-ease), visibility 0s linear 0s;
}

.bf-lightbox__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 1200px;
	max-height: 100%;
	transform: scale(0.965);
	transition: transform 0.35s var(--bf-ease);
}

.bf-lightbox.is-open .bf-lightbox__dialog {
	transform: none;
}

/* ==========================================================================
   2. Photograph — the polaroid frame
   ========================================================================== */

/*
 * The figure is the polaroid card itself: white background, slight rounded
 * corners, a deep drop shadow so the photograph looks pinned to the dark
 * surface. Slightly more padding below than above so the caption (when one
 * exists) has somewhere to sit inside the white border.
 */
.bf-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-height: 0;
	margin: 0;
	padding: 8px 8px 14px;
	background-color: var(--bf-white);
	border-radius: 3px;
	box-shadow:
		0 14px 50px rgba(0, 0, 0, 0.55),
		0 2px 6px rgba(0, 0, 0, 0.25);
}

.bf-lightbox__stage {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	width: 100%;
}

/*
 * The image is sharp-edged inside the polaroid — no rounded corners of its
 * own, no fill colour behind it, no shadow. The white frame does all of that.
 * max-height leaves room for the figure padding, the counter below, and a
 * little margin so the photograph does not touch the scrim edges.
 */
.bf-lightbox__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 12rem);
	border-radius: 0;
	background-color: transparent;
	box-shadow: none;
	opacity: 1;
	transition: opacity 0.25s var(--bf-ease);
}

/* Held blank between setting a new src and its load event. */
.bf-lightbox__img.is-loading {
	opacity: 0;
}

/* ==========================================================================
   3. Caption and counter
   ========================================================================== */

/*
 * Caption lives inside the white card, in dark text. Italic and small — it is
 * a printed line under the photograph, not a heading. Width tracks the
 * image so long captions wrap inside the polaroid rather than spilling.
 */
.bf-lightbox__caption {
	max-width: 100%;
	margin: 12px 4px 0;
	font-family: var(--bf-font-display);
	font-size: 0.95rem;
	font-style: italic;
	line-height: 1.4;
	text-align: center;
	color: var(--bf-charcoal);
	letter-spacing: 0.01em;
}

.bf-lightbox__caption:empty {
	display: none;
}

.bf-lightbox__counter {
	margin: 0.85rem 0 0;
	font-size: 0.7rem;
	font-weight: 500;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--bf-amber);
}

/* ==========================================================================
   4. Controls — solid charcoal circles
   ========================================================================== */

.bf-lightbox__close,
.bf-lightbox__control {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	/* Solid charcoal disc with a hairline white edge so it does not disappear
	 * against the very darkest photographs. Flips to gold on hover/focus. */
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	background-color: rgba(0, 0, 0, 0.7);
	color: var(--bf-white);
	line-height: 1;
	cursor: pointer;
	transition:
		background-color var(--bf-transition),
		border-color var(--bf-transition),
		color var(--bf-transition),
		transform var(--bf-transition);
}

.bf-lightbox__close:hover,
.bf-lightbox__close:focus-visible,
.bf-lightbox__control:hover,
.bf-lightbox__control:focus-visible {
	background-color: var(--bf-amber);
	border-color: var(--bf-amber);
	color: var(--bf-charcoal);
	transform: scale(1.08);
}

.bf-lightbox__close {
	position: absolute;
	top: clamp(0.5rem, 1.5vw, 1rem);
	right: clamp(0.5rem, 1.5vw, 1rem);
	z-index: 3;
	width: 38px;
	height: 38px;
	font-size: 0.95rem;
}

.bf-lightbox__control {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 38px;
	height: 38px;
	font-size: 1.05rem;
	transform: translateY(-50%);
}

.bf-lightbox__control[hidden] {
	display: none;
}

.bf-lightbox__control--prev {
	left: clamp(0.5rem, 1.5vw, 1rem);
}

.bf-lightbox__control--next {
	right: clamp(0.5rem, 1.5vw, 1rem);
}

/* ==========================================================================
   5. Responsive
   ========================================================================== */

@media (min-width: 768px) {

	.bf-lightbox__close,
	.bf-lightbox__control {
		width: 44px;
		height: 44px;
		font-size: 1.1rem;
	}
}

@media (max-width: 767.98px) {

	.bf-lightbox__img {
		max-height: calc(100vh - 9rem);
	}

	.bf-lightbox__figure {
		padding: 6px 6px 10px;
	}
}

@media (max-width: 575.98px) {

	.bf-lightbox__caption {
		margin-top: 8px;
		font-size: 0.85rem;
	}

	.bf-lightbox__close,
	.bf-lightbox__control {
		width: 36px;
		height: 36px;
	}

	.bf-lightbox__close {
		top: 0.4rem;
		right: 0.4rem;
	}

	.bf-lightbox__control--prev {
		left: 0.3rem;
	}

	.bf-lightbox__control--next {
		right: 0.3rem;
	}
}

/* ==========================================================================
   6. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

	.bf-lightbox,
	.bf-lightbox__dialog,
	.bf-lightbox__img,
	.bf-lightbox__close,
	.bf-lightbox__control {
		transition: none;
	}

	.bf-lightbox__dialog {
		transform: none;
	}

	.bf-lightbox__close:hover,
	.bf-lightbox__close:focus-visible,
	.bf-lightbox__control:hover,
	.bf-lightbox__control:focus-visible {
		transform: none;
	}

	/* The counter still needs to be readable the instant the image swaps. */
	.bf-lightbox__img.is-loading {
		opacity: 1;
	}
}
