/* Barbarian Folio: front end. One carousel of photographs, and optionally one line of type. */

@font-face {
	font-family: "Big Shoulders Display";
	font-weight: 700;
	font-style: normal;
	font-display: swap;
	src: url("fonts/big-shoulders-display-latin-700-normal.woff2") format("woff2");
}

@font-face {
	font-family: "Big Shoulders Display";
	font-weight: 800;
	font-style: normal;
	font-display: swap;
	src: url("fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2");
}

:root {
	--wall: #000;
	--ink: #fff;
	--bar: 0px;                              /* WordPress toolbar, when signed in */
	--plate: clamp(52px, 8vh, 72px);         /* the line of type under the photographs */
	--edge: clamp(16px, 3vw, 44px);
	--gap: clamp(3px, 0.5vw, 10px);          /* gutter between photographs */
}

.wall-grey  { --wall: #767676; --ink: #000; }
.wall-white { --wall: #fff;    --ink: #000; }

/* Nothing under the photographs: they take the whole window. */
.no-plate { --plate: 0px; }

.admin-bar { --bar: 32px; }
@media (max-width: 782px) { .admin-bar { --bar: 46px; } }

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

html, body {
	height: 100%;
	margin: 0;
	background: var(--wall);
	color: var(--ink);
	overflow: hidden;
	overscroll-behavior: none;
	-webkit-text-size-adjust: 100%;
}

.folio {
	position: relative;
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
	height: calc(100vh - var(--bar));
	font-family: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}

@supports (height: 100svh) {
	.folio { height: calc(100svh - var(--bar)); }
}

/* ---- The carousel --------------------------------------------------
 * The script groups the photographs into sets, one set per screen:
 * one photograph on a phone, two on a tablet, three or four on a desktop.
 * The carousel moves a whole set at a time, sideways or up and down.
 * ------------------------------------------------------------------ */

.strip {
	position: relative;
	display: flex;
	gap: var(--gap);
	min-height: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	outline: none;
}

.strip::-webkit-scrollbar { display: none; }

.dir-vertical .strip {
	flex-direction: column;
	overflow-x: hidden;
	overflow-y: auto;
	scroll-snap-type: y mandatory;
}

.set {
	flex: none;
	display: flex;
	gap: var(--gap);
	width: 100%;
	height: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.slide {
	flex: 1 1 0;
	min-width: 0;
	height: 100%;
	overflow: hidden;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.slide img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

/* Whole photographs, uncropped, with the background showing around them. */
.fit-contain .slide img { object-fit: contain; }

/* Before the script has grouped them, or without scripting: the same frame sizes, simply scrolled. */
.strip > .slide {
	flex: none;
	width: 100%;
	scroll-snap-align: start;
}

@media (min-width: 700px) and (orientation: landscape) {
	.dir-horizontal .strip > .slide { width: calc((100% - var(--gap)) / 2); }
}

@media (min-width: 1100px) and (orientation: landscape) {
	.dir-horizontal .strip > .slide { width: calc((100% - 2 * var(--gap)) / 3); }
}

/* No space between photographs: edge to edge. */
.no-gap { --gap: 0px; }

/*
 * Vertical slider: the photographs sit in columns and change in place.
 * The script slides each new photograph in over the old one, alternately from the top and from the bottom.
 */
.dir-vertical .strip.is-columns {
	flex-direction: row;
	overflow: hidden;
	scroll-snap-type: none;
	touch-action: none;
}

.vcol {
	position: relative;
	flex: 1 1 0;
	min-width: 0;
	height: 100%;
	overflow: hidden;
}

.vcol > .slide,
.preload > .slide {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.vcol > .slide { will-change: transform; }

/* Photographs fetched ahead of time, at the size a column needs, out of sight. */
.preload {
	position: absolute;
	top: 0;
	left: 0;
	width: calc(100% / var(--per, 3));
	height: 100%;
	overflow: hidden;
	visibility: hidden;
	pointer-events: none;
}

/* One photograph at a time: one row, a fixed number of frames per screen, a stop at every frame. */
.strip.is-single > .slide {
	width: calc((100% - (var(--per, 3) - 1) * var(--gap)) / var(--per, 3));
}

/* The carousel can be dragged with a mouse. While it is, it follows the pointer and ignores its stops. */
.js .strip { cursor: grab; }
.js .strip .slide { cursor: inherit; }
.js .click-lightbox .strip .slide { cursor: zoom-in; }
.strip.is-dragging { scroll-snap-type: none; cursor: grabbing; }
.strip.is-dragging .slide { cursor: grabbing; }

/* ---- The lightbox: one photograph, whole, filling the window -------- */

.lightbox {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--wall);
	color: var(--ink);
	overflow: hidden;
}

@supports (height: 100dvh) {
	.lightbox { height: 100dvh; }
}

.lightbox::backdrop { background: var(--wall); }

.lightbox img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	cursor: zoom-out;
	-webkit-user-select: none;
	user-select: none;
}

.lightbox-btn {
	position: absolute;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0 0 4px;
	border: 0;
	border-radius: 50%;
	background: var(--wall);
	color: var(--ink);
	font: 400 2rem/1 Arial, Helvetica, sans-serif;
	cursor: pointer;
	opacity: 0.72;
}

.lightbox-btn:hover,
.lightbox-btn:focus-visible { opacity: 1; }
.lightbox-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.lightbox-close { top: max(12px, env(safe-area-inset-top, 0px)); right: 12px; }
.lightbox-prev  { top: calc(50% - 24px); left: 12px; }
.lightbox-next  { top: calc(50% - 24px); right: 12px; }

/* Hidden until the first photograph has arrived, then one fade. */
.js .strip { opacity: 0; }
.js .is-ready .strip { opacity: 1; transition: opacity 0.7s ease; }

.strip:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---- The line of type --------------------------------------------- */

.plate {
	height: var(--plate);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0 var(--edge);
	padding-bottom: env(safe-area-inset-bottom, 0);
	line-height: 1;
}

.wordmark {
	margin: 0;
	font-size: clamp(1.375rem, 1.1rem + 0.9vw, 1.875rem);
	font-weight: 800;
	letter-spacing: 0.015em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.count {
	margin: 0 0 0 auto;
	font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.count-of { opacity: 0.5; }

/* ---- Chevron arrows: left and right, or up and down ---------------- */

.arrow {
	position: absolute;
	z-index: 5;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.2s ease, opacity 0.7s ease;
}

.arrow svg { width: 26px; height: 26px; }
.arrow:hover { background: rgba(0, 0, 0, 0.72); }
.arrow:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.dir-horizontal .arrow { top: calc((100% - var(--plate)) / 2 - 24px); }
.dir-horizontal .arrow-prev { left: clamp(10px, 1.6vw, 24px); }
.dir-horizontal .arrow-next { right: clamp(10px, 1.6vw, 24px); }

.dir-vertical .arrow { left: calc(50% - 24px); }
.dir-vertical .arrow-prev { top: clamp(10px, 1.6vh, 24px); }
.dir-vertical .arrow-next { bottom: calc(var(--plate) + clamp(10px, 1.6vh, 24px)); }

@media (max-width: 699px) {
	.arrow { width: 40px; height: 40px; }
	.arrow svg { width: 22px; height: 22px; }
	.dir-horizontal .arrow { top: calc((100% - var(--plate)) / 2 - 20px); }
	.dir-vertical .arrow { left: calc(50% - 20px); }
}

/* Arrows turned off: kept for keyboards, shown only when focused. */
.arrow.is-quiet,
.js .is-ready .arrow.is-quiet { opacity: 0; pointer-events: none; }
.arrow.is-quiet:focus-visible,
.js .is-ready .arrow.is-quiet:focus-visible { opacity: 1; pointer-events: auto; }

.js .arrow { opacity: 0; }
.js .is-ready .arrow { opacity: 1; }

/* ---- Empty portfolio, shown only to someone who can fix it --------- */

.empty {
	align-self: center;
	margin: 0;
	padding: 0 var(--edge);
	font-size: 1.5rem;
	font-weight: 700;
	text-align: center;
}

.empty a { color: inherit; text-underline-offset: 0.2em; }

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.js .is-ready .strip,
	.arrow { transition: none; }
}
