/**
 * Portfolio Displays — The Rack.
 *
 * A wire rack drawn in CSS, not a photograph: it recolours instantly from one
 * custom property and stays sharp at any size. Depends on pages.css.
 */

.pfd-rack {
	--pfd-rack: #afcbff;
	--pfd-navy: #0e1c36;
	--pfd-cream: #ffede1;
	--pfd-cyan: #d7f9ff;
	--pfd-cols: 3;
	position: relative;
	isolation: isolate;
	padding: clamp(18px, 3vw, 44px) 0;
	background: var(--pfd-navy);
	overflow: hidden;
	font-family: inherit;
}

.pfd-rack-bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	background-size: cover;
	background-position: center;
	opacity: 0.4;
	pointer-events: none;
}

.pfd-rack-stage {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 22px clamp(14px, 2vw, 26px) 18px;
}

.pfd-rack--full .pfd-rack-stage { max-width: none; }

.pfd-rack-stage--intro {
	animation: pfd-cam 2.1s cubic-bezier(0.19, 1, 0.22, 1) both;
}

@keyframes pfd-cam {
	from {
		transform: perspective(1500px) rotateY(-22deg) scale(1.34) translate3d(7%, 6%, 0);
		filter: blur(4px);
		opacity: 0;
	}
	to {
		transform: perspective(1500px) rotateY(0) scale(1) translate3d(0, 0, 0);
		filter: blur(0);
		opacity: 1;
	}
}

/* --- The frame ----------------------------------------------------- */

.pfd-rack-frame {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.pfd-post {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 7px;
	background: linear-gradient(90deg,
		color-mix(in srgb, var(--pfd-rack) 55%, #000) 0%,
		var(--pfd-rack) 38%,
		color-mix(in srgb, var(--pfd-rack) 70%, #fff) 52%,
		color-mix(in srgb, var(--pfd-rack) 50%, #000) 100%);
	box-shadow: 0 0 12px rgba(0, 0, 0, 0.45);
}
.pfd-post--l { left: 0; }
.pfd-post--r { right: 0; }

/* --- Shelves ------------------------------------------------------- */

.pfd-shelf-list.is-sortable .pfd-slot[data-post] { cursor: grab; }
.pfd-shelf-list .pfd-slot.is-dragging { opacity: 0.4; }
.pfd-shelf-list.is-saving { opacity: 0.85; }

.pfd-shelf-list {
	display: grid;
	grid-template-columns: repeat(var(--pfd-cols), 1fr);
	gap: clamp(12px, 1.6vw, 22px);
	margin: 0;
	padding: 0;
	list-style: none;
}

.pfd-slot {
	position: relative;
	padding-bottom: 26px;
}

/* The wire rail each row of covers stands on */
.pfd-slot::after {
	content: "";
	position: absolute;
	left: -6px;
	right: -6px;
	bottom: 12px;
	height: 5px;
	border-radius: 3px;
	background: linear-gradient(180deg,
		color-mix(in srgb, var(--pfd-rack) 78%, #fff),
		var(--pfd-rack) 40%,
		color-mix(in srgb, var(--pfd-rack) 45%, #000));
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
	z-index: 3;
}

/* The retainer wire that crosses the lower part of each cover */
.pfd-retainer {
	position: absolute;
	left: -4px;
	right: -4px;
	bottom: 26%;
	height: 3px;
	border-radius: 2px;
	background: linear-gradient(180deg,
		color-mix(in srgb, var(--pfd-rack) 82%, #fff),
		var(--pfd-rack));
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
	z-index: 4;
	pointer-events: none;
}

.pfd-shelf-rail {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 18%;
	background: linear-gradient(180deg, rgba(22, 41, 75, 0.9), rgba(10, 20, 37, 0.95));
	z-index: 0;
	pointer-events: none;
}

/* --- Covers -------------------------------------------------------- */

.pfd-cover {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	padding: 0;
	border: 0;
	background: var(--pfd-paper, #f9fbf2);
	color: var(--pfd-ink, #0e1c36);
	cursor: pointer;
	overflow: hidden;
	transform: rotate(var(--pfd-tilt, 0deg));
	transform-origin: bottom center;
	transition: transform 0.42s cubic-bezier(0.22, 0.86, 0.24, 1), box-shadow 0.42s ease;
	box-shadow:
		0 14px 26px rgba(0, 0, 0, 0.5),
		inset 0 0 0 1px rgba(14, 28, 54, 0.08);
	z-index: 2;
}

.pfd-cover:hover,
.pfd-cover:focus-visible {
	transform: rotate(var(--pfd-tilt, 0deg)) translateY(-14px);
	box-shadow: 0 26px 44px rgba(0, 0, 0, 0.6);
	z-index: 5;
}

.pfd-cover:focus-visible {
	outline: 2px solid var(--pfd-cyan);
	outline-offset: 2px;
}

.pfd-cover-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pfd-cover > .pfd-texture {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: var(--pfd-paper-op, 0.42);
	background-image: repeating-linear-gradient(41deg, rgba(14, 28, 54, 0.05) 0 1px, transparent 1px 3px);
}

.pfd-cover > .pfd-glare {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: var(--pfd-glare-op, 0.16);
	background: linear-gradient(114deg, transparent 30%, rgba(255, 255, 255, 0.66) 46%, rgba(255, 255, 255, 0.1) 56%, transparent 70%);
}

/* Spine shading down the bound edge */
.pfd-cover-spine {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 11%;
	background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1) 30%, transparent);
	pointer-events: none;
}
.pfd-cover-spine::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 4px;
	background: rgba(0, 0, 0, 0.32);
}

.pfd-cover-copy {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: clamp(8px, 1vw, 15px) clamp(8px, 1vw, 15px) 30%;
	text-align: left;
}

.pfd-cover-copy .pfd-cover-top {
	display: flex;
	justify-content: space-between;
	font-size: 8.5px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	opacity: 0.8;
}

.pfd-cover-copy .pfd-cover-rule {
	display: block;
	height: 3px;
	width: 46%;
	margin-bottom: 6px;
}

.pfd-cover-copy .pfd-cover-title {
	display: block;
	font-size: clamp(15px, 2.1vw, 30px);
	font-weight: 900;
	line-height: 0.9;
	letter-spacing: -0.042em;
	text-transform: uppercase;
}

.pfd-cover-copy .pfd-cover-disc {
	display: block;
	margin-top: 6px;
	font-size: 8px;
	font-weight: 600;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	opacity: 0.72;
}

/* --- Reader -------------------------------------------------------- */

.pfd-reader {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(8, 16, 32, 0);
	perspective: 2800px;
	transition: background 0.7s ease;
}

.pfd-reader[hidden] { display: none; }
.pfd-reader.is-up { background: rgba(8, 16, 32, 0.72); }

.pfd-reader-bar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 8;
	display: flex;
	align-items: baseline;
	gap: 11px;
	padding: 13px 16px;
	pointer-events: none;
}

.pfd-reader-title {
	font-size: 15px;
	font-weight: 900;
	letter-spacing: -0.03em;
	text-transform: uppercase;
	color: var(--pfd-cream);
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.pfd-reader-meta {
	font-size: 9.5px;
	font-weight: 600;
	letter-spacing: 0.17em;
	text-transform: uppercase;
	color: rgba(255, 237, 225, 0.62);
	text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.pfd-close {
	margin-left: auto;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: var(--pfd-cream);
	color: var(--pfd-navy);
	font-size: 20px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
	transition: background 0.18s ease;
}
.pfd-close:hover { background: #fff; }
.pfd-close:focus-visible { outline: 2px solid var(--pfd-cyan); outline-offset: 2px; }

/* The book itself. Sized in px by the script — a spread must halve exactly
   or the flip library can't resolve a landscape rect. */
.pfd-book {
	position: relative;
	opacity: 0;
	transform: translate3d(0, 0, 0) rotateY(-16deg) scale(0.2);
	transition:
		transform 1.05s cubic-bezier(0.22, 0.86, 0.24, 1),
		opacity 0.5s ease;
	touch-action: pan-y;
	cursor: pointer;
}
.pfd-reader.is-up .pfd-book {
	opacity: 1;
	transform: translate3d(0, 0, 0) rotateY(0) scale(1);
}

/* Flip library internals */
.pfd-book .stf__parent { margin: 0 auto; position: relative; }
.pfd-book .stf__block { overflow: visible; }
.pfd-book .stf__item {
	overflow: hidden;
	box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
	transition: none;
}

.pfd-reader-foot {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 8;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 13px 16px;
}

.pfd-folio {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 9.5px;
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: rgba(255, 237, 225, 0.78);
	text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.pfd-folio b { font-size: 13px; font-weight: 900; color: var(--pfd-cream); }
.pfd-folio i { font-style: normal; opacity: 0.45; }
.pfd-folio i::before { content: "/ "; }
.pfd-folio em { font-style: normal; color: var(--pfd-cyan); }
.pfd-folio em::before { content: "\2014\00a0"; opacity: 0.5; }

.pfd-thumbs {
	display: flex;
	gap: 5px;
	overflow-x: auto;
	max-width: 46%;
	padding: 2px;
	scrollbar-width: thin;
}

.pfd-thumb {
	flex: 0 0 auto;
	width: 26px;
	height: 34px;
	padding: 0;
	border: 0;
	cursor: pointer;
	background: rgba(255, 237, 225, 0.28);
	box-shadow: inset 0 0 0 1px rgba(255, 237, 225, 0.4);
	transition: background 0.18s ease, transform 0.18s ease;
}
.pfd-thumb:hover { background: rgba(255, 237, 225, 0.55); transform: translateY(-2px); }
.pfd-thumb.is-current { background: var(--pfd-cream); }
.pfd-thumb:focus-visible { outline: 2px solid var(--pfd-cyan); outline-offset: 2px; }

.pfd-arrows { display: flex; gap: 7px; }

.pfd-arrow {
	width: 52px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: var(--pfd-cream);
	color: var(--pfd-navy);
	font-size: 17px;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	transition: transform 0.18s ease, opacity 0.18s ease;
}
.pfd-arrow:hover { transform: translateY(-2px); }
.pfd-arrow:focus-visible { outline: 2px solid var(--pfd-cyan); outline-offset: 2px; }
.pfd-arrow[disabled] { opacity: 0.34; cursor: default; transform: none; }

body.pfd-reader-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.pfd-rack-stage--intro { animation: none; }
	.pfd-book { transition: opacity 0.2s ease; transform: none; }
	.pfd-reader.is-up .pfd-book { transform: none; }
	.pfd-cover { transition: none; }
}

@media (max-width: 860px) {
	.pfd-shelf-list { grid-template-columns: repeat(2, 1fr); }
	.pfd-thumbs { display: none; }
}

@media (max-width: 560px) {
	.pfd-shelf-list { grid-template-columns: 1fr; }
	.pfd-reader-title { font-size: 13px; }
	.pfd-arrow { width: 46px; height: 40px; }
}
