/**
 * MH Menu Manager — Frontend CSS
 *
 * Architecture:
 *   - CSS custom properties for theming (values injected via PHP / wp_head)
 *   - BEM naming: .mh-{block}__element--modifier
 *   - Mobile-first responsive layout
 *   - GPU-composited transitions (transform + opacity, NOT height)
 *   - No external font or icon dependency
 *
 * @package MH_Menu
 */

/* ── Design tokens (defaults, overridden by PHP-injected :root block) ───── */
.mh-menu {
	--mh-container-width:    1200px;
	--mh-header-height:      80px;
	--mh-font-family:        inherit;
	--mh-font-size-base:     15px;
	--mh-font-size-price:    16px;
	--mh-price-color:        #d4a843;
	--mh-bg-color:           #f9f9f9;
	--mh-card-radius:        10px;
	--mh-card-shadow:        0 2px 12px rgba(0,0,0,.08);
	--mh-animation-duration: 300ms;
	--mh-cols-desktop:       4;
	--mh-cols-tablet:        2;
	--mh-cols-mobile:        1;
	--mh-desc-line-limit:    3;

	/* Category header defaults — overridden per-item via inline style vars */
	--mh-cat-overlay:        rgba(0,0,0,.45);
	--mh-cat-title-color:    #ffffff;
}

/* ── Reset scoped to plugin ──────────────────────────────────────────────── */
.mh-menu *,
.mh-menu *::before,
.mh-menu *::after {
	box-sizing: border-box;
}

/* ── Container ───────────────────────────────────────────────────────────── */
.mh-menu {
	max-width: var(--mh-container-width);
	margin: 0 auto;
	font-family: var(--mh-font-family);
	font-size: var(--mh-font-size-base);
	background: var(--mh-bg-color);
	color: #1a1a1a;
	line-height: 1.5;
}

/* ── Header (logo + language switcher) ───────────────────────────────────── */
.mh-menu__header {
	display: flex;
	align-items: stretch;
	background: #fff;
	border-bottom: 1px solid rgba(0,0,0,.08);
}
.mh-menu__header--sticky {
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.mh-menu__header-inner {
	max-width: var(--mh-container-width);
	margin: 0 auto;
	padding: 0 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	min-height: 64px;
}
.mh-menu__logo      { display: flex; align-items: center; }
.mh-menu__logo-img  { max-height: 48px; width: auto; display: block; }

/* Language switcher */
.mh-menu__lang-switcher {
	display: flex;
	align-items: center;
	gap: 4px;
}
.mh-lang-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	color: #555;
	border: 1px solid transparent;
	transition: background .15s, border-color .15s, color .15s;
}
.mh-lang-btn:hover {
	background: #f4f4f4;
	color: #111;
}
.mh-lang-btn--active {
	background: #1a1a1a;
	color: #fff;
	border-color: #1a1a1a;
}
.mh-lang-btn__flag { font-size: 16px; line-height: 1; }

/* ── Accordion ───────────────────────────────────────────────────────────── */
.mh-accordion { width: 100%; }

/* ── Accordion item ──────────────────────────────────────────────────────── */
.mh-accordion__item {
	border-bottom: 1px solid rgba(0,0,0,.06);
}
.mh-accordion__item:last-child { border-bottom: none; }

/* ── Category header button ──────────────────────────────────────────────── */
.mh-accordion__header {
	display: flex;
	align-items: center;
	width: 100%;
	min-height: var(--mh-header-height);
	padding: 16px 24px;
	border: none;
	cursor: pointer;
	text-align: left;
	position: relative;
	overflow: hidden;
	background-color: #1a1a1a;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	transition: filter var(--mh-animation-duration);
	-webkit-appearance: none;
	appearance: none;
}
.mh-accordion__header:focus-visible {
	outline: 3px solid var(--mh-price-color);
	outline-offset: -3px;
}
.mh-accordion__header:hover { filter: brightness(1.08); }

/* Overlay pseudo-element (darkens the banner image) */
.mh-accordion__header-overlay {
	position: absolute;
	inset: 0;
	background: var(--mh-cat-overlay);
	pointer-events: none;
}

/* Title */
.mh-accordion__header-title {
	position: relative;
	font-size: 1.1em;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--mh-cat-title-color);
	flex: 1;
	z-index: 1;
}

/* Item count */
.mh-accordion__header-meta { position: relative; z-index: 1; }
.mh-accordion__count {
	font-size: 12px;
	color: rgba(255,255,255,.7);
	background: rgba(0,0,0,.2);
	padding: 2px 8px;
	border-radius: 20px;
	margin-right: 10px;
}

/* Chevron */
.mh-accordion__chevron {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	color: var(--mh-cat-title-color);
	transition: transform var(--mh-animation-duration) ease;
	flex-shrink: 0;
}
.mh-accordion__header.is-open .mh-accordion__chevron {
	transform: rotate(180deg);
}

/* ── Accordion content panel ─────────────────────────────────────────────── */
.mh-accordion__content {
	padding: 24px 20px;
	background: var(--mh-bg-color);
}
/* CSS-driven collapse (overriding the HTML hidden attr with display) */
.mh-accordion__content[hidden] {
	display: none;
}
/* Animate open */
.mh-accordion__content.is-animating {
	display: block !important;
	overflow: hidden;
}

/* ── Items grid ──────────────────────────────────────────────────────────── */
.mh-items-grid {
	display: grid;
	grid-template-columns: repeat( var(--mh-cols-desktop), 1fr );
	gap: 20px;
}

@media (max-width: 900px) {
	.mh-items-grid {
		grid-template-columns: repeat( var(--mh-cols-tablet), 1fr );
	}
}
@media (max-width: 560px) {
	.mh-items-grid {
		grid-template-columns: repeat( var(--mh-cols-mobile), 1fr );
		gap: 14px;
	}
}

/* Allow per-instance override via data-cols attribute (set by JS) */
.mh-items-grid[style*="--cols"] {
	grid-template-columns: repeat( var(--cols), 1fr );
}

/* ── Item card ───────────────────────────────────────────────────────────── */
.mh-item-card {
	background: #fff;
	border-radius: var(--mh-card-radius);
	box-shadow: var(--mh-card-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: transform .2s, box-shadow .2s;
	cursor: default;
}
.mh-item-card[role="button"] { cursor: pointer; }
.mh-item-card[role="button"]:hover {
	transform: translateY(-3px);
	box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.mh-item-card[role="button"]:focus-visible {
	outline: 3px solid var(--mh-price-color);
	outline-offset: 2px;
}

/* Image */
.mh-item-card__image-wrap {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	background: #f0f0f0;
}
.mh-item-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s ease;
}
.mh-item-card[role="button"]:hover .mh-item-card__image {
	transform: scale(1.04);
}

/* Badges on image */
.mh-item-card__badges {
	position: absolute;
	top: 8px;
	left: 8px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}
.mh-badge {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	background: var(--mh-badge-color, #333);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 4px;
	white-space: nowrap;
}
.mh-badge svg { flex-shrink: 0; }

/* Card body */
.mh-item-card__body {
	padding: 14px 16px 16px;
	display: flex;
	flex-direction: column;
	flex: 1;
}
.mh-item-card__title {
	font-size: 1em;
	font-weight: 700;
	margin: 0 0 6px;
	line-height: 1.3;
}
.mh-item-card__desc {
	font-size: .875em;
	color: #555;
	margin: 0 0 10px;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--mh-desc-line-limit, 3);
	overflow: hidden;
}
.mh-item-card--no-image .mh-item-card__desc {
	-webkit-line-clamp: 5;
}

/* Allergens */
.mh-item-card__allergens {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-bottom: 8px;
}
.mh-allergen {
	font-size: 10px;
	background: #fff3e0;
	color: #e65100;
	padding: 1px 6px;
	border-radius: 4px;
	border: 1px solid #ffe0b2;
}

/* Footer: price + calories + detail hint */
.mh-item-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: auto;
	padding-top: 10px;
}
.mh-item-card__pricing { display: flex; align-items: baseline; gap: 8px; }
.mh-item-card__price {
	font-size: var(--mh-font-size-price);
	font-weight: 700;
	color: var(--mh-price-color);
}
.mh-item-card__price span { font-weight: inherit; }
.mh-item-card__old-price {
	font-size: .8em;
	color: #aaa;
	text-decoration: line-through;
}
.mh-item-card__calories {
	font-size: 11px;
	color: #999;
}
.mh-item-card__detail-hint {
	margin-left: auto;
	color: #ccc;
	display: flex;
	align-items: center;
	transition: color .15s;
}
.mh-item-card[role="button"]:hover .mh-item-card__detail-hint { color: var(--mh-price-color); }

/* ── Skeleton loading ────────────────────────────────────────────────────── */
.mh-skeleton {
	background: linear-gradient(90deg, #ececec 25%, #f4f4f4 50%, #ececec 75%);
	background-size: 200% 100%;
	animation: mh-shimmer 1.4s infinite linear;
	border-radius: 4px;
}
@keyframes mh-shimmer {
	from { background-position: 200% 0; }
	to   { background-position: -200% 0; }
}
.mh-item-card--skeleton .mh-item-card__image-wrap,
.mh-item-card--skeleton .mh-item-card__title,
.mh-item-card--skeleton .mh-item-card__desc {
	background: linear-gradient(90deg, #ececec 25%, #f4f4f4 50%, #ececec 75%);
	background-size: 200% 100%;
	animation: mh-shimmer 1.4s infinite linear;
	color: transparent;
	border-radius: 4px;
}

/* ── Lazy placeholder ────────────────────────────────────────────────────── */
.mh-lazy-placeholder {
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #bbb;
}
.mh-lazy-placeholder::after {
	content: '';
	width: 32px;
	height: 32px;
	border: 3px solid #eee;
	border-top-color: var(--mh-price-color);
	border-radius: 50%;
	animation: mh-spin .8s linear infinite;
}
@keyframes mh-spin {
	to { transform: rotate(360deg); }
}

/* ── Item detail modal ───────────────────────────────────────────────────── */
.mh-item-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.mh-item-modal[hidden] { display: none; }

.mh-item-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.6);
	cursor: pointer;
	backdrop-filter: blur(2px);
}
.mh-item-modal__box {
	position: relative;
	background: #fff;
	border-radius: calc( var(--mh-card-radius) * 1.5 );
	overflow: hidden;
	max-width: 600px;
	width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: 0 20px 60px rgba(0,0,0,.3);
	animation: mh-modal-in var(--mh-animation-duration) ease;
}
@keyframes mh-modal-in {
	from { opacity: 0; transform: scale(.95) translateY(10px); }
	to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.mh-item-modal__close {
	position: absolute;
	top: 12px; right: 12px;
	z-index: 1;
	width: 36px; height: 36px;
	display: flex; align-items: center; justify-content: center;
	background: rgba(0,0,0,.3);
	border: none;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	transition: background .15s;
	backdrop-filter: blur(4px);
	-webkit-appearance: none;
	appearance: none;
}
.mh-item-modal__close:hover { background: rgba(0,0,0,.6); }

.mh-item-modal__image-wrap { position: relative; }
.mh-item-modal__image {
	width: 100%;
	max-height: 320px;
	object-fit: cover;
	display: block;
}
.mh-item-modal__badges {
	position: absolute;
	bottom: 12px;
	left: 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.mh-item-modal__body    { padding: 24px; }
.mh-item-modal__title   { font-size: 1.3em; font-weight: 700; margin: 0 0 10px; }
.mh-item-modal__desc    { color: #555; line-height: 1.6; margin: 0 0 16px; white-space: pre-line; }

.mh-item-modal__meta    { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.mh-item-modal__pricing { display: flex; align-items: baseline; gap: 8px; }
.mh-item-modal__pricing .mh-item-card__price { font-size: 1.2em; }
.mh-item-modal__calories { color: #999; font-size: 13px; }

.mh-item-modal__allergens { font-size: 13px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.mh-item-modal__allergens-label { color: #333; margin-right: 6px; }

/* ── No-content notice (admin only) ─────────────────────────────────────── */
.mh-menu__no-content {
	padding: 20px;
	text-align: center;
	color: #888;
	background: #fff3cd;
	border: 1px solid #ffe69c;
	border-radius: 6px;
	margin: 20px 0;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.mh-accordion__header   { min-height: 60px; padding: 12px 16px; }
	.mh-accordion__content  { padding: 16px 12px; }
	.mh-item-card__body     { padding: 10px 12px 14px; }
	.mh-menu__header-inner  { padding: 0 14px; min-height: 54px; }
	.mh-lang-btn            { padding: 5px 8px; font-size: 12px; }
}

@media (max-width: 400px) {
	.mh-items-grid { gap: 10px; }
	.mh-item-card__title  { font-size: .95em; }
}

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
	.mh-accordion__content[hidden] { display: block !important; }
	.mh-accordion__chevron,
	.mh-item-card__detail-hint,
	.mh-menu__lang-switcher,
	.mh-item-modal { display: none !important; }
	.mh-item-card { box-shadow: none; border: 1px solid #ddd; }
}
