/**
 * Header, announcement bar, and mobile drawer.
 *
 * Pixel-matched to https://flanfudge-direct.lovable.app/ — same gutters,
 * circular icon pills (cart filled olive, menu outlined), drawer slides
 * down from below the masthead and overlays the page.
 *
 * @package FlanFudge
 */

/* =========================================================================
 * 1. Announcement bar (off by default; opt-in via Customizer)
 * ========================================================================= */

.ff-announce {
	position: relative;
	z-index: 60;
	background: var(--ff-foreground);
	color: var(--ff-cream);
	font-size: var(--ff-text-sm);
	font-weight: var(--ff-weight-semibold);
	letter-spacing: var(--ff-tracking-wider);
}

.ff-announce__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--ff-space-3);
	min-height: 38px;
	padding-block: 8px;
	padding-inline: var(--ff-gutter);
	text-align: center;
}

.ff-announce__text a {
	color: inherit;
	border-bottom: 1px solid currentColor;
	font-weight: var(--ff-weight-bold);
}

.ff-announce__close {
	position: absolute;
	right: 6px;
	top: 50%;
	translate: 0 -50%;
	/* Visual circle stays compact (26 px) but the hit area is widened
	   to a 36-px square so it meets WCAG 2.5.5 on touch. */
	width: 36px;
	height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: transparent;
	color: inherit;
	border-radius: var(--ff-radius-pill);
	cursor: pointer;
	opacity: 0.7;
	-webkit-tap-highlight-color: transparent;
	transition: opacity var(--ff-dur-fast) var(--ff-ease),
	            background-color var(--ff-dur-fast) var(--ff-ease);
}

.ff-announce__close:hover,
.ff-announce__close:focus-visible {
	opacity: 1;
	background: rgb(255 255 255 / 0.1);
	outline: none;
}

.ff-announce__close svg {
	width: 14px;
	height: 14px;
}

body.is-announce-dismissed .ff-announce {
	display: none;
}

/* =========================================================================
 * 2. Masthead
 * ========================================================================= */

.site-header.flanfudge-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--ff-bg);
	border-bottom: 1px solid #d5dacb;
	border-bottom-color: #d5dacb;
	transition: background-color var(--ff-dur-base) var(--ff-ease),
	            border-color var(--ff-dur-base) var(--ff-ease),
	            box-shadow var(--ff-dur-base) var(--ff-ease);
}

.site-header.flanfudge-header.is-scrolled {
	background: color-mix(in oklab, var(--ff-bg) 92%, transparent);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	border-bottom-color: #d5dacb;
}

.flanfudge-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ff-space-4);
	padding-block: 18px;
	min-height: 84px;
}

@media (max-width: 640px) {
	.flanfudge-header__inner {
		padding-block: 14px;
		min-height: 72px;
	}
}

/* =========================================================================
 * 3. Branding (logo)
 * ========================================================================= */

.ff-branding {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
}

.ff-branding__link {
	display: inline-flex;
	align-items: center;
	line-height: 0;
}

.ff-branding__logo {
	display: block;
	width: auto;
	height: clamp(48px, 5vw, 64px);
}

/* When the WP Site Identity logo isn't set we fall back to a wordmark. */
.ff-branding__wordmark {
	display: inline-flex;
	flex-direction: column;
	font-family: var(--ff-font-display);
	font-weight: var(--ff-weight-bold);
	font-size: clamp(1.4rem, 1.6vw + 0.7rem, 2rem);
	line-height: 0.95;
	color: var(--ff-foreground);
	letter-spacing: -0.02em;
}

.ff-branding__wordmark span:last-child {
	color: var(--ff-accent);
	margin-left: 0.4em;
}

/* =========================================================================
 * 4. Header actions (cart + menu pills)
 * ========================================================================= */

.ff-actions {
	display: inline-flex;
	align-items: center;
	gap: var(--ff-space-3);
}

.ff-icon-btn {
	position: relative;
	width: 48px;
	height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--ff-radius-pill);
	border: 1px solid var(--ff-border);
	background: var(--ff-card);
	color: var(--ff-foreground);
	font: inherit;
	cursor: pointer;
	transition: background-color var(--ff-dur-fast) var(--ff-ease),
	            color var(--ff-dur-fast) var(--ff-ease),
	            border-color var(--ff-dur-fast) var(--ff-ease),
	            transform var(--ff-dur-fast) var(--ff-ease);
}

.ff-icon-btn:hover {
	background: var(--ff-bg-alt);
	color: var(--ff-foreground);
}

.ff-icon-btn:focus-visible {
	outline: 2px solid var(--ff-ring);
	outline-offset: 3px;
}

.ff-icon-btn:active {
	transform: scale(0.96);
}

/* `body.flanfudge` prefix is required to beat `body.flanfudge svg`
   in main.css. Without it the cart icon collapses to height: auto
   and renders as a 0px-tall sliver. */
body.flanfudge .ff-icon-btn svg {
	width: 22px;
	height: 22px;
	max-width: none;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: block;
}

/* Cart variant — filled olive pill, white icon. */
.ff-icon-btn--cart {
	background: var(--ff-primary);
	border-color: var(--ff-primary);
	color: var(--ff-primary-foreground);
}

.ff-icon-btn--cart:hover {
	background: var(--ff-olive-soft);
	border-color: var(--ff-olive-soft);
	color: var(--ff-primary-foreground);
}

/* Live cart count badge. */
.ff-cart-count {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: var(--ff-radius-pill);
	background: var(--ff-accent);
	color: var(--ff-cream);
	font-size: 11px;
	font-weight: var(--ff-weight-bold);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	box-shadow: 0 0 0 2px var(--ff-bg);
	transition: transform var(--ff-dur-fast) var(--ff-ease-out);
}

.ff-cart-count[data-count="0"] {
	display: none;
}

.ff-cart-count.is-bumping {
	transform: scale(1.18);
}

/* Menu pill — toggles aria-expanded; icon swaps via [data-icon-state]. */
.ff-menu-toggle[aria-expanded="true"] .ff-menu-toggle__bars { display: none; }
.ff-menu-toggle[aria-expanded="false"] .ff-menu-toggle__close { display: none; }

.ff-menu-toggle__sr-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* =========================================================================
 * 5. Inline desktop primary nav (Menu / About / Reviews / Delivery)
 *
 *    Hidden by default; revealed at >=1024px when the Customizer flag
 *    `flanfudge_header_desktop_nav` is on (default ON, matches Lovable).
 * ========================================================================= */

.ff-primary-nav {
	display: none;
}

.ff-primary-nav ul,
.ff-primary-nav__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: inline-flex;
	align-items: center;
	gap: clamp(20px, 2.4vw, 36px);
}

.ff-primary-nav a {
	font-family: inherit;
	font-size: var(--ff-text-base);
	font-weight: var(--ff-weight-semibold);
	color: var(--ff-foreground);
	letter-spacing: 0.01em;
	transition: color var(--ff-dur-fast) var(--ff-ease);
}

.ff-primary-nav a:hover,
.ff-primary-nav a:focus-visible {
	color: var(--ff-accent);
}

@media (min-width: 1024px) {
	body.has-desktop-nav .ff-primary-nav {
		display: inline-flex;
		flex: 1 1 auto;
		justify-content: center;
	}
}

/* =========================================================================
 * 5a. Support pill (links to WhatsApp). Desktop-only.
 *     Outlined sage pill, sits between desktop nav and cart icon.
 * ========================================================================= */

.ff-support-btn {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 0.55rem 1.05rem;
	border: 1px solid var(--ff-border);
	border-radius: var(--ff-radius-pill);
	background: transparent;
	color: var(--ff-foreground);
	font-size: var(--ff-text-base);
	font-weight: var(--ff-weight-bold);
	line-height: 1;
	text-decoration: none;
	transition: background-color var(--ff-dur-fast) var(--ff-ease),
	            color var(--ff-dur-fast) var(--ff-ease),
	            border-color var(--ff-dur-fast) var(--ff-ease);
}

.ff-support-btn svg {
	width: 16px;
	height: 16px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ff-support-btn:hover,
.ff-support-btn:focus-visible {
	background: var(--ff-bg-alt);
	color: var(--ff-foreground);
	border-color: var(--ff-foreground);
}

@media (min-width: 1024px) {
	body.has-desktop-nav .ff-support-btn {
		display: inline-flex;
	}
}

/* =========================================================================
 * 5b. Hamburger pill — visible at every width by default; hidden on
 *     desktop ONLY when the inline nav is enabled (matches Lovable).
 * ========================================================================= */

@media (min-width: 1024px) {
	body.has-desktop-nav .ff-menu-toggle {
		display: none;
	}
}

/* =========================================================================
 * 6. Mobile drawer / off-canvas
 *
 *    Slides down from below the masthead and covers the page.
 *    Width is 100% on mobile and 480px on tablet+ (matches Lovable).
 * ========================================================================= */

.ff-drawer {
	position: fixed;
	inset: 0;
	z-index: 49;
	pointer-events: none;
	visibility: hidden;
}

.ff-drawer.is-open {
	pointer-events: auto;
	visibility: visible;
}

.ff-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.35);
	opacity: 0;
	transition: opacity var(--ff-dur-base) var(--ff-ease);
}

.ff-drawer.is-open .ff-drawer__overlay {
	opacity: 1;
}

.ff-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(480px, 100vw);
	background: var(--ff-bg);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform var(--ff-dur-slow) var(--ff-ease-out);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.ff-drawer.is-open .ff-drawer__panel {
	transform: translateX(0);
}

/* On the smallest screens the drawer fills the whole viewport. */
@media (max-width: 480px) {
	.ff-drawer__panel { width: 100vw; }
}

/* The drawer pads itself below the sticky header so the close (X) button
   on the masthead stays clickable while the drawer is open. */
.ff-drawer__panel {
	padding-top: 84px; /* matches header min-height */
}

@media (max-width: 640px) {
	.ff-drawer__panel { padding-top: 72px; }
}

.ff-drawer__nav {
	padding: var(--ff-space-6) var(--ff-gutter);
	display: flex;
	flex-direction: column;
	gap: var(--ff-space-2);
}

.ff-drawer__nav ul {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
}

.ff-drawer__nav li + li {
	border-top: 1px solid color-mix(in oklab, var(--ff-border) 80%, transparent);
}

.ff-drawer__nav a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--ff-space-5) 0;
	font-size: var(--ff-text-2xl);
	font-weight: var(--ff-weight-semibold);
	color: var(--ff-foreground);
}

.ff-drawer__nav a::after {
	content: "";
	width: 18px;
	height: 18px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14'/><path d='m13 5 7 7-7 7'/></svg>") no-repeat center / contain;
	        mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14'/><path d='m13 5 7 7-7 7'/></svg>") no-repeat center / contain;
	opacity: 0.45;
	transform: translateX(-4px);
	transition: opacity var(--ff-dur-base) var(--ff-ease),
	            transform var(--ff-dur-base) var(--ff-ease);
}

.ff-drawer__nav a:hover::after,
.ff-drawer__nav a:focus-visible::after {
	opacity: 1;
	transform: translateX(0);
}

.ff-drawer__support {
	margin: 0 var(--ff-gutter) var(--ff-space-12);
	padding-top: var(--ff-space-6);
	border-top: 1px solid var(--ff-border);
	display: flex;
	flex-direction: column;
	gap: var(--ff-space-3);
}

.ff-drawer__support a {
	display: inline-flex;
	align-items: center;
	gap: var(--ff-space-2);
	color: var(--ff-muted-fg);
	font-size: var(--ff-text-base);
	font-weight: var(--ff-weight-semibold);
}

.ff-drawer__support a:hover {
	color: var(--ff-foreground);
}

.ff-drawer__support svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}
