/*
  Flygen — header & navigation. ONE stylesheet for the homepage (public/index.html) and the Next pages
  (src/app/layout.tsx), with public/flygen-header.js as its behaviour, so both stay identical.

  STATE MOVES. STRUCTURE STAYS CONTROLLED.
  - The header's box never changes (85px, fixed): the hero graphic avoids it as a whole, so it must not resize.
    Scrolled, only its surface compacts (transforms), never its layout.
  - One thin cobalt line carries every state (active page, hover, open menu). One line at a time: the previous
    one retracts, then the next grows left → right with a brief light at its leading edge, then it is still.
  - Nav is typographic; the "Let's talk" pill is the only tactile element.
  - Reduced motion: every state still works, nothing travels.
*/

/* ── the line (shared by nav, industries rows, language, mobile menu) ── */
[data-line] { position: relative; }
[data-line]::after,
[data-line]::before { content: ""; position: absolute; left: 0; right: 0; bottom: var(--ln-y, 2px); height: 1px; pointer-events: none; }
[data-line]::after { background: var(--ln-c, #2146D8); clip-path: inset(0 100% 0 0); }
/* the leading edge: a tiny concentration of light that rides the growing edge, then resolves */
[data-line]::before { z-index: 1; opacity: 0; background: linear-gradient(90deg, rgba(178,199,248,0) calc(100% - 22px), var(--ln-g, #7E98F6) calc(100% - 4px), var(--ln-g2, #D6E0FC) 100%); }
[data-ln="in"]::after, [data-ln="on"]::after { clip-path: inset(0 0 0 0); }
[data-ln="in"]::after { transition: clip-path .24s cubic-bezier(.16,.84,.24,1); }
[data-ln="in"]::before { animation: fg-ln-glint .4s both; }
[data-ln="out"]::after { clip-path: inset(0 0 0 100%); transition: clip-path .12s cubic-bezier(.55,0,.8,.3); }
@keyframes fg-ln-glint {
  0% { opacity: 1; transform: translateX(calc(-100% + 22px)); animation-timing-function: cubic-bezier(.16,.84,.24,1); }
  60% { opacity: 1; transform: translateX(0); animation-timing-function: ease-out; }
  100% { opacity: 0; transform: translateX(0); }
}

/* ── header: fixed, 85px box that never changes ── */
[data-hd] { position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 85px; pointer-events: none; color: #121219; font-size: clamp(15px, 1.12vw, 16.5px); }
/* surface: none at the top (the page itself), a quiet legibility layer once scrolled, solid while a menu is open */
[data-hd]::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 85px; transform-origin: 0 0; pointer-events: none;
  background: rgba(251,250,246,.88); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); opacity: 0;
  transition: opacity .36s cubic-bezier(.16,.84,.24,1), transform .36s cubic-bezier(.16,.84,.24,1), background-color .3s ease; }
[data-hd]::after { content: ""; position: absolute; left: 0; right: 0; top: 84px; height: 1px; background: rgba(18,18,25,.07); opacity: 0; pointer-events: none;
  transition: opacity .36s cubic-bezier(.16,.84,.24,1), transform .36s cubic-bezier(.16,.84,.24,1); }
html[data-hd-scrolled] [data-hd]::before { opacity: 1; transform: scaleY(.882); }
html[data-hd-scrolled] [data-hd]::after { opacity: 1; transform: translateY(-10px); }
html[data-hd-open] [data-hd]::before { opacity: 1; background-color: #FBFAF6; }
html:is([data-hd-open="services"], [data-hd-open="industries"]) [data-hd]::after { opacity: 0; }

[data-hd-bar] { position: static; max-width: 1560px; height: 84px; margin: 0 auto; padding: 0 clamp(20px,4.4vw,68px);
  display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; column-gap: 32px; }
/* the header box itself lets clicks through (it is taller than the compact bar); everything in it takes them */
[data-hd-logo], [data-hd-nav], [data-hd-item], [data-hd-end], [data-burger] { pointer-events: auto; }
[data-hd-logo], [data-hd-item], [data-hd-end] { transition: transform .36s cubic-bezier(.16,.84,.24,1); }
html[data-hd-scrolled] :is([data-hd-logo], [data-hd-nav] [data-hd-item], [data-hd-end]) { transform: translateY(-5px); }
[data-hd-logo] { position: relative; justify-self: start; display: flex; align-items: center; }
[data-hd-logo] img { height: 30px; width: auto; display: block; }
[data-hd-logo]:focus-visible { outline: 1px solid #2146D8; outline-offset: 6px; }

/* primary nav: plain type, centred on the grid */
[data-hd-nav] { display: flex; align-items: center; gap: 38px; }
[data-hd-item] { all: unset; pointer-events: auto; box-sizing: border-box; position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 9px 0; line-height: 1; font: inherit; color: #121219; cursor: pointer; --ln-y: 2px;
  transition: color .18s ease, transform .36s cubic-bezier(.16,.84,.24,1); -webkit-tap-highlight-color: transparent; }
[data-hd-item]:hover, [data-hd-item]:focus-visible, [data-hd-item][data-on], [data-hd-item][aria-current="page"], [data-hd-item][aria-expanded="true"] { color: #2146D8; }
[data-hd-item]:focus-visible { outline: 1px solid #2146D8; outline-offset: 5px; }
[data-hd-chev] { display: flex; color: #5E5C68; transition: color .18s ease; }
[data-hd-item]:hover [data-hd-chev], [data-hd-item][aria-expanded="true"] [data-hd-chev] { color: currentColor; }
/* before the script runs (or without it): the current page is marked statically */
html:not([data-hd-ready]) [data-hd-item][aria-current="page"]::after { clip-path: inset(0 0 0 0); }

[data-hd-end] { justify-self: end; position: relative; display: flex; align-items: center; gap: 26px; }

/* ── Services / Industries: the header expands downward (no card, no shadow); one pattern, one menu open at a time ── */
[data-hd-drop] { display: contents; }
[data-hd-mega] { position: absolute; left: 0; right: 0; top: 84px; pointer-events: none; visibility: hidden;
  background: #FBFAF6; border-bottom: 1px solid rgba(18,18,25,.07);
  clip-path: inset(0 0 100% 0); transition: clip-path .28s cubic-bezier(.4,0,.2,1), visibility 0s linear .28s; }
html[data-hd-scrolled] [data-hd-mega] { transform: translateY(-10px); }
html[data-hd-scrolled] [data-hd-lang-panel] { transform: translateY(-5px); }
html[data-hd-open="services"] [data-hd-mega="services"], html[data-hd-open="industries"] [data-hd-mega="industries"] { visibility: visible; pointer-events: auto; clip-path: inset(0 0 -1px 0);
  transition: clip-path .42s cubic-bezier(.16,.84,.24,1), visibility 0s; }
[data-hd-mega-in] { max-width: 1560px; margin: 0 auto; padding: clamp(26px,2.8vw,40px) clamp(20px,4.4vw,68px) clamp(34px,3.6vw,52px);
  display: grid; grid-template-columns: minmax(0,1fr) var(--hd-nav-w, 340px) minmax(0,1fr); column-gap: 32px; align-items: start;
  opacity: 0; transform: translateY(-6px); transition: opacity .16s ease, transform .28s cubic-bezier(.4,0,.2,1); }
html[data-hd-open="services"] [data-hd-mega="services"] [data-hd-mega-in], html[data-hd-open="industries"] [data-hd-mega="industries"] [data-hd-mega-in] { opacity: 1; transform: none; transition: opacity .3s ease .06s, transform .42s cubic-bezier(.16,.84,.24,1) .04s; }
[data-hd-mega-label] { padding-top: 12px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #5E5C68; }
[data-hd-list] { display: flex; flex-direction: column; align-items: flex-start; }
[data-hd-row] { display: inline-block; padding: 7px 0 9px; white-space: nowrap; font-size: clamp(22px,2vw,30px); line-height: 1.1; letter-spacing: -.028em; color: #121219; --ln-y: 3px; transition: color .2s ease; }
[data-hd-list][data-hot] [data-hd-row] { color: #8A8894; }
[data-hd-list] [data-hd-row][data-hot], [data-hd-row]:focus-visible { color: #2146D8; }
[data-hd-row]:focus-visible { outline: 1px solid #2146D8; outline-offset: 4px; }
/* "All services": the way to the overview, quieter than the services themselves */
[data-hd-row][data-hd-all] { margin-top: 14px; padding: 6px 0 8px; font-size: clamp(15px, 1.12vw, 16.5px); letter-spacing: 0; line-height: 1.2; --ln-y: 2px; }

/* the page behind an open menu: barely de-emphasised; a click on it closes the menu */
[data-hd-scrim] { position: absolute; left: 0; right: 0; top: 0; height: 100vh; z-index: -1; background: rgba(6,16,47,.07); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
html:is([data-hd-open="services"], [data-hd-open="industries"]) [data-hd-scrim] { opacity: 1; pointer-events: auto; }

/* ── language: understated text menu ── */
[data-hd-lang] { position: relative; }
[data-hd-lang] [data-hd-item] { gap: 6px; }
[data-hd-lang-panel] { position: absolute; top: calc(50% + 42px); right: -20px; min-width: 150px; padding: 12px 20px 14px; background: #FBFAF6; border: 1px solid rgba(18,18,25,.07); border-top: 0;
  visibility: hidden; pointer-events: none; clip-path: inset(0 0 100% 0); transition: clip-path .22s cubic-bezier(.4,0,.2,1), visibility 0s linear .22s; }
html[data-hd-open="lang"] [data-hd-lang-panel] { visibility: visible; pointer-events: auto; clip-path: inset(0 -1px -1px -1px); transition: clip-path .32s cubic-bezier(.16,.84,.24,1), visibility 0s; }
[data-hd-lang-panel] > a { display: block; width: fit-content; padding: 7px 0; font-size: 15px; line-height: 1.1; color: #121219; --ln-y: 3px; transition: color .18s ease; }
[data-hd-lang-panel] > a:hover, [data-hd-lang-panel] > a:focus-visible, [data-hd-lang-panel] > a[aria-current] { color: #2146D8; }
[data-hd-lang-panel] > a:focus-visible { outline: 1px solid #2146D8; outline-offset: 3px; }
[data-hd-lang-panel] > a[aria-current]::after { clip-path: inset(0 0 0 0); }

/* ── Let's talk: the one tactile element (current pill, a touch more expressive on hover) ── */
[data-hd-cta] { display: inline-flex; align-items: center; line-height: 1; gap: 16px; height: 50px; padding: 0 7px 0 26px; background: #121219; color: #FAF9F5; border-radius: 999px; font-size: clamp(15px, 1.12vw, 16px);
  transition: background-color .32s cubic-bezier(.16,.84,.24,1), color .32s ease; }
[data-hd-cta]:hover, [data-hd-cta]:focus-visible { background: #1C39B0; color: #FFFFFF; }
[data-hd-cta]:focus-visible { outline: 1px solid #2146D8; outline-offset: 3px; }
[data-hd-cta] > span:first-child { display: flex; align-items: center; line-height: 1; padding-bottom: 1px; }
[data-hd-cta] em { font-size: 1.1em; line-height: 1; }
[data-hd-cta] > [data-fly] { width: 36px; height: 36px; border-radius: 999px; background: #C9B8FF; color: #2146D8; display: flex; align-items: center; justify-content: center; line-height: 1; font-size: 14px; transition: background-color .32s ease; }
[data-hd-cta]:hover > [data-fly] { background: #D6C9FF; }

/* ── mobile & tablet (<1024px): logo left, trigger right; a full-height editorial menu ── */
[data-burger], [data-mmenu] { display: none; }
@media (max-width: 1023px) {
  [data-hd-bar] { grid-template-columns: auto minmax(0,1fr); }
  [data-hd-nav], [data-hd-lang], [data-hd-mega], [data-hd-scrim] { display: none !important; }
  [data-burger], [data-mm-close] { all: unset; pointer-events: auto; box-sizing: border-box; display: inline-flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 7px; width: 44px; height: 44px; margin-right: -10px; padding: 0 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  /* the icon: two lines drawn as tapered hero blades, the lower one shorter */
  [data-burger] svg { display: block; width: 24px; height: 12px; fill: #121219; }
  [data-burger] svg polygon:last-child { transform-box: fill-box; transform-origin: 100% 50%; transition: transform .22s cubic-bezier(.16,.84,.24,1); }
  [data-burger]:hover svg polygon:last-child { transform: scaleX(1.5); }
  [data-burger]:focus-visible, [data-mm-close]:focus-visible { outline: 1px solid #2146D8; outline-offset: 2px; }
  [data-mm-close]:focus-visible { outline-color: #C9B8FF; }
  [data-mm-close] > span { display: block; width: 24px; height: 1.5px; background: #F3F4FA; }
  [data-mm-close] > span:first-child { transform: translateY(4.25px) rotate(45deg); }
  [data-mm-close] > span:last-child { transform: translateY(-4.25px) rotate(-45deg); }

  [data-mmenu] { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; background: #06102F; color: #F3F4FA; padding: 0 clamp(20px,4.4vw,68px) clamp(28px,6vw,48px); overflow-y: auto; overscroll-behavior: contain;
    visibility: hidden; clip-path: inset(0 0 100% 0); transition: clip-path .46s cubic-bezier(.4,0,.2,1) .08s, visibility 0s linear .54s; }
  html[data-menu-open] [data-mmenu] { visibility: visible; clip-path: inset(0 0 0 0); transition: clip-path .56s cubic-bezier(.22,1,.36,1), visibility 0s; }
  [data-mm-top] { flex: none; height: 84px; display: flex; align-items: center; justify-content: space-between; }
  [data-mm-top] img { height: 28px; width: auto; display: block; }
  [data-mm-top] > a:focus-visible { outline: 1px solid #C9B8FF; outline-offset: 6px; }

  [data-mm-nav] { display: flex; flex-direction: column; align-items: flex-start; gap: clamp(4px,1.2vw,10px); margin-top: clamp(28px,8vh,72px); }
  [data-mm-item] { all: unset; box-sizing: border-box; position: relative; display: inline-flex; align-items: baseline; gap: 14px; cursor: pointer; padding: 2px 0 8px;
    color: #F3F4FA; font-family: inherit; font-size: clamp(36px,8.4vw,58px); line-height: 1.08; letter-spacing: -.035em; --ln-c: #C9B8FF; --ln-g: #F3F4FA; --ln-g2: #FFFFFF; --ln-y: 4px;
    transition: color .2s ease; -webkit-tap-highlight-color: transparent; }
  [data-mm-item]:hover, [data-mm-item][data-on], [data-mm-item][aria-current="page"] { color: #C9B8FF; }
  [data-mm-item]:focus-visible { outline: 1px solid #C9B8FF; outline-offset: 4px; }
  /* Services and Industries open inline: a quiet +/− in the type's own colour, no rotation */
  [data-mm-sign] { position: relative; width: 14px; height: 14px; flex: none; align-self: center; margin-top: 4px; opacity: .6; }
  [data-mm-sign]::before, [data-mm-sign]::after { content: ""; position: absolute; left: 0; top: 50%; width: 14px; height: 1.5px; margin-top: -.75px; background: currentColor; }
  [data-mm-sign]::after { transform: rotate(90deg); transition: opacity .2s ease; }
  [aria-expanded="true"] > [data-mm-sign]::after { opacity: 0; }
  [data-mm-sub] { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .36s cubic-bezier(.16,.84,.24,1), visibility 0s linear .36s; }
  [data-mm-ind][data-open] [data-mm-sub] { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows .42s cubic-bezier(.16,.84,.24,1), visibility 0s; }
  [data-mm-sub] > div { min-height: 0; overflow: hidden; }
  [data-mm-sub] ul { list-style: none; margin: 0; padding: 6px 0 16px clamp(18px,4vw,28px); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  [data-mm-sub] a { position: relative; display: inline-block; padding: 5px 0 7px; font-size: clamp(17px,3.6vw,20px); letter-spacing: -.01em; color: rgba(243,244,250,.72); --ln-c: #C9B8FF; --ln-g: #F3F4FA; --ln-g2: #FFFFFF; --ln-y: 2px;
    opacity: 0; transform: translateY(-4px); transition: color .2s ease, opacity .16s ease, transform .2s ease; }
  [data-mm-ind][data-open] [data-mm-sub] a { opacity: 1; transform: none; transition: color .2s ease, opacity .3s ease, transform .42s cubic-bezier(.16,.84,.24,1); }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(2) a { transition-delay: 0s, .04s, .04s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(3) a { transition-delay: 0s, .08s, .08s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(4) a { transition-delay: 0s, .12s, .12s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(5) a { transition-delay: 0s, .16s, .16s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(6) a { transition-delay: 0s, .2s, .2s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(7) a { transition-delay: 0s, .24s, .24s; }
  [data-mm-ind][data-open] [data-mm-sub] li:nth-child(8) a { transition-delay: 0s, .28s, .28s; }
  [data-mm-sub] a:hover, [data-mm-sub] a:focus-visible { color: #C9B8FF; }
  [data-mm-sub] a:focus-visible { outline: 1px solid #C9B8FF; outline-offset: 3px; }

  [data-mm-foot] { margin-top: auto; padding-top: clamp(40px,8vh,72px); display: flex; flex-wrap: wrap; align-items: center; gap: 22px 28px; }
  [data-mm-lang] { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 20px; font-size: 12px; letter-spacing: .2em; color: rgba(243,244,250,.56); }
  [data-mm-lang] > a { position: relative; padding: 4px 0 6px; --ln-c: #C9B8FF; --ln-y: 0px; transition: color .2s ease; }
  [data-mm-lang] > a:hover, [data-mm-lang] > a[aria-current] { color: #F3F4FA; }
  [data-mm-lang] > a[aria-current]::after { clip-path: inset(0 0 0 0); }
  [data-mm-lang] > a:focus-visible { outline: 1px solid #C9B8FF; outline-offset: 3px; }
  [data-mm-time] { margin-left: auto; white-space: nowrap; }
  [data-mm-cta] { display: inline-flex; align-items: center; gap: 16px; height: 52px; padding: 0 6px 0 26px; border-radius: 999px; background: #F3F7FF; color: #0B1948; font-size: 16px; transition: background-color .32s cubic-bezier(.16,.84,.24,1); }
  [data-mm-cta]:hover, [data-mm-cta]:focus-visible { background: #C9B8FF; color: #0B1948; }
  [data-mm-cta]:focus-visible { outline: 1px solid #C9B8FF; outline-offset: 3px; }
  [data-mm-cta] em { font-size: 1.1em; }
  [data-mm-cta] > [data-fly] { width: 40px; height: 40px; border-radius: 999px; background: #C9B8FF; color: #2146D8; display: flex; align-items: center; justify-content: center; }
  [data-mm-mail] { font-size: 15px; color: rgba(243,244,250,.8); }
  [data-mm-mail]:hover, [data-mm-mail]:focus-visible { color: #C9B8FF; }

  /* opening: the panel wipes down, then the lines rise in one after another (50ms apart); closing reverses, faster */
  :is([data-mm-nav] > *, [data-mm-foot]) { opacity: 0; transform: translateY(12px); transition: opacity .18s ease, transform .22s ease; }
  html[data-menu-open] :is([data-mm-nav] > *, [data-mm-foot]) { opacity: 1; transform: none; transition: opacity .45s ease, transform .6s cubic-bezier(.22,1,.36,1); }
  html[data-menu-open] [data-mm-nav] > :nth-child(1) { transition-delay: .14s; }
  html[data-menu-open] [data-mm-nav] > :nth-child(2) { transition-delay: .19s; }
  html[data-menu-open] [data-mm-nav] > :nth-child(3) { transition-delay: .24s; }
  html[data-menu-open] [data-mm-nav] > :nth-child(4) { transition-delay: .29s; }
  html[data-menu-open] [data-mm-foot] { transition-delay: .34s; }
}
@media (max-width: 599px) { [data-hd-cta] { display: none !important; } }

/* ── reduced motion: the same states, nothing travels ── */
@media (prefers-reduced-motion: reduce) {
  [data-hd]::before, [data-hd]::after, [data-hd-logo], [data-hd-item], [data-hd-end], [data-hd-mega], [data-hd-mega-in], [data-hd-lang-panel], [data-hd-scrim],
  [data-mmenu], [data-mm-sub], [data-mm-sub] a, [data-mm-item], :is([data-mm-nav] > *, [data-mm-foot]), [data-burger] svg polygon, [data-line]::after { transition: none !important; }
  [data-line]::before { animation: none !important; opacity: 0 !important; }
  html[data-hd-scrolled] :is([data-hd-logo], [data-hd-nav] [data-hd-item], [data-hd-end]), html[data-hd-scrolled] [data-hd-mega], [data-hd-mega-in], [data-mm-sub] a, :is([data-mm-nav] > *, [data-mm-foot]) { transform: none !important; }
  [data-burger]:hover svg polygon:last-child { transform: none; }
}

/* links held back until they have content (e.g. Thinking) */
[data-hd] [hidden], [data-mmenu] [hidden], footer [hidden], #contact [hidden], [data-held] { display: none !important; }
