/* =====================================================================
   viewers.css
   Styling for the actual project media — gallery, before/after, video,
   panorama, carousel, book pages, and the file-download notes for 3D
   and print formats. Kept separate from single-project.css because
   single-pfs_case.php (a later step) reuses this same markup and CSS
   when it shows a related project's media inside a case study.
   ===================================================================== */

.pv-gallery {
	display: grid;
	gap: var(--space-3);
	grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 700px) {
	.pv-gallery {
		grid-template-columns: repeat(3, 1fr);
	}
}
.pv-gallery a,
.pv-gallery figure {
	display: block;
	margin: 0;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: var(--surface);
	cursor: zoom-in;
}
.pv-gallery img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	display: block;
}
.pv-gallery figcaption {
	font-family: var(--font-ui);
	font-size: var(--text-xs);
	color: var(--muted);
	padding: var(--space-2) var(--space-3);
}

.pv-compare {
	display: grid;
	gap: var(--space-3);
	grid-template-columns: 1fr;
}
@media (min-width: 640px) {
	.pv-compare {
		grid-template-columns: repeat(2, 1fr);
	}
}
.pv-compare figure {
	margin: 0;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	overflow: hidden;
}
.pv-compare img {
	width: 100%;
	display: block;
}
.pv-compare figcaption {
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: var(--text-xs);
	padding: var(--space-2) var(--space-3);
	background: var(--surface);
}

.pv-video {
	aspect-ratio: 16 / 9;
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: #0F1330;
	max-width: 800px;
	margin-inline: auto;
}
.pv-video iframe,
.pv-video video {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.pv-panorama {
	max-height: 360px;
	overflow-x: auto;
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
	cursor: grab;
}
.pv-panorama.is-dragging {
	cursor: grabbing;
}
.pv-panorama img {
	height: 340px;
	max-width: none;
	display: block;
}

/* -------------------------------------------------------------------
   Before/after drag slider: compare.js rebuilds the plain side-by-side
   markup into this structure. Both images fill the same fixed-ratio
   box; the "before" one is clipped to reveal only up to --pos percent
   from the left, driven by the range input dragged across the whole
   image (the range itself is invisible — see the opacity rule below).
   ----------------------------------------------------------------- */
.pv-compare-slider {
	--pos: 50;
	position: relative;
	grid-column: 1 / -1; /* the parent .pv-compare grid has 2 columns, for the no-JS figures; this makes the slider span both once JS replaces them with itself */
	width: 100%;
	max-width: 900px;
	margin-inline: auto;
	aspect-ratio: 16 / 9;
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: #e5e7ec;
}
.pv-compare-base,
.pv-compare-clip img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.pv-compare-clip {
	position: absolute;
	inset: 0;
	clip-path: inset(0 calc(100% - var(--pos) * 1%) 0 0);
}
.pv-compare-handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: calc(var(--pos) * 1%);
	width: 3px;
	margin-left: -1.5px;
	background: #fff;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
	pointer-events: none;
}
.pv-compare-handle::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.pv-compare-tag {
	position: absolute;
	top: var(--space-3);
	padding: 0.25rem 0.7rem;
	border-radius: var(--radius-pill);
	background: var(--surface);
	color: var(--ink);
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: var(--text-xs);
	border: 1px solid var(--line);
	z-index: 2;
}
.pv-compare-tag-l {
	left: var(--space-3);
}
.pv-compare-tag-r {
	right: var(--space-3);
}
.pv-compare-slider input[type="range"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: ew-resize;
	-webkit-appearance: none;
}

.pv-carousel {
	display: flex;
	gap: var(--space-3);
	overflow-x: auto;
	scroll-snap-type: x proximity;
	padding-bottom: var(--space-2);
}
.pv-carousel img {
	flex: 0 0 80%;
	scroll-snap-align: center;
	border-radius: var(--radius-sm);
	aspect-ratio: 1;
	object-fit: cover;
	border: 1px solid var(--line);
}
@media (min-width: 700px) {
	.pv-carousel img {
		flex-basis: 31%;
	}
}

/* -------------------------------------------------------------------
   Book / page viewer: book.js rebuilds the flat page-thumbnail grid
   into this two-page spread, one spread visible at a time.
   ----------------------------------------------------------------- */
.pv-book-viewer {
	grid-column: 1 / -1; /* .pv-book carries .pv-gallery's own class too, which sets a
	                         2-column grid at 700px+ — this makes the viewer span both
	                         columns instead of being squeezed into just the first one.
	                         The same fix .pv-compare-slider already needed. */
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-4);
	outline: none;
}
.pv-book-viewer:focus-visible {
	outline: 3px solid var(--brand-text);
	outline-offset: 6px;
	border-radius: var(--radius-sm);
}
.pv-book-pages {
	display: flex;
	justify-content: center;
	width: 100%;
	max-width: 760px;
}
.pv-book-page {
	flex: 0 1 50%;
	aspect-ratio: 3 / 4;
	display: block;
	border: 1px solid var(--line);
	background: var(--surface);
	padding: 0;
	margin: 0;
	cursor: zoom-in;
	overflow: hidden;
}
.pv-book-page img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.pv-book-page:first-child {
	border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.pv-book-page:last-child {
	border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	border-left: 0;
}
.pv-book-controls {
	display: flex;
	align-items: center;
	gap: var(--space-4);
}
.pv-book-prev,
.pv-book-next {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 1.5px solid var(--line);
	background: var(--surface);
	color: var(--ink);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
}
.pv-book-prev:disabled,
.pv-book-next:disabled {
	opacity: 0.35;
	cursor: default;
}
.pv-book-note {
	font-family: var(--font-ui);
	font-size: var(--text-xs);
	color: var(--muted);
	min-width: 90px;
	text-align: center;
}

.pv-file-note {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-3);
	margin-bottom: var(--space-4);
	font-family: var(--font-ui);
	font-size: var(--text-xs);
	color: var(--muted);
}

/* -------------------------------------------------------------------
   Lightbox: built once by lightbox.js and appended to <body>, shared
   by every gallery on the page. The [hidden] rule is required here —
   see work-grid.css's own .work-more-row[hidden] rule for why a plain
   "display: grid" alone isn't enough to make the hidden attribute work.
   ----------------------------------------------------------------- */
.pv-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: grid;
	place-items: center;
	background: rgba(8, 10, 25, 0.9);
	padding: var(--space-5);
}
.pv-lightbox[hidden] {
	display: none;
}
.pv-lightbox img {
	max-width: 92vw;
	max-height: 86vh;
	border-radius: var(--radius-sm);
	display: block;
}
.pv-lightbox-close {
	position: absolute;
	top: var(--space-4);
	right: var(--space-4);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1.5px solid rgba(255, 255, 255, 0.5);
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-size: 1.3rem;
	line-height: 1;
	cursor: pointer;
}
.pv-lightbox-close:hover {
	background: rgba(255, 255, 255, 0.2);
}
