/* tempire.photos — field-journal gallery (J5).
   Paper and ink, a full-bleed mosaic, signage-condensed titles, data in mono,
   one trail-blaze accent. Motion: staggered wipe-in, scroll reveals, hover
   zoom, a viewer that grows out of the tile you clicked. */

:root {
	--paper: #efece5;
	--paper-2: #e6e2d8;
	--ink: #141412;
	--mute: #77736a;
	--line: rgba(20, 20, 18, .14);
	--blaze: #ff4f1a;
	--night: #0f0f0e;
	--night-line: rgba(239, 236, 229, .1);
	--gap: 8px;
	--edge: clamp(16px, 3.2vw, 48px);
	--ease: cubic-bezier(.2, .8, .2, 1);
	--display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
	--serif: 'Newsreader', Georgia, serif;
	--mono: 'Spline Sans Mono', ui-monospace, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	min-height: 100vh;
	background: var(--paper);
	color: var(--ink);
	font: 400 15px/1.5 var(--serif);
	-webkit-font-smoothing: antialiased;
	display: flex;
	flex-direction: column;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

/* Paper grain over everything, very faint. */
.grain {
	position: fixed; inset: -50%; z-index: 100; pointer-events: none; opacity: .07;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
	0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
	60% { transform: translate(-4%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---- header ---------------------------------------------------------- */
.top {
	display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
	padding: clamp(20px, 3vw, 36px) var(--edge) 18px;
	border-bottom: 1px solid var(--line);
}
.brand img { width: clamp(120px, 13vw, 170px); height: auto; }
.brand { opacity: 0; transform: translateY(-8px); animation: drop .7s var(--ease) .05s forwards; }
.stats { margin: 0 0 6px; color: var(--mute); text-align: right; opacity: 0; animation: fade .6s var(--ease) .35s forwards; }
.stats b { color: var(--ink); font-weight: 500; }

main { flex: 1; }

/* ---- section heads ------------------------------------------------- */
.lead {
	display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
	padding: 28px var(--edge) 14px;
}
.lead .label { margin: 0; color: var(--mute); }
.lead .label i { font-style: normal; color: var(--blaze); }

/* ---- album mosaic ---------------------------------------------------- */
.mosaic {
	list-style: none; margin: 0; padding: 0 var(--edge) var(--edge);
	display: grid; gap: var(--gap);
	grid-template-columns: repeat(12, 1fr);
	grid-auto-rows: clamp(170px, 19vw, 300px);
	grid-auto-flow: dense;
}
.mosaic > li { grid-column: span 4; }
.mosaic > li:nth-child(12n+1), .mosaic > li:nth-child(12n+8) { grid-column: span 8; grid-row: span 2; }
.mosaic.n-1 > li { grid-column: 1 / -1; grid-row: span 2; }
.mosaic.n-2 > li:nth-child(1) { grid-column: span 7; grid-row: span 2; }
.mosaic.n-2 > li:nth-child(2) { grid-column: span 5; grid-row: span 2; }

.tile { position: relative; overflow: hidden; background: var(--paper-2); }
.tile > a { position: absolute; inset: 0; display: block; text-decoration: none; color: var(--paper); outline-offset: -3px; }
.tile img {
	width: 100%; height: 100%; object-fit: cover;
	transform: scale(1.14); transition: transform 1.2s var(--ease), filter .6s var(--ease);
}
.tile .shade {
	position: absolute; inset: 0;
	background: linear-gradient(180deg, rgba(15, 15, 14, 0) 45%, rgba(15, 15, 14, .72) 100%);
	transition: opacity .6s var(--ease);
}
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: clamp(14px, 2vw, 28px); transform: translateY(10px); transition: transform .6s var(--ease); }
.tile .no { color: var(--blaze); display: block; margin-bottom: 6px; }
.tile h2 {
	margin: 0; font: 800 clamp(30px, 4.4vw, 72px)/.88 var(--display); text-transform: uppercase; letter-spacing: .005em;
	text-wrap: balance;
}
.mosaic.n-1 h2, .mosaic > li:nth-child(12n+1) h2 { font-size: clamp(44px, 8vw, 132px); }
.tile .meta { margin: 10px 0 0; color: rgba(239, 236, 229, .78); }
.tile .bar { display: block; width: 28px; height: 3px; margin-top: 14px; background: var(--blaze); transition: width .6s var(--ease); }

/* reveal: a wipe from below, the photo settling */
.tile { clip-path: inset(100% 0 0 0); }
.tile.in { clip-path: inset(0 0 0 0); transition: clip-path 1s var(--ease) calc(var(--i, 0) * 90ms); }
.tile.in img { transform: scale(1.02); transition-delay: calc(var(--i, 0) * 90ms), 0s; }
@media (hover: hover) {
	.tile.in:hover img { transform: scale(1.08); transition-delay: 0s; filter: saturate(1.08) contrast(1.04); }
	.tile:hover .cap { transform: translateY(0); }
	.tile:hover .bar { width: 72px; }
}

/* ---- album page ------------------------------------------------------ */
.album-head { padding: clamp(22px, 3vw, 40px) var(--edge) clamp(18px, 2.4vw, 28px); }
.back { text-decoration: none; color: var(--mute); display: inline-flex; gap: 10px; align-items: center; transition: color .3s; }
.back:hover { color: var(--blaze); }
.back span { display: inline-block; transition: transform .4s var(--ease); }
.back:hover span { transform: translateX(-5px); }
.album-head h1 {
	margin: 14px 0 0; font: 900 clamp(52px, 8.6vw, 150px)/.84 var(--display); text-transform: uppercase; letter-spacing: -.005em;
	text-wrap: balance;
}
.album-head h1 .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .04em; }
.album-head h1 .w > span { display: inline-block; transform: translateY(105%); animation: rise .9s var(--ease) forwards; animation-delay: calc(var(--w, 0) * 70ms + 80ms); }
.facts { display: flex; flex-wrap: wrap; gap: 10px 48px; margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--line); opacity: 0; animation: fade .8s var(--ease) .45s forwards; }
.facts div { min-width: 120px; }
.facts dt { color: var(--mute); margin-bottom: 4px; }
.facts dd { margin: 0; font: 500 13px/1.4 var(--mono); letter-spacing: .06em; }

/* justified photo rows: every photo whole, rows exactly filling the width */
.justified { padding: 0 var(--edge) var(--edge); }
.justified .row { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.justified .row.last { justify-content: center; }
.ph { position: relative; display: block; overflow: hidden; background: var(--paper-2); flex: none; cursor: zoom-in; outline-offset: -3px; }
.ph img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.12); transition: transform 1.1s var(--ease), opacity .3s; }
.ph::after {
	content: attr(data-label); position: absolute; left: 12px; bottom: 10px; color: var(--paper);
	font: 400 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
	opacity: 0; transform: translateY(6px); transition: .45s var(--ease); text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}
.ph { clip-path: inset(100% 0 0 0); }
.ph.in { clip-path: inset(0); transition: clip-path .9s var(--ease) calc(var(--i, 0) * 60ms); }
.ph.in img { transform: scale(1.01); transition-delay: calc(var(--i, 0) * 60ms), 0s; }
@media (hover: hover) {
	.ph.in:hover img { transform: scale(1.06); transition-delay: 0s; }
	.ph:hover::after { opacity: 1; transform: none; }
}
.ph.hidden-for-flight img { opacity: 0; }

.empty { padding: 18vh var(--edge); text-align: center; color: var(--mute); }
.empty h2 { font: 800 clamp(40px, 7vw, 96px)/.9 var(--display); text-transform: uppercase; color: var(--ink); margin: 0 0 14px; }

/* ---- footer ---------------------------------------------------------- */
.foot { padding: 22px var(--edge) 28px; border-top: 1px solid var(--line); color: var(--mute); }
.foot p { display: inline; margin: 0; }
.foot a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--blaze); }

/* ---- viewer ---------------------------------------------------------- */
.lb { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 400px); color: var(--paper); }
.lb[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: var(--night); opacity: 0; transition: opacity .45s var(--ease); }
.lb.open .lb-backdrop { opacity: 1; }
.lb-stage { position: relative; margin: 0; display: flex; align-items: center; justify-content: center; padding: 6vh max(4vw, 96px); min-height: 0; }
.lb-img { box-shadow: 0 40px 90px rgba(0, 0, 0, .55); opacity: 0; }
.lb.ready .lb-img { opacity: 1; }
.lb-img.swap { animation: swap .5s var(--ease); }
.lb-nav {
	position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
	width: 56px; height: 56px; border: 1px solid var(--night-line); border-radius: 50%;
	background: rgba(15, 15, 14, .35); color: var(--paper); font: 300 22px/1 var(--mono); cursor: pointer;
	opacity: 0; transition: opacity .4s var(--ease) .2s, background .3s, border-color .3s;
}
.lb.open .lb-nav { opacity: 1; }
.lb-nav:hover { background: var(--blaze); border-color: var(--blaze); }
.lb-nav[disabled] { visibility: hidden; }
.lb-prev { left: 1.6vw; }
.lb-next { right: 1.6vw; }
.lb-info {
	position: relative; overflow-y: auto; padding: 11vh 30px 30px; border-left: 1px solid var(--night-line);
	opacity: 0; transform: translateX(36px); transition: opacity .55s var(--ease) .1s, transform .7s var(--ease) .1s;
}
.lb.open .lb-info { opacity: 1; transform: none; }
.lb-count { color: var(--blaze); margin: 0 0 18px; }
.lb-title { margin: 0; font: 800 clamp(34px, 3.4vw, 54px)/.9 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.lb-title.untitled { color: rgba(239, 236, 229, .35); }
.lb-desc { margin: 14px 0 0; font: italic 300 19px/1.35 var(--serif); color: rgba(239, 236, 229, .82); }
.lb-desc:empty { display: none; }
.lb-facts { margin: 28px 0 0; }
.lb-facts > div { padding: 14px 0; border-top: 1px solid var(--night-line); }
.lb-facts dt { color: rgba(239, 236, 229, .45); margin-bottom: 6px; }
.lb-facts dd { margin: 0; }
.lb-day { font: italic 300 18px/1.3 var(--serif); }
.lb-clock { margin-top: 6px !important; color: rgba(239, 236, 229, .7); letter-spacing: .1em; }
.lb-coords { letter-spacing: .1em; color: rgba(239, 236, 229, .85); }
.lb-map { height: 210px; margin: 4px 0 0; border: 1px solid var(--night-line); background: #1c1c1a; }
.lb-map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.92) contrast(.92); }
.lb-map .leaflet-control-attribution { background: rgba(15, 15, 14, .7); color: rgba(239, 236, 229, .55); font: 9px/1.6 var(--mono); }
.lb-map .leaflet-control-attribution a { color: rgba(239, 236, 229, .8); }
.lb-map .leaflet-bar a { background: var(--night); color: var(--paper); border-color: var(--night-line); }
.lb-full {
	display: inline-flex; gap: 10px; margin-top: 26px; padding: 12px 18px; text-decoration: none;
	border: 1px solid rgba(239, 236, 229, .3); transition: background .3s, border-color .3s, color .3s;
}
.lb-full:hover { background: var(--blaze); border-color: var(--blaze); color: var(--night); }
.lb-close {
	position: absolute; top: 18px; right: 22px; z-index: 3; background: none; border: 0; color: var(--paper); cursor: pointer;
	display: flex; gap: 10px; align-items: center; opacity: 0; transition: opacity .4s .2s, color .3s;
}
.lb.open .lb-close { opacity: 1; }
.lb-close:hover { color: var(--blaze); }
.lb-close kbd { font: inherit; padding: 3px 6px; border: 1px solid var(--night-line); }
.fly { position: fixed; z-index: 60; margin: 0; object-fit: cover; transform-origin: 0 0; pointer-events: none; will-change: transform; }

/* ---- keyframes --------------------------------------------------------- */
@keyframes drop { to { opacity: 1; transform: none; } }
@keyframes fade { to { opacity: 1; } }
@keyframes rise { to { transform: none; } }
@keyframes swap { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

/* ---- small screens ----------------------------------------------------- */
@media (max-width: 760px) {
	:root { --gap: 5px; }
	.mosaic { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 46vw; }
	.mosaic > li { grid-column: span 1; grid-row: span 1; }
	.mosaic > li:nth-child(5n+1), .mosaic.n-1 > li, .mosaic.n-2 > li { grid-column: 1 / -1; grid-row: span 2; }
	.mosaic > li:nth-child(12n+8) { grid-column: span 1; grid-row: span 1; }
	.tile h2 { font-size: clamp(26px, 9vw, 44px); }
	.mosaic > li:nth-child(5n+1) h2, .mosaic.n-1 h2 { font-size: clamp(40px, 14vw, 72px); }
	.tile .cap { transform: none; }
	.stats { font-size: 10px; }
	.lb { grid-template-columns: 1fr; grid-template-rows: 58vh auto; overflow-y: auto; }
	.lb-stage { padding: 52px 10px 10px; }
	.lb-info { border-left: 0; border-top: 1px solid var(--night-line); padding: 22px 20px 40px; overflow: visible; transform: translateY(24px); }
	.lb-nav { width: 44px; height: 44px; top: auto; bottom: 14px; transform: none; }
	.lb-prev { left: 12px; }
	.lb-next { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; transition-delay: 0s !important; }
	.grain { animation: none; }
}

/* keyboard focus: the blaze, never the browser's blue */
a:focus-visible, button:focus-visible { outline: 2px solid var(--blaze); outline-offset: 3px; }
.tile > a:focus-visible, .ph:focus-visible { outline-offset: -4px; }
.lb :focus-visible { outline-color: var(--blaze); }
:focus:not(:focus-visible) { outline: none; }
