/*
 * A shop's cart (assets/js/shop-cart.js): Add to cart on the cards and an
 * item's page, the button that opens the bag, and the bag from the side.
 * The site's own colours throughout -- a shop recoloured in its Design
 * recolours its cart.
 */

/* Add to cart ------------------------------------------------------------- */

/* Above the card's stretched link, which makes the rest of the card its page. */
.aws-shop__buy { margin: 0; position: relative; z-index: 1; }

.aws-cart__add {
	align-items: center;
	background: var(--wp--preset--color--accent);
	border: 1px solid transparent;
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--background);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	gap: 0.4em;
	min-height: 2.5rem;
	padding: 0.4rem 1.1rem;
	text-decoration: none;
}

.aws-cart__add:hover { background: var(--wp--preset--color--accent-600); color: var(--wp--preset--color--background); }

/* In the cart already: Update cart, in the ink rather than the accent. */
.aws-cart__add.is-in,
.aws-cart__add-big.is-in { background: var(--wp--preset--color--ink); color: var(--wp--preset--color--background); }
.aws-cart__add.is-in:hover,
.aws-cart__add-big.is-in:hover { background: color-mix(in srgb, var(--wp--preset--color--ink) 82%, var(--wp--preset--color--background)); color: var(--wp--preset--color--background); }

a.aws-cart__add {
	background: transparent;
	border-color: var(--wp--preset--color--divider);
	color: inherit;
}

a.aws-cart__add:hover { background: var(--wp--preset--color--neutral-200); color: inherit; }

.aws-cart__buy {
	align-items: end;
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--3);
	margin: var(--wp--preset--spacing--4) 0;
}

.aws-cart__field {
	display: grid;
	font-size: var(--wp--preset--font-size--small);
	gap: 0.3rem;
}

.aws-cart__field > span { color: var(--wp--preset--color--neutral-600); font-weight: 600; }
.aws-cart__field em { font-style: normal; font-weight: 400; }

.aws-cart__field input,
.aws-cart__field select,
.aws-cart__field textarea {
	background: var(--wp--preset--color--background);
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--md);
	color: var(--wp--preset--color--ink);
	font: inherit;
	min-height: var(--wp--custom--tap-target);
	padding: 0.55rem 0.8rem;
	width: 100%;
}

.aws-cart__field textarea { min-height: 0; resize: vertical; }
.aws-cart__field--qty input { width: 5.5rem; }
.aws-cart__buy select { min-width: 10rem; }

.aws-cart__field input:focus,
.aws-cart__field select:focus,
.aws-cart__field textarea:focus { border-color: var(--wp--preset--color--accent); outline: 2px solid color-mix(in srgb, var(--wp--preset--color--accent) 25%, transparent); outline-offset: 0; }

/* The button that opens it ------------------------------------------------ */

.aws-cart__fab {
	align-items: center;
	background: var(--wp--preset--color--ink);
	border: 0;
	border-radius: var(--wp--custom--radius--circle);
	box-shadow: 0 0.5rem 1.5rem color-mix(in srgb, var(--wp--preset--color--ink) 30%, transparent);
	color: var(--wp--preset--color--background);
	cursor: pointer;
	display: inline-flex;
	height: 3.25rem;
	justify-content: center;
	position: fixed;
	right: 1.25rem;
	top: 1.25rem;
	width: 3.25rem;
	z-index: 90;
}

.aws-cart__fab[hidden] { display: none; }

/* In the header: the last thing in its row, in the header's own colours. */
.aws-cart__fab.is-head {
	background: transparent;
	border: 1px solid var(--wp--preset--color--divider);
	box-shadow: none;
	color: inherit;
	flex: none;
	height: var(--wp--custom--tap-target);
	order: 99;
	position: relative;
	right: auto;
	top: auto;
	width: var(--wp--custom--tap-target);
	z-index: auto;
}

/* Beside the menu's button on a phone: it takes the space that pushed the button right. */
.aws-cart__fab.is-by-menu { margin-inline-start: auto; order: 0; }
.aws-cart__fab.is-by-menu + .aws-head__toggle { margin-inline-start: -0.75rem; }
/* The shop's name, the cart and the menu's button one row; the header's own buttons the row under it, as they are on a phone without a cart. */
.aws-head__inner:has(.aws-cart__fab.is-by-menu) .aws-head__brand { flex: 1 1 0; min-width: 0; }
.aws-head__inner:has(.aws-cart__fab.is-by-menu) .aws-head__ways { flex-basis: 100%; }

.aws-cart__fab.is-head:hover { background: color-mix(in srgb, currentColor 8%, transparent); }

.aws-cart__count {
	background: var(--wp--preset--color--accent);
	border: 2px solid var(--wp--preset--color--background);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--background);
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1;
	min-width: 1.4rem;
	padding: 0.2rem 0.35rem;
	position: absolute;
	right: -0.2rem;
	top: -0.2rem;
}

.aws-cart__count:empty { display: none; }

/* The bag ----------------------------------------------------------------- */

.aws-cart {
	background: transparent;
	border: 0;
	color: var(--wp--preset--color--ink);
	height: 100%;
	inset: 0 0 0 auto;
	margin: 0 0 0 auto;
	max-height: none;
	max-width: 100%;
	padding: 0;
	width: 26rem;
}

.aws-cart::backdrop { background: color-mix(in srgb, var(--wp--preset--color--ink) 40%, transparent); }

.aws-cart[open] { animation: aws-cart-in 0.2s ease-out; }

@keyframes aws-cart-in { from { transform: translateX(2rem); opacity: 0; } }

@media (prefers-reduced-motion: reduce) { .aws-cart[open] { animation: none; } }

.aws-cart__panel {
	background: var(--wp--preset--color--background);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--3);
	height: 100%;
	overflow-y: auto;
	padding: var(--wp--preset--spacing--4);
}

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

.aws-cart__head { align-items: center; display: flex; justify-content: space-between; }
.aws-cart__title { font-size: var(--wp--preset--font-size--large); margin: 0; }

.aws-cart__x {
	background: transparent;
	border: 0;
	border-radius: var(--wp--custom--radius--circle);
	color: inherit;
	cursor: pointer;
	font-size: 1.6rem;
	height: 2.5rem;
	line-height: 1;
	width: 2.5rem;
}

.aws-cart__x:hover { background: var(--wp--preset--color--neutral-200); }

.aws-cart__said {
	background: var(--wp--preset--color--surface);
	border-radius: var(--wp--custom--radius--md);
	font-size: var(--wp--preset--font-size--small);
	margin: 0;
	padding: 0.65rem 0.85rem;
}

.aws-cart__said[hidden], .aws-cart__view[hidden], .aws-cart__foot[hidden], .aws-cart__empty[hidden], .aws-cart__field[hidden], .aws-cart__fine[hidden] { display: none; }

.aws-cart__view { display: flex; flex: 1; flex-direction: column; gap: var(--wp--preset--spacing--3); }

.aws-cart__lines { display: grid; gap: var(--wp--preset--spacing--3); list-style: none; margin: 0; padding: 0; }

.aws-cart__line {
	align-items: start;
	border-bottom: 1px solid var(--wp--preset--color--divider);
	display: grid;
	gap: var(--wp--preset--spacing--3);
	grid-template-columns: 4rem minmax(0, 1fr) auto;
	padding-bottom: var(--wp--preset--spacing--3);
}

.aws-cart__pic {
	aspect-ratio: 1;
	background: var(--wp--preset--color--surface);
	border-radius: var(--wp--custom--radius--md);
	display: block;
	object-fit: cover;
	width: 4rem;
}

.aws-cart__what { display: grid; gap: 0.2rem; min-width: 0; }
.aws-cart__what a { color: inherit; font-weight: 600; text-decoration: none; }
.aws-cart__what a:hover { text-decoration: underline; }
.aws-cart__what small { color: var(--wp--preset--color--neutral-600); }

.aws-cart__qty {
	align-items: center;
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--pill);
	display: inline-flex;
	justify-self: start;
	margin-top: 0.3rem;
}

.aws-cart__qty button {
	background: transparent;
	border: 0;
	border-radius: var(--wp--custom--radius--circle);
	color: inherit;
	cursor: pointer;
	font-size: 1.05rem;
	height: 2rem;
	width: 2rem;
}

.aws-cart__qty button:hover { background: var(--wp--preset--color--neutral-200); }
.aws-cart__qty output { min-width: 1.6rem; text-align: center; }

/* A page of the bag at a time (perPage() in the script). */
.aws-cart__pages { align-items: center; display: flex; gap: var(--wp--preset--spacing--2); justify-content: center; }
.aws-cart__pages[hidden] { display: none; }
.aws-cart__pages span { color: var(--wp--preset--color--neutral-600); font-size: var(--wp--preset--font-size--small); min-width: 6rem; text-align: center; }

.aws-cart__pages button {
	background: transparent;
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--circle);
	color: inherit;
	cursor: pointer;
	font-size: 1.1rem;
	height: 2.25rem;
	width: 2.25rem;
}

.aws-cart__pages button:hover:not(:disabled) { background: var(--wp--preset--color--neutral-200); }
.aws-cart__pages button:disabled { cursor: default; opacity: 0.35; }

.aws-cart__cost { display: grid; gap: 0.35rem; justify-items: end; }

.aws-cart__drop, .aws-cart__quiet, .aws-cart__back {
	background: transparent;
	border: 0;
	color: var(--wp--preset--color--neutral-600);
	cursor: pointer;
	font: inherit;
	font-size: var(--wp--preset--font-size--x-small);
	padding: 0;
	text-decoration: underline;
}

.aws-cart__back { align-self: start; font-size: var(--wp--preset--font-size--small); text-decoration: none; }
/* Keep shopping beside Checkout, the way back before the way on. */
.aws-cart__acts { align-items: center; display: flex; gap: var(--wp--preset--spacing--2); }
.aws-cart__acts .aws-cart__go { flex: 1; }

.aws-cart__quiet {
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--pill);
	color: inherit;
	flex: none;
	font-size: var(--wp--preset--font-size--small);
	min-height: var(--wp--custom--tap-target);
	padding: 0 1.1rem;
	text-decoration: none;
}

.aws-cart__quiet:hover { background: var(--wp--preset--color--neutral-200); }

.aws-cart__empty { color: var(--wp--preset--color--neutral-600); margin: var(--wp--preset--spacing--6) 0; text-align: center; }

.aws-cart__foot {
	background: var(--wp--preset--color--background);
	border-top: 1px solid var(--wp--preset--color--divider);
	bottom: calc(-1 * var(--wp--preset--spacing--4));
	display: grid;
	gap: var(--wp--preset--spacing--2);
	margin-top: auto;
	padding: var(--wp--preset--spacing--3) 0 var(--wp--preset--spacing--4);
	position: sticky;
}

/* Place order stays in reach however long the form: the foot of the panel, as the bag's Checkout is. */
.aws-cart__foot--pay { gap: var(--wp--preset--spacing--1); }
.aws-cart__foot--pay .aws-cart__go { margin-top: var(--wp--preset--spacing--1); }

/* The address: picked from what it finds, the list under the box. */
.aws-cart__where { position: relative; }
.aws-cart__where input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.aws-cart__where input[data-picked] { border-color: var(--wp--preset--color--accent); }

.aws-cart__found {
	background: var(--wp--preset--color--background);
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--md);
	box-shadow: 0 0.75rem 2rem color-mix(in srgb, var(--wp--preset--color--ink) 18%, transparent);
	inset: 100% 0 auto;
	list-style: none;
	margin: 0.25rem 0 0;
	padding: 0.25rem;
	position: absolute;
	z-index: 2;
}

.aws-cart__found[hidden] { display: none; }

.aws-cart__found button {
	background: transparent;
	border: 0;
	border-radius: var(--wp--custom--radius--sm);
	color: inherit;
	cursor: pointer;
	display: block;
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	padding: 0.55rem 0.65rem;
	text-align: start;
	width: 100%;
}

.aws-cart__found button:hover, .aws-cart__found button:focus-visible { background: var(--wp--preset--color--neutral-200); }

.aws-cart__sum { align-items: baseline; display: flex; justify-content: space-between; margin: 0; }
.aws-cart__sum strong { font-family: var(--wp--preset--font-family--heading); font-size: var(--wp--preset--font-size--large); }

.aws-cart__go { border: 0; cursor: pointer; width: 100%; }
.aws-cart__go:disabled { cursor: progress; opacity: 0.6; }

.aws-cart__form { display: grid; gap: var(--wp--preset--spacing--3); }

.aws-cart__how { border: 0; display: flex; flex-wrap: wrap; gap: var(--wp--preset--spacing--2); margin: 0; padding: 0; }
.aws-cart__how legend { color: var(--wp--preset--color--neutral-600); font-size: var(--wp--preset--font-size--small); font-weight: 600; margin-bottom: 0.3rem; padding: 0; }

.aws-cart__how label {
	align-items: center;
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--pill);
	cursor: pointer;
	display: inline-flex;
	font-size: var(--wp--preset--font-size--small);
	gap: 0.45rem;
	padding: 0.45rem 0.9rem;
}

.aws-cart__how label:has(input:checked) { border-color: var(--wp--preset--color--accent); background: color-mix(in srgb, var(--wp--preset--color--accent) 10%, transparent); }
.aws-cart__how input { accent-color: var(--wp--preset--color--accent); margin: 0; }

.aws-cart__card {
	background: var(--wp--preset--color--background);
	border: 1px solid var(--wp--preset--color--divider);
	border-radius: var(--wp--custom--radius--md);
	padding: 0.85rem 0.8rem;
}

.aws-cart__fine { color: var(--wp--preset--color--neutral-600); font-size: var(--wp--preset--font-size--x-small); margin: 0; }

.aws-cart__trap { height: 1px; left: -100vw; overflow: hidden; position: absolute; width: 1px; }

.aws-cart__done { align-items: center; justify-content: center; text-align: center; }
.aws-cart__done h3 { margin: 0; }
.aws-cart__done p { margin: 0; }

.aws-cart__tick {
	align-items: center;
	background: color-mix(in srgb, var(--wp--preset--color--accent) 14%, transparent);
	border-radius: var(--wp--custom--radius--circle);
	color: var(--wp--preset--color--accent);
	display: inline-flex;
	font-size: 1.8rem;
	height: 4rem;
	justify-content: center;
	width: 4rem;
}


@media (max-width: 30rem) {
	.aws-cart { width: 100%; }
}
