/**
 * Servery front end.
 *
 * Written to sit inside somebody else's theme without fighting it: no resets,
 * no global element selectors, everything namespaced. Typography and spacing
 * inherit where sensible so the menu looks like part of the site rather than
 * a widget bolted onto it.
 *
 * The accent colour comes from the plugin settings as `--servery-accent`,
 * printed inline in the page head.
 *
 * @package Servery
 */

.servery-menu,
.servery-cart,
.servery-checkout,
.servery-single,
.servery-track,
.servery-track-form {
	--df-accent: var( --servery-accent, #c8402f );
	--df-on-accent: var( --servery-on-accent, #fff );
	--df-surface: #fff;
	--df-muted: #6d635c;
	--df-border: #e5e0da;
	--df-radius: 12px;
	--df-shadow: 0 1px 3px rgba( 0, 0, 0, 0.06 ), 0 12px 32px -16px rgba( 0, 0, 0, 0.18 );

	color: inherit;
}

@media ( prefers-color-scheme: dark ) {
	.servery-menu,
	.servery-cart,
	.servery-checkout,
	.servery-single,
	.servery-track,
	.servery-track-form {
		--df-surface: #211e1b;
		--df-muted: #b0a79f;
		--df-border: #38332e;
	}
}

/* -------------------------------------------------------------------------
 * Category navigation
 * ---------------------------------------------------------------------- */

.servery-menu__nav {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding: 4px 0 12px;
	position: sticky;
	top: 0;
	z-index: 20;
	background: inherit;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.servery-menu__navlink {
	flex: 0 0 auto;
	padding: 7px 14px;
	border-radius: 999px;
	border: 1px solid var( --df-border );
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
	color: inherit;
	white-space: nowrap;
}

.servery-menu__navlink:hover,
.servery-menu__navlink:focus {
	border-color: var( --df-accent );
	color: var( --df-accent );
}

/* -------------------------------------------------------------------------
 * Sections and cards
 * ---------------------------------------------------------------------- */

.servery-section {
	margin: 0 0 2.5rem;
	scroll-margin-top: 72px;
}

.servery-section__title {
	margin: 0 0 0.25rem;
	font-size: 1.375rem;
	line-height: 1.25;
}

.servery-section__description {
	margin: 0 0 1rem;
	color: var( --df-muted );
	font-size: 0.9375rem;
}

.servery-items {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 260px, 1fr ) );
	gap: 16px;
}

.servery-item {
	display: flex;
	flex-direction: column;
	background: var( --df-surface );
	border: 1px solid var( --df-border );
	border-radius: var( --df-radius );
	overflow: hidden;
	transition: box-shadow 160ms ease, transform 160ms ease;
}

.servery-item:hover {
	box-shadow: var( --df-shadow );
	transform: translateY( -2px );
}

@media ( prefers-reduced-motion: reduce ) {
	.servery-item {
		transition: none;
	}

	.servery-item:hover {
		transform: none;
	}
}

.servery-item--unavailable {
	opacity: 0.55;
}

.servery-item__media {
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: var( --df-border );
}

.servery-item__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.servery-item__body {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 14px 16px 16px;
	flex: 1;
}

.servery-item__name {
	margin: 0;
	font-size: 1rem;
	line-height: 1.35;
}

.servery-item__description {
	margin: 0;
	font-size: 0.875rem;
	color: var( --df-muted );
	line-height: 1.5;
}

.servery-item__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.servery-tag {
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	padding: 2px 7px;
	border-radius: 999px;
	background: color-mix( in srgb, var( --df-accent ) 10%, transparent );
	color: var( --df-accent );
}

.servery-item__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: auto;
	padding-top: 10px;
}

.servery-item__price {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.servery-item__was {
	text-decoration: line-through;
	color: var( --df-muted );
	font-weight: 400;
	margin-right: 4px;
}

.servery-item__now {
	color: inherit;
}

.servery-item__soldout {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var( --df-muted );
}

/* -------------------------------------------------------------------------
 * Buttons
 * ---------------------------------------------------------------------- */

.servery-menu .servery-button,
.servery-cart .servery-button,
.servery-sheet .servery-button,
.servery-checkout .servery-button,
.servery-single .servery-button,
.servery-track-form .servery-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 16px;
	border: 1px solid transparent;
	border-radius: 8px;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	text-decoration: none;
	/* Comfortably tappable on a phone held in one hand. */
	min-height: 40px;
}

.servery-button--primary {
	background: var( --df-accent );
	color: var( --df-on-accent );
}

.servery-button--primary:hover {
	filter: brightness( 0.92 );
}

.servery-button--ghost {
	background: transparent;
	border-color: var( --df-border );
	color: inherit;
}

/* -------------------------------------------------------------------------
 * Quantity stepper
 * ---------------------------------------------------------------------- */

.servery-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var( --df-border );
	border-radius: 8px;
	overflow: hidden;
}

.servery-qty button {
	width: 40px;
	height: 40px;
	border: 0;
	background: transparent;
	font-size: 1.125rem;
	cursor: pointer;
	color: inherit;
	line-height: 1;
}

.servery-qty button:hover {
	background: color-mix( in srgb, var( --df-accent ) 8%, transparent );
}

.servery-qty output {
	min-width: 34px;
	text-align: center;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.servery-qty--sm button {
	width: 30px;
	height: 30px;
	font-size: 1rem;
}

/* -------------------------------------------------------------------------
 * Options sheet
 * ---------------------------------------------------------------------- */

.servery-sheet {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

@media ( min-width: 640px ) {
	.servery-sheet {
		align-items: center;
	}
}

.servery-sheet__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.45 );
	backdrop-filter: blur( 2px );
}

.servery-sheet__panel {
	position: relative;
	width: 100%;
	max-width: 520px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	background: var( --df-surface, #fff );
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -8px 40px rgba( 0, 0, 0, 0.25 );
	animation: servery-rise 220ms cubic-bezier( 0.32, 0.72, 0, 1 );
}

@media ( min-width: 640px ) {
	.servery-sheet__panel {
		border-radius: 16px;
	}
}

@keyframes servery-rise {
	from {
		transform: translateY( 24px );
		opacity: 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.servery-sheet__panel {
		animation: none;
	}
}

.servery-sheet__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var( --df-border );
}

.servery-sheet__head h2 {
	margin: 0;
	font-size: 1.125rem;
}

.servery-sheet__close {
	border: 0;
	background: transparent;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	color: var( --df-muted );
	padding: 0 4px;
}

.servery-sheet__body {
	padding: 16px 20px;
	overflow-y: auto;
	flex: 1;
}

.servery-sheet__description {
	margin: 0 0 16px;
	color: var( --df-muted );
	font-size: 0.9375rem;
}

.servery-group {
	border: 0;
	padding: 0;
	margin: 0 0 20px;
}

.servery-group__title {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 0 0 8px;
	font-weight: 700;
	font-size: 0.9375rem;
}

.servery-group__rule {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var( --df-muted );
}

.servery-group--error .servery-group__rule {
	color: #b4271f;
}

.servery-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px solid var( --df-border );
	cursor: pointer;
	font-size: 0.9375rem;
}

.servery-option:last-of-type {
	border-bottom: 0;
}

.servery-option--disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.servery-option__name {
	flex: 1;
}

.servery-option__price {
	font-variant-numeric: tabular-nums;
	color: var( --df-muted );
	font-size: 0.875rem;
}

.servery-sheet__notes {
	display: block;
	margin-top: 8px;
}

.servery-sheet__notes span {
	display: block;
	font-weight: 700;
	font-size: 0.9375rem;
	margin-bottom: 6px;
}

.servery-sheet__notes textarea {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var( --df-border );
	border-radius: 8px;
	font: inherit;
	font-size: 0.9375rem;
	resize: vertical;
	background: transparent;
	color: inherit;
}

.servery-sheet__foot {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	border-top: 1px solid var( --df-border );
	/* Clear of the home indicator on an iPhone. */
	padding-bottom: max( 14px, env( safe-area-inset-bottom ) );
}

.servery-sheet__add {
	flex: 1;
}

/* -------------------------------------------------------------------------
 * Basket
 * ---------------------------------------------------------------------- */

.servery-cart__lines {
	list-style: none;
	margin: 0;
	padding: 0;
}

.servery-cart__line {
	display: grid;
	grid-template-columns: 1fr auto auto;
	align-items: center;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var( --df-border );
}

.servery-cart__name {
	display: block;
	font-weight: 600;
	font-size: 0.9375rem;
}

.servery-cart__mods,
.servery-cart__notes {
	display: block;
	font-size: 0.8125rem;
	color: var( --df-muted );
	margin-top: 2px;
}

.servery-cart__notes {
	font-style: italic;
}

.servery-cart__price {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	min-width: 68px;
	text-align: right;
}

.servery-cart__totals {
	padding-top: 12px;
}

.servery-cart__row {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 4px 0;
	font-size: 0.9375rem;
	color: var( --df-muted );
	font-variant-numeric: tabular-nums;
}

.servery-cart__row--total {
	margin-top: 8px;
	padding-top: 12px;
	border-top: 1px solid var( --df-border );
	font-size: 1.0625rem;
	font-weight: 700;
	color: inherit;
}

.servery-cart__empty {
	padding: 32px 0;
	text-align: center;
	color: var( --df-muted );
}

.servery-cart__warning {
	margin: 12px 0 0;
	padding: 10px 12px;
	border-radius: 8px;
	background: color-mix( in srgb, #9a6212 12%, transparent );
	color: #9a6212;
	font-size: 0.875rem;
}

/* Slide-out drawer */
.servery-cart--drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min( 420px, 100% );
	z-index: 9999;
	display: flex;
	flex-direction: column;
	background: var( --df-surface, #fff );
	border-left: 1px solid var( --df-border );
	box-shadow: -8px 0 40px rgba( 0, 0, 0, 0.18 );
	transform: translateX( 100% );
	transition: transform 240ms cubic-bezier( 0.32, 0.72, 0, 1 );
	padding: 20px;
	overflow-y: auto;
}

.servery-cart-open .servery-cart--drawer {
	transform: translateX( 0 );
}

@media ( prefers-reduced-motion: reduce ) {
	.servery-cart--drawer {
		transition: none;
	}
}

/* Floating basket button */
.servery-cart-toggle {
	position: fixed;
	right: 20px;
	bottom: max( 20px, env( safe-area-inset-bottom ) );
	z-index: 9998;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px;
	border: 0;
	border-radius: 999px;
	background: var( --df-accent );
	color: var( --df-on-accent );
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba( 0, 0, 0, 0.22 );
	transition: transform 160ms ease;
}

.servery-cart-toggle.is-bumped {
	transform: scale( 1.08 );
}

.servery-cart-toggle__count {
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: rgba( 255, 255, 255, 0.25 );
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
 * Order tracking
 * ---------------------------------------------------------------------- */

.servery-track {
	max-width: 560px;
	margin: 0 auto;
	padding: 32px 20px;
}

.servery-track__number {
	font-variant-numeric: tabular-nums;
	color: var( --df-muted );
}

.servery-track__steps {
	list-style: none;
	margin: 24px 0;
	padding: 0;
	display: grid;
	gap: 2px;
}

.servery-track__step {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 0;
	color: var( --df-muted );
}

.servery-track__step::before {
	content: "";
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 2px solid currentColor;
	flex: 0 0 12px;
}

.servery-track__step.is-done {
	color: var( --df-accent );
	font-weight: 600;
}

.servery-track__step.is-done::before {
	background: currentColor;
}

/* -------------------------------------------------------------------------
 * Toast
 * ---------------------------------------------------------------------- */

.servery-toast {
	position: fixed;
	left: 50%;
	bottom: 32px;
	transform: translateX( -50% );
	z-index: 100000;
	max-width: min( 420px, calc( 100vw - 32px ) );
	padding: 12px 18px;
	border-radius: 10px;
	background: #1c1917;
	color: #fff;
	font-size: 0.9375rem;
	box-shadow: 0 8px 32px rgba( 0, 0, 0, 0.3 );
	animation: servery-toast-in 200ms ease;
}

.servery-toast.is-leaving {
	opacity: 0;
	transition: opacity 300ms ease;
}

@keyframes servery-toast-in {
	from {
		transform: translate( -50%, 12px );
		opacity: 0;
	}
}

/* -------------------------------------------------------------------------
 * Opening hours
 * ---------------------------------------------------------------------- */

.servery-hours {
	list-style: none;
	margin: 0;
	padding: 0;
}

.servery-hours li {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 7px 0;
	border-bottom: 1px solid var( --df-border );
	font-size: 0.9375rem;
}

.servery-hours li:last-child {
	border-bottom: 0;
}

.servery-hours .is-today {
	font-weight: 700;
	color: var( --df-accent );
}

/* -------------------------------------------------------------------------
 * Links into a dish's own page, and the drawer's way out
 * ---------------------------------------------------------------------- */

.servery-item__link {
	color: inherit;
	text-decoration: none;
}

.servery-item__link:hover,
.servery-item__link:focus {
	color: var( --df-accent );
	text-decoration: underline;
	text-underline-offset: 3px;
}

.servery-cart .servery-cart__checkout {
	width: 100%;
	margin-top: 16px;
	min-height: 48px;
	font-size: 1rem;
}

/* -------------------------------------------------------------------------
 * A dish's own page
 * ---------------------------------------------------------------------- */

.servery-single {
	margin: 0 0 2rem;
}

.servery-single__back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 1rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var( --df-muted );
	text-decoration: none;
}

.servery-single__back:hover,
.servery-single__back:focus {
	color: var( --df-accent );
}

.servery-single__grid {
	display: grid;
	grid-template-columns: minmax( 0, 1.15fr ) minmax( 0, 1fr );
	gap: clamp( 20px, 4vw, 40px );
	align-items: start;
}

.servery-single__grid--no-media {
	grid-template-columns: minmax( 0, 1fr );
	max-width: 560px;
}

.servery-single__media {
	margin: 0;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: var( --df-radius );
	background: var( --df-border );
}

.servery-single__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.servery-single__panel {
	position: sticky;
	top: calc( 24px + var( --wp-admin--admin-bar--height, 0px ) );
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 20px;
	background: var( --df-surface );
	border: 1px solid var( --df-border );
	border-radius: var( --df-radius );
	box-shadow: var( --df-shadow );
}

.servery-single__price {
	margin: 0;
	font-size: 1.625rem;
	font-weight: 700;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
}

.servery-single__lead {
	margin: 0;
	color: var( --df-muted );
	font-size: 0.9375rem;
	line-height: 1.55;
}

.servery-single .servery-single__add {
	width: 100%;
	min-height: 48px;
	font-size: 1rem;
}

.servery-single__hint {
	margin: -6px 0 0;
	font-size: 0.8125rem;
	color: var( --df-muted );
	text-align: center;
}

.servery-single__soldout {
	margin: 0;
	padding: 12px 14px;
	border-radius: 8px;
	background: color-mix( in srgb, var( --df-muted ) 12%, transparent );
	font-weight: 600;
	text-align: center;
}

.servery-single__facts {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 110px, 1fr ) );
	gap: 10px;
	margin: 0;
	padding-top: 14px;
	border-top: 1px solid var( --df-border );
}

.servery-single__facts div {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.servery-single__facts dt {
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var( --df-muted );
}

.servery-single__facts dd {
	margin: 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.servery-single__details {
	display: grid;
	gap: 24px;
	max-width: 720px;
	margin-top: clamp( 24px, 4vw, 40px );
}

.servery-single__section h2 {
	margin: 0 0 8px;
	font-size: 1.125rem;
	line-height: 1.3;
}

.servery-single__section p {
	margin: 0;
	line-height: 1.6;
}

.servery-single__allergens {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* The same amber as a basket warning: this is the part people must not miss. */
.servery-single__allergens li {
	padding: 4px 10px;
	border: 1px solid color-mix( in srgb, #9a6212 35%, transparent );
	border-radius: 999px;
	background: color-mix( in srgb, #9a6212 10%, transparent );
	color: #9a6212;
	font-size: 0.8125rem;
	font-weight: 600;
}

.servery-single__muted {
	color: var( --df-muted );
	font-size: 0.9375rem;
}

@media ( max-width: 720px ) {
	.servery-single__grid {
		grid-template-columns: minmax( 0, 1fr );
	}

	.servery-single__panel {
		position: static;
	}
}

/* -------------------------------------------------------------------------
 * Tracking lookup
 * ---------------------------------------------------------------------- */

.servery-track-form {
	display: grid;
	gap: 10px;
	max-width: 440px;
	padding: 20px;
	background: var( --df-surface );
	border: 1px solid var( --df-border );
	border-radius: var( --df-radius );
}

.servery-track-form label {
	font-size: 0.9375rem;
	font-weight: 600;
}

.servery-track-form input {
	width: 100%;
	min-height: 44px;
	padding: 8px 12px;
	border: 1px solid var( --df-border );
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
	letter-spacing: 0.04em;
}

.servery-track-form input:focus {
	outline: 2px solid var( --df-accent );
	outline-offset: 1px;
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media ( max-width: 480px ) {
	.servery-items {
		grid-template-columns: 1fr;
	}

	.servery-item {
		flex-direction: row;
	}

	.servery-item__media {
		flex: 0 0 108px;
		aspect-ratio: 1;
	}
}
