/*
 * TableNow menu (core module) structural styles ONLY (layout, spacing,
 * flex/grid resets). Deliberately free of brand colors/fonts so the active
 * theme's own CSS can fully restyle every BEM class below.
 *
 * Layout model: a menu-book style list — each dish is one row (number, name
 * block, dotted leader, price) with a legend section below. Ordering
 * controls are styled by tablenow-ordering.css, loaded only when that
 * module is enabled.
 */

.tablenow-app {
	display: flex;
	flex-wrap: wrap;
	gap: 2rem;
}

.tablenow-menu {
	flex: 2 1 480px;
	min-width: 0;
	/* Hard cap: without it the horizontally scrolling tab track can blow
	   the column (and the page) out to its content width on wrapped
	   (single-column) layouts. */
	max-width: 100%;
}

/* Dish-name search bar, rendered above the category tabs. */
.tablenow-menu__search {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 1.5rem;
}

.tablenow-menu__search-icon {
	flex: 0 0 auto;
	width: 1.1rem;
	height: 1.1rem;
}

.tablenow-menu__search-input {
	flex: 1 1 auto;
	min-width: 0;
	border: none;
	background: none;
	font: inherit;
}

.tablenow-menu__search-input:focus {
	outline: none;
}

/* Hidden by the search filter. `.tablenow-menu__item` carries an explicit
   `display: flex` elsewhere in this file, which would otherwise defeat the
   `hidden` attribute's UA-stylesheet rule; `.tablenow-menu__tab` has no such
   rule but is listed here too so both stay explicit and grep-able together. */
.tablenow-menu__item[hidden],
.tablenow-menu__tab[hidden] {
	display: none;
}

.tablenow-menu__search-empty {
	margin: 0 0 1.5rem;
}

/* Sticky category nav. Themes with a fixed header set
   --tablenow-tabs-offset to its height (and should give the bar a
   background so content doesn't show through while stuck). */
.tablenow-menu__tabs-bar {
	position: sticky;
	top: var(--tablenow-tabs-offset, 0px);
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 2rem;
}

.tablenow-menu__tabs {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.5rem;
	margin: 0;
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.tablenow-menu__tabs::-webkit-scrollbar {
	display: none;
}

.tablenow-menu__tab {
	flex: 0 0 auto;
	white-space: nowrap;
	cursor: pointer;
}

.tablenow-menu__tabs-arrow {
	flex: 0 0 auto;
	cursor: pointer;
}

.tablenow-menu__tabs-arrow[hidden] {
	display: none;
}

.tablenow-menu__category {
	margin: 0 0 2.5rem;
}

.tablenow-menu__category[hidden] {
	display: none;
}

.tablenow-menu__category-title {
	margin: 0 0 0.5rem;
}

.tablenow-menu__category-description {
	margin: 0 0 0.5rem;
}

.tablenow-menu__category-notice {
	margin: 0 0 1rem;
}

.tablenow-menu__items {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
}

.tablenow-menu__item {
	display: flex;
	flex-direction: column;
	padding: 0;
	margin: 0;
}

.tablenow-menu__item-row {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	width: 100%;
}

.tablenow-menu__item-image {
	display: block;
	width: 3.5rem;
	height: 3.5rem;
	object-fit: cover;
	flex: 0 0 auto;
	align-self: center;
}

.tablenow-menu__item-nr {
	flex: 0 0 3.25rem;
}

.tablenow-menu__item-main {
	flex: 0 1 auto;
	min-width: 0;
}

.tablenow-menu__item-name {
	margin: 0;
}

.tablenow-menu__item-description {
	margin: 0;
}

.tablenow-menu__item-allergens {
	margin: 0;
}

/* Dietary badge: icon + short label on one baseline. */
.tablenow-menu__badge {
	display: inline-flex;
	align-items: center;
	gap: 0.25em;
}

.tablenow-menu__badge-icon {
	width: 1em;
	height: 1em;
	flex: 0 0 auto;
}

/*
 * Allergen trigger + expandable panel. The trigger is a plain button; the
 * panel is a normal in-flow block on wide viewports (expands in place, like the
 * variant picker) and is turned into a fixed bottom sheet further below.
 */
.tablenow-menu__allergen-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	margin: 0;
	padding: 0;
	border: none;
	background: none;
	font: inherit;
	cursor: pointer;
}

.tablenow-menu__allergen-toggle-icon {
	width: 1em;
	height: 1em;
	flex: 0 0 auto;
}

.tablenow-menu__allergen-toggle-chevron {
	width: 1em;
	height: 1em;
	flex: 0 0 auto;
	transition: transform 0.2s ease;
}

.tablenow-menu__item--allergens-open .tablenow-menu__allergen-toggle-chevron {
	transform: rotate( 180deg );
}

/* Closed by default; the open dish reveals its panel. */
.tablenow-menu__allergen-panel {
	display: none;
	margin: 0.5rem 0 0;
}

.tablenow-menu__item--allergens-open .tablenow-menu__allergen-panel {
	display: block;
}

.tablenow-menu__allergen-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}

.tablenow-menu__allergen-panel-title {
	margin: 0;
}

/* The close button is only needed while the panel is a bottom sheet. */
.tablenow-menu__allergen-panel-close {
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none;
	background: none;
	color: inherit;
	cursor: pointer;
}

.tablenow-menu__allergen-panel-close-icon {
	width: 1.25rem;
	height: 1.25rem;
}

.tablenow-menu__allergen-group-title {
	margin: 0.75rem 0 0.25rem;
}

.tablenow-menu__allergen-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tablenow-menu__allergen-row {
	display: grid;
	grid-template-columns: auto auto 1fr;
	align-items: baseline;
	gap: 0.25rem 0.6rem;
	padding: 0.2rem 0;
}

.tablenow-menu__allergen-row-icon {
	width: 1.1em;
	height: 1.1em;
	align-self: center;
}

/* Shared backdrop for the mobile bottom sheet; hidden on wide viewports. */
.tablenow-menu__allergen-backdrop {
	display: none;
}

.tablenow-menu__allergen-backdrop[hidden] {
	display: none;
}

.tablenow-menu__item-dots {
	flex: 1 1 auto;
	min-width: 1.5rem;
}

.tablenow-menu__item-price {
	margin: 0;
	flex: 0 0 auto;
	white-space: nowrap;
}

/* Pickup and delivery prices differ: small label above both amounts. */
.tablenow-menu__item-price--split {
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
	line-height: 1.25;
}

.tablenow-menu__item-price-label {
	font-size: 0.75em;
	font-weight: normal;
	opacity: 0.75;
}

/*
 * Per-item availability. A RESTAURANT_ONLY / UNAVAILABLE dish stays visible and
 * priced but reads as muted and non-interactive, distinct from the transient
 * serving-hours `--unorderable` state.
 */
.tablenow-menu__item--restaurant-only,
.tablenow-menu__item--unavailable {
	opacity: 0.6;
}

.tablenow-menu__status-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	margin: 0.15rem 0;
	padding: 0.1em 0.5em;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.75em;
	line-height: 1.4;
	white-space: nowrap;
}

.tablenow-menu__status-icon {
	width: 1em;
	height: 1em;
	flex: 0 0 auto;
}

/*
 * A blocked variant option: greyed, its disabled radio not interactive, with
 * the same badge the dish level uses.
 */
.tablenow-menu__variant-option--status-restaurant-only,
.tablenow-menu__variant-option--status-unavailable {
	opacity: 0.6;
	cursor: not-allowed;
}

.tablenow-menu__variant-option--status-restaurant-only input,
.tablenow-menu__variant-option--status-unavailable input {
	cursor: not-allowed;
}

.tablenow-menu__legend {
	margin: 2rem 0 0;
}

.tablenow-menu__legend-list {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.25rem 0.75rem;
	margin: 0.5rem 0 1rem;
}

.tablenow-menu__legend-list dd {
	margin: 0;
}

/*
 * Narrow viewports: the allergen panel becomes a bottom sheet (fixed to the
 * viewport, above a dimmed backdrop) instead of expanding inline. Same DOM
 * node, toggled by the `--allergens-open` class on the dish; mirrors the order
 * panel's sheet behavior.
 */
@media ( max-width: 640px ) {
	.tablenow-menu__allergen-panel-close {
		display: inline-flex;
	}

	.tablenow-menu__item--allergens-open .tablenow-menu__allergen-panel {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		/* Above the ordering FAB / order sheet (≤1000) so the open panel reads
		   as a modal; kept below the order toast (1200). */
		z-index: 1101;
		margin: 0;
		max-height: min( 80vh, 32rem );
		overflow-y: auto;
		box-sizing: border-box;
	}

	.tablenow-menu__allergen-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1100;
	}

	.tablenow-menu__allergen-backdrop[hidden] {
		display: none;
	}
}
