/* ==========================================================================
   fbl-header.css — хедер, поиск, wordmark (W3-header)
   Источник значений: design/ui-upgrade-blueprint.md §5.1 (+ §2–4, §6, §9);
   токены — ТОЛЬКО из style.css :root (gcid/gvid-фолбэки уже там).
   Зона: css/fbl-header.css (один писатель: W3-header). style.css / fbl-woo.css /
   fbl.js / functions.php не трогаются.
   Бан-лист §9 соблюдён: НЕТ стекла/размытия фона, НЕТ теней по умолчанию,
   НЕТ pill на primary-CTA/карточках/крупных контейнерах, НЕТ новых цветов.
   z-index масштаб (§5.7 + аудит mobile-widgets §9): хедер 9000 (ниже jump-bar
   9999 и ShareMyPost modal 10000, ниже CookieAdmin 99999); раскрытый
   поиск-контейнер на мобиле получает 10002 (W5.1) — выше ShareMyPost.
   ========================================================================== */

/* --- 0. Утилита a11y: только для скринридеров (fbl-namespace) ------------ */
.fbl-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- 1. Хедер: sticky, сплошной --surface + hairline (БЕЗ blur) ---------- */
.et-l--header .et_pb_section.fbl-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 9000;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  /* высота 72px desktop (§5.1): контент 44 (тач-таргеты) + 2 x 14 */
  min-height: 72px;
  padding-top: var(--fbl-space-12);
  padding-bottom: var(--fbl-space-12);
  display: flex;
  align-items: center;
}

/* под admin-bar: sticky не должен уезжать под него */
body.admin-bar .et-l--header .et_pb_section.fbl-header {
  top: 32px;
}

/* --- 2. Сетка 25 / 60 / 15 (§5.1) -------------------------------------- */
.et-l--header .fbl-header__inner {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

.et-l--header .fbl-header__inner > .fbl-header__brand,
.et-l--header .fbl-header__inner > .fbl-header__nav,
.et-l--header .fbl-header__inner > .fbl-header__utils {
  min-width: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.et-l--header .fbl-header__inner > .fbl-header__brand {
  flex: 0 0 25%;
  width: 25%;
  max-width: 25%;
}

.et-l--header .fbl-header__inner > .fbl-header__nav {
  flex: 0 0 60%;
  width: 60%;
  max-width: 60%;
}

.et-l--header .fbl-header__inner > .fbl-header__utils {
  flex: 0 0 15%;
  width: 15%;
  max-width: 15%;
}

/* --- 3. Wordmark (§5.1, закон §6.1: словесный знак) --------------------- */
.et-l--header .fbl-header__brand-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 96px;
  text-decoration: none;
  color: inherit;
  font-family: var(--fbl-font-display);
  font-weight: 600;
  line-height: 1.2;
}

.et-l--header .fbl-header__brand-link:hover {
  color: var(--accent-hover);
}

.et-l--header .fbl-header__brand-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- 4. Меню: одна строка, центр ячейки 60% (§5.1) ---------------------- */
.et-l--header .fbl-header__nav .et_pb_menu__wrap {
  justify-content: center;
}

.et-l--header .fbl-header__nav .et-menu {
  white-space: nowrap;
}

.et-l--header .fbl-header__nav .et-menu li a:hover {
  color: var(--accent-hover);
}

.et-l--header .fbl-header__nav .et-menu li.current-menu-item > a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.et-l--header .fbl-header__nav .et-menu li a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- 5. Поиск: компактный pill-инпут на чистой WP-форме -----------------
   Форма поиска — собственная разметка (role="search", GET /?s=), НЕ divi/search
   (латентный баг §5.1: divi/search не отдаёт серверный рендер формы).
   Вариант «всегда видимый pill-инпут» выбран заданием W3 (без JS/модалки).
   Pill — на поле ввода (не на CTA: кнопка-иконка радиус 8px). ------------- */
.et-l--header .fbl-header-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--fbl-space-4);
  width: 100%;
  max-width: 320px;
  min-height: 48px;
  margin-left: auto;
  padding: 1px 2px 1px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--fbl-radius-999);
}

.et-l--header .fbl-header-search:focus-within {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.et-l--header .fbl-header-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--fbl-font-body);
  font-size: 16px;
  line-height: 1.2;
  color: var(--text);
}

.et-l--header .fbl-header-search__input:focus {
  outline: none;
}

.et-l--header .fbl-header-search__input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* кнопка-иконка: радиус 8px (§5.1 «иконка-кнопка»), НЕ pill/CTA */
.et-l--header .fbl-header-search__submit {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--fbl-radius-8);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.et-l--header .fbl-header-search__submit:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.et-l--header .fbl-header-search__submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.et-l--header .fbl-header-search__icon {
  display: block;
  width: 20px;
  height: 20px;
}

/* --- 6. Мобильный хедер (<=980: брейкпоинт меню Divi) -------------------
   Одна строка: логотип | поиск-иконка | бургер (меню — в бургер Divi,
   логика не трогается). Поиск сворачивается в иконку 44x44 и разворачивается
   в поле на :focus-within (CSS-only, без JS/инлайна/checkbox-hack). -------- */
@media (max-width: 980px) {
  .et-l--header .et_pb_section.fbl-header {
    min-height: 64px;
    padding-top: var(--fbl-space-8);
    padding-bottom: var(--fbl-space-8);
    /* admin-bar на мобиле ниже 782px = 46px */
  }

  body.admin-bar .et-l--header .et_pb_section.fbl-header {
    top: 46px;
  }

  .et-l--header .fbl-header__inner {
    flex-wrap: nowrap;
  }

  .et-l--header .fbl-header__inner > .fbl-header__brand,
  .et-l--header .fbl-header__inner > .fbl-header__nav,
  .et-l--header .fbl-header__inner > .fbl-header__utils {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none;
    margin: 0 !important;
  }

  .et-l--header .fbl-header__brand {
    order: 1;
  }

  .et-l--header .fbl-header__utils {
    order: 2;
    margin-left: auto;
  }

  .et-l--header .fbl-header__nav {
    order: 3;
    margin-left: var(--fbl-space-8);
  }

  .et-l--header .fbl-header__brand-link {
    min-width: 0;
    min-height: 44px;
    font-size: 21px;
    white-space: nowrap;
  }

  .et-l--header .fbl-header-search {
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin-left: 0;
    padding: 0;
    gap: 0;
    justify-content: flex-end;
    /* свёрнутая иконка 44x44: обрезка обязательна; раскрытое состояние
       (:focus-within / .is-open) снимает её ниже (W5.1) */
    overflow: hidden;
    transition: width 200ms ease;
  }

  /* инпут перекрывает кнопку-лупу сверху (тач = фокус инпута, iOS-safe);
     после фокуса уезжает влево от кнопки, поле ввода разворачивается */
  .et-l--header .fbl-header-search__input {
    position: absolute;
    right: 0;
    top: 0;
    width: 44px;
    height: 44px;
    min-height: 44px;
    z-index: 2;
    padding: 0;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    transition: width 200ms ease, right 200ms ease;
  }

  .et-l--header .fbl-header-search__input::placeholder {
    color: transparent;
  }

  /* .is-open (список подсказок открыт) держит форму развёрнутой и после blur:
     тап по результату на мобильном не схлопывает поле раньше перехода
     по ссылке (W5.2 п.5). */
  .et-l--header .fbl-header-search:focus-within,
  .et-l--header .fbl-header-search.is-open {
    width: min(232px, calc(100vw - 140px));
  }

  .et-l--header .fbl-header-search:focus-within .fbl-header-search__input,
  .et-l--header .fbl-header-search.is-open .fbl-header-search__input {
    right: 42px;
    width: calc(100% - 46px);
    background: var(--surface);
    color: var(--text);
    caret-color: var(--text);
    padding: 0 12px;
  }

  .et-l--header .fbl-header-search:focus-within .fbl-header-search__input::placeholder,
  .et-l--header .fbl-header-search.is-open .fbl-header-search__input::placeholder {
    color: var(--text-muted);
  }

  /* W5.1 (2026-11-13): раскрытый поиск (фокус ИЛИ открытый список .is-open)
     не должен отсекать .fbl-live-search рамкой 44px: overflow:hidden из
     свёрнутого правила выше остаётся только свёрнутому состоянию
     (:not(:focus-within):not(.is-open)). */
  .et-l--header .fbl-header-search:focus-within,
  .et-l--header .fbl-header-search.is-open {
    overflow: visible !important;
    z-index: 10002 !important;
  }
}

@media (max-width: 479px) {
  .et-l--header .fbl-header-search:focus-within,
  .et-l--header .fbl-header-search.is-open {
    width: min(216px, calc(100vw - 132px));
  }
}

/* --- 7. Reduced-motion (обязательно в каждом новом CSS-файле, §6) ------- */
@media (prefers-reduced-motion: reduce) {
  .et-l--header .fbl-header-search,
  .et-l--header .fbl-header-search__input,
  .et-l--header .fbl-header-search__submit {
    transition: none;
  }
}


/* ==========================================================================
   Live search dropdown (2026-10-22, Gemini directive S3.4)
   js/fbl-live-search.js builds the DOM; this is the visual layer.
   z-index scale (design system 5.7): header 200 < dropdown 300.
   ========================================================================== */
.fbl-header-search,
.fbl-hero-search {
	position: relative;
}

.fbl-live-search {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 300;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--fbl-radius-12);
	box-shadow: var(--fbl-shadow-sticky);
	padding: var(--fbl-space-8);
	max-height: 60vh;
	overflow-y: auto;
}

.fbl-live-search[hidden] {
	display: none;
}

.fbl-live-search__item {
	display: flex;
	align-items: center;
	gap: var(--fbl-space-12);
	padding: var(--fbl-space-8);
	border-radius: var(--fbl-radius-8);
	text-decoration: none;
}

.fbl-live-search__item:hover,
.fbl-live-search__item.is-active {
	background: var(--accent-soft);
}

.fbl-live-search__item:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.fbl-live-search__item img {
	width: 56px;
	height: 42px;
	object-fit: cover;
	border-radius: var(--fbl-radius-4);
	flex: none;
}

.fbl-live-search__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.fbl-live-search__title {
	font-family: var(--fbl-font-body);
	font-weight: 600;
	font-size: 16px;
	line-height: 1.3;
	color: var(--text);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.fbl-live-search__item:hover .fbl-live-search__title,
.fbl-live-search__item.is-active .fbl-live-search__title {
	text-decoration: underline;
}

.fbl-live-search__meta {
	font-family: var(--fbl-font-body);
	font-size: 14px;
	letter-spacing: 0.02em;
	color: var(--text-muted);
}

.fbl-live-search__note {
	padding: var(--fbl-space-12);
	font-family: var(--fbl-font-body);
	font-size: 16px;
	color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
	.fbl-live-search {
		transition: none !important;
	}
}

/* W5.1 (2026-11-13): на телефонах (<768px) список не зажимается в ~216px
   раскрытого инпута — он фиксируется во вьюпорте под шапкой (64px) во всю
   ширину. Тень 0 8px 24px rgba(34, 48, 42, 0.12) — единственное допустимое
   исключение из запрета теней для этого выпадающего списка (задание W5). */
@media (max-width: 767px) {
	.et-l--header .fbl-header-search .fbl-live-search {
		position: fixed !important;
		top: 64px !important;
		left: 16px !important;
		right: 16px !important;
		width: calc(100vw - 32px) !important;
		max-height: calc(100vh - 96px) !important;
		overflow-y: auto !important;
		border-radius: var(--fbl-radius-8, 8px) !important;
		box-shadow: 0 8px 24px rgba(34, 48, 42, 0.12) !important;
	}
}

/* ==========================================================================
   Header column rebalance (2026-10-22, owner feedback): the search form
   lives in the 15% utils column (~180px at 1200px) and the "Search recipes…"
   placeholder was clipped. The nav only carries 4 short items, so the utils
   column grows to 25% on desktop. Base rule override: later in the file wins
   at equal specificity. Mobile (<981px) keeps the collapse-to-icon pattern.
   ========================================================================== */
@media (min-width: 981px) {
	.et-l--header .fbl-header__inner > .fbl-header__brand {
		flex: 0 0 22%;
		width: 22%;
		max-width: 22%;
	}

	.et-l--header .fbl-header__inner > .fbl-header__nav {
		flex: 0 0 53%;
		width: 53%;
		max-width: 53%;
	}

	.et-l--header .fbl-header__inner > .fbl-header__utils {
		flex: 0 0 25%;
		width: 25%;
		max-width: 25%;
	}

	.et-l--header .fbl-header-search {
		min-width: 220px;
	}
}

/* ==========================================================================
   TZ 2026-11-13 QA round 1 fixes (visual review):
   1) .fbl-hero-search rendered with UA-default input/button (inset gray
      border, 29px high). Style to design tokens: 48px targets, --border
      input, --accent CTA, 16px text (mobile zoom guard).
   2) Collapsed mobile header search (44x44 icon-only) leaked a placeholder
      sliver ("Se") right next to the brand text - transparent placeholder
      in the collapsed state.
   3) Brand/search read as one glued word at <=980px (zero gap) - 4px gap.
   ========================================================================== */
.fbl-hero-search {
	display: flex;
	flex-wrap: wrap;
	gap: var(--fbl-space-8, 8px);
	align-items: stretch;
}

.fbl-hero-search__input {
	flex: 1 1 220px;
	min-width: 0;
	height: 48px;
	padding: 0 14px;
	font-family: var(--fbl-font-body);
	font-size: 16px;
	line-height: 1.3;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--fbl-radius-4);
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
}

.fbl-hero-search__input::placeholder {
	color: var(--text-muted);
	opacity: 1;
	font-size: 14px;
}

.fbl-hero-search__input:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
	border-color: var(--accent);
}

.fbl-hero-search__submit {
	flex: 0 0 auto;
	height: 48px;
	padding: 0 22px;
	font-family: var(--fbl-font-body);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	color: var(--surface);
	background: var(--accent);
	border: 1px solid var(--accent);
	border-radius: var(--fbl-radius-8);
	cursor: pointer;
}

.fbl-hero-search__submit:hover,
.fbl-hero-search__submit:focus-visible {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

@media (max-width: 640px) {
	.fbl-hero-search__input,
	.fbl-hero-search__submit {
		flex: 1 1 100%;
	}
}

@media (max-width: 980px) {
	.et-l--header .fbl-header-search {
		margin-left: 4px;
	}

	.et-l--header .fbl-header-search:not(:focus-within):not(.is-open) .fbl-header-search__input {
		color: transparent !important;
		caret-color: transparent !important;
	}

	.et-l--header .fbl-header-search:not(:focus-within):not(.is-open) .fbl-header-search__input::placeholder {
		color: transparent !important;
	}
}

/* TZ QA round 3: the header row lost its horizontal inset on <=980px (logo
   glued to the viewport edge while content has a gutter). 16px matches the
   live-search panel inset. */
@media (max-width: 980px) {
	.et-l--header .et_pb_row_0_tb_header {
		padding-left: 16px !important;
		padding-right: 16px !important;
	}
}
