/* ===========================================================================
   Glass navbar (frosted blur) + compact-on-scroll.

   Loaded AFTER style.css and laptop3d.css (see layout/base.html), so it wins on the
   header rules without touching them. Works for both header variants:
     - header.madds-header  (home page)   : floats over the hero video
     - header.main-header   (inner pages) : floats over the banner / content
   header-glass.js adds `.is-scrolled` once the page has scrolled, and sets
   --hdr-full / --hdr-compact (the measured heights) so nothing here is hard-coded.
   =========================================================================== */

:root {
  --hdr-full: 108px;     /* fallbacks, overwritten by header-glass.js */
  --hdr-compact: 64px;
  --hdr-dur: 0.6s;                              /* navbar transition speed: change this one value */
  --hdr-ease: cubic-bezier(0.22, 0.61, 0.36, 1); /* soft start, long gentle finish */
}

html {
  scroll-padding-top: var(--hdr-compact);
}

/* ---------- the bar ---------------------------------------------------------- */

/* DEFAULT (top of the page): fully transparent. No tint, no blur, no line, no shadow, so the
   hero video / banner image shows straight through. The values below are "zero" versions of the
   glass ones (same colour, alpha 0 / blur 0), so the change to glass animates smoothly. */
header.madds-header,
header.main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  margin-bottom: 0;               /* the old -120px overlap trick is no longer needed */
  z-index: 1000;                  /* above page content, below the side menu (9999) */

  /* The header itself carries NO glass. Its height simply follows its content, which shrinks
     through the padding / logo transitions below, so only ONE thing drives the size. */
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
  transition: none;
}

/* LEGACY OVERRIDE: script.js still toggles the old `.scrolled` class, and style.css has
   `.madds-header.scrolled` / `.main-header.scrolled` rules (big box-shadow, tint, blur). Those
   have higher specificity than the reset above, so after scrolling they painted a dark shadowy
   background on the header itself. The glass lives on ::after now, so the header element must
   stay bare in every state. */
header.madds-header.scrolled,
header.main-header.scrolled,
header.madds-header.is-scrolled,
header.main-header.is-scrolled {
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
}

/* The glass is its own layer with a FIXED size and a FIXED blur; only its opacity fades in.
   Before, the blur radius and the bar height were both animating at once, so the browser
   re-blurred the video behind the bar on every frame. That was the stutter / flicker.
   Same duration + easing as the logo / nav shrink below, so they now move together. */
header.madds-header::after,
header.main-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hdr-compact);     /* the final (compact) bar height, measured by header-glass.js */
  box-sizing: border-box;
  z-index: -1;                    /* behind logo / nav / buttons, inside the header */
  pointer-events: none;

  background-color: rgba(34, 12, 78, 0.5);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 34px rgba(15, 0, 45, 0.28);

  opacity: 0;
  transition: opacity var(--hdr-dur) var(--hdr-ease);
}

/* Inner pages scroll over white content, so their glass is tinted a little stronger */
header.main-header::after {
  background-color: rgba(80, 19, 149, 0.62);
}

/* SCROLLED: glass fades in (header-glass.js adds .is-scrolled) */
header.madds-header.is-scrolled::after,
header.main-header.is-scrolled::after {
  opacity: 1;
}

/* Browsers without backdrop-filter: solid bar once scrolled, so the text stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header.madds-header::after {
    background-color: #401380;
  }
  header.main-header::after {
    background-color: #4d1494;
  }
}

/* ---------- inner pages: let the banner run underneath the transparent bar ------ */
/* The bar no longer takes any space, so the banner is made taller by the bar's height and its
   title moved down by half of it: the banner looks exactly as before, with the image now
   visible behind the transparent navbar. */

header.main-header ~ .other-slider {
  height: calc(380px + var(--hdr-full));
}

header.main-header ~ .other-slider .about-hd {
  top: calc(50% + var(--hdr-full) / 2);
}

/* ---------- compact state: smaller logo + shorter bar ----------------------- */

header .logo img {
  transition: height var(--hdr-dur) var(--hdr-ease);
}

header .nav ul li.dropdown,
header .nav ul li.mega-dropdown {
  transition: padding var(--hdr-dur) var(--hdr-ease);
}

header .quote-btn,
header .icon-btn {
  transition:
    padding var(--hdr-dur) var(--hdr-ease),
    width var(--hdr-dur) var(--hdr-ease),
    height var(--hdr-dur) var(--hdr-ease),
    background 0.4s ease,
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

/* the buttons are almost opaque, their own blur is invisible but costs a blur pass per frame */
header .quote-btn,
header .icon-btn {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

header.is-scrolled .logo img {
  height: 58px;                   /* was 100px */
}

header.is-scrolled .nav ul li.dropdown,
header.is-scrolled .nav ul li.mega-dropdown {
  padding-top: 17px;              /* was 40px */
  padding-bottom: 17px;
}

header.is-scrolled .quote-btn {
  padding: 8px 22px;
}

header.is-scrolled .icon-btn {
  width: 36px;
  height: 36px;
}

/* measuring pass in header-glass.js: no animation, so heights are read at their final value */
header.hdr-measuring {
  height: auto !important;
}

header.hdr-measuring,
header.hdr-measuring *,
header.hdr-measuring::after {
  transition: none !important;
}

/* ---------- dropdowns stay SOLID (never see-through) ------------------------- */

.mega-menu {
  background: #fff !important;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  top: calc(100% - 2px);          /* follows the bar's real height as it shrinks */
  border-radius: 0 0 14px 14px;
  box-shadow: 0 18px 40px rgba(15, 0, 45, 0.22);
}

.dropdown-menu {
  background: #ccc !important;
}

/* ---------- pinned Solutions block: sit below the compact bar ---------------- */

section.custom-tabs .tabs-container {
  padding-top: calc(var(--hdr-compact) + 1vh);
}

/* ---------- small screens ---------------------------------------------------- */

@media (max-width: 992px) {
  header.is-scrolled .logo img {
    height: 44px;
  }
}

@media (max-width: 768px) {
  header.is-scrolled .logo img {
    height: 32px;                 /* was 42px */
  }
}

@media (max-width: 520px) {
  header.is-scrolled .logo img {
    height: 42px;                 /* was 60px */
  }
}

@media (prefers-reduced-motion: reduce) {
  header.madds-header,
  header.main-header,
  header.madds-header::after,
  header.main-header::after,
  header .logo img,
  header .nav ul li {
    transition: none;
  }
}