/* ============================================================
   FTEX — компакт-панель при скролле + живой поиск по курсам.
   Появляется вместо обычного хедера после ~140px прокрутки.
   Токены совпадают с course-design-system.css.
   ============================================================ */

/* Токены — на :root, потому что .ftex-bar__menu лежит ВНЕ .ftex-bar
   и иначе не видит переменные (кнопка «Войти» оставалась без заливки). */
:root {
  --fb-navy: var(--ftx-navy,#14285C);
  --fb-orange: var(--ftx-accent-bright,#FF6A2C);
  --fb-text: var(--ftx-text,#5A6478);
  --fb-muted: var(--ftx-muted,#8A93A8);
  --fb-pill: var(--ftx-pill,#EDF0F6);
  --fb-ease:   cubic-bezier(0.23, 1, 0.32, 1);
}

.ftex-bar {
  position: fixed;
  top: var(--fb-offset, 0px);   /* админ-бар WP; у посетителей 0 */
  left: 0; right: 0;
  z-index: 10000;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  box-sizing: border-box;

  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid rgba(232, 119, 34, 0.13);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.07);

  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
  transition: opacity .38s var(--fb-ease), transform .45s var(--fb-ease);
}

body.fx-scrolled .ftex-bar { opacity: 1; transform: none; pointer-events: auto; }

/* Обычный хедер уезжает вверх. Место он занимать продолжает (sticky), поэтому скачка нет. */
body.fx-scrolled #site-header {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
  transition: opacity .30s var(--fb-ease), transform .40s var(--fb-ease);
}
#site-header { transition: opacity .30s var(--fb-ease), transform .40s var(--fb-ease); }

@media (prefers-reduced-motion: reduce) {
  .ftex-bar, #site-header, body.fx-scrolled #site-header { transition: none; }
}

/* ---------- Логотип ---------- */
.ftex-bar__logo { flex: 0 0 auto; display: inline-flex; align-items: center; }
.ftex-bar__logo img { display: block; height: 30px; width: auto; }

/* ---------- Поиск ---------- */
.ftex-bar__search { position: relative; flex: 1 1 auto; max-width: 560px; }

.ftex-bar__field {
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 16px;
  background: var(--fb-pill);
  border: 1.5px solid transparent;
  border-radius: 999px;
  transition: background .25s var(--fb-ease), border-color .25s var(--fb-ease), box-shadow .25s var(--fb-ease);
}
.ftex-bar__search.is-open .ftex-bar__field,
.ftex-bar__field:focus-within {
  background: #fff;
  border-color: var(--fb-navy);
  box-shadow: 0 4px 18px rgba(20, 40, 92, 0.10);
}
.ftex-bar__field svg { flex: 0 0 auto; color: var(--fb-muted); }

.ftex-bar input.ftex-bar__input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; background: transparent;
  box-shadow: none; border-radius: 0;
  padding: 0; margin: 0; height: auto;
  font: inherit; font-size: 15px; color: var(--fb-navy);
}
.ftex-bar input.ftex-bar__input:focus { border: 0; outline: 0; box-shadow: none; }
.ftex-bar__input::placeholder { color: var(--fb-muted); }
/* WebKit рисует собственный крестик в type=search — он дублирует наш .ftex-bar__clear */
.ftex-bar__input::-webkit-search-cancel-button,
.ftex-bar__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }

.ftex-bar__clear {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: var(--fb-muted); line-height: 0; padding: 4px; border-radius: 50%;
}
.ftex-bar__clear:hover { color: var(--fb-navy); background: transparent !important; }
.ftex-bar__clear[hidden] { display: none; }

/* ---------- Выпадающие подсказки ---------- */
.ftex-bar__drop {
  position: absolute; top: calc(100% + 10px); left: 0; right: 0;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(20, 40, 92, 0.16);
  padding: 10px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .22s var(--fb-ease), transform .22s var(--fb-ease);
}
.ftex-bar__search.is-open .ftex-bar__drop { opacity: 1; transform: none; pointer-events: auto; }
.ftex-bar__drop[hidden] { display: none; }

.ftex-bar__opt {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 12px; border-radius: 12px;
  text-decoration: none; color: var(--fb-navy);
  cursor: pointer;
}
.ftex-bar__opt:hover, .ftex-bar__opt.is-active { background: #F4F6FA; }
.ftex-bar__opt b { color: var(--fb-navy); font-weight: 700; }

.ftex-bar__thumb { flex: 0 0 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--fb-pill); }
.ftex-bar__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.ftex-bar__ico {
  flex: 0 0 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--fb-muted);
}

.ftex-bar__txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ftex-bar__title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.ftex-bar__note { font-size: 12.5px; color: var(--fb-muted); }

.ftex-bar__all {
  display: block; margin: 8px 12px 4px; padding: 11px 0;
  text-align: center; text-decoration: none;
  color: var(--fb-navy); font-weight: 700; font-size: 13.5px; letter-spacing: .02em;
  border: 1.5px solid rgba(22, 38, 94, 0.22); border-radius: 999px;
  transition: border-color .2s var(--fb-ease), background .2s var(--fb-ease);
}
.ftex-bar__all:hover { border-color: var(--fb-navy); background: #F4F6FA; }

.ftex-bar__empty { padding: 18px 14px; color: var(--fb-text); font-size: 14px; }

/* ---------- Телефон и CTA ---------- */
.ftex-bar__spacer { flex: 1 1 auto; }

.ftex-bar__phone {
  flex: 0 0 auto; text-decoration: none;
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px;
  color: var(--fb-navy); white-space: nowrap;
  transition: color .2s var(--fb-ease);
}
.ftex-bar__phone-num   { font-weight: 700; font-size: 15px; line-height: 1.2; }
.ftex-bar__phone-hours { font-weight: 500; font-size: 11px; letter-spacing: .01em; color: var(--fb-muted); line-height: 1.2; }
.ftex-bar__phone:hover .ftex-bar__phone-num { color: var(--fb-navy); }

.ftex-bar__cta {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 26px;
  background: var(--fb-navy); color: #fff !important;
  border: 0; border-radius: 24px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14px; letter-spacing: .02em; white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 3px 14px rgba(22, 38, 94, 0.32);
  transition: background .22s var(--fb-ease), box-shadow .22s var(--fb-ease), transform .22s var(--fb-ease);
}
.ftex-bar__cta:hover { background: #101b45; box-shadow: 0 6px 20px rgba(22, 38, 94, 0.45); transform: translateY(-1px); }

/* ---------- Мобильные элементы ---------- */
/* Тема hello-elementor задаёт свои правила для button — держим специфичность выше одного класса */
.ftex-bar .ftex-bar__burger { display: none; }

.ftex-bar .ftex-bar__burger {
  flex: 0 0 auto; width: 40px; height: 40px; padding: 0;
  border: 0; background: transparent !important; cursor: pointer;
  color: var(--fb-navy);
  align-items: center; justify-content: center;
}
.ftex-bar__burger span {
  display: block; position: relative; width: 20px; height: 2px; border-radius: 2px; background: currentColor;
  transition: background .2s var(--fb-ease);
}
.ftex-bar__burger span::before, .ftex-bar__burger span::after {
  content: ''; position: absolute; left: 0; width: 20px; height: 2px; border-radius: 2px; background: currentColor;
  transition: transform .28s var(--fb-ease), top .28s var(--fb-ease);
}
.ftex-bar__burger span::before { top: -6px; }
.ftex-bar__burger span::after  { top: 6px; }
body.fx-menu-open .ftex-bar__burger span { background: transparent; }
body.fx-menu-open .ftex-bar__burger span::before { top: 0; transform: rotate(45deg); }
body.fx-menu-open .ftex-bar__burger span::after  { top: 0; transform: rotate(-45deg); }

/* Панель мобильного меню бара */
.ftex-bar__menu {
  position: fixed; top: calc(var(--fb-offset, 0px) + 56px); left: 0; right: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.14);
  padding: 14px 16px 20px;
  overflow: visible;
  z-index: 9999;
  opacity: 0; transform: translateY(-10px); pointer-events: none;
  transition: opacity .28s var(--fb-ease), transform .32s var(--fb-ease);
}
body.fx-menu-open .ftex-bar__menu { opacity: 1; transform: none; pointer-events: auto; }
.ftex-bar__menu ul { list-style: none; margin: 0; padding: 0; }
.ftex-bar__menu li { margin: 0; }

/* Строка 1: «Войти» + телефон. Стоит НАД чипами, чтобы карточка подменю её не перекрывала. */
.ftex-bar__menu-top { display: flex; gap: 12px; align-items: center; margin: 0 0 14px; }
.ftex-bar__menu-top .ftex-bar__cta { flex: 0 0 auto; }
.ftex-bar__menu-top .ftex-bar__phone { align-items: flex-start; }

/* Строка 2: чипы верхнего уровня — геометрия 1:1 с мобильным меню темы */
.ftex-bar__chips { position: relative; display: flex; gap: 8px; }
.ftex-bar__chips > li { flex: 1 1 0; min-width: 0; position: static; }

.ftex-bar__chips > li > a {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  box-sizing: border-box;
  height: 44px; padding: 0 6px;
  border: 1.5px solid var(--fb-navy); border-radius: 24px;
  background: #fff; color: #1a1a1a;
  font-size: 13px; font-weight: 600; text-decoration: none;
  box-shadow: 0 2px 10px rgba(22, 38, 94, 0.18);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .2s var(--fb-ease), color .2s var(--fb-ease);
}
.ftex-bar__chips > li > a:hover,
.ftex-bar__chips > li.is-open > a { background: rgba(22, 38, 94, 0.06); color: var(--fb-navy); }

/* «Нейросети» — фиолетовый со звёздочкой, как в меню темы */
.ftex-bar__chips > li.is-ai > a { color: #8b5cf6; }
.ftex-bar__chips > li.is-ai > a::before { content: '✦'; font-size: .75em; line-height: 1; }

/* Подменю — белая карточка под всем рядом чипов */
.ftex-bar__menu .sub-menu {
  display: none;
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 50;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(22, 38, 94, 0.25);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}
.ftex-bar__chips > li.is-open > .sub-menu { display: block; }

.ftex-bar__menu .sub-menu > li > a {
  display: block; padding: 11px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: #333; text-decoration: none;
  transition: background .2s var(--fb-ease), color .2s var(--fb-ease);
}
.ftex-bar__menu .sub-menu > li > a:hover { background: rgba(22, 38, 94, 0.08); color: var(--fb-navy); }

/* ---------- Адаптив ---------- */
@media (max-width: 1200px) {
  .ftex-bar { gap: 16px; padding: 0 18px; }
  .ftex-bar__phone { font-size: 14px; }
}

@media (max-width: 1024px) {
  .ftex-bar { height: 56px; gap: 10px; padding: 0 12px; }
  .ftex-bar__logo img { height: 24px; }
  /* button.ftex-bar__cta — иначе тема ([type=button]) перебивает display одним классом */
  .ftex-bar__phone, .ftex-bar__spacer,
  .ftex-bar button.ftex-bar__cta { display: none; }
  .ftex-bar .ftex-bar__burger { display: inline-flex; }
  .ftex-bar__menu-top .ftex-bar__cta { display: inline-flex; }
  .ftex-bar__menu-top .ftex-bar__phone { display: inline-flex; }

  .ftex-bar__search { max-width: none; }
  .ftex-bar__field { height: 38px; padding: 0 12px; }
  .ftex-bar__input { font-size: 16px; } /* iOS не зумит поле от 16px */

  .ftex-bar__drop {
    position: fixed; top: calc(var(--fb-offset, 0px) + 56px); left: 8px; right: 8px;
    border-radius: 16px; max-height: calc(100vh - var(--fb-offset, 0px) - 76px);
  }
  .ftex-bar__thumb, .ftex-bar__ico { flex-basis: 38px; height: 38px; }
  .ftex-bar__title { font-size: 14.5px; }
}

/* Пока открыто мобильное меню — прячем выпадашку поиска */
body.fx-menu-open .ftex-bar__drop { display: none; }

/* На десктопе панели меню нет вовсе (иначе она «зависает» при ресайзе с мобильной ширины) */
@media (min-width: 1025px) {
  .ftex-bar__menu { display: none; }
}

/* ============================================================
   Тема hello-elementor красит ЛЮБОЙ [type="button"]:
   background: transparent; border: 1px solid #CC3366; color: #CC3366
   Специфичность у [type=button] такая же, как у одного класса, поэтому
   перебиваем тегом+классом внутри .ftex-bar (0,2,1).
   ============================================================ */
.ftex-bar button.ftex-bar__cta {
  background: var(--fb-navy); border: 0; color: #fff;
  border-radius: 24px;          /* тема ставит 3px */
  height: 40px; padding: 0 26px; /* тема ставит 8px 16px */
  box-shadow: 0 3px 14px rgba(22, 38, 94, 0.32);
}
.ftex-bar button.ftex-bar__cta:hover,
.ftex-bar button.ftex-bar__cta:focus {
  background: #101b45; border: 0; color: #fff;
  box-shadow: 0 6px 20px rgba(22, 38, 94, 0.45);
}

.ftex-bar button.ftex-bar__clear,
.ftex-bar button.ftex-bar__clear:hover,
.ftex-bar button.ftex-bar__clear:focus {
  background: transparent; border: 0; width: auto; height: auto;
}
.ftex-bar button.ftex-bar__clear { color: var(--fb-muted); }
.ftex-bar button.ftex-bar__clear:hover { color: var(--fb-navy); }

.ftex-bar button.ftex-bar__burger,
.ftex-bar button.ftex-bar__burger:hover,
.ftex-bar button.ftex-bar__burger:focus {
  background: transparent; border: 0; color: var(--fb-navy);
}
