/*
 * Overlays: quick-add (603px modal on desktop / bottom sheet on mobile) and
 * the cart drawer (517px right panel beside the cart collage on desktop /
 * full screen on mobile). Square corners, no shadows.
 *
 * dialog.js toggles [hidden] and .is-open; transitions key off .is-open and
 * collapse to 0ms under prefers-reduced-motion via the motion tokens.
 */

.overlay {
	position: fixed;
	inset: 0;
	z-index: var(--z-overlay);
	display: flex;
}

.overlay__backdrop {
	position: absolute;
	inset: 0;
	background: var(--color-backdrop);
	opacity: 0;
	transition: opacity var(--duration-base) var(--ease-out);
}

.overlay.is-open .overlay__backdrop {
	opacity: 1;
}

.overlay [role="dialog"] {
	position: relative;
	background: var(--color-surface);
	outline: none;
	transition: transform var(--duration-base) var(--ease-out), opacity var(--duration-base) var(--ease-out);
}

/* ---- Quick-add: mobile bottom sheet (XD 375x460) ------------------------ */

.overlay--quick-add {
	align-items: flex-end;
}

.quick-add {
	display: grid;
	grid-template-columns: 94px minmax(0, 1fr);
	align-content: start;
	gap: 0 11px;
	width: 100%;
	max-height: 90vh;
	overflow: auto;
	padding: 31px var(--gutter) calc(40px + env(safe-area-inset-bottom));
	transform: translateY(100%);
}

.overlay.is-open .quick-add {
	transform: none;
}

/* 52x8 #CCCCCC grab handle, centered 12px from the top. */
.quick-add__handle {
	position: absolute;
	top: 12px;
	left: 50%;
	width: 52px;
	height: 8px;
	border-radius: 5px;
	background: var(--color-handle);
	transform: translateX(-50%);
}

.quick-add__close {
	position: absolute;
	top: 14px;
	right: 12px;
}

.quick-add__close .icon--close {
	width: 12px;
	height: 12px;
}

.quick-add__media {
	grid-column: 1;
	grid-row: 1;
	/* The row can grow taller than the thumbnail (a two-line variation note):
	   hug the image instead of stretching the grey placeholder box under it. */
	align-self: start;
	overflow: hidden;
	border-radius: var(--radius-thumb);
	background: var(--color-placeholder);
}

.quick-add__image,
.quick-add__placeholder {
	width: 100%;
	/* Every product photo is 1200x916 (OCEANSFIJ0-25): the frame takes that
	   aspect on both breakpoints so cover never crops (the patches lost their
	   top and bottom rows at 522/322 and their sides in the old square). */
	aspect-ratio: 1200 / 916;
	object-fit: cover;
	object-position: center;
}

/* Name and price sit beside the thumbnail; everything else spans. */
.quick-add__body {
	display: contents;
}

.quick-add__name,
.quick-add__price,
.quick-add__note {
	grid-column: 2;
	grid-row: 1;
	padding-right: var(--space-6);
}

.quick-add__name {
	align-self: start;
	margin-top: 15px;
	font-size: var(--text-13);
}

.quick-add__price {
	align-self: start;
	margin-top: 42px;
	font-size: var(--text-12);
}

.quick-add__note {
	align-self: start;
	margin-top: 62px;
	font-size: var(--text-12);
}

.quick-add__options,
.quick-add__qty,
.quick-add .notice-region,
.quick-add__submit {
	grid-column: 1 / -1;
}

.quick-add__options {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	margin-top: 17px;
}

.quick-add__qty {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px var(--space-3);
	margin-top: 26px;
}

.quick-add__label {
	width: 100%;
	font-size: var(--text-12);
	text-transform: uppercase;
}

.quick-add__hint {
	font-size: var(--text-12);
}

.quick-add__hint:empty {
	display: none;
}

.quick-add .notice-region {
	margin-top: var(--space-4);
}

.quick-add__submit {
	margin-top: 33px;
}

/* ---- Quick-add: desktop modal (XD 603x791, centered) ------------------- */

@media (min-width: 768px) {
	.overlay--quick-add {
		align-items: center;
		justify-content: center;
		padding: var(--space-4);
	}

	.quick-add {
		display: flex;
		flex-direction: column;
		width: min(100%, var(--modal-width));
		max-height: calc(100vh - 2 * var(--space-4));
		padding: var(--modal-pad-y) var(--modal-pad-x);
		opacity: 0;
		transform: translateY(var(--space-4));
	}

	.overlay.is-open .quick-add {
		opacity: 1;
	}

	.quick-add__close {
		top: 0;
		right: 0;
	}

	.quick-add__close .icon--close {
		width: 18px;
		height: 18px;
	}

	.quick-add__media {
		flex: none;
		align-self: stretch;
		border-radius: var(--radius-image);
	}

	.quick-add__name,
	.quick-add__price,
	.quick-add__note {
		padding-right: 0;
	}

	.quick-add__name {
		margin-top: 16px;
		font-size: var(--text-24);
	}

	.quick-add__price {
		margin-top: 6px;
		font-size: var(--text-20);
		font-weight: var(--weight-bold);
	}

	.quick-add__note {
		margin-top: 6px;
		font-size: var(--text-14);
	}

	.quick-add__options {
		margin-top: 36px;
	}

	.quick-add__qty {
		margin-top: 37px;
	}

	.quick-add__submit {
		margin-top: 14px;
	}
}

/* ---- Cart drawer -------------------------------------------------------- */

.overlay--drawer {
	justify-content: flex-end;
}

/* Desktop: the collage fills the left side instead of a scrim. */
.drawer__backdrop {
	background: var(--color-bg);
}

.drawer__collage {
	display: none;
}

@media (min-width: 768px) {
	.drawer__collage {
		display: block;
		width: calc(100% - var(--drawer-width));
		height: 100%;
		object-fit: cover;
		object-position: center;
	}
}

.drawer {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	transform: translateX(100%);
}

.overlay.is-open .drawer {
	transform: none;
}

.drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-4);
	padding: 24px 8px 0 var(--gutter);
}

.drawer__title {
	font-size: var(--text-20);
}

.drawer__close .icon--close {
	width: 12px;
	height: 12px;
}

.drawer__notice {
	padding: var(--space-3) var(--gutter) 0;
}

.drawer__body {
	flex: 1;
	overflow-y: auto;
	padding: 30px var(--gutter) var(--space-4);
}

.drawer__body[aria-busy="true"] {
	opacity: 0.6;
}

.drawer__lines {
	display: flex;
	flex-direction: column;
	gap: 38px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* thumbnail | name, value, stepper | price */
.line {
	--stepper-width: 95px;
	--stepper-height: 34px;

	display: grid;
	grid-template-columns: var(--thumb-size) minmax(0, 1fr) auto;
	grid-template-rows: auto auto 1fr;
	gap: 0 9px;
}

.line__media {
	grid-row: 1 / -1;
	align-self: start;
	overflow: hidden;
	border-radius: var(--radius-thumb);
	background: var(--color-placeholder);
}

.line__image {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
}

.line__name {
	grid-column: 2;
	margin-top: 16px;
	font-size: var(--text-14);
	font-weight: var(--weight-bold);
	line-height: var(--leading-snug);
	text-transform: uppercase;
}

.line__meta {
	grid-column: 2;
	margin-top: 4px;
	font-size: var(--text-12);
	text-transform: uppercase;
}

.line__total {
	grid-column: 3;
	grid-row: 1 / -1;
	align-self: center;
	font-size: var(--text-12);
	text-align: right;
}

.line__actions {
	grid-column: 2;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-4);
	margin-top: 14px;
	font-size: var(--text-12);
}

.line__remove {
	padding: var(--space-1) 0;
	border: 0;
	background: transparent;
	color: var(--color-text);
	font-size: var(--text-10);
	text-decoration: underline;
	text-transform: uppercase;
}

.line__remove[aria-disabled="true"] {
	color: var(--color-disabled-text);
	cursor: not-allowed;
}

.drawer__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-5);
	padding: var(--space-8) 0;
	text-align: center;
	font-size: var(--text-14);
	text-transform: uppercase;
}

.drawer__footer {
	display: flex;
	flex-direction: column;
	padding: var(--space-4) var(--gutter) calc(33px + env(safe-area-inset-bottom));
	background: var(--color-surface);
}

.drawer__subtotal {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-size: var(--text-12);
	text-transform: uppercase;
}

.drawer__note {
	margin-top: 6px;
	font-size: var(--text-12);
	text-transform: uppercase;
}

.drawer__checkout {
	margin-top: 24px;
}

.drawer__continue {
	align-self: center;
	margin-top: 16px;
	padding: var(--space-1) var(--space-2);
	border: 0;
	background: transparent;
	color: var(--color-text);
	font-size: var(--text-12);
	text-transform: uppercase;
}

.drawer__continue:hover {
	text-decoration: underline;
}

/* Desktop: 517px panel, 28px padding, the XD's larger type. */
@media (min-width: 768px) {
	.drawer {
		width: min(100%, var(--drawer-width));
	}

	.drawer__header {
		padding: 30px 14px 0 var(--drawer-pad);
	}

	.drawer__title {
		font-size: var(--text-24);
	}

	.drawer__close .icon--close {
		width: 18px;
		height: 18px;
	}

	.drawer__notice {
		padding-inline: var(--drawer-pad);
	}

	.drawer__body {
		padding: 30px var(--drawer-pad) var(--space-4);
	}

	.drawer__lines {
		gap: 40px;
	}

	.line {
		--stepper-width: 103px;
		--stepper-height: 36px;

		gap: 0 17px;
	}

	.line__name {
		font-size: var(--text-16);
	}

	.line__meta {
		font-size: var(--text-14);
	}

	.line__total {
		padding-right: 18px;
		font-size: var(--text-16);
	}

	.line__actions {
		font-size: var(--text-16);
	}

	.line .stepper {
		font-size: var(--text-16);
	}

	.drawer__footer {
		margin-inline: var(--drawer-pad);
		padding: 30px 0 33px;
		border-top: var(--border-width) solid var(--color-border);
	}

	.drawer__subtotal {
		font-size: var(--text-18);
	}

	.drawer__subtotal > :last-child {
		padding-right: 18px;
		font-size: var(--text-20);
	}

	.drawer__checkout {
		margin-top: 40px;
		font-size: var(--text-18);
	}
}
