/*
 * Cart surfaces: the header mini-cart and the add-to-cart controls that sit on
 * dish cards. All colour, spacing and motion comes from the design tokens, so
 * these pieces follow the rest of the theme (light and dark) without a single
 * hardcoded value.
 */

.franchesco-mini-cart {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-2) var(--space-4);
	border: 1px solid var(--color-neutral-200);
	border-radius: var(--radius-full);
	background: var(--color-neutral-50);
	color: var(--color-neutral-800);
	font-family: var(--font-body);
	font-size: var(--text-sm, 0.889rem);
	line-height: 1;
	text-decoration: none;
	transition: background var(--duration-normal) var(--ease-default),
		border-color var(--duration-normal) var(--ease-default),
		color var(--duration-normal) var(--ease-default);
}

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

.franchesco-mini-cart:focus-visible {
	outline: 2px solid var(--color-primary-500);
	outline-offset: 2px;
}

.franchesco-mini-cart__icon {
	display: inline-flex;
	align-items: center;
}

/* Visible from the tablet breakpoint up; hidden below it so the header row
   still fits brand + call + cart + hamburger at 320px (see the 1024px block). */
.franchesco-mini-cart__label {
	display: inline;
}

.franchesco-mini-cart__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5rem;
	height: 1.5rem;
	padding: 0 var(--space-1);
	border-radius: var(--radius-full);
	background: var(--color-primary-500);
	color: var(--color-neutral-50);
	font-weight: 700;
	font-size: var(--text-xs, 0.79rem);
}

.franchesco-mini-cart__count.is-empty {
	background: var(--color-neutral-300);
	color: var(--color-neutral-800);
}

/* Shared breakpoint (--bp-lg). Replaces an off-system 900px query: every
   media query in the theme now uses 1024 / 768 / 480 only. */
@media (max-width: 1024px) {
	.franchesco-mini-cart__label {
		display: none;
	}
}

/* Add-to-cart controls on a dish card, and on the single-dish page. */
.franchesco-cart-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: var(--space-3);
	margin-top: var(--space-4);
	padding-top: var(--space-4);
	border-top: 1px solid var(--color-neutral-200);
}

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

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

.franchesco-cart-form select {
	/* 44px minimum on every interactive control in the card — the size picker,
	   the stepper and the add button are all thumb-sized on touch. */
	min-height: 44px;
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--color-neutral-300);
	border-radius: var(--radius-md);
	background: var(--color-neutral-50);
	color: var(--color-neutral-900);
	font-family: var(--font-body);
	/* Never under 16px at any width: mobile Safari zooms the page in when a
	   focused control is smaller than that, on a phone and on a tablet alike. */
	font-size: max(1rem, var(--text-sm));
}

.franchesco-cart-form select:focus-visible,
.franchesco-cart-form input:focus-visible,
.franchesco-cart-form button:focus-visible {
	outline: 2px solid var(--color-primary-500);
	outline-offset: 2px;
}

/* Quantity stepper: minus, field, plus, as one pill. */
.franchesco-qty {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid var(--color-neutral-300);
	border-radius: var(--radius-md);
	background: var(--color-neutral-50);
	overflow: hidden;
}

.franchesco-qty__step {
	/* Square, at least 44x44 CSS px: the WCAG 2.5.8 target size, and the size
	   a thumb actually hits on a phone. */
	min-width: 44px;
	min-height: 44px;
	border: 0;
	background: transparent;
	color: var(--color-neutral-800);
	font-size: var(--text-lg);
	line-height: 1;
	cursor: pointer;
	transition: background var(--duration-normal) var(--ease-default),
		color var(--duration-normal) var(--ease-default);
}

.franchesco-qty__step:hover {
	background: var(--color-primary-50);
	color: var(--color-primary-700);
}

.franchesco-qty__input {
	width: 3rem;
	min-height: 44px;
	padding: var(--space-2) 0;
	border: 0;
	border-left: 1px solid var(--color-neutral-200);
	border-right: 1px solid var(--color-neutral-200);
	background: transparent;
	color: var(--color-neutral-900);
	font-family: var(--font-body);
	/* Never under 16px: mobile Safari zooms the page in on a smaller field. */
	font-size: max(1rem, var(--text-base));
	text-align: center;
	/* Strip the number spinners: the stepper's own buttons replace them. */
	appearance: textfield;
	-moz-appearance: textfield;
}

.franchesco-qty__input::-webkit-outer-spin-button,
.franchesco-qty__input::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

/* The price of the variant currently selected. */
.franchesco-cart-form__price {
	display: flex;
	align-items: baseline;
	gap: var(--space-1);
	margin: 0;
	margin-inline-start: auto;
}

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

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

.franchesco-cart-form__add {
	flex-basis: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	text-align: center;
}

/* Narrow cards (one column below 480px, two columns up to 768px): the size
   picker and the stepper each take a full row so neither is squeezed, and the
   selected price sits on its own line above the button instead of being
   pushed against it. */
@media (max-width: 768px) {
	.franchesco-cart-form {
		align-items: stretch;
		gap: var(--space-3);
	}

	.franchesco-cart-form__field {
		flex-basis: 100%;
		min-width: 0;
	}

	.franchesco-cart-form select {
		width: 100%;
		min-height: 48px;
		font-size: max(1rem, var(--text-base));
	}

	/* The stepper keeps its own 16px floor from the base rule above. */

	.franchesco-qty {
		width: 100%;
	}

	.franchesco-qty__step {
		flex: 0 0 auto;
	}

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

	.franchesco-cart-form__price {
		flex-basis: 100%;
		margin-inline-start: 0;
		flex-wrap: wrap;
	}
}

.franchesco-cart-form__feedback,
.franchesco-cart-form__error {
	flex-basis: 100%;
	margin: 0;
	font-size: var(--text-xs);
}

.franchesco-cart-form__feedback {
	color: var(--color-success);
	opacity: 0;
	transition: opacity var(--duration-normal) var(--ease-default);
}

.franchesco-cart-form__feedback.is-visible {
	opacity: 1;
}

/* A capped quantity is a notice, not a success: warn without shouting. */
.franchesco-cart-form__feedback.is-clamped {
	color: var(--color-primary-600);
	font-weight: 600;
}

.franchesco-cart-form__error {
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-sm);
	background: var(--color-primary-50);
	color: var(--color-error);
}

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

.franchesco-cart-form button[disabled] {
	opacity: 0.6;
	cursor: progress;
}

/* The roomier version on the single-dish page. */
.franchesco-cart-form--detail {
	gap: var(--space-4);
	padding: var(--space-5);
	border: 1px solid var(--color-neutral-200);
	border-radius: var(--radius-lg);
	background: var(--color-neutral-50);
	box-shadow: var(--shadow-sm);
}

.franchesco-cart-form--detail .franchesco-cart-form__amount {
	font-size: var(--text-2xl);
}

/* Single-dish page: photo on one side, copy and controls on the other. */
.franchesco-dish-detail {
	display: grid;
	gap: var(--space-12);
	align-items: center;
	grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}

.franchesco-dish-detail__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-lg);
	object-fit: cover;
	aspect-ratio: 4 / 3;
}

.franchesco-dish-detail__title {
	margin: var(--space-2) 0 var(--space-4);
	font-family: var(--font-heading);
	font-size: var(--text-3xl);
	letter-spacing: var(--letter-tight, -0.02em);
}

.franchesco-dish-detail__desc {
	margin: 0;
	color: var(--color-neutral-600);
	font-size: var(--text-lg);
}

.franchesco-dish-detail__links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-5);
	margin-top: var(--space-5);
	font-size: var(--text-sm);
}

.franchesco-dish-detail__links .franchesco-link {
	color: var(--color-primary-600);
	font-family: var(--font-body);
	text-decoration: none;
	border-bottom: 1px solid var(--color-primary-200);
	transition: color var(--duration-normal) var(--ease-default),
		border-color var(--duration-normal) var(--ease-default);
}

.franchesco-dish-detail__links .franchesco-link:hover,
.franchesco-dish-detail__links .franchesco-link:focus-visible {
	color: var(--color-primary-700);
	border-bottom-color: currentColor;
}

/* "View dish" on a card sits opposite the price. */
.franchesco-dish-card__link {
	/* inline-flex + min-height gives the link a real 44px touch target
	   instead of the bare height of its text. */
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	min-width: 44px;
	justify-content: flex-end;
	color: var(--color-primary-600);
	font-size: var(--text-sm);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--duration-normal) var(--ease-default);
}

.franchesco-dish-card__link:hover,
.franchesco-dish-card__link:focus-visible {
	border-bottom-color: currentColor;
}

/* Image above copy from the tablet breakpoint down — side by side the photo
   drops under ~300px wide and the price/quantity row starts wrapping. */
@media (max-width: 1024px) {
	.franchesco-dish-detail {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--space-8);
	}
}

@media (prefers-reduced-motion: reduce) {
	.franchesco-mini-cart,
	.franchesco-qty__step,
	.franchesco-cart-form__feedback,
	.franchesco-dish-card__link {
		transition: none;
	}
}
