/* Site header, mega menu and phone menu.
   Figma «LidFly — Бренд и UI Kit 2026» → «06 · Компоненты» → «Навигация»: header 69:1875, mega menu 54:1046,
   phone menu 55:1222. Markup: scripts/lib/site-header.mjs from content/site-header/nav.config.json. Colours,
   radii and shadows are the --lf-* tokens of tokens.css; buttons take palette and size from landing-buttons.css.
   Every link stays in the server HTML; /js/mobile-nav.js only toggles state. */

/* Height of the bar, desktop and phone. Sticky rows and tables below the header dock to it. */
:root {
  --lf-header-height: 64px;
  /* One motion for the header and the section row under it: they hide and return together, with no gap. */
  --lf-header-motion: 240ms cubic-bezier(0.2, 0, 0, 1);
  --lf-sheet-motion: 200ms cubic-bezier(0.2, 0, 0, 1); /* phone menu: fades in, only its content rises 8 px */
}
/* Side gutter of the page container: 1200 px centred in 1440, narrowing to 24 px (as .lf-page-nav and the pages). */
.lf-header { --lf-header-gutter: clamp(24px, calc(50vw - 600px), 120px); }

/* Mono/Overline of the kit (column captions). Declared here, not in fonts.css: the header is its only user and
   this file is versioned by content, so a cached fonts.css cannot leave it out. The menus are hidden until
   opened, so the font files load only then. JetBrains Mono, SIL OFL 1.1 (/fonts/jetbrains-mono/OFL.txt). */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/fonts/jetbrains-mono/jetbrains-mono-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.lf-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--lf-header-height);
  color: var(--lf-text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 18px;
  -webkit-font-smoothing: antialiased;
  transition: transform var(--lf-header-motion);
}
.lf-header,
.lf-header * { box-sizing: border-box; }
/* Reset with the specificity of one class: page CSS cannot add margins, component rules below still win. */
.lf-header :where(ul, li, p, figure, figcaption) { margin: 0; padding: 0; }
.lf-header :where(ul) { list-style: none; }
.lf-header :where(a) { text-decoration: none; }
.lf-header svg { flex: 0 0 auto; }
.lf-header__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* States. Top of the page: no fill, no line. Scrolled by 1 px or more, or a menu open: Glass and a line.
   The glass is a layer behind the bar: backdrop-filter on the header itself would become the containing
   block of the fixed phone sheet. The line sits inside the 64 px. */
.lf-header::before,
.lf-header::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lf-header::before {
  inset: 0;
  z-index: -1;
  background: var(--lf-bg-glass);
  box-shadow: var(--lf-shadow-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lf-header::after {
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--lf-border-subtle);
}
.lf-header:is([data-scrolled], [data-panel-open])::before,
.lf-header:is([data-scrolled], [data-panel-open])::after { opacity: 1; }

/* Bar: logo · menu · actions, 32 between them, inside the page container (x=120…1320 at 1440). The bar is the
   positioning box of the mega menu, so the menu starts at the container edge. */
.lf-header__bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--lf-header-gutter);
}
.lf-header .lf-header__logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  border-radius: var(--lf-radius-sm);
}
.lf-header__logo img { display: block; width: auto; height: 32px; }
.lf-header__nav { flex: 1 1 auto; min-width: 0; }
.lf-header__menu { display: flex; align-items: center; gap: 2px; }

/* Menu items: pills, Label/Header 15/20 Medium; a menu item has a 16 px chevron */
.lf-header .lf-header__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--lf-radius-full);
  background: transparent;
  color: var(--lf-text-primary);
  font: 500 15px/20px var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lf-header button.lf-header__trigger { padding-right: 8px; }
.lf-header__chevron { width: 16px; height: 16px; color: inherit; transition: transform 0.2s ease; }
.lf-header .lf-header__trigger:hover,
.lf-header .lf-header__trigger[aria-expanded="true"] { background: var(--lf-bg-hover); }
.lf-header__trigger[aria-expanded="true"] .lf-header__chevron { transform: rotate(180deg); }
/* Current section: 2 px --lf-action-primary under the text of the item (not under the chevron). */
@media (min-width: 1120px) {
  .lf-header .lf-header__trigger.is-current {
    text-decoration: underline 2px var(--lf-action-primary);
    text-decoration-skip-ink: none;
    text-underline-offset: 6px;
  }
}

/* Focus of every interactive element: a surface gap and the focus colour. */
.lf-header :is(a, button):focus { outline: none; }
.lf-header :is(a, button):focus-visible { outline: none; box-shadow: var(--lf-focus-ring); }

/* Actions: Войти (Ghost) · Начать бесплатно (Primary), button size Header, as a pair 8 apart, pushed right: the free space of the
   bar lies between the menu and the pair. Phone: Войти (Gray S) · menu button. */
.lf-header__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; margin-left: auto; }
.lf-header__cta,
.lf-header__login { white-space: nowrap; }
.lf-header .lf-header__burger {
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--lf-radius-full);
  background: transparent;
  color: var(--lf-text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .lf-header .lf-header__burger:hover { background: var(--lf-bg-hover); }
}
.lf-header__burger svg { width: 20px; height: 20px; transition: opacity var(--lf-sheet-motion); }
.lf-header__burger-close { position: absolute; opacity: 0; } /* lies on the menu icon: they cross-fade */
.lf-header[data-menu-open] .lf-header__burger-open { opacity: 0; }
.lf-header[data-menu-open] .lf-header__burger-close { opacity: 1; }

/* Mega menu: 8 below the header, left edge on the edge of the page container, as wide as its content */
.lf-header__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: var(--lf-header-gutter);
  display: none;
  flex-direction: column;
  gap: 4px;
  max-width: calc(100% - 2 * var(--lf-header-gutter));
  padding: 8px;
  border: 1px solid var(--lf-border-subtle);
  border-radius: var(--lf-radius-xl);
  background: var(--lf-bg-surface);
  box-shadow: var(--lf-shadow-elevation-3);
  color: var(--lf-text-primary);
  cursor: auto;
}
.lf-header__item[data-open] > .lf-header__panel { display: flex; }
/* The pointer crosses the 8 px gap between the header and the panel without leaving the item (hover opening). */
.lf-header__panel::before { content: ""; position: absolute; right: 0; bottom: 100%; left: 0; height: 9px; }
/* «Возможности» spans the page container (both edges on it); its three columns share the width equally. */
.lf-header__panel--features { right: var(--lf-header-gutter); }
.lf-header__panel--features .lf-header__columns { flex: 1 1 0; min-width: min-content; }
/* Every description stays on one line: on narrow screens the intro gives way first, not the columns. */
.lf-header__panel--features .lf-header__column { flex: 1 1 0; width: auto; min-width: min-content; }
.lf-header__panel-body { display: flex; align-items: stretch; gap: 8px; min-width: 0; }

/* «Возможности»: intro with the example dialog */
.lf-header__intro {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 12px;
  width: 296px;
  min-width: 200px;
  padding: 20px;
  border-radius: var(--lf-radius-lg);
  background: var(--lf-bg-subtle);
}
.lf-header .lf-header__intro-title { font-size: 18px; font-weight: 600; line-height: 24px; letter-spacing: -0.01em; }
.lf-header .lf-header__intro-text { color: var(--lf-text-secondary); font-size: 15px; line-height: 22px; }
.lf-header__dialog {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: var(--lf-radius-md);
  background: var(--lf-bg-surface);
  font-size: 13px;
  line-height: 18px;
}
.lf-header__dialog figcaption { color: var(--lf-text-tertiary); }
.lf-header .lf-header__bubble { padding: 6px 10px; border-radius: var(--lf-radius-sm); background: var(--lf-bg-subtle); color: var(--lf-text-primary); }
.lf-header .lf-header__bubble--user { align-self: flex-end; background: var(--lf-bg-brand-soft); color: var(--lf-text-primary); }

/* Columns: 263 wide, 4 apart; caption in Mono/Overline */
.lf-header__columns { display: flex; flex: 0 1 auto; align-items: flex-start; gap: 4px; min-width: 0; padding: 12px 4px 8px; }
.lf-header__panel--features .lf-header__columns { padding-right: 0; padding-left: 0; }
/* An explicit width, not flex-basis: the panel takes its width from the content (max-content). */
.lf-header__column { display: flex; flex: 0 1 auto; flex-direction: column; gap: 2px; width: 263px; min-width: 0; }
.lf-header .lf-header__column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 0 4px 10px;
  color: var(--lf-text-tertiary);
  font-family: var(--lf-font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* Column width per section (Figma 54:1046): «Подключения» 322, «Обучение» 301. */
.lf-header__panel--connect .lf-header__column { width: 322px; }
.lf-header__panel--learn .lf-header__column { width: 301px; }
.lf-header__list { display: flex; flex-direction: column; gap: 2px; }

/* Lime badge: «Новое», «Старт 30 ноября» */
.lf-header .lf-header__badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--lf-radius-full);
  background: var(--lf-pastel-lime);
  color: var(--lf-pastel-lime-text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

/* «Mega item»: tile 36 with an icon 20, title and a one-line description */
.lf-header .lf-header__link,
.lf-header .lf-header__brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  border-radius: var(--lf-radius-md);
  color: var(--lf-text-primary);
}
.lf-header .lf-header__link-icon,
.lf-header__brand-link .lf-header__tile {
  display: flex;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--lf-radius-sm);
  background: var(--lf-bg-subtle);
  color: var(--lf-text-primary);
}
.lf-header__icon,
.lf-header__brand { display: block; width: 20px; height: 20px; }
.lf-header__link-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lf-header .lf-header__link-title { font-size: 14px; font-weight: 500; line-height: 18px; }
.lf-header .lf-header__link-desc {
  overflow: hidden;
  color: var(--lf-text-tertiary);
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lf-header .lf-header__brand-link { font-size: 14px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.lf-header :is(.lf-header__link, .lf-header__brand-link):is(:hover, [aria-current="page"]) { background: var(--lf-bg-hover); }
.lf-header :is(.lf-header__link, .lf-header__brand-link):is(:hover, [aria-current="page"]) :is(.lf-header__link-icon, .lf-header__tile) { background: var(--lf-bg-surface); }

/* Bottom strip: caption, account logos 20 apart 8, Ghost S with an arrow */
.lf-header__panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 8px 10px 16px;
  border-radius: var(--lf-radius-lg);
  background: var(--lf-bg-subtle);
}
.lf-header__tiles { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.lf-header .lf-header__tiles-label,
.lf-header .lf-header__note { color: var(--lf-text-secondary); font-size: 13px; line-height: 18px; }
.lf-header .lf-header__note { display: flex; align-items: center; gap: 8px; }
.lf-header__note-icon { width: 16px; height: 16px; }
.lf-header__tile-list { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.lf-header .lf-header__tile-link { display: flex; border-radius: 4px; }
.lf-header__tile-link .lf-header__tile { display: flex; }
.lf-header__tile-link .lf-header__brand { width: 20px; height: 20px; }
.lf-header__tile-link:hover .lf-header__brand { opacity: 0.8; }
.lf-header__more { flex: 0 0 auto; }
.lf-header__arrow { width: 16px; height: 16px; }

/* «Обучение»: promo card */
.lf-header__promo {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  padding: 20px;
  border-radius: var(--lf-radius-lg);
  background: var(--lf-bg-brand-soft);
}
.lf-header__promo-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lf-header__promo-icon { width: 24px; height: 24px; color: var(--lf-text-primary); }
.lf-header .lf-header__promo-title { font-size: 18px; font-weight: 600; line-height: 24px; letter-spacing: -0.01em; }
.lf-header .lf-header__promo-text { flex: 1 1 auto; color: var(--lf-text-secondary); font-size: 15px; line-height: 22px; }
.lf-header__promo-link { align-self: flex-start; }

.lf-header__sheet-foot { display: none; }

/* Phone and narrow windows: 64 px bar with a line, «Войти» and the menu button; the menu is a sheet over
   the whole screen with one section open at a time. */
@media (max-width: 1119.98px) {
  .lf-header { transition: transform var(--lf-header-motion), background-color var(--lf-sheet-motion); }
  .lf-header.is-hidden:not([data-menu-open]) { transform: translateY(-100%); }
  .lf-header::after { opacity: 1; }
  .lf-header[data-panel-open]:not([data-scrolled])::before { opacity: 0; }
  .lf-header[data-menu-open] { background: var(--lf-bg-canvas); }
  .lf-header[data-menu-open]::before { opacity: 0; }
  .lf-header__bar { position: static; gap: 8px; max-width: none; padding: 0 8px 0 16px; }
  .lf-header__actions > .lf-header__cta { display: none; }
  .lf-header .lf-header__burger { display: inline-flex; }

  .lf-header__nav {
    position: fixed;
    top: var(--lf-header-height);
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--lf-bg-canvas);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--lf-sheet-motion), visibility 0s linear 200ms;
  }
  /* The sheet fades in; only its content rises 8 px. The bar with the logo and the button does not move. */
  .lf-header[data-menu-open] .lf-header__nav { opacity: 1; visibility: visible; transition: opacity var(--lf-sheet-motion), visibility 0s; }
  .lf-header__menu,
  .lf-header__sheet-foot { transform: translateY(8px); transition: transform var(--lf-sheet-motion); }
  .lf-header[data-menu-open] :is(.lf-header__menu, .lf-header__sheet-foot) { transform: none; }
  .lf-header__menu { flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px; }
  .lf-header__item { border-bottom: 1px solid var(--lf-border-subtle); }
  .lf-header .lf-header__trigger,
  .lf-header button.lf-header__trigger {
    justify-content: space-between;
    width: 100%;
    min-height: 56px;
    padding: 0;
    border-radius: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
    letter-spacing: -0.01em;
  }
  .lf-header .lf-header__trigger:hover,
  .lf-header .lf-header__trigger[aria-expanded="true"] { background: transparent; }
  .lf-header .lf-header__trigger:focus-visible { border-radius: var(--lf-radius-sm); }
  .lf-header__chevron { width: 20px; height: 20px; }

  /* An open section: column captions and items as in the mega menu, full width; no intro, strip or promo. */
  .lf-header__panel {
    position: static;
    max-width: none;
    padding: 0 0 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .lf-header__item[data-open] > .lf-header__panel { display: block; }
  .lf-header__panel::before { content: none; }
  .lf-header__intro,
  .lf-header__panel-foot,
  .lf-header__promo { display: none; }
  .lf-header__panel-body,
  .lf-header__columns { flex-direction: column; align-items: stretch; gap: 4px; padding: 0; }
  .lf-header__panel--features .lf-header__columns { padding: 0; }
  .lf-header__column,
  .lf-header__panel--connect .lf-header__column,
  .lf-header__panel--learn .lf-header__column,
  .lf-header__panel--features :is(.lf-header__columns, .lf-header__column) { flex: 0 0 auto; width: auto; }

  /* Pinned foot: account logos 24 and «Начать бесплатно» (Primary L) across the sheet. */
  .lf-header__sheet-foot {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--lf-border-subtle);
    background: var(--lf-bg-canvas);
  }
  .lf-header__sheet-foot .lf-header__tiles { flex-direction: column; align-items: flex-start; gap: 12px; }
  /* Ten logos 24 in one row: 10 apart on a 390 px phone, closer on narrower ones. */
  .lf-header__sheet-foot .lf-header__tile-list { flex-wrap: nowrap; gap: clamp(4px, calc((100vw - 32px - 240px) / 9), 10px); }
  .lf-header__sheet-foot .lf-header__brand { width: 24px; height: 24px; }
  .lf-header__sheet-actions { display: flex; }
  .lf-header__sheet-actions > * { flex: 1 1 auto; }
}
/* Below 1200 px the mega menu narrows: the dialog of «Возможности» gives way to the columns. */
@media (min-width: 1120px) and (max-width: 1199.98px) {
  .lf-header__panel--features .lf-header__dialog { display: none; }
}

@media (max-width: 359.98px) {
  .lf-header__bar { padding: 0 4px 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lf-header,
  .lf-header::before,
  .lf-header::after,
  .lf-header__chevron,
  .lf-header__burger svg,
  :is(.lf-header, .lf-header[data-menu-open]) .lf-header__nav,
  :is(.lf-header__menu, .lf-header__sheet-foot) { transition: none; }
}

/* Open mobile menu locks page scroll through <body> only: with <html> left visible, the browser applies
   body overflow to the viewport. Setting it on <html> too would turn <body> (often overflow-x: hidden on
   landings) into the scroll container of the sticky header, and after a scroll the bar with the close
   button would stay above the screen. */
html.lf-header-locked body { overflow: hidden; }
