/**
 * =============================================================================
 * HIPHEN V2 — Header Styles (header.css)
 * =============================================================================
 * Generic site header: logo, nav, lang toggle, search, nav dots, mobile menu.
 * Uses CSS custom properties from variables.css exclusively.
 *
 * @package Hiphen_V2
 */

/* =============================================================================
 * HEADER SHELL
 * ============================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: var(--header-border);
}

.header-container {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: var(--header-pad-y) var(--padding-x-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
}

@media (min-width: 900px) {
  .header-container {
    padding-left: var(--padding-x-md);
    padding-right: var(--padding-x-md);
  }
}

@media (min-width: 1200px) {
  .header-container {
    padding-left: var(--padding-x);
    padding-right: var(--padding-x);
  }
}

/* =============================================================================
 * LOGO
 * ============================================================================= */

.header-logo {
  width: var(--logo-width);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo img {
  width: 100%;
  height: auto;
}

.header-logo:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 4px;
  border-radius: 4px;
}

/* =============================================================================
 * MAIN NAVIGATION
 * ============================================================================= */

.header-nav {
  display: none;
}

@media (min-width: 900px) {
  .header-nav {
    display: flex;
    align-items: center;
  }
}

.main-nav {
  display: flex;
  gap: var(--nav-gap);
  list-style: none;
  align-items: center;
  margin: 0;
  padding: 0;
}

.main-nav li {
  margin: 0;
}

/* Pill-button menu item (e.g. Blog) — pushed to the far right via auto margin
   and trimmed to fit the header rhythm. */
.main-nav__cta {
  margin-left: auto;
}

.main-nav__cta .btn {
  font-size: var(--nav-link-size);
  font-weight: var(--fw-medium);
  padding: 0 var(--space-8);
  height: 36px;
  gap: var(--space-3);
  border: 1px solid var(--color-white-20);
}

.main-nav__cta .btn:hover,
.main-nav__cta .btn:focus-visible {
  /* Hover = full green radial fill (signature CTA flip) + white text.
     Attenuation = drop the upward shift and the glow shadow so the button
     stays aligned with the row. */
  background: var(--gradient-radial-green);
  border-color: var(--color-white-40);
  color: var(--color-white);
  transform: none;
  box-shadow: none;
}

/* Don't render the dropdown dot on the button — defensive in case Blog ever gets
   the has-dropdown class accidentally. */
.main-nav__cta a.has-dropdown::after,
.main-nav__cta .menu-item-has-children > a::after {
  content: none;
}

.main-nav a {
  color: var(--color-white);
  text-decoration: none;
  font-family: var(--font-gilroy);
  font-size: var(--nav-link-size);
  font-weight: var(--fw-regular);
  line-height: normal;
  position: relative;
  transition: color var(--transition-base);
}

.main-nav a:hover {
  color: var(--color-light-green);
}

/* Active state via WP .current-menu-item or manual .active class */
.main-nav .current-menu-item > a,
.main-nav .current_page_item > a,
.main-nav a.active {
  color: var(--color-light-green);
}

.main-nav .current-menu-item > a::after,
.main-nav .current_page_item > a::after,
.main-nav a.active::after {
  content: '';
  position: absolute;
  bottom: calc(-1 * var(--header-pad-y));
  left: 0;
  right: 0;
  height: var(--nav-underline-h);
  background: var(--color-light-green);
}

/* Dropdown indicator — small round dot to the right of the link.
   Uses currentColor so it follows the link's text color (white → green on hover). */
.main-nav a.has-dropdown::after,
.main-nav .menu-item-has-children > a::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: var(--space-2);
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  transition:
    background var(--transition-base),
    transform var(--transition-base);
}

/* Subtle pulse when its overlay is open */
.main-nav a[aria-expanded="true"]::after {
  transform: scale(1.3);
}

.main-nav a:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 4px;
  border-radius: 2px;
}

/* =============================================================================
 * HEADER RIGHT (lang toggle, search, nav dots)
 * ============================================================================= */

.header-right {
  display: none;
}

@media (min-width: 900px) {
  .header-right {
    display: flex;
    gap: var(--space-8);
    align-items: center;
  }
}

/* =============================================================================
 * LANGUAGE TOGGLE
 * ============================================================================= */

.lang-toggle {
  display: flex;
  border: 1px solid var(--color-white-20);
  border-radius: 20px;
  overflow: hidden;
  background: var(--color-white-10);
  padding: 2px;
  height: 40px;
  align-items: center;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  color: var(--color-white-70);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-gilroy);
  font-size: var(--text-sm);
  font-weight: var(--fw-regular);
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  border-radius: var(--radius-circle);
}

.lang-btn.active {
  background: var(--gradient-lang-active);
  color: var(--color-white);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 20px;
  border: var(--border-pill);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.1);
}

.lang-btn:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * SLIDER VARIANT — single sliding thumb behind both buttons.
 * The whole pill is clickable; clicking flips the active language.
 * Crops page keeps its original .lang-toggle (no --slider modifier).
 * --------------------------------------------------------------------------- */

.lang-toggle--slider {
  position: relative;
  cursor: pointer;
}

.lang-toggle--slider .lang-btn {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  transition: color var(--transition-base);
}

/* In slider mode the thumb provides the active background — cancel the
   per-button bg/shadow/border so they don't double up. */
.lang-toggle--slider .lang-btn.active {
  background: transparent;
  box-shadow: none;
  border: none;
}

.lang-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 36px;
  height: 36px;
  box-sizing: border-box;
  border-radius: 20px;
  background: var(--gradient-lang-active);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.1);
  z-index: 0;
  pointer-events: none;
  /* Amplified motion — overshoot easing gives a small bounce-into-place feel */
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-toggle--slider[data-lang="fr"] .lang-toggle__thumb {
  transform: translateX(0);
}

.lang-toggle--slider[data-lang="en"] .lang-toggle__thumb {
  /* Slide to second button: button width (36px) + gap (2px) = 38px */
  transform: translateX(38px);
}

/* =============================================================================
 * SEARCH WRAPPER
 * ============================================================================= */

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-white-15);
  border: 1px solid var(--color-white-20);
  border-radius: 24px;
  padding: var(--space-4);
  width: 44px;
  height: 44px;
  transition: width var(--transition-slow);
  overflow: hidden;
  cursor: pointer;
}

.search-wrapper.expanded {
  width: 200px;
  cursor: default;
}

.search-wrapper:hover {
  background: var(--color-white-20);
  border-color: rgba(255, 255, 255, 0.3);
}

.search-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-white-70);
  transition: color var(--transition-base);
}

.search-wrapper.expanded .search-icon {
  color: rgba(255, 255, 255, 0.9);
}

.search-input {
  background: transparent;
  border: none;
  color: var(--color-white);
  font-family: var(--font-gilroy);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  outline: none;
  width: 0;
  opacity: 0;
  margin-left: 0;
  transition:
    width var(--transition-slow),
    opacity var(--transition-base) 0.1s,
    margin-left var(--transition-slow);
}

.search-wrapper.expanded .search-input {
  width: 140px;
  opacity: 1;
  margin-left: var(--space-4);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Native browser X (Chrome/Safari) replaced with a white SVG to match the
   header's color scheme. Firefox doesn't render this pseudo by default. */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M18 6L6 18M6 6l12 12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  opacity: 0.7;
  margin-left: 4px;
  transition: opacity 0.2s ease;
}

.search-input::-webkit-search-cancel-button:hover {
  opacity: 1;
}

/* =============================================================================
 * NAV DOTS (3x3 grid)
 * ============================================================================= */

.nav-dots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-dots span {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-circle);
  cursor: pointer;
  transition: all var(--transition-base);
  place-self: center;
}

.nav-dots span.active {
  background: var(--color-light-green);
}

.nav-dots span:not(.active) {
  background: var(--color-white-15);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-white-20);
}

.nav-dots span:not(.active):hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-dots:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 4px;
  border-radius: 4px;
}

/* =============================================================================
 * MOBILE BURGER & MENU
 * ============================================================================= */

.header-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: var(--space-5);
  background: none;
  border: 2px solid var(--color-white-20);
  border-radius: 22px;
  cursor: pointer;
  position: absolute;
  right: var(--padding-x-sm);
  top: 50%;
  transform: translateY(-50%);
  transition: border-color var(--transition-base);
}

@media (min-width: 900px) {
  .header-burger {
    display: none;
  }
}

.header-burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-white);
  border-radius: 1px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.header-burger:hover {
  border-color: var(--color-white-40);
}

.header-burger:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 2px;
}

/* Open state */
.header-burger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.header-burger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.header-burger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile menu — off-canvas side drawer
 * ---------------------------------------------------------------------------
 * The drawer sits BELOW the sticky header (z just under --z-header) so the
 * header bar — logo + burger (which animates into a ✕) — stays visible and
 * interactive on top. It slides in from the right at 3/4 width with the nav
 * items stacked vertically; a dimming backdrop covers the rest of the page.
 * `--header-h` is set by header.js to the live header height.
 * --------------------------------------------------------------------------- */
.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) - 5);
  background: rgba(4, 48, 65, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.mobile-menu-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu {
  position: fixed;
  top: var(--header-h, 88px);
  right: 0;
  z-index: calc(var(--z-header) - 1);
  display: flex;
  flex-direction: column;
  width: 75%;
  max-width: 360px;
  height: calc(100dvh - var(--header-h, 88px));
  padding: var(--space-10) var(--padding-x-sm) var(--space-20);
  background: var(--color-bg-surface, #184455);
  border-left: 1px solid var(--color-white-10);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  visibility: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: transform 0.32s ease, visibility 0s linear 0.32s;
}

.mobile-menu.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.32s ease;
}

@media (min-width: 900px) {
  .mobile-menu,
  .mobile-menu-backdrop {
    display: none !important;
  }
}

/* Lock the page behind the drawer. */
body.mobile-menu-open {
  overflow: hidden;
}

/* The primary menu has no assigned menu, so wp_nav_menu falls back to
   hiphen_fallback_menu() which always outputs <ul class="main-nav"> — the
   horizontal desktop layout. The drawer nav is therefore scoped to
   .mobile-menu descendants (not the ul class) so it stacks vertically no
   matter which class the list carries (fallback `main-nav` or a real menu's
   `mobile-nav`), overriding the desktop flex-row. */
.mobile-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

.mobile-menu li {
  width: 100%;
}

/* Stacked text links (every item except the Blog CTA button). */
.mobile-menu a:not(.btn) {
  display: block;
  width: 100%;
  color: var(--color-white);
  font-family: var(--font-gilroy);
  font-size: var(--text-xl);
  font-weight: var(--fw-medium);
  padding: var(--space-7) 0;
  text-decoration: none;
  border-bottom: 1px solid var(--color-white-10);
  transition: color var(--transition-base), padding-left var(--transition-base);
}

.mobile-menu a:not(.btn):hover {
  color: var(--color-light-green);
  padding-left: var(--space-3);
}

.mobile-menu .current-menu-item > a,
.mobile-menu .current_page_item > a {
  color: var(--color-light-green);
}

/* The "has-dropdown" dot is a desktop affordance (the Solutions overlay is
   hidden < 900px); drop it inside the drawer where the link just navigates. */
.mobile-menu a.has-dropdown::after {
  display: none;
}

/* Blog CTA — full-width button on its own row, below the links. */
.mobile-menu .main-nav__cta {
  margin-top: var(--space-10);
}

.mobile-menu .main-nav__cta .btn {
  width: 100%;
  justify-content: center;
}

/* Close button — minimalist text button below the Blog CTA. No fill, no
   border, no hover colour; just the ✕ glyph + label. Dismisses the drawer
   (wired in header.js). */
.mobile-menu__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  margin-top: var(--space-8);
  padding: var(--space-7) 0;
  background: none;
  border: 0;
  color: var(--color-white);
  font-family: var(--font-gilroy);
  font-size: var(--text-lg);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.mobile-menu__close:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: 2px;
}

.mobile-menu__close-icon {
  display: inline-flex;
}

.mobile-menu__close-icon svg {
  width: 18px;
  height: 18px;
}

/* =============================================================================
 * HEADER OVERLAYS — dropdown panels anchored under triggers
 * ============================================================================= */

.header-overlay {
  position: absolute;
  top: calc(100% + 5px);
  z-index: calc(var(--z-header) + 1);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity var(--transition-base),
    transform var(--transition-base);
}

.header-overlay[data-open="true"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 899px) {
  .header-overlay {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
 * SOLUTIONS OVERLAY (under main-nav "Solutions" link)
 * Shares the liquid-glass treatment of the Quicknav launcher.
 * --------------------------------------------------------------------------- */

.header-overlay--solutions,
.header-overlay--usecases {
  width: 280px;
  /* Strong opaque base in the page bg colour so the dropdown reliably
     blocks whatever sits behind it (hero title, photos…), with a subtle
     radial blue sheen on top for the design-system glass feel. */
  background:
    radial-gradient(
      ellipse at 40% 40%,
      rgba(255, 255, 255, 0.06) 0%,
      transparent 70%
    ),
    var(--color-bg-page);
  /* The blur still kicks in for whatever shows through the 6 % sheen at
     the centre — keeps the glass aesthetic without sacrificing legibility. */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-white-20);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
}

.solutions-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.solutions-menu__item {
  margin: 0;
}

.solutions-menu__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-gilroy);
  font-size: var(--text-sm);
  font-weight: var(--fw-regular);
  color: var(--color-white);
  text-decoration: none;
  transition:
    background var(--transition-base),
    color var(--transition-base),
    transform var(--transition-base);
}

.solutions-menu__link:hover {
  background: var(--color-white-10);
  color: var(--color-light-green);
  transform: translateX(2px);
}

.solutions-menu__link:focus-visible {
  outline: 2px solid var(--color-light-green);
  outline-offset: -2px;
}

/* ---------------------------------------------------------------------------
 * QUICKNAV OVERLAY (under .nav-dots — Hiphen sites launcher)
 * --------------------------------------------------------------------------- */

.header-overlay--quicknav {
  width: 220px;
  /* Same opaque base + radial sheen as the Solutions overlay — keeps the
     two header dropdowns visually consistent and the items legible against
     any hero / page background colour. */
  background:
    radial-gradient(
      ellipse at 40% 40%,
      rgba(255, 255, 255, 0.06) 0%,
      transparent 70%
    ),
    var(--color-bg-page);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-white-20);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
}

.quicknav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quicknav-section + .quicknav-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-white-10);
}

.quicknav-section__title {
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-3);
  font-family: var(--font-gilroy);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-white-70);
}

.quicknav__item {
  --icon-color: var(--color-white);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-gilroy);
  font-size: var(--text-sm);
  color: var(--color-white);
  text-decoration: none;
  transition:
    background var(--transition-base),
    color var(--transition-base),
    transform var(--transition-base);
}

.quicknav__item:hover,
.quicknav__item:focus-visible {
  background: var(--color-white-10);
  color: var(--color-light-green);
  transform: translateX(2px);
  outline: none;
}

.quicknav__item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-color: var(--icon-color);
  -webkit-mask: url('../images/icons/favicon-hiphen.svg') no-repeat center / contain;
          mask: url('../images/icons/favicon-hiphen.svg') no-repeat center / contain;
}

.quicknav__item-label {
  flex: 1;
  min-width: 0;
}

.quicknav__item-external {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-base);
}

.quicknav__item:hover .quicknav__item-external {
  opacity: 1;
}

/* Per-product icon tinting (uses existing --product-* tokens) */
.quicknav__item--cloverfield   { --icon-color: var(--color-white); }
.quicknav__item--hiphen        { --icon-color: var(--color-white); }
.quicknav__item--phenoscale    { --icon-color: var(--product-phenoscale); }
.quicknav__item--phenomobile   { --icon-color: var(--product-phenomobile); }
.quicknav__item--literal       { --icon-color: var(--product-literal); }
.quicknav__item--phenolite     { --icon-color: var(--product-phenolite); }
.quicknav__item--phenostation  { --icon-color: var(--product-phenostation); }
.quicknav__item--phenoresearch { --icon-color: var(--product-phenoresearch); }
.quicknav__item--wps           { --icon-color: var(--product-wps); }
.quicknav__item--hcc           { --icon-color: var(--color-white-70); }

/* =============================================================================
 * RESPONSIVE
 * ============================================================================= */

@media (max-width: 899px) {
  .header-container {
    padding-right: 70px; /* room for burger */
  }
}
