/**
 * Peak Arrangements — what the runtime switches on.
 *
 * `.peak-arrange-on` is stamped by peak-arrange.js only while an arrangement
 * is actually running (the right breakpoint, scripts, no reduced motion), so
 * everything here is scoped to it and the box is its designed flow otherwise.
 * The first paint before the runtime is Peak_Arrange::first_paint_css().
 */

/* ---- Layered: every layer in the same grid cell ---- */
.peak-arrange--layered.peak-arrange-on > .pka-host,
.peak-arrange--layered.peak-arrange-on.pka-host {
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) !important;
	grid-template-rows: auto !important;
	grid-template-areas: none !important;
}

.pka-host > .pka-item,
.pka-host > .pkb-rep > .pka-item {
	grid-area: 1 / 1 / 2 / 2 !important;
	z-index: calc(var(--pka-i, 0) + 1);
	will-change: transform;
}
/* The box's flex alignment, read along its direction (peak-arrange.js
   alignStack): a grid centres a layer with justify-items, not justify-content. */
.pka-host.pka-aligned {
	justify-items: var(--pka-ji, normal) !important;
	align-items: var(--pka-ai, normal) !important;
}

/* What is not a layer keeps its place: a Collection's filter bar above the
   stack (its pager falls in after it on its own). */
.pka-host > [data-peak-arrange-skip="before"] {
	grid-area: 1 / 1 / 2 / 2 !important;
}
.pka-host:has(> [data-peak-arrange-skip="before"]) > .pka-item,
.pka-host:has(> [data-peak-arrange-skip="before"]) > .pkb-rep > .pka-item {
	grid-row: 2 / 3 !important;
}

/* A peek: each layer stops a little below the one before, and the stack is
   as tall as the deepest one needs. Top AND bottom margins, so that a
   stretched layer keeps the height of every other one. */
.pka-host.pka-peek > .pka-item,
.pka-host.pka-peek > .pkb-rep > .pka-item {
	margin-top: calc(var(--pka-i, 0) * var(--pka-peek, 0px)) !important;
	margin-bottom: calc((var(--pka-n, 1) - 1 - var(--pka-i, 0)) * var(--pka-peek, 0px)) !important;
}

/* Layers that arrive from the side must not widen the page on the way in. */
.peak-arrange-on.pka-clip-x {
	overflow-x: clip;
}

/* An editor preview plays inside the box itself. */
.peak-arrange-on.pka-preview {
	overflow: clip;
}
