/*
 * Studio Project Gallery – front-end styles.
 *
 * Everything is scoped under .spg (or uses an spg- prefixed class) so it sits alongside any theme.
 * Text colour is inherited from the theme; lines and muted text use neutral transparency so the
 * portfolio works on light and dark backgrounds. The overlay and lightbox set their own colours.
 */

.spg {
	--spg-gap: clamp(1rem, 2.4vw, 2rem);
	--spg-line: rgba(127, 127, 127, 0.3);
	--spg-wash: rgba(127, 127, 127, 0.14);
	--spg-focus: #1d4ed8;
	--spg-ratio: 4 / 3;

	box-sizing: border-box;
	width: 100%;
	color: inherit;
	font-family: inherit;
	line-height: 1.5;
}

.spg *,
.spg *::before,
.spg *::after {
	box-sizing: inherit;
}

/* Author display rules would otherwise defeat the hidden attribute. */
.spg [hidden],
.spg dialog:not([open]) {
	display: none !important;
}

.spg ul,
.spg ol {
	margin: 0;
	padding: 0;
	list-style: none;
}

.spg figure {
	margin: 0;
}

.spg img {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.spg button {
	font-family: inherit;
}

.spg a:focus-visible,
.spg button:focus-visible {
	outline: 3px solid var(--spg-focus);
	outline-offset: 3px;
	box-shadow: 0 0 0 2px #fff;
}

.spg .spg-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.spg .spg-icon {
	display: block;
	width: 1.5rem;
	height: 1.5rem;
}

.spg .spg-empty {
	margin: 0;
	padding: clamp(2rem, 6vw, 4rem) 1rem;
	border: 1px dashed var(--spg-line);
	text-align: center;
	opacity: 0.8;
}

/* ------------------------------------------------------------------ columns */

.spg .spg-cols-1 { --spg-cols: 1; }
.spg .spg-cols-2 { --spg-cols: 2; }
.spg .spg-cols-3 { --spg-cols: 3; }
.spg .spg-cols-4 { --spg-cols: 4; }
.spg .spg-cols-5 { --spg-cols: 5; }
.spg .spg-cols-6 { --spg-cols: 6; }

@media (max-width: 1100px) {
	.spg .spg-cols-5,
	.spg .spg-cols-6 { --spg-cols: 4; }
}

@media (max-width: 900px) {
	.spg .spg-cols-4,
	.spg .spg-cols-5,
	.spg .spg-cols-6 { --spg-cols: 3; }
}

@media (max-width: 680px) {
	.spg .spg-cols-3,
	.spg .spg-cols-4,
	.spg .spg-cols-5,
	.spg .spg-cols-6 { --spg-cols: 2; }
}

@media (max-width: 480px) {
	/* Large editorial thumbnails: one project per row on phones. */
	.spg .spg-projects { --spg-cols: 1; }
}

/* ------------------------------------------------------------------ filters */

.spg .spg-filters {
	margin: 0 0 clamp(1.5rem, 4vw, 3rem);
}

.spg .spg-filters__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.75rem;
}

.spg .spg-filter {
	appearance: none;
	margin: 0;
	padding: 0.4rem 0;
	border: 0;
	border-bottom: 1px solid transparent;
	border-radius: 0;
	background: none;
	color: inherit;
	font-size: 0.8125rem;
	font-weight: 400;
	letter-spacing: 0.14em;
	line-height: 1.4;
	text-transform: uppercase;
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.spg .spg-filter:hover,
.spg .spg-filter.is-active {
	opacity: 1;
}

.spg .spg-filter.is-active {
	border-bottom-color: currentColor;
}

/* ------------------------------------------------------------ project cards */

.spg .spg-projects {
	display: grid;
	grid-template-columns: repeat(var(--spg-cols, 3), minmax(0, 1fr));
	gap: clamp(2rem, 5vw, 4rem) var(--spg-gap);
}

.spg .spg-card {
	min-width: 0;
	margin: 0;
	padding: 0;
}

.spg .spg-card__link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.spg .spg-card__media {
	position: relative;
	display: block;
	aspect-ratio: var(--spg-ratio);
	overflow: hidden;
	background: var(--spg-wash);
}

.spg .spg-card__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.8s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.spg .spg-card__link:hover .spg-card__media img,
.spg .spg-card__link:focus-visible .spg-card__media img {
	transform: scale(1.035);
}

.spg .spg-card__media--empty {
	display: flex;
	align-items: center;
	justify-content: center;
}

.spg .spg-card__placeholder {
	font-size: 0.75rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	opacity: 0.6;
}

.spg .spg-card__body {
	display: block;
	padding-top: 1rem;
}

.spg .spg-card__title {
	margin: 0;
	padding: 0;
	color: inherit;
	font-family: inherit;
	font-size: clamp(1.05rem, 1.4vw, 1.35rem);
	font-weight: 400;
	letter-spacing: 0.01em;
	line-height: 1.3;
	text-transform: none;
	text-decoration: none;
}

.spg .spg-card__link:hover .spg-card__title,
.spg .spg-card__link:focus-visible .spg-card__title {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
}

.spg .spg-card__meta {
	display: block;
	margin-top: 0.45rem;
	font-size: 0.75rem;
	letter-spacing: 0.12em;
	line-height: 1.5;
	text-transform: uppercase;
	opacity: 0.65;
}

.spg .spg-card__summary {
	display: none;
}

/* List layout */
.spg .spg-layout-list .spg-projects,
.spg.spg-layout-list .spg-projects {
	display: block;
	border-top: 1px solid var(--spg-line);
}

.spg.spg-layout-list .spg-card {
	border-bottom: 1px solid var(--spg-line);
}

.spg.spg-layout-list .spg-card__link {
	display: grid;
	grid-template-columns: minmax(0, 30%) minmax(0, 1fr);
	gap: var(--spg-gap);
	align-items: center;
	padding: var(--spg-gap) 0;
}

.spg.spg-layout-list .spg-card__body {
	display: grid;
	gap: 0.6rem;
	padding: 0;
}

.spg.spg-layout-list .spg-card__title {
	font-size: clamp(1.4rem, 3vw, 2.25rem);
	font-weight: 300;
	line-height: 1.15;
}

.spg.spg-layout-list .spg-card__meta {
	margin: 0;
}

.spg.spg-layout-list .spg-card__summary {
	display: block;
	max-width: 60ch;
	font-size: 0.95rem;
	line-height: 1.6;
	opacity: 0.75;
}

@media (max-width: 680px) {
	.spg.spg-layout-list .spg-card__link {
		grid-template-columns: minmax(0, 1fr);
		gap: 1rem;
	}
}

/* ---------------------------------------------------------------- galleries */

.spg .spg-gallery__item {
	min-width: 0;
	margin: 0;
	padding: 0;
}

.spg .spg-gallery--grid .spg-gallery__list {
	display: grid;
	grid-template-columns: repeat(var(--spg-cols, 3), minmax(0, 1fr));
	gap: var(--spg-gap);
}

.spg .spg-gallery--grid .spg-gallery__figure img {
	width: 100%;
	aspect-ratio: var(--spg-ratio);
	object-fit: cover;
}

.spg .spg-gallery--masonry .spg-gallery__list {
	column-count: var(--spg-cols, 3);
	column-gap: var(--spg-gap);
}

.spg .spg-gallery--masonry .spg-gallery__item {
	margin: 0 0 var(--spg-gap);
	break-inside: avoid;
}

.spg .spg-gallery--masonry .spg-gallery__figure img {
	width: 100%;
}

.spg .spg-gallery__link {
	display: block;
	overflow: hidden;
	background: var(--spg-wash);
	color: inherit;
	cursor: zoom-in;
	text-decoration: none;
}

.spg .spg-gallery__link img {
	transition: opacity 0.25s ease;
}

.spg .spg-gallery__link:hover img {
	opacity: 0.88;
}

.spg .spg-gallery__caption {
	margin-top: 0.6rem;
	font-size: 0.8125rem;
	line-height: 1.5;
	opacity: 0.75;
}

.spg.spg-standalone {
	margin: 1.5rem 0;
}

/* ----------------------------------------------------------- project detail */

.spg .spg-detail__header {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	gap: var(--spg-gap) clamp(2rem, 6vw, 5rem);
	align-items: end;
	margin-bottom: clamp(1.5rem, 4vw, 3rem);
	padding-bottom: clamp(1.5rem, 4vw, 3rem);
	border-bottom: 1px solid var(--spg-line);
}

.spg .spg-detail__header > :only-child {
	grid-column: 1 / -1;
}

.spg .spg-detail__kicker {
	margin: 0 0 0.75rem;
	font-size: 0.75rem;
	letter-spacing: 0.16em;
	line-height: 1.5;
	text-transform: uppercase;
	opacity: 0.65;
}

.spg .spg-detail__title {
	margin: 0;
	padding: 0;
	color: inherit;
	font-family: inherit;
	font-size: clamp(2rem, 5vw, 3.75rem);
	font-weight: 300;
	letter-spacing: -0.01em;
	line-height: 1.08;
	text-transform: none;
}

.spg .spg-detail__facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
	gap: 1rem;
	margin: 0;
	padding: 0;
}

.spg .spg-detail__fact {
	margin: 0;
}

.spg .spg-detail__fact dt {
	margin: 0 0 0.2rem;
	font-size: 0.7rem;
	font-weight: 400;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	opacity: 0.65;
}

.spg .spg-detail__fact dd {
	margin: 0;
	font-size: 1rem;
}

.spg .spg-detail__text {
	max-width: 68ch;
	margin: 0 0 clamp(2rem, 5vw, 4rem);
	font-size: 1.0625rem;
	line-height: 1.7;
}

.spg .spg-detail__text > :first-child {
	margin-top: 0;
}

.spg .spg-detail__text > :last-child {
	margin-bottom: 0;
}

@media (max-width: 800px) {
	.spg .spg-detail__header {
		grid-template-columns: minmax(0, 1fr);
		align-items: start;
	}
}

/* ------------------------------------------------------------------ overlay */

.spg .spg-overlay {
	--spg-line: #dedbd4;
	--spg-wash: #f1efea;
	--spg-focus: #1d4ed8;

	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: auto;
	overscroll-behavior: contain;
	border: 0;
	background: #fff;
	color: #161616;
	font-size: 1rem;
}

.spg .spg-overlay[open],
.spg .spg-lightbox[open] {
	animation: spg-fade-in 0.28s ease-out;
}

@keyframes spg-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.spg .spg-overlay__inner {
	max-width: 1400px;
	margin: 0 auto;
	padding: clamp(1rem, 2vw, 1.5rem) clamp(1rem, 4vw, 3.5rem) clamp(2.5rem, 7vw, 6rem);
}

.spg .spg-close {
	position: sticky;
	top: 1rem;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin: 0 0 0 auto;
	padding: 0;
	border: 1px solid var(--spg-line);
	border-radius: 50%;
	background: #fff;
	color: #161616;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.spg .spg-close:hover {
	background: #161616;
	color: #fff;
}

/* Pull the heading up so it shares a row with the close button. */
.spg .spg-overlay__content {
	margin-top: -3rem;
}

.spg .spg-overlay .spg-detail__header {
	padding-top: clamp(0.5rem, 2vw, 2rem);
}

.spg .spg-overlay .spg-detail__heading {
	padding-inline-end: 4rem;
}

/* ----------------------------------------------------------------- lightbox */

.spg .spg-lightbox {
	--spg-focus: #fff;

	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: rgba(10, 10, 10, 0.97);
	color: #fff;
}

.spg .spg-lightbox a:focus-visible,
.spg .spg-lightbox button:focus-visible {
	box-shadow: 0 0 0 2px #000;
}

.spg .spg-lightbox__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 4.5rem 5rem;
	touch-action: pan-y pinch-zoom;
}

.spg .spg-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.9rem;
	max-width: 100%;
	max-height: 100%;
	min-height: 0;
}

.spg .spg-lightbox__img {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 11rem);
	max-height: calc(100dvh - 11rem);
	object-fit: contain;
	transition: opacity 0.25s ease;
}

.spg .spg-lightbox__stage.is-loading .spg-lightbox__img {
	opacity: 0.25;
}

.spg .spg-lightbox__caption {
	max-width: 60ch;
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.5;
	text-align: center;
	opacity: 0.9;
}

.spg .spg-lightbox__count {
	position: absolute;
	top: 1.6rem;
	left: 1.5rem;
	z-index: 2;
	margin: 0;
	font-size: 0.75rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	opacity: 0.85;
}

.spg .spg-lightbox__btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.4);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.spg .spg-lightbox__btn:hover {
	background: rgba(255, 255, 255, 0.2);
}

.spg .spg-lightbox__close {
	top: 1rem;
	right: 1rem;
}

.spg .spg-lightbox__prev,
.spg .spg-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.spg .spg-lightbox__prev {
	left: 1rem;
}

.spg .spg-lightbox__next {
	right: 1rem;
}

@media (max-width: 680px) {
	.spg .spg-lightbox__stage {
		padding: 4rem 1rem 5.5rem;
	}

	.spg .spg-lightbox__img {
		max-height: calc(100vh - 12rem);
		max-height: calc(100dvh - 12rem);
	}

	.spg .spg-lightbox__prev,
	.spg .spg-lightbox__next {
		top: auto;
		bottom: 1rem;
		transform: none;
	}
}

/* ------------------------------------------------------------- page scroll */

html.spg-scroll-locked {
	overflow: hidden;
	padding-inline-end: var(--spg-scrollbar, 0);
}

/* ---------------------------------------------------------- user preferences */

@media (prefers-reduced-motion: reduce) {
	.spg *,
	.spg *::before,
	.spg *::after {
		animation: none !important;
		transition: none !important;
	}

	.spg .spg-card__link:hover .spg-card__media img,
	.spg .spg-card__link:focus-visible .spg-card__media img {
		transform: none;
	}
}

@media (forced-colors: active) {
	.spg .spg-filter.is-active {
		border-bottom-color: Highlight;
	}

	.spg .spg-close,
	.spg .spg-lightbox__btn {
		border-color: ButtonText;
	}
}
