/* =================================================================
   BASE LAYOUT
   Recreates the page / window structure the site was designed in
   (Cargo), so the site's own stylesheet works unchanged.
   Root font size is set by app.js from the window size:
     desktop: 1.4316% of the window height
     mobile (portrait): about 2.2% of the screen width
   ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	min-height: var(--viewport-height, 100vh);
	overflow-anchor: none;
}

html {
	position: relative;
	touch-action: manipulation;
	/* no blue/grey box flashing over things when they're tapped on a phone */
	-webkit-tap-highlight-color: transparent;
	background-color: #050505;
}

body {
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: none;
	text-size-adjust: none;
	display: flex;
	flex-direction: column;
	width: 100%;
	position: relative;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14.5px;
	background-color: #050505;
}

html.mobile body { font-size: 16px; }

body.no-scroll { overflow: hidden; }

/* ---------- page structure ---------- */

.content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: flex-start;
	min-height: 100%;
	position: relative;
	flex-grow: 1;
}

.pages {
	width: 100%;
	flex: 1 0 auto;
}

.page {
	position: relative;
	isolation: isolate;
	display: flex;
	justify-content: center;
	flex-flow: row;
	max-width: 100%;
	width: 100%;
	flex: 0 1 0%;
}

.mobile .page { flex-wrap: wrap; }

.page.overlay { position: absolute; }

.page.pinned-bottom {
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
}

.page.overlay,
.page.overlay .page-layout { pointer-events: none; }

.page.overlay .page-content bodycopy a,
.page.overlay .page-content bodycopy media-item,
.page.overlay .page-content bodycopy video,
.page.overlay .page-content bodycopy iframe,
.page.overlay .page-content bodycopy button,
.page.overlay .page-content bodycopy summary { pointer-events: auto; }

.page-layout {
	flex-grow: 1;
	position: relative;
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	justify-content: flex-start;
	width: 0%;
	contain: layout;
}

.page-content {
	display: flex;
	flex-direction: row;
	height: 100%;
	align-items: flex-start;
	width: 100%;
	position: relative;
	isolation: isolate;
}

bodycopy {
	display: block;
	contain: layout;
	overflow-wrap: break-word;
	position: relative;
	max-width: 100%;
	width: 100%;
	--font-scale: 1;
}

bodycopy * { border-width: 0; }

a:active,
.linked:active { opacity: 0.7; }

/* Icons and clickable thumbnails behave like buttons: tapping or pressing on them
   never selects them (no blue selection highlight) or pops up the save-image menu. */
.mobile-icon-link,
.desktop-icons,
a.linked,
.linked {
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

/* no focus ring after a tap or click (keyboard users still get it) */
a:focus:not(:focus-visible),
.linked:focus:not(:focus-visible) { outline: none; }

/* ---------- windows (overlays) ---------- */

.overlay-content {
	position: fixed;
	inset: 0;
	max-height: 100dvh;
	--viewport-height: 100dvh;
	overflow: auto;
	overscroll-behavior: none;
	pointer-events: none;
	scrollbar-width: none;
}

.overlay-content::-webkit-scrollbar { display: none; }

.overlay-content .page-layout { min-height: fit-content; }

.overlay-content .page,
.overlay-content .page-layout,
.overlay-content .page-content { pointer-events: auto; }

.overlay-content.is-passthrough-overlay .page,
.overlay-content.is-passthrough-overlay .page-layout { pointer-events: none; }

.overlay-content.is-passthrough-overlay .page-content { pointer-events: auto; }

/* IMPORTANT: nothing around the frosted glass (.page, .page-layout, .overlay-content) may
   fade, or even be marked as about to fade (will-change: opacity). While a surrounding layer
   fades, browsers only blur what's inside that layer, so the desktop icons behind stayed
   sharp for the whole animation and then blurred all at once when it ended.
   All open/close animation therefore happens on the glass itself (.page-content). */
.overlay-content.overlay-open.overlay-animating .page-content {
	animation: overlayOpenContent var(--overlay-open-duration) var(--overlay-open-easing, ease-in-out);
}

/* Closing is instant: the window simply disappears (see closeOverlay in app.js). */

.overlay-content.overlay-animating .page-layout { contain: layout; }

/* Frosted glass opening: the blur builds from 0 to full and the dark tint deepens
   with it, then the window's contents fade up. The blur itself is animated, which
   the graphics chip handles directly, so it stays smooth.
   (Every window uses blur 2rem and rgba(30,30,30,0.69).) */
html body .overlay-content.lisa-entering .page .page-content {
	will-change: backdrop-filter;
	/* starts gently (even a little blur softens the icons a lot), so the blur is visibly gradual */
	animation: lisaGlassIn 0.6s cubic-bezier(0.5, 0, 0.5, 1) both !important;
}

html body .overlay-content.lisa-entering .page .page-content bodycopy {
	animation: lisaContentIn 0.35s 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both !important;
}

/* Phones: the same growing blur, quicker, starting a little sooner, with the contents arriving earlier. */
html.mobile body .overlay-content.lisa-entering .page .page-content {
	animation: lisaGlassIn 0.36s cubic-bezier(0.35, 0, 0.45, 1) both !important;
}

html.mobile body .overlay-content.lisa-entering .page .page-content bodycopy {
	animation-duration: 0.24s !important;
	animation-delay: 0.14s !important;
}

@keyframes lisaGlassIn {
	from {
		-webkit-backdrop-filter: blur(0px);
		backdrop-filter: blur(0px);
		background-color: rgba(30, 30, 30, 0);
	}
	to {
		-webkit-backdrop-filter: blur(2rem);
		backdrop-filter: blur(2rem);
		background-color: rgba(30, 30, 30, 0.69);
	}
}

/* While a window is open, the grain behind its frosted glass holds still
   (it's invisible through the blur, and moving it forces a re-blur 16 times a second).
   The faint grain on top of the windows keeps moving. */
html.window-open .vhs-grain { animation-play-state: paused !important; }


@keyframes overlayOpen {
	0% { opacity: var(--overlay-open-from-opacity, 1); }
}

@keyframes overlayOpenContent {
	0% { transform: var(--overlay-open-content-from-transform, translate3d(0, 0, 0)); }
	100% { transform: translate3d(0, 0, 0); }
}

@keyframes overlayClose {
	100% { opacity: var(--overlay-close-to-opacity, 1); }
}

@keyframes overlayCloseContent {
	0% { transform: translate3d(0, 0, 0); }
	100% { transform: var(--overlay-close-content-to-transform, translate3d(0, 0, 0)); }
}

/* ---------- galleries and columns ---------- */

gallery-grid {
	display: grid;
	grid-template-columns: repeat(var(--gg-cols, 1), minmax(0, 1fr));
	gap: var(--gg-gutter, 1rem);
	align-items: start;
	width: 100%;
}

/* on mobile, gutters scale with the site's mobile padding offset (1.83) */
.mobile gallery-grid {
	grid-template-columns: repeat(var(--gg-mobile-cols, 1), minmax(0, 1fr));
	gap: calc(var(--gg-mobile-gutter, var(--gg-gutter, 1rem)) * var(--mobile-padding-offset, 1));
}

gallery-grid > media-item { width: 100%; }

column-set {
	display: flex;
	align-items: flex-start;
	gap: calc(var(--cs-gutter, 1) * 1rem);
	width: 100%;
}

column-unit {
	display: block;
	flex: var(--cu-span, 1) 1 0;
	min-width: 0;
}

column-unit > media-item { width: 100%; }

/* a gallery or column row that follows another one gets a gutter above it */
gallery-grid + gallery-grid,
column-set + gallery-grid,
media-item + gallery-grid { margin-top: var(--gg-gutter, 1rem); }

column-set + column-set,
gallery-grid + column-set,
media-item + column-set { margin-top: calc(var(--cs-gutter, 1) * 1rem); }

.mobile gallery-grid + gallery-grid,
.mobile column-set + gallery-grid,
.mobile media-item + gallery-grid { margin-top: calc(var(--gg-mobile-gutter, var(--gg-gutter, 1rem)) * var(--mobile-padding-offset, 1)); }

.mobile column-set + column-set,
.mobile gallery-grid + column-set,
.mobile media-item + column-set { margin-top: calc(var(--cs-gutter, 1) * 1rem * var(--mobile-padding-offset, 1)); }

.mobile column-set {
	flex-direction: column;
	gap: calc(var(--cs-gutter, 1) * 1rem * var(--mobile-padding-offset, 1));
}
.mobile column-unit { width: 100%; flex: none; }

/* media-item renders its own inner structure (see app.js) */
media-item {
	display: inline-flex;
	vertical-align: bottom;
	flex-direction: column;
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
}

/* ---------- image zoom (lightbox) ---------- */

.lisa-zoom {
	position: fixed;
	inset: 0;
	z-index: 5000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10rem;
	background: rgba(0, 0, 0, 0.25);
	-webkit-backdrop-filter: blur(2rem);
	backdrop-filter: blur(2rem);
	cursor: zoom-out;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.mobile .lisa-zoom { padding: calc(1rem * var(--mobile-padding-offset, 1)); }

.lisa-zoom.is-visible { opacity: 1; }

.lisa-zoom img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
	transform: scale(0.97);
	transition: transform 0.25s ease;
}

.lisa-zoom.is-visible img { transform: none; }

/* My Work thumbnails: taps go straight to the card's link, never to the playing video
   (iPhone Safari can swallow taps that land on a video). */
a.work-card > media-item { pointer-events: none; }
