/* =============================================================================
 * Vitalum Header Widget — self-contained.
 * Every rule is scoped under .vheader so no theme can leak into it and it can’t
 * leak into the rest of the page. Uses `all: revert` on descendants to reset
 * any menu / anchor styling the active theme imposes.
 * ============================================================================= */

/* Hard reset: neutralise theme rules for elements INSIDE the header */
.vheader,
.vheader *,
.vheader *::before,
.vheader *::after {
  box-sizing: border-box;
}
.vheader ul { list-style: none; margin: 0; padding: 0; }
.vheader a  { text-decoration: none; color: inherit; }
.vheader img { display: block; max-width: 100%; height: auto; border: 0; }

.vheader {
  --vh-link:       rgba(242,247,251,0.85);
  --vh-accent:     #1ebf95;
  --vh-accent-alt: #2ac7dc;
  --vh-drop-bg:    #0d0d0d;
  --vh-drop-fg:    rgba(242,247,251,0.80);
  --vh-drop-brd:   rgba(255,255,255,0.07);

  position: relative;
  width: 100%;
  z-index: 999;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: transparent;
  transition: background-color 0.4s ease, box-shadow 0.4s ease, padding 0.3s ease;
}

/* Fixed / sticky variant */
.vheader.vh-fixed {
  position: fixed;
  top: 0; left: 0; right: 0;
}

/* Scrolled state — added by JS after threshold. Shadow depth matches
 * public_html/assets/css/navbar.css exactly. */
.vheader.vh-scrolled {
  background-color: #000;
  box-shadow: 0 4px 16px -6px rgba(0,0,0,0.6);
}

/* Menu links turn pure white when scrolled (matches navbar.css `.nk-header.scrolled` rule) */
.vheader.vh-scrolled .vheader-menu > li > a {
  color: #ffffff;
}
.vheader.vh-scrolled .vheader-menu > li > a:hover,
.vheader.vh-scrolled .vheader-menu > li > a:focus,
.vheader.vh-scrolled .vheader-menu > li.is-active > a {
  color: var(--vh-accent);
}

/* Shrink option — padding tightens AND logo scales down (matches is-shrink) */
.vheader.vh-shrink .vheader-inner { transition: padding 0.3s ease; }
.vheader.vh-shrink.vh-scrolled .vheader-inner {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}
.vheader.vh-shrink .vheader-logo img { transition: width 0.3s ease; }
.vheader.vh-shrink.vh-scrolled .vheader-logo img { width: 180px; }

/* -------- Layout row -------- */
.vheader-inner {
  max-width: 1230px;   /* matches body-wider container in the HTML */
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* -------- Logo -------- */
.vheader-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
  transition: opacity 0.3s;
}
.vheader-logo:hover { opacity: 0.85; }
.vheader-logo img { width: 210px; }

/* Swap logo on scrolled state (mirrors .logo-light / .logo-dark in the theme) */
.vheader .vh-logo-dark { display: none; }
.vheader.vh-scrolled .vh-logo-light { display: none; }
.vheader.vh-scrolled .vh-logo-dark  { display: block; }

/* If the header is NOT transparent-on-top, always show the dark logo */
.vheader:not(.vh-transparent-top) .vh-logo-light { display: none; }
.vheader:not(.vh-transparent-top) .vh-logo-dark  { display: block; }

/* -------- Nav -------- */
.vheader-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.vheader-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}
.vheader-menu > li { position: relative; }

.vheader-menu > li > a {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--vh-link);
  white-space: nowrap;
  transition: color 0.3s;
}
.vheader-menu > li > a:hover,
.vheader-menu > li > a:focus,
.vheader-menu > li.is-active > a { color: var(--vh-accent); outline: none; }

/* Caret */
.vh-caret {
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.3s;
  opacity: 0.7;
}
.vh-has-sub:hover .vh-caret { transform: rotate(225deg); }

/* Dropdown (desktop) */
.vh-sub {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  padding: 6px 0;
  background: var(--vh-drop-bg);
  border: 1px solid var(--vh-drop-brd);
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 100;
}
.vh-has-sub:hover > .vh-sub,
.vh-has-sub:focus-within > .vh-sub {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.vh-sub li a {
  display: block;
  padding: 10px 18px;
  font-size: 0.8125rem;
  color: var(--vh-drop-fg);
  transition: background 0.2s, color 0.2s;
}
.vh-sub li a:hover,
.vh-sub li a:focus {
  background: rgba(30,191,149,0.08);
  color: var(--vh-accent);
  outline: none;
}

/* -------- Login button -------- */
.vheader-cta { display: inline-flex; align-items: center; }
.vheader-login {
  display: inline-flex;
  align-items: center;
  padding: 8px 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--vh-accent);
  background: transparent;
  border-radius: 0;
  transition: color 0.3s;
}
.vheader-login:hover,
.vheader-login:focus { color: var(--vh-accent-alt); outline: none; }

/* -------- Mobile toggle -------- */
.vheader-toggle {
  display: none;
  width: 40px; height: 40px;
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.3s;
}
.vheader-toggle:hover { border-color: var(--vh-accent); }
.vheader-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: #fff;
  transition: transform 0.3s, opacity 0.3s;
}
.vheader-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.vheader-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.vheader-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* -------- Responsive: slide-in drawer from LEFT -------- */
@media (max-width: 991px) {
  .vheader-logo img { width: 160px; }
  .vheader.vh-shrink.vh-scrolled .vheader-logo img { width: 140px; }

  .vheader-toggle { display: flex; }

  /* Backdrop */
  .vheader::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    z-index: 998;
    backdrop-filter: blur(2px);
  }
  .vheader.vh-menu-open::before { opacity: 1; visibility: visible; }

  /* The drawer */
  .vheader-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    max-width: 86vw;
    height: 100vh;
    background: linear-gradient(180deg, #050505 0%, #0d0d0d 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.55);
    padding: 84px 24px 32px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(.22, .61, .36, 1);
    z-index: 999;
  }
  .vheader.vh-menu-open .vheader-nav { transform: translateX(0); }

  /* In-drawer close (X) — auto-generated by JS or fallback to toggle in header */
  .vheader-drawer-close {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.25s, background 0.25s, transform 0.25s;
  }
  .vheader-drawer-close:hover {
    border-color: var(--vh-accent);
    background: rgba(30, 191, 149, 0.10);
    transform: rotate(90deg);
  }
  .vheader-drawer-close::before,
  .vheader-drawer-close::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    top: 50%;
    left: 50%;
  }
  .vheader-drawer-close::before { transform: translate(-50%, -50%) rotate(45deg); }
  .vheader-drawer-close::after  { transform: translate(-50%, -50%) rotate(-45deg); }

  /* Menu items — staggered fade+slide in when drawer opens */
  .vheader-menu {
    flex-direction: column;
    gap: 2px;
    width: 100%;
  }
  .vheader-menu > li {
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.4s ease, transform 0.4s ease;
  }
  .vheader.vh-menu-open .vheader-menu > li { opacity: 1; transform: translateX(0); }
  /* Stagger up to 10 items */
  .vheader.vh-menu-open .vheader-menu > li:nth-child(1)  { transition-delay: 0.10s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(2)  { transition-delay: 0.14s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(3)  { transition-delay: 0.18s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(4)  { transition-delay: 0.22s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(5)  { transition-delay: 0.26s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(6)  { transition-delay: 0.30s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(7)  { transition-delay: 0.34s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(8)  { transition-delay: 0.38s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(9)  { transition-delay: 0.42s; }
  .vheader.vh-menu-open .vheader-menu > li:nth-child(10) { transition-delay: 0.46s; }

  .vheader-menu > li > a {
    padding: 14px 4px;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }

  /* Sub-menu inside drawer */
  .vh-sub {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 4px 0 8px 14px;
    min-width: 0;
    display: none;
  }
  .vh-has-sub.vh-open > .vh-sub { display: block; }
  .vh-has-sub.vh-open .vh-caret { transform: rotate(225deg); }
  .vh-sub li a { padding: 10px 4px; font-size: 0.875rem; }

  .vheader-cta {
    padding-top: 20px;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    transition-delay: 0.50s;
  }
  .vheader.vh-menu-open .vheader-cta { opacity: 1; transform: translateX(0); }

  /* Lock body scroll while drawer is open */
  body.vh-drawer-open { overflow: hidden; }
}
