/* Sheet (assets/js/sheet.js): the shell of the panels over the page. A bottom sheet, capped below the full height so a
   strip of the page stays visible; each client's CSS places it on computers. Header and foot stay put, the body
   between them scrolls. */
.sheet {
	position: fixed;
	inset: auto 0 0 0;
	display: none;
	flex-direction: column;
	inline-size: 100%;
	max-inline-size: none;
	block-size: calc(100vh - 3.5rem);
	block-size: calc(100dvh - 3.5rem);
	max-block-size: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 22px 22px 0 0;
	overflow: hidden;
	color: var(--color-ink);
	background: var(--color-bg);
	box-shadow: var(--shadow-soft);
	animation: sheet-rise var(--duration-panel) var(--ease-out);
}

.sheet[open] {
	display: flex;
}

.sheet:focus {
	outline: none;
}

/* Dimming alone leaves near-black buttons behind looking live; the blur pushes the whole page back. */
.sheet::backdrop {
	background: rgb(0 0 0 / 0.45);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
}

/* Following the finger on a swipe down; let go, it springs back or closes. */
.sheet:not([data-dragging]) {
	transition: transform var(--duration-base) var(--ease-out);
}

@keyframes sheet-rise {
	from {
		transform: translateY(100%);
	}
}

/* Header: the client's heading, the round ×, and the handle a finger pulls down. */
.sheet__head {
	position: relative;
	flex: none;
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: var(--space-4) var(--space-4) var(--space-3);
	background: var(--color-surface);
	border-block-end: var(--border);
	touch-action: none;
}

.sheet__handle {
	position: absolute;
	inset-block-start: var(--space-2);
	inset-inline: 0;
	inline-size: 2.5rem;
	block-size: 4px;
	margin-inline: auto;
	border-radius: var(--radius-pill);
	background: var(--color-sand);
}

.sheet__close {
	flex: none;
	display: grid;
	place-items: center;
	inline-size: var(--tap);
	block-size: var(--tap);
	padding: 0;
	border: var(--border);
	border-radius: 50%;
	background: var(--color-surface);
	color: var(--color-ink);
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
}

.sheet__close:hover {
	background: var(--color-accent-tint);
}

.sheet__close:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.sheet__body {
	flex: 1;
	min-block-size: 0;
	padding: var(--space-4);
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Buttons and their messages, pinned under the body. */
.sheet__foot {
	flex: none;
	display: grid;
	gap: var(--space-2);
	padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
	background: var(--color-surface);
	border-block-start: var(--border);
}

.sheet__foot[hidden] {
	display: none;
}

/* Open: the page behind holds still. */
html[data-sheet-open] {
	overflow: hidden;
}

/* Open: the corner (social links, the phone's cart button) steps aside. */
html[data-sheet-open] .corner-dock {
	display: none;
}

/* Phones (mobile UI D, owner's brief points 2 and 5): a thin head, a 36px × whose tap area still reaches 44px, and
   one fluid set of type sizes the sheets' clients share, so 360px and 412px screens get proportionate text. */
@media (max-width: 47.99rem) {
	.sheet {
		--sheet-fs-title: clamp(1rem, 0.9rem + 0.6vw, 1.1875rem);
		--sheet-fs-body: clamp(0.875rem, 0.8rem + 0.35vw, 0.9375rem);
		--sheet-fs-small: clamp(0.75rem, 0.71rem + 0.2vw, 0.8125rem);
	}

	/* One surface from head to foot, as in D: the page colour inside the sheet read as a second, grey panel. */
	.sheet {
		border-radius: 20px 20px 0 0;
		background: var(--color-surface);
	}

	/* The handle sits in the top 10px, so the head's own padding starts under it. */
	.sheet__head {
		padding-block: 0.625rem var(--space-1);
		padding-inline-end: var(--space-3);
	}

	.sheet__handle {
		inset-block-start: 0.3125rem;
	}

	.sheet__close {
		position: relative;
		inline-size: 2.25rem;
		block-size: 2.25rem;
		border: 0;
		background: var(--color-bg);
		font-size: 1.375rem;
	}

	.sheet__close::before {
		content: "";
		position: absolute;
		inset: calc((var(--tap) - 2.25rem) / -2);
	}
}

@media (min-width: 56rem) {
	.sheet__handle {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sheet,
	.sheet:not([data-dragging]) {
		animation: none;
		transition: none;
	}
}

