/**
 * Bookfolino - menu 10.2026 (inc/header-v2.php) + podpowiedzi wyszukiwarki (assets/js/site-search.js).
 *
 * Prefiksy: bfh- (nagłówek, overlay), bfs- (panel podpowiedzi - także pod wyszukiwarką strony głównej).
 * Markup grupy z parts/header.html (padding, contentSize 1440px) nadpisujemy tylko wtedy, gdy
 * w nagłówku jest nowe menu (:has(.bfh)) - po powrocie do [bookfolino_header_nav] wraca stary wygląd.
 */

:root {
	--bfh-text: #14132B;
	--bfh-muted: #55546B;
	--bfh-muted-2: #3B3A55;
	--bfh-accent: #4F39F6;
	--bfh-accent-dark: #3420C8;
	--bfh-border: #E3E2EE;
	--bfh-bg: #F6F6FA;
	--bfh-tint: #F6F5FF;
	--bfh-tint-2: #EEEBFF;
	--bfh-font: var(--wp--preset--font-family--body, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
	--bfh-font-display: var(--wp--preset--font-family--display, 'Playfair Display', Georgia, serif);
}

/* ============================================================
   Rama nagłówka (grupa z parts/header.html)
   ============================================================ */

header.wp-block-template-part:has(.bfh) {
	position: relative;
	z-index: 60;
}

header.wp-block-template-part:has(.bfh) > .wp-block-group {
	padding: 12px 24px !important;
	background: #fff !important;
	border-bottom: 1px solid var(--bfh-border) !important;
}

header.wp-block-template-part:has(.bfh) > .wp-block-group > .wp-block-group {
	max-width: 1320px !important;
	margin-left: auto !important;
	margin-right: auto !important;
	gap: 24px;
	align-items: center;
	flex-wrap: nowrap;
}

header.wp-block-template-part:has(.bfh) .wp-block-site-title {
	flex-shrink: 0;
	margin: 0;
	font-family: var(--bfh-font-display) !important;
	font-weight: 700 !important;
	line-height: 1;
}

header.wp-block-template-part:has(.bfh) .wp-block-site-title a {
	color: var(--bfh-accent);
	text-decoration: none;
}

/* Strona główna: nagłówek przyklejony, bo wyszukiwarka wjeżdża do niego po przewinięciu
   hero. Na podstronach zostaje w normalnym przepływie (sticky panele listingu i wizytówki
   liczą top od krawędzi ekranu). */
body.home header.wp-block-template-part:has(.bfh--front) {
	position: sticky;
	top: 0;
}

body.home.admin-bar header.wp-block-template-part:has(.bfh--front) {
	top: 32px;
}

@media (max-width: 782px) {
	body.home.admin-bar header.wp-block-template-part:has(.bfh--front) {
		top: 46px;
	}
}

@media (max-width: 600px) {
	body.home.admin-bar header.wp-block-template-part:has(.bfh--front) {
		top: 0;
	}
}

/* ============================================================
   Układ
   ============================================================ */

.bfh {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 24px;
	font-family: var(--bfh-font);
	color: var(--bfh-text);
}

.bfh__actions {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	flex-shrink: 0;
}

/* ============================================================
   Wyszukiwarka w nagłówku
   ============================================================ */

.bfh__search {
	position: relative;
	flex: 1 1 auto;
	max-width: 600px;
	min-width: 0;
	height: 48px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 6px 0 14px;
	background: var(--bfh-bg);
	border: 1px solid var(--bfh-border);
	border-radius: 14px;
	box-sizing: border-box;
	transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.bfh__search:focus-within {
	background: #fff;
	border: 2px solid var(--bfh-accent);
	padding-left: 13px;
	padding-right: 5px;
}

.bfh__search-icon {
	display: inline-flex;
	color: var(--bfh-muted);
	flex-shrink: 0;
}

.bfh__search-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	border: 0 !important;
	outline: 0;
	background: transparent !important;
	box-shadow: none !important;
	padding: 0 !important;
	font: 400 15px/1.2 var(--bfh-font);
	color: var(--bfh-text);
	-webkit-appearance: none;
	appearance: none;
}

.bfh__search-input::placeholder {
	color: var(--bfh-muted);
	opacity: 1;
}

.bfh__search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.bfh__search-submit {
	flex-shrink: 0;
	height: 36px;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background: var(--bfh-accent);
	color: #fff;
	font: 600 14px/1 var(--bfh-font);
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.bfh__search-submit:hover,
.bfh__search-submit:focus-visible {
	background: var(--bfh-accent-dark);
}

.bfh__search-submit:focus-visible {
	outline: 2px solid var(--bfh-accent);
	outline-offset: 2px;
}

/* Strona główna: dopóki widać wyszukiwarkę w hero, w nagłówku jej nie ma (miejsce zostaje
   zarezerwowane, żeby prawa strona nie skakała). Bez JS zostaje schowana - hero ją ma. */
.bfh--front .bfh__search {
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	pointer-events: none;
}

.bfh--front.bfh--show-search .bfh__search {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
}

/* ============================================================
   Prawa strona
   ============================================================ */

.bfh__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 12px;
	border-radius: 10px;
	color: var(--bfh-muted-2);
	font: 500 14px/1 var(--bfh-font);
	text-decoration: none;
	white-space: nowrap;
}

.bfh__link:hover,
.bfh__link:focus-visible {
	color: var(--bfh-accent);
	background: var(--bfh-tint);
}

.bfh__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: var(--bfh-muted-2);
	cursor: pointer;
	text-decoration: none;
	flex-shrink: 0;
}

.bfh__icon:hover,
.bfh__icon:focus-visible {
	color: var(--bfh-accent);
	background: var(--bfh-tint);
}

.bfh a:focus-visible,
.bfh button:focus-visible {
	outline: 2px solid var(--bfh-accent);
	outline-offset: 2px;
}

/* Lupa i burger tylko na telefonie. Burger ma klasę ze starego nagłówka (mobile-drawer.js),
   a main.css pokazuje ją z !important poniżej 900px - stąd wyższa specyficzność + !important. */
.bfh .bfh__icon--search,
.bfh .bookfolino-header-burger.bfh__burger {
	display: none !important;
}

.bfh .bookfolino-header-burger.bfh__burger {
	margin: 0;
	border: 0;
	background: transparent;
}

.bfh__bell {
	display: inline-flex;
	align-items: center;
}

.bfh__bell .bf-notifications__trigger {
	min-width: 44px;
	min-height: 44px;
}

.bfh__login {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid var(--bfh-border);
	border-radius: 12px;
	background: #fff;
	color: var(--bfh-text);
	font: 600 14px/1 var(--bfh-font);
	text-decoration: none;
	white-space: nowrap;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.bfh__login:hover,
.bfh__login:focus-visible {
	border-color: var(--bfh-accent);
	color: var(--bfh-accent);
}

/* ---------- Konto ---------- */

.bfh__account {
	position: relative;
}

.bfh__account-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 4px 10px 4px 4px;
	border: 1px solid var(--bfh-border);
	border-radius: 999px;
	background: #fff;
	color: var(--bfh-muted-2);
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bfh__account-btn:hover,
.bfh__account-btn[aria-expanded="true"] {
	border-color: var(--bfh-accent);
	box-shadow: 0 0 0 3px var(--bfh-tint-2);
}

.bfh__avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--bfh-tint-2);
	color: var(--bfh-accent-dark);
	font: 700 13px/1 var(--bfh-font);
	letter-spacing: 0.02em;
}

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

.bfh__chevron {
	display: inline-flex;
	transition: transform 0.15s ease;
}

.bfh__account-btn[aria-expanded="true"] .bfh__chevron {
	transform: rotate(180deg);
}

.bfh__menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 80;
	width: 264px;
	padding: 6px;
	background: #fff;
	border: 1px solid var(--bfh-border);
	border-radius: 14px;
	box-shadow: 0 16px 40px -12px rgba(20, 19, 43, 0.22), 0 2px 6px rgba(20, 19, 43, 0.06);
}

.bfh__menu[hidden] {
	display: none;
}

.bfh__menu-head {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 10px 12px 12px;
	margin-bottom: 4px;
	border-bottom: 1px solid var(--bfh-border);
}

.bfh__menu-head strong {
	font: 600 14px/1.3 var(--bfh-font);
	color: var(--bfh-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bfh__menu-head span {
	font: 400 12px/1.3 var(--bfh-font);
	color: var(--bfh-muted);
}

.bfh__menu-section {
	padding: 12px 12px 4px;
	font: 600 11px/1 var(--bfh-font);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--bfh-muted);
}

.bfh__menu-sep {
	height: 1px;
	margin: 6px 0;
	background: var(--bfh-border);
}

.bfh__menu a {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 0 12px;
	border-radius: 10px;
	color: var(--bfh-muted-2);
	font: 500 14px/1.2 var(--bfh-font);
	text-decoration: none;
}

.bfh__menu a svg {
	color: var(--bfh-muted);
	flex-shrink: 0;
}

.bfh__menu a:hover,
.bfh__menu a:focus {
	background: var(--bfh-tint);
	color: var(--bfh-accent);
	outline: none;
}

.bfh__menu a:hover svg,
.bfh__menu a:focus svg {
	color: var(--bfh-accent);
}

/* ============================================================
   Panel podpowiedzi (nagłówek, overlay i hero strony głównej)
   ============================================================ */

.bfs-form {
	position: relative;
}

.bfs-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 70;
	min-width: 320px;
	max-height: min(70vh, 560px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px;
	background: #fff;
	border: 1px solid var(--bfh-border);
	border-radius: 16px;
	box-shadow: 0 20px 48px -16px rgba(20, 19, 43, 0.25), 0 2px 6px rgba(20, 19, 43, 0.06);
	font-family: var(--bfh-font);
	color: var(--bfh-text);
	text-align: left;
	box-sizing: border-box;
}

.bfs-panel[hidden] {
	display: none;
}

.bfs-panel *,
.bfs-panel *::before,
.bfs-panel *::after {
	box-sizing: border-box;
}

.bfs-cols {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px 16px;
}

.bfs-group + .bfs-group {
	margin-top: 4px;
}

.bfs-cols .bfs-group + .bfs-group {
	margin-top: 0;
}

.bfs-group__label {
	padding: 10px 12px 6px;
	font: 600 11px/1 var(--bfh-font);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--bfh-muted);
}

.bfs-opt {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
	padding: 6px 12px;
	border-radius: 10px;
	color: var(--bfh-text);
	text-decoration: none;
	cursor: pointer;
	font-size: 14px;
	line-height: 1.3;
}

.bfs-opt:hover,
.bfs-opt.is-active {
	background: var(--bfh-tint);
	color: var(--bfh-text);
}

.bfs-opt.is-active {
	box-shadow: inset 0 0 0 1px var(--bfh-tint-2);
}

.bfs-opt__main {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.bfs-opt__title {
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bfs-opt__title b,
.bfs-opt__title strong {
	font-weight: 700;
	color: var(--bfh-text);
}

.bfs-opt__meta {
	font-size: 12px;
	color: var(--bfh-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bfs-opt__side {
	flex-shrink: 0;
	font-size: 13px;
	color: var(--bfh-muted-2);
	white-space: nowrap;
}

.bfs-opt__count {
	flex-shrink: 0;
	min-width: 28px;
	padding: 3px 8px;
	border-radius: 999px;
	background: var(--bfh-bg);
	color: var(--bfh-muted);
	font-size: 12px;
	font-weight: 500;
	text-align: center;
}

.bfs-opt__icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 9px;
	background: var(--bfh-tint);
	color: var(--bfh-accent);
}

.bfs-opt:hover .bfs-opt__icon,
.bfs-opt.is-active .bfs-opt__icon {
	background: var(--bfh-tint-2);
}

.bfs-opt__thumb {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 9px;
	object-fit: cover;
	background: var(--bfh-bg);
	display: block;
}

span.bfs-opt__thumb {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--bfh-muted);
}

/* Łączona podpowiedź („Cyklorama w Warszawie") - wyróżniona. */
.bfs-opt--combo .bfs-opt__icon {
	background: var(--bfh-accent);
	color: #fff;
}

.bfs-opt--combo .bfs-opt__title {
	font-weight: 600;
}

/* Sale pod marką. */
.bfs-opt--hall {
	min-height: 44px;
	padding-left: 64px;
	font-size: 13px;
}

.bfs-opt--hall .bfs-opt__title {
	font-weight: 400;
	color: var(--bfh-muted-2);
}

.bfs-opt--more {
	padding-left: 64px;
	font-size: 13px;
	color: var(--bfh-accent);
}

.bfs-opt--more .bfs-opt__title {
	font-weight: 500;
}

.bfs-opt--all {
	margin-top: 4px;
	border-top: 1px solid var(--bfh-border);
	border-radius: 0 0 10px 10px;
	color: var(--bfh-accent);
	font-weight: 600;
}

.bfs-opt--all .bfs-opt__icon {
	background: transparent;
}

.bfs-opt--link {
	color: var(--bfh-accent);
	font-weight: 600;
	font-size: 13px;
}

.bfs-empty {
	padding: 14px 12px;
	font-size: 14px;
	color: var(--bfh-muted);
}

/* Hero strony głównej: panel w szerokości formularza, stary dropdown niewidoczny. */
.bookfolino-home__search .bfs-panel {
	top: calc(100% + 6px);
}

.bfs-form .bookfolino-hero-search__suggest {
	display: none !important;
}

/* ============================================================
   Overlay wyszukiwania (telefon)
   ============================================================ */

.bfh-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	background: #fff;
	font-family: var(--bfh-font);
}

.bfh-overlay[hidden] {
	display: none;
}

.bfh-overlay__form {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.bfh-overlay__bar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px 8px 4px;
	border-bottom: 1px solid var(--bfh-border);
	flex-shrink: 0;
}

.bfh-overlay__back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: var(--bfh-text);
	cursor: pointer;
	flex-shrink: 0;
}

.bfh-overlay__input {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	padding: 0 14px !important;
	border: 2px solid var(--bfh-accent) !important;
	border-radius: 12px !important;
	background: #fff !important;
	font: 400 16px/1.2 var(--bfh-font) !important; /* 16px - iOS nie przybliża strony */
	color: var(--bfh-text);
	outline: 0;
	box-shadow: none !important;
	-webkit-appearance: none;
	appearance: none;
}

.bfh-overlay .bfs-panel {
	position: static;
	flex: 1 1 auto;
	min-width: 0;
	max-height: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	padding: 8px 8px calc(16px + env(safe-area-inset-bottom, 0px));
}

html.bfh-lock,
html.bfh-lock body {
	overflow: hidden;
}

/* ============================================================
   Responsywność
   ============================================================ */

@media (max-width: 1080px) {
	.bfh {
		gap: 16px;
	}
	.bfh__search {
		max-width: 440px;
	}
}

@media (max-width: 920px) {
	.bfh__link--owner {
		display: none;
	}
}

@media (max-width: 767px) {
	header.wp-block-template-part:has(.bfh) > .wp-block-group {
		padding: 8px 12px 8px 16px !important;
	}
	header.wp-block-template-part:has(.bfh) > .wp-block-group > .wp-block-group {
		gap: 8px;
	}
	header.wp-block-template-part:has(.bfh) .wp-block-site-title {
		font-size: 1.5rem !important;
	}

	.bfh__search,
	.bfh__bell,
	.bfh__account,
	.bfh__login,
	.bfh__link--owner {
		display: none !important;
	}

	.bfh__actions {
		gap: 2px;
	}

	.bfh .bfh__icon--search,
	.bfh .bookfolino-header-burger.bfh__burger {
		display: inline-flex !important;
	}

	/* Strona główna: lupa pojawia się razem z wyszukiwarką (po przewinięciu hero). */
	.bfh--front .bfh__icon--search {
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.2s ease, visibility 0.2s;
	}
	.bfh--front.bfh--show-search .bfh__icon--search {
		opacity: 1;
		visibility: visible;
	}

	.bfs-cols {
		grid-template-columns: 1fr;
	}

	.bfs-panel {
		min-width: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bfh__search,
	.bfh__chevron,
	.bfh--front .bfh__icon--search {
		transition: none;
	}
}

/* Licznik ulubionych na serduszku (10.2026). */
.bfh__icon--fav {
	position: relative;
}

.bfh__badge {
	position: absolute;
	top: 4px;
	right: 2px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	box-sizing: border-box;
	border-radius: 999px;
	background: #4F39F6;
	color: #fff;
	font: 700 11px/18px Inter, system-ui, sans-serif;
	text-align: center;
	pointer-events: none;
}

.bfh__badge[hidden] {
	display: none;
}

.bfh__badge.is-bump {
	animation: bfh-bump 0.45s ease;
}

@keyframes bfh-bump {
	0% { transform: scale(1); }
	40% { transform: scale(1.35); }
	100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.bfh__badge.is-bump {
		animation: none;
	}
}
