@use "tokens" as *;
@use "mixins" as *;

.header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  color: $c-white;
  transition: opacity 0.8s $ease-out 0.2s;
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(36, 36, 36, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: -1;
    transition: background 0.5s $ease-out, backdrop-filter 0.5s $ease-out, border-color 0.5s $ease-out, box-shadow 0.5s $ease-out;
  }
}
// At the very top the bar is clear, so the hero photo shows edge to edge; a soft fade keeps the links legible.
.top::before {
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.42), rgba(20, 20, 20, 0));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom-color: transparent;
  background-origin: border-box;
  background-repeat: no-repeat;
}
.topOnLight::before {
  background: $c-ink; // solid over light pages (Projects, Industries…), not a see-through grey
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px -20px rgba(0, 0, 0, 0.5);
}
.solid::before { background: rgba(46, 46, 46, 0.97); }
.compact::before {
  background: rgba(40, 40, 40, 0.92);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.6);
}
.compact .bar { height: 68px; @include down($bp-md) { height: 60px; } }
.compact .logo img { transform: scale(0.88); }

.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 84px;
  transition: height 0.45s $ease-out;
  @include down($bp-md) { height: 68px; }
}
.logo {
  flex: none;
  img { width: 130px; height: auto; transform-origin: left center; transition: transform 0.45s $ease-out; }
  [dir="rtl"] & img { transform-origin: right center; }
  @include focus-ring;
}

.nav {
  margin-inline: auto;
  @include down($bp-xl) { display: none; }
  > ul {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
  }
  > ul > li { position: relative; }
  > ul > li > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 13px;
    white-space: nowrap;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.86);
    transition: background $dur-fast, color $dur-fast;
    &:hover { background: rgba(255, 255, 255, 0.08); color: $c-white; }
    @include focus-ring;
  }
}
.chev {
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.45s $ease-out;
}
.hasDropdown:hover .chev, .hasDropdown:focus-within .chev { transform: translateY(1px) rotate(225deg); }

/* ---- Solutions mega menu ------------------------------------------------
 * Opens like a shutter: the panel unrolls from the nav bar (clip-path), the
 * services rise in on a diagonal stagger, then the yellow CTA lands with a
 * light sweep. Closing is quicker and in one piece. */
$mega-ease: cubic-bezier(0.16, 1, 0.3, 1);
.dropdown {
  position: absolute;
  top: calc(100% - 2px);
  inset-inline: 0;
  padding: 14px 14px 16px;
  background: $c-ink;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  clip-path: inset(0 0 100% 0 round 0 0 20px 20px);
  transform: translateY(-6px);
  transition:
    clip-path 0.3s cubic-bezier(0.7, 0, 0.84, 0),
    opacity 0.25s linear 0.05s,
    transform 0.3s cubic-bezier(0.7, 0, 0.84, 0),
    visibility 0s linear 0.3s;
  &::before { content: ""; position: absolute; inset: -40px 0 auto; height: 40px; }
  li, .megaCta {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.2s linear, transform 0.25s ease-in;
  }
}
.hasDropdown:focus-within .dropdown,
.dropdownOpen {
  visibility: visible;
  opacity: 1;
  clip-path: inset(0 0 0 0 round 0 0 20px 20px);
  transform: none;
  transition:
    clip-path 0.7s $mega-ease,
    opacity 0.2s linear,
    transform 0.7s $mega-ease,
    visibility 0s;
  li, .megaCta {
    opacity: 1;
    transform: none;
    // Diagonal wave across the 3-column grid (--d is set per item: column + row).
    transition: opacity 0.5s $mega-ease var(--d, 0s), transform 0.7s $mega-ease var(--d, 0s);
  }
  .megaCta::after { animation: megaSweep 1.1s $mega-ease 0.55s both; }
  .megaGlow { opacity: 1; transform: translateX(-50%) scale(1); }
}
// Soft warm light that blooms under the bar as the panel opens.
.megaGlow {
  position: absolute; top: -140px; left: 50%;
  width: 70%; height: 260px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 197, 74, 0.16), transparent);
  opacity: 0; transform: translateX(-50%) scale(0.6);
  transition: opacity 0.8s $mega-ease, transform 1s $mega-ease;
  pointer-events: none;
}
.hasDropdown { position: static !important; }
// Five equal columns (one per service group): header card on top, sub-services under it,
// all sharing one start edge; hairlines separate the columns.
.mega {
  position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 0;
  @include up($bp-xl) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  // Subgrid: every column's sub-list starts on the same line, whatever the title/description length.
  > li { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 0; align-content: start; padding-inline: 6px; }
  > li > .megaSub { align-self: start; }
  > li + li { border-inline-start: 1px solid rgba(255, 255, 255, 0.07); }
}
.megaItem {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: 1fr auto; row-gap: 8px; align-items: center; align-content: start;
  padding: 14px 14px 16px; border: 1px solid transparent; border-radius: 14px;
  transition: border-color 0.4s $mega-ease;
  // Hover: a lifted surface grows from the start edge, the number turns yellow,
  // a short accent rule draws under the title and the arrow slides in.
  &::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    transform: scaleX(0.92); transform-origin: left center; opacity: 0;
    transition: transform 0.5s $mega-ease, opacity 0.35s linear;
    :global([dir="rtl"]) & { transform-origin: right center; }
  }
  strong {
    position: relative;
    font-family: $f-display; font-weight: 600; font-size: 0.9375rem; color: $c-white;
    &::after {
      content: ""; position: absolute; inset-inline-start: 0; bottom: -5px; width: 28px; height: 2px;
      background: $c-yellow; transform: scaleX(0); transform-origin: left center;
      transition: transform 0.5s $mega-ease;
      :global([dir="rtl"]) & { transform-origin: right center; }
    }
  }
  strong { grid-column: 1 / -1; line-height: 1.3; }
  span { grid-column: 1 / -1; max-width: 260px; font-size: 0.75rem; line-height: 1.5; color: rgba(255, 255, 255, 0.66); transition: color 0.4s; }
  &:hover, &:focus-visible {
    border-color: rgba(255, 255, 255, 0.1);
    &::before { transform: none; opacity: 1; }
    strong::after { transform: scaleX(1); }
    span { color: rgba(255, 255, 255, 0.86); }
    .megaNum { color: $c-yellow; }
    .megaArrow { opacity: 1; transform: none; }
  }
  @include focus-ring;
}
// Sub-services under each group (International Freight, Contract Logistics, Project Logistics).
.megaSub {
  display: grid; gap: 0; margin: 2px 14px 0; padding: 8px 0 10px; list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  a {
    display: inline-flex; align-items: center; gap: 8px; min-height: 30px;
    font-size: 0.8125rem; color: rgba(255, 255, 255, 0.72); transition: color 0.3s;
    &::before { content: ""; width: 10px; height: 1px; background: rgba(255, 197, 74, 0.6); transition: width 0.3s $mega-ease; }
    &:hover, &:focus-visible { color: $c-yellow; &::before { width: 16px; } }
    @include focus-ring;
  }
}
.megaNum {
  grid-row: 1; grid-column: 1;
  font-style: normal; font-family: $f-display; font-weight: 500; font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.4); letter-spacing: 0.06em;
  transition: color 0.4s;
}
.megaArrow {
  grid-row: 1; grid-column: 2; align-self: center;
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  background: $c-yellow; color: $c-ink;
  opacity: 0; transform: translateX(-8px);
  transition: opacity 0.35s linear, transform 0.5s $mega-ease;
  :global([dir="rtl"]) & { transform: translateX(8px) scaleX(-1); }
}
:global([dir="rtl"]) .megaItem:hover .megaArrow { transform: scaleX(-1); }
.megaCta {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-top: 14px; padding: 22px 24px;
  border-radius: 16px; background: $c-yellow; color: $c-ink;
  @include notch(36px);
  div { display: grid; gap: 6px; }
  strong { font-family: $f-display; font-weight: 600; font-size: 1.125rem; }
  span { font-size: 0.75rem; }
  &::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
    transform: translateX(-100%);
  }
}
@keyframes megaSweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.current { background: rgba(255, 255, 255, 0.1); color: $c-white !important; }
@media (prefers-reduced-motion: reduce) {
  .dropdown, .dropdown li, .dropdown .megaCta, .dropdownOpen, .dropdownOpen li, .dropdownOpen .megaCta { transition: none !important; }
  .megaCta::after { display: none; }
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  @include down($bp-xl) { margin-inline-start: auto; }
}
.track {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 16px;
  border-radius: 4px;
  background: $c-yellow;
  color: $c-ink;
  font-family: $f-display;
  font-weight: 500;
  font-size: 0.8125rem;
  white-space: nowrap;
  position: relative; isolation: isolate; overflow: hidden;
  // Hover: a white wash sweeps across.
  &::before {
    content: ""; position: absolute; inset: 0; z-index: -1; background: $c-white;
    transform: translateX(-101%); transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    :global([dir="rtl"]) & { transform: translateX(101%); }
  }
  @media (hover: hover) {
    &:hover::before { transform: none; }
  }
  @include focus-ring($c-white);
}
.langGlobe { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; transition: rotate 0.6s $ease-out; }
.lang:hover .langGlobe { rotate: 25deg; }
.lang {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  font-family: "Space Grotesk", "Readex Pro", sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.45s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.45s, color 0.45s;
  &:hover { background: rgba(255, 197, 74, 0.08); border-color: $c-yellow; color: $c-yellow; }
  @include focus-ring;
  @include down($bp-sm) { min-width: 44px; height: 44px; }
}
.mobileLang { align-self: flex-start; padding: 10px 16px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px; font-size: 1rem; }
.actions > .track { @include down($bp-md) { display: none; } }
.quote { @include down($bp-sm) { display: none !important; } }

.burger {
  display: none;
  position: relative;
  width: 44px; height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: transparent;
  @include down($bp-xl) { display: block; }
  span {
    position: absolute; left: 12px; right: 12px; height: 1.5px;
    background: currentColor;
    transition: transform $dur $ease-out;
    &:first-child { top: 17px; }
    &:last-child { top: 25px; }
  }
  @include focus-ring;
}
.burgerOpen span:first-child { transform: translateY(4px) rotate(45deg); }
.burgerOpen span:last-child { transform: translateY(-4px) rotate(-45deg); }

.mobile {
  position: fixed;
  inset: 84px 0 0;
  padding: 24px $gutter 40px;
  background: $c-ink;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
  opacity: 0;
  transition: opacity $dur $ease-out;
  @include down($bp-md) { inset: 68px 0 0; }
  &[hidden] { display: none; }
  li {
    border-bottom: 1px solid $c-line-on-dark;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity $dur $ease-out, transform $dur-slow $ease-out;
  }
  a {
    display: flex; align-items: baseline; gap: 16px;
    padding: 18px 0;
    font-family: $f-display; font-size: 1.5rem; font-weight: 500;
    span { font-size: 0.75rem; color: $c-yellow; }
  }
}
.mobileOpen { opacity: 1; li { opacity: 1; transform: none; } }
.mobileSub {
  display: grid; gap: 4px; padding-bottom: 16px; padding-inline: 34px 0;
  li { border: 0 !important; opacity: 1 !important; transform: none !important; }
  a { padding: 6px 0 !important; font-family: $f-body !important; font-size: 0.9375rem !important; color: rgba(255, 255, 255, 0.75); }
}
.mobileSubChild a { padding-inline-start: 16px !important; font-size: 0.875rem !important; color: rgba(255, 255, 255, 0.6) !important; }
.mobileCtas { display: flex; flex-wrap: wrap; gap: 12px; .track { height: 44px; } }
