/*
 * The cart page: the line item list, the summary panel and the empty state.
 * Every colour, space, radius and shadow comes from the design tokens, so the
 * page follows the theme in light and dark without a hardcoded value.
 */

.franchesco-cart-page {
	padding-block: var(--space-section, 5rem);
	background: var(--color-neutral-100);
}

/*
 * Desktop first, then the three shared breakpoints (1024 / 768 / 480px, see
 * design-tokens.css) narrow it down — the same max-width-only scheme the rest
 * of the theme uses, so there is one reading order for every stylesheet.
 */
.franchesco-cart-page__layout {
	display: grid;
	gap: var(--space-12);
	align-items: start;
	grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
}

.franchesco-cart-page__heading {
	margin: 0 0 var(--space-6);
	color: var(--color-neutral-900);
	font-family: var(--font-heading);
	font-size: var(--text-2xl);
	letter-spacing: var(--letter-tight, -0.01em);
}

.franchesco-cart-lines {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	margin: 0;
	padding: 0;
	list-style: none;
}

.franchesco-cart-lines[hidden] {
	display: none;
}

/* One line item: photo, copy, quantity, subtotal, remove. */
.franchesco-cart-line {
	display: grid;
	align-items: center;
	padding: var(--space-4);
	border: 1px solid var(--color-neutral-200);
	border-radius: var(--radius-lg);
	background: var(--color-neutral-50);
	box-shadow: var(--shadow-sm);
	gap: var(--space-5);
	grid-template-columns: 6.5rem minmax(0, 1fr) auto auto auto;
	transition: box-shadow var(--duration-normal) var(--ease-default),
		opacity var(--duration-normal) var(--ease-default);
}

.franchesco-cart-line:hover {
	box-shadow: var(--shadow-md);
}

.franchesco-cart-line.is-busy {
	opacity: 0.65;
}

.franchesco-cart-line__image {
	width: 6.5rem;
	height: 6.5rem;
	border-radius: var(--radius-md);
	object-fit: cover;
}

.franchesco-cart-line__body {
	min-width: 0;
}

.franchesco-cart-line__name {
	margin: 0 0 var(--space-1);
	font-family: var(--font-heading);
	font-size: var(--text-lg);
	letter-spacing: var(--letter-tight, -0.01em);
}

.franchesco-cart-line__link {
	color: var(--color-neutral-900);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--duration-normal) var(--ease-default),
		color var(--duration-normal) var(--ease-default);
}

.franchesco-cart-line__link:hover,
.franchesco-cart-line__link:focus-visible {
	color: var(--color-primary-600);
	border-bottom-color: currentColor;
}

.franchesco-cart-line__variant {
	display: inline-block;
	margin: 0 0 var(--space-2);
	padding: var(--space-1) var(--space-3);
	border-radius: var(--radius-full);
	background: var(--color-primary-50);
	color: var(--color-primary-700);
	font-size: var(--text-xs);
}

.franchesco-cart-line__unit {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--space-1);
	margin: 0;
	color: var(--color-neutral-600);
	font-size: var(--text-sm);
}

.franchesco-cart-line__unit-label::after {
	content: ":";
}

.franchesco-cart-line__unit-amount {
	color: var(--color-neutral-900);
	font-weight: 600;
}

.franchesco-cart-line__each {
	color: var(--color-neutral-500);
	font-size: var(--text-xs);
}

.franchesco-cart-line__qty {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
}

.franchesco-cart-line__qty-label {
	color: var(--color-neutral-600);
	font-size: var(--text-xs);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.franchesco-cart-line__subtotal {
	display: flex;
	flex-direction: column;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: var(--space-1);
	min-width: 7rem;
	margin: 0;
	text-align: right;
}

.franchesco-cart-line__subtotal-label {
	color: var(--color-neutral-600);
	font-size: var(--text-xs);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.franchesco-cart-line__subtotal-amount {
	color: var(--color-primary-600);
	font-family: var(--font-heading);
	font-size: var(--text-xl);
}

.franchesco-cart-line__remove {
	justify-self: start;
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--color-neutral-200);
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--color-neutral-600);
	font-family: var(--font-body);
	font-size: var(--text-xs);
	cursor: pointer;
	transition: background var(--duration-normal) var(--ease-default),
		border-color var(--duration-normal) var(--ease-default),
		color var(--duration-normal) var(--ease-default);
}

.franchesco-cart-line__remove:hover,
.franchesco-cart-line__remove:focus-visible {
	border-color: var(--color-error, var(--color-primary-300));
	background: var(--color-primary-50);
	color: var(--color-error, var(--color-primary-700));
}

.franchesco-cart-line__remove:focus-visible,
.franchesco-cart-line .franchesco-qty__input:focus-visible,
.franchesco-cart-line .franchesco-qty__step:focus-visible {
	outline: 2px solid var(--color-primary-500);
	outline-offset: 2px;
}

.franchesco-cart-line__remove[disabled] {
	cursor: progress;
}

.franchesco-cart-line__error {
	margin: 0;
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-sm);
	background: var(--color-primary-50);
	color: var(--color-error);
	font-size: var(--text-xs);
	grid-column: 1 / -1;
}

.franchesco-cart-line__error[hidden] {
	display: none;
}

/* The summary panel: what the cart costs, and where to go next. */
.franchesco-cart-summary {
	position: sticky;
	top: var(--space-6);
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding: var(--space-6);
	border: 1px solid var(--color-neutral-200);
	border-radius: var(--radius-lg);
	background: var(--color-neutral-50);
	box-shadow: var(--shadow-md);
}

.franchesco-cart-summary[hidden] {
	display: none;
}

.franchesco-cart-summary__title {
	margin: 0;
	font-family: var(--font-heading);
	font-size: var(--text-lg);
	letter-spacing: var(--letter-tight, -0.01em);
}

.franchesco-cart-summary__count {
	display: flex;
	align-items: baseline;
	gap: var(--space-1);
	margin: 0;
	color: var(--color-neutral-600);
	font-size: var(--text-sm);
}

.franchesco-cart-summary__count-value {
	color: var(--color-neutral-900);
	font-weight: 700;
}

.franchesco-cart-summary__total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-3);
	margin: 0;
	padding-top: var(--space-3);
	border-top: 1px solid var(--color-neutral-200);
}

.franchesco-cart-summary__total-label {
	color: var(--color-neutral-700);
	font-size: var(--text-sm);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.franchesco-cart-summary__total-amount {
	color: var(--color-primary-600);
	font-family: var(--font-heading);
	font-size: var(--text-2xl);
	letter-spacing: var(--letter-tight, -0.02em);
}

.franchesco-cart-summary__note {
	margin: 0;
	color: var(--color-neutral-500);
	font-size: var(--text-xs);
}

.franchesco-cart-summary__checkout {
	justify-content: center;
	text-align: center;
}

.franchesco-cart-summary__continue {
	color: var(--color-primary-600);
	font-size: var(--text-sm);
	text-align: center;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--duration-normal) var(--ease-default);
}

.franchesco-cart-summary__continue:hover,
.franchesco-cart-summary__continue:focus-visible {
	border-bottom-color: currentColor;
}

/* Empty cart: never a bare line of text. */
.franchesco-cart-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-4);
	padding: var(--space-12) var(--space-6);
	border: 1px dashed var(--color-neutral-300);
	border-radius: var(--radius-xl);
	background: var(--color-neutral-50);
	text-align: center;
}

.franchesco-cart-empty[hidden] {
	display: none;
}

.franchesco-cart-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 4.5rem;
	height: 4.5rem;
	border-radius: var(--radius-full);
	background: var(--color-primary-50);
	color: var(--color-primary-600);
}

.franchesco-cart-empty__title {
	margin: 0;
	font-family: var(--font-heading);
	font-size: var(--text-2xl);
	letter-spacing: var(--letter-tight, -0.02em);
}

.franchesco-cart-empty__body {
	max-width: 46ch;
	margin: 0;
	color: var(--color-neutral-600);
	font-size: var(--text-base);
}

/* ---------- Tablets: the summary drops under the list ---------- */

@media (max-width: 1024px) {
	.franchesco-cart-page__layout {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--space-8);
	}
}

/* ---------- Phones: the line item stacks ----------
   Below the shared 768px breakpoint every line becomes a vertical card: the
   photo beside the name on top, then the stepper, the subtotal and the remove
   action each on their own full-width row, so all three sit under the thumb
   instead of being squeezed into a strip. */

@media (max-width: 768px) {
	.franchesco-cart-line {
		grid-template-columns: 5.5rem minmax(0, 1fr);
		gap: var(--space-3) var(--space-4);
		padding: var(--space-4);
	}

	/* The photo keeps the name beside it on the first row only. It must not
	   span further down: the three controls below span the whole card, so a
	   taller image column would leave them indented behind an empty gutter. */
	.franchesco-cart-line__image {
		width: 5.5rem;
		height: 5.5rem;
	}

	.franchesco-cart-line__qty,
	.franchesco-cart-line__subtotal,
	.franchesco-cart-line__remove {
		grid-column: 1 / -1;
	}

	.franchesco-cart-line__subtotal {
		flex-direction: row;
		align-items: baseline;
		justify-content: space-between;
		gap: var(--space-2);
		min-width: 0;
		text-align: left;
	}

	/* The stepper spans the row and its buttons grow: 48px tall targets with a
	   wide field between them, all reachable one-handed. */
	.franchesco-cart-line__qty {
		gap: var(--space-2);
	}

	.franchesco-cart-line .franchesco-qty {
		display: flex;
		width: 100%;
		max-width: 16rem;
	}

	.franchesco-cart-line .franchesco-qty__step {
		flex: 0 0 auto;
		min-width: 48px;
		min-height: 48px;
	}

	.franchesco-cart-line .franchesco-qty__input {
		flex: 1 1 auto;
		width: auto;
		min-width: 0;
		min-height: 48px;
		font-size: max(1rem, var(--text-base));
	}

	/* Remove is a real button on a phone, not a 12px link. */
	.franchesco-cart-line__remove {
		justify-self: stretch;
		width: 100%;
		min-height: 48px;
		font-size: var(--text-sm);
	}

	/* The summary stops floating and becomes the last card in the column, with
	   a full-width checkout action. */
	.franchesco-cart-summary {
		position: static;
		padding: var(--space-5);
	}

	.franchesco-cart-summary__checkout,
	.franchesco-cart-summary .franchesco-btn {
		width: 100%;
		min-height: 48px;
	}

	.franchesco-cart-empty {
		padding: var(--space-8) var(--space-4);
	}

	.franchesco-cart-empty .franchesco-btn {
		width: 100%;
		min-height: 48px;
	}
}

@media (max-width: 480px) {
	/* Narrowest phones: the photo moves above the copy so the name and the
	   variant get the full width instead of a 5.5rem-wide leftover column. */
	.franchesco-cart-line {
		grid-template-columns: minmax(0, 1fr);
	}

	.franchesco-cart-line__image {
		width: 100%;
		height: auto;
		aspect-ratio: 16 / 9;
		grid-row: auto;
	}

	.franchesco-cart-line__qty,
	.franchesco-cart-line__subtotal,
	.franchesco-cart-line__remove {
		grid-column: 1;
	}

	.franchesco-cart-line .franchesco-qty {
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.franchesco-cart-line,
	.franchesco-cart-line__link,
	.franchesco-cart-line__remove,
	.franchesco-cart-summary__continue {
		transition: none;
	}
}
