/* ==========================================================================
   FLEXIONEX — HEADER + MEGA MENU
   Variants: --transparent (over hero), --solid (default), --compact (scrolled)
   Mega menu layouts: products, industries, solutions, engineering
   ========================================================================== */

/* ── HEADER SHELL ────────────────────────────────────────────────────── */

.fx-header {
  position: sticky;
  top: 0;
  z-index: var(--fx-header-z);
  background: var(--fx-white);
  border-bottom: 1px solid var(--fx-border);
  transition:
    background-color var(--fx-dur) var(--fx-ease-in-out),
    border-color     var(--fx-dur) var(--fx-ease-in-out),
    box-shadow       var(--fx-dur) var(--fx-ease-in-out);
}

.fx-header__inner {
  display: flex;
  align-items: center;
  gap: var(--fx-s5);
  height: var(--fx-header-h-mobile);
  transition: height var(--fx-dur) var(--fx-ease-in-out);
}

@media (min-width: 1024px) {
  .fx-header__inner { height: var(--fx-header-h); }
}

/* Transparent variant — sits over a hero until scroll */
.fx-header--transparent {
  background: transparent;
  border-bottom-color: transparent;
}

.fx-header--transparent:not(.is-scrolled) {
  --fx-text:        var(--fx-white);
  --fx-text-strong: var(--fx-white);
  --fx-text-muted:  rgba(255, 255, 255, .82);
  --fx-border:      rgba(255, 255, 255, .18);
}

/* Scrolled state — applies to every variant */
.fx-header.is-scrolled {
  background: var(--fx-white);
  border-bottom-color: var(--fx-border);
  box-shadow: var(--fx-shadow-sm);
}

@media (min-width: 1024px) {
  .fx-header.is-scrolled .fx-header__inner { height: var(--fx-header-h-compact); }
}

/* Menu-open state on mobile keeps the bar opaque */
.fx-header.is-menu-open {
  background: var(--fx-white);
  border-bottom-color: var(--fx-border);
}

/* ── LOGO ────────────────────────────────────────────────────────────── */

.fx-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--fx-text-strong);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--fx-text-lg);
  letter-spacing: var(--fx-tracking-tight);
  transition: opacity var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-header__logo:hover { opacity: .8; color: var(--fx-text-strong); }

.fx-header__logo svg {
  height: 28px;
  width: auto;
  transition: height var(--fx-dur) var(--fx-ease-in-out);
}

.fx-header.is-scrolled .fx-header__logo svg { height: 24px; }

/* ── PRIMARY NAV ─────────────────────────────────────────────────────── */

.fx-nav { display: none; }

@media (min-width: 1024px) {
  .fx-nav {
    display: flex;
    align-items: center;
    gap: var(--fx-s1);
    margin-inline-start: auto;
  }
}

.fx-nav__item { position: relative; }

.fx-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--fx-s1);
  height: var(--fx-touch-min);
  padding-inline: var(--fx-s3);
  font-size: var(--fx-text-sm);
  font-weight: 500;
  color: var(--fx-text);
  text-decoration: none;
  border-radius: var(--fx-radius-sm);
  transition: color var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-nav__link:hover,
.fx-nav__link[aria-expanded="true"] { color: var(--fx-text-strong); }

/* Current-section indicator — the only place orange appears in the nav */
.fx-nav__link[aria-current="page"],
.fx-nav__link[aria-current="true"] {
  color: var(--fx-text-strong);
  font-weight: 600;
}

.fx-nav__link[aria-current="page"]::after,
.fx-nav__link[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: var(--fx-s3);
  right: var(--fx-s3);
  bottom: 8px;
  height: 2px;
  background: var(--fx-orange-400);
}

.fx-nav__chevron {
  width: 14px;
  height: 14px;
  opacity: .55;
  transition: transform var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-nav__link[aria-expanded="true"] .fx-nav__chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── HEADER ACTIONS ──────────────────────────────────────────────────── */

.fx-header__actions {
  display: flex;
  align-items: center;
  gap: var(--fx-s3);
  margin-inline-start: auto;
}

@media (min-width: 1024px) {
  .fx-header__actions { margin-inline-start: var(--fx-s5); }
}

.fx-header__cta { display: none; }

@media (min-width: 1024px) {
  .fx-header__cta { display: inline-flex; }
}

/* Language switcher */
.fx-lang {
  display: none;
  position: relative;
}

@media (min-width: 1024px) {
  .fx-lang { display: block; }
}

.fx-lang__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--fx-s1);
  height: var(--fx-touch-min);
  padding-inline: var(--fx-s3);
  font-size: var(--fx-text-sm);
  font-weight: 500;
  color: var(--fx-text-muted);
  border-radius: var(--fx-radius-sm);
}

.fx-lang__toggle:hover { color: var(--fx-text-strong); }

/* ── HAMBURGER ───────────────────────────────────────────────────────── */

.fx-hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fx-touch-min);
  height: var(--fx-touch-min);
  color: var(--fx-text-strong);
  border-radius: var(--fx-radius-sm);
}

@media (min-width: 1024px) { .fx-hamburger { display: none; } }

.fx-hamburger__box {
  position: relative;
  width: 20px;
  height: 14px;
}

.fx-hamburger__line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition:
    transform var(--fx-dur) var(--fx-ease-in-out),
    opacity   var(--fx-dur-fast) var(--fx-ease-in-out),
    top       var(--fx-dur) var(--fx-ease-in-out);
}

.fx-hamburger__line:nth-child(1) { top: 0; }
.fx-hamburger__line:nth-child(2) { top: 6px; }
.fx-hamburger__line:nth-child(3) { top: 12px; }

.fx-hamburger[aria-expanded="true"] .fx-hamburger__line:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.fx-hamburger[aria-expanded="true"] .fx-hamburger__line:nth-child(2) {
  opacity: 0;
}

.fx-hamburger[aria-expanded="true"] .fx-hamburger__line:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

/* ==========================================================================
   MEGA MENU
   ========================================================================== */

.fx-mega {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--fx-megamenu-z);

  background: var(--fx-white);
  border-top: 1px solid var(--fx-border);
  border-bottom: 1px solid var(--fx-border);
  box-shadow: var(--fx-shadow-lg);

  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition:
    opacity    var(--fx-dur-fast) var(--fx-ease-in-out),
    transform  var(--fx-dur-fast) var(--fx-ease-in-out),
    visibility var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-mega.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 1023px) {
  /* Mega menus are never rendered on mobile — mobile nav takes over */
  .fx-mega { display: none; }
}

.fx-mega__inner {
  display: grid;
  gap: var(--fx-s7);
  padding-block: var(--fx-s7);
}

/* Layout: Products — 4 columns, last one is a featured panel */
.fx-mega--products .fx-mega__inner {
  grid-template-columns: repeat(3, 1fr) minmax(260px, .9fr);
}

/* Layout: Industries — 2 text columns + image panel */
.fx-mega--industries .fx-mega__inner {
  grid-template-columns: 1fr 1fr minmax(280px, 1fr);
}

/* Layout: Solutions — 3 problem groups */
.fx-mega--solutions .fx-mega__inner {
  grid-template-columns: repeat(3, 1fr);
}

/* Layout: Engineering — 3 columns + resource panel */
.fx-mega--engineering .fx-mega__inner {
  grid-template-columns: repeat(3, 1fr) minmax(240px, .8fr);
}

/* ── MEGA COLUMN ─────────────────────────────────────────────────────── */

.fx-mega__col { display: flex; flex-direction: column; gap: var(--fx-s4); }

.fx-mega__heading {
  font-size: var(--fx-text-xs);
  font-weight: 600;
  letter-spacing: var(--fx-tracking-wide);
  text-transform: uppercase;
  color: var(--fx-text-subtle);
  padding-block-end: var(--fx-s3);
  border-bottom: 1px solid var(--fx-border);
}

.fx-mega__list { display: flex; flex-direction: column; gap: var(--fx-s1); }

.fx-mega__link {
  display: flex;
  align-items: baseline;
  gap: var(--fx-s2);
  padding: var(--fx-s2) var(--fx-s2) var(--fx-s2) 0;
  font-size: var(--fx-text-sm);
  color: var(--fx-text);
  text-decoration: none;
  border-radius: var(--fx-radius-xs);
  transition: color var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-mega__link:hover { color: var(--fx-orange-400); }

/* Category-level link is heavier than its children */
.fx-mega__link--parent {
  font-weight: 600;
  color: var(--fx-text-strong);
}

.fx-mega__link--parent:hover { color: var(--fx-navy-600); }

.fx-mega__link-meta {
  font-family: var(--fx-font-mono);
  font-size: var(--fx-text-2xs);
  color: var(--fx-text-subtle);
}

/* ── FEATURED PANEL ──────────────────────────────────────────────────── */

.fx-mega__feature {
  display: flex;
  flex-direction: column;
  gap: var(--fx-s3);
  padding: var(--fx-s5);
  background: var(--fx-navy-50);
  border-radius: var(--fx-radius);
  border: 1px solid var(--fx-navy-100);
}

.fx-mega__feature-img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  border-radius: var(--fx-radius-xs);
  background: var(--fx-steel-100);
}

.fx-mega__feature-title {
  font-size: var(--fx-text-base);
  font-weight: 600;
  color: var(--fx-text-strong);
  line-height: 1.3;
}

.fx-mega__feature-text {
  font-size: var(--fx-text-sm);
  color: var(--fx-text-muted);
  line-height: var(--fx-leading-normal);
}

/* ── INDUSTRY ITEM (icon + label) ────────────────────────────────────── */

.fx-mega__industry {
  display: flex;
  align-items: center;
  gap: var(--fx-s3);
  padding: var(--fx-s2) var(--fx-s2) var(--fx-s2) 0;
  font-size: var(--fx-text-sm);
  color: var(--fx-text);
  text-decoration: none;
  border-radius: var(--fx-radius-xs);
}

.fx-mega__industry:hover { color: var(--fx-orange-400); }

.fx-mega__industry svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--fx-steel-500);
}

.fx-mega__industry:hover svg { color: var(--fx-orange-400); }

/* ── MEGA FOOTER ─────────────────────────────────────────────────────── */

.fx-mega__footer {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--fx-s4);
  margin-block-start: calc(var(--fx-s7) * -1 + var(--fx-s5));
  padding-block-start: var(--fx-s5);
  border-top: 1px solid var(--fx-border);
}

.fx-mega__footer-text {
  font-size: var(--fx-text-sm);
  color: var(--fx-text-muted);
}

/* ── BACKDROP ────────────────────────────────────────────────────────── */

.fx-mega-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--fx-megamenu-z) - 1);
  background: rgba(10, 14, 20, .28);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity    var(--fx-dur-fast) var(--fx-ease-in-out),
    visibility var(--fx-dur-fast) var(--fx-ease-in-out);
}

.fx-mega-backdrop.is-visible { opacity: 1; visibility: visible; }

@media (max-width: 1023px) { .fx-mega-backdrop { display: none; } }

/* ── NO-JS FALLBACK ──────────────────────────────────────────────────────
   Without JS the mega panels open on hover and keyboard focus, so the whole
   navigation remains usable.
   ------------------------------------------------------------------------ */

@media (min-width: 1024px) {
  html:not(.js) .fx-nav__item:hover .fx-mega,
  html:not(.js) .fx-nav__item:focus-within .fx-mega {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}
