/**
 * MA Steelfixing: site photos
 *  - Homepage: one large photo, marked up with leader lines and tags like a drawing
 *  - Projects: a black contact sheet in natural rows; tap a photo to view it large
 *  - About: one photo edge to edge with a small label
 */

/* ---------- Homepage feature: a marked-up site photo ---------- */
.ms-feature-cols {
	align-items: center !important;
	gap: clamp(2rem, 5vw, 5rem) !important;
}

.ms-feature {
	margin: 0;
}

.ms-feature-frame {
	position: relative;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--ms-ink);
}

.ms-feature-frame img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ms-markup {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.ms-markup .ms-leader {
	fill: none;
	stroke: var(--ms-white);
	stroke-width: 2.5;
	filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.55));
}

.ms-markup .ms-pin {
	fill: var(--ms-orange);
	stroke: var(--ms-ink);
	stroke-width: 2.5;
}

.ms-markup .ms-pin-no {
	font-family: var(--wp--preset--font-family--archivo);
	font-weight: 700;
	font-size: 17px;
	fill: var(--ms-ink);
}

.ms-markup .ms-tag rect {
	fill: var(--ms-white);
	stroke: var(--ms-ink);
	stroke-width: 2;
}

.ms-markup .ms-tag text {
	font-family: var(--ms-annot);
	font-size: 20px;
	fill: var(--ms-ink);
}

/* The key: hidden on large screens (the tags say it), shown on phones */
ol.ms-feature-key {
	list-style: none;
	counter-reset: ms-key;
	padding: 0;
	margin: 1.5rem 0;
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}

ol.ms-feature-key li {
	counter-increment: ms-key;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 0;
	border-top: 1px solid var(--ms-hair);
}

ol.ms-feature-key li::before {
	content: counter(ms-key);
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.7rem;
	height: 1.7rem;
	border-radius: 50%;
	background: var(--ms-orange);
	border: var(--ms-line) solid var(--ms-ink);
	font-weight: 700;
	font-size: 0.85rem;
}

/* One reveal when the photo first scrolls into view: the mark-ups appear in turn */
@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: view()) {
		.ms-markup .ms-note {
			animation: ms-fade linear both;
			animation-timeline: view();
			animation-range: entry 40% cover 35%;
		}

		.ms-markup .ms-note:nth-child(2) { animation-range: entry 55% cover 40%; }
		.ms-markup .ms-note:nth-child(3) { animation-range: entry 70% cover 45%; }
	}
}

/* ---------- Projects: black contact sheet ---------- */
.ms-dark {
	background: var(--ms-ink);
	color: var(--ms-film);
}

.ms-dark h2 {
	color: var(--ms-film);
}

.ms-dark .ms-sub {
	color: var(--ms-concrete);
}

.ms-contact {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 6px;
}

/* Even frames, like a contact sheet; the full photo opens on tap */
.ms-contact-item {
	position: relative;
	display: block;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: #1a1a1a;
	cursor: zoom-in;
}

@media (max-width: 1100px) {
	.ms-contact {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.ms-contact-item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease, opacity 0.2s ease;
}

.ms-contact-item:hover img {
	transform: scale(1.03);
}

.ms-contact-item:focus-visible {
	outline: 2px solid var(--ms-orange);
	outline-offset: 2px;
}

.ms-contact-no {
	position: absolute;
	left: 0;
	bottom: 0;
	padding: 0.2rem 0.45rem;
	background: var(--ms-ink);
	color: var(--ms-film);
	font-family: var(--ms-annot);
	font-size: 0.7rem;
	line-height: 1.3;
}

/* ---------- Full-screen viewer (opens on tap, no JavaScript) ---------- */
.ms-lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 300;
	background: rgba(0, 0, 0, 0.94);
	align-items: center;
	justify-content: center;
	padding: 3.5rem 4.5rem;
}

.ms-lightbox:target {
	display: flex;
	animation: ms-fade 0.18s ease both;
}

body:has(.ms-lightbox:target) {
	overflow: hidden;
}

body:has(.ms-lightbox:target) .ms-mobile-bar,
body:has(.ms-lightbox:target) header.wp-block-template-part {
	visibility: hidden;
}

.ms-lb-close-bg {
	position: absolute;
	inset: 0;
	cursor: zoom-out;
}

.ms-lb-figure {
	position: relative;
	margin: 0;
	max-width: min(1200px, 100%);
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	pointer-events: none;
}

.ms-lb-img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 9rem);
	max-height: calc(100dvh - 9rem);
	width: auto;
	height: auto;
	object-fit: contain;
}

.ms-lb-figure figcaption {
	margin-top: 0.9rem;
	color: var(--ms-film);
	font-size: 0.95rem;
	display: flex;
	gap: 1rem;
	align-items: baseline;
}

.ms-lb-no {
	font-family: var(--ms-annot);
	font-size: 0.75rem;
	color: var(--ms-concrete);
}

.ms-lb-prev,
.ms-lb-next {
	position: absolute;
	top: 50%;
	width: 3.25rem;
	height: 3.25rem;
	margin-top: -1.6rem;
	border: var(--ms-line) solid var(--ms-film);
	border-radius: 50%;
	z-index: 2;
}

.ms-lb-prev { left: 1rem; }
.ms-lb-next { right: 1rem; }

.ms-lb-prev::before,
.ms-lb-next::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0.7rem;
	height: 0.7rem;
	border-top: 2px solid var(--ms-film);
	border-right: 2px solid var(--ms-film);
}

.ms-lb-prev::before { transform: translate(-30%, -50%) rotate(-135deg); }
.ms-lb-next::before { transform: translate(-70%, -50%) rotate(45deg); }

.ms-lb-prev:hover,
.ms-lb-next:hover {
	background: var(--ms-orange);
	border-color: var(--ms-orange);
}

.ms-lb-close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 2;
	color: var(--ms-film);
	font-weight: 600;
	text-decoration: none;
	padding: 0.5rem 0.9rem;
	border: var(--ms-line) solid var(--ms-film);
}

.ms-lb-close:hover {
	background: var(--ms-film);
	color: var(--ms-ink);
}

/* ---------- About: one photo edge to edge ---------- */
.ms-photo-band {
	padding: 0 !important;
}

.ms-band {
	position: relative;
	margin: 0 !important;
	max-width: none !important;
}

.ms-photo-band > .ms-band,
.ms-photo-band > p:has(.ms-band) {
	margin-left: calc(var(--wp--style--root--padding-left, 0px) * -1) !important;
	margin-right: calc(var(--wp--style--root--padding-right, 0px) * -1) !important;
	max-width: none !important;
}

.ms-band img {
	display: block;
	width: 100%;
	height: clamp(260px, 52vw, 680px);
	object-fit: cover;
}

.ms-band-tag {
	position: absolute;
	left: clamp(1rem, 4vw, 4.5rem);
	bottom: clamp(1rem, 3vw, 2rem);
	background: var(--ms-white);
	border: var(--ms-line) solid var(--ms-ink);
	padding: 0.45rem 0.8rem;
	font-family: var(--ms-annot);
	font-size: 0.8rem;
}

/* ---------- Phones ---------- */
@media (max-width: 781px) {
	/* Tags would be too small to read: keep the numbered pins, show the key */
	.ms-markup .ms-tag,
	.ms-markup .ms-leader {
		display: none;
	}

	.ms-markup .ms-pin {
		r: 24px;
	}

	.ms-markup .ms-pin-no {
		font-size: 26px;
		transform: translateY(3px);
		transform-box: fill-box;
	}

	ol.ms-feature-key {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip-path: none;
	}

	.ms-feature-cols {
		gap: 1.75rem !important;
	}

	.ms-on-site-section .ms-feature {
		margin-left: calc(var(--wp--style--root--padding-left, 1.5rem) * -1);
		margin-right: calc(var(--wp--style--root--padding-right, 1.5rem) * -1);
	}

	.ms-contact {
		gap: 4px;
		margin-left: calc(var(--wp--style--root--padding-left, 1.5rem) * -1);
		margin-right: calc(var(--wp--style--root--padding-right, 1.5rem) * -1);
	}

	.ms-lightbox {
		padding: 4rem 0 5rem;
	}

	.ms-lb-img {
		max-height: calc(100dvh - 11rem);
	}

	.ms-lb-figure figcaption {
		padding: 0 1rem;
		flex-direction: column;
		gap: 0.2rem;
	}

	.ms-lb-prev,
	.ms-lb-next {
		top: auto;
		bottom: 1rem;
		margin-top: 0;
	}

	.ms-lb-prev { left: calc(50% - 4rem); }
	.ms-lb-next { right: calc(50% - 4rem); }

	.ms-band-tag {
		font-size: 0.7rem;
		bottom: 0.75rem;
	}
}
