/*
 * YHN 4.0 — Header, Mega-Menu, Icons, Footer & Floating Controls Safe-Zone
 * Safeguard: NEVER overrides Flatsome icon-font family or codepoints (<i class="icon-*">).
 *
 * Covers:
 *   1. Announcement Topbar contrast & zero mobile clipping.
 *   2. Main Header + FiboSearch Pro bar + Discovery shortcut links.
 *   3. Single-row Desktop Primary Nav (fixes TPCN wrapping at 1024px–1280px) + crisp menu icons.
 *   4. Elevated Mega-Menu dropdowns with smooth hover effects.
 *   5. Harmonized Quiet Premium Footer (replaces flat #5b5c62 + neon #ef2b7a divider).
 *   6. Non-colliding Floating Contact (.yhn-contact) + Back-to-Top (.back-to-top) + Footer safe-zone.
 */

/* =========================================================
   1. ANNOUNCEMENT TOP BAR (High-specificity lock across ALL templates)
   ========================================================= */
html body.yhn-redesign-40 #header #top-bar,
html body.yhn-redesign-40 #header #top-bar.nav-dark,
html body.yhn-redesign-40:is(.yhn-archive-phase1c,.yhn-search-product,.single-product,.archive,.home,.page) #header #top-bar.nav-dark {
  background-color: var(--yhn-topbar-bg) !important;
  color: var(--yhn-topbar-fg) !important;
  min-height: 36px !important;
  padding-block: 4px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.yhn-redesign-40 #header #top-bar .flex-row {
  min-height: 28px !important;
  align-items: center !important;
}

body.yhn-redesign-40 #header #top-bar .nav > li > a,
body.yhn-redesign-40 #header #top-bar .nav > li.html,
body.yhn-redesign-40 #header #top-bar .nav > li.html strong,
body.yhn-redesign-40 #header #top-bar .nav > li.html span {
  color: var(--yhn-topbar-fg) !important;
  font-size: 12px !important;
  line-height: 1.45 !important;
}

/* =========================================================
   2. MAIN HEADER, SEARCH BAR & DISCOVERY SHORTCUTS
   ========================================================= */
body.yhn-redesign-40 #header #masthead {
  background-color: var(--yhn-bg) !important;
  border-bottom: 1px solid var(--yhn-line);
}

body.yhn-redesign-40 #header .header-search-form :is(input.search-field, input.dgwt-wcas-search-input) {
  background-color: var(--yhn-surface) !important;
  border: 1px solid var(--yhn-line) !important;
  border-radius: var(--yhn-radius-pill) !important;
  color: var(--yhn-ink) !important;
  transition: border-color var(--yhn-transition), box-shadow var(--yhn-transition), background-color var(--yhn-transition);
}

body.yhn-redesign-40 #header .header-search-form :is(input.search-field, input.dgwt-wcas-search-input):focus {
  background-color: var(--yhn-bg) !important;
  border-color: var(--yhn-brand) !important;
  box-shadow: 0 0 0 3px var(--yhn-brand-soft) !important;
}

body.yhn-redesign-40 #header .yhn-header-discovery__label {
  color: var(--yhn-muted) !important;
}

body.yhn-redesign-40 #header .yhn-header-discovery a {
  color: var(--yhn-brand) !important;
  font-weight: 500;
  transition: color 0.15s ease;
}

body.yhn-redesign-40 #header .yhn-header-discovery a:hover {
  color: var(--yhn-brand-hover) !important;
}

/* =========================================================
   3. DESKTOP PRIMARY NAV (SINGLE ROW) + CRISP WHITE MENU ICONS
   ========================================================= */
html body.yhn-redesign-40 #header #wide-nav,
html body.yhn-redesign-40 #header #wide-nav.nav-dark,
html body.yhn-redesign-40:is(.yhn-archive-phase1c,.yhn-search-product,.single-product,.archive,.home,.page) #header #wide-nav.nav-dark {
  background-color: var(--yhn-nav-bg) !important;
  min-height: 46px !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Mobile search bar wrapper harmonized (fixes legacy hot-pink strip on archives/PDP) */
@media (max-width: 849px) {
  html body.yhn-redesign-40 #header #wide-nav,
  html body.yhn-redesign-40 #header .header-bottom,
  html body.yhn-redesign-40 .yhn-mobile-search-bar {
    background-color: var(--yhn-bg) !important;
    border-bottom: 1px solid var(--yhn-line) !important;
  }
}

@media (min-width: 850px) {
  body.yhn-redesign-40 #header #wide-nav .flex-row {
    min-height: 46px !important;
    flex-wrap: nowrap !important;
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between;
    gap: clamp(2px, 0.65vw, 12px) !important;
    width: 100%;
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li {
    flex: 0 1 auto;
    margin: 0 !important;
    white-space: nowrap !important;
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li > a {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px;
    padding: 0 clamp(6px, 0.75vw, 12px) !important;
    min-height: 44px;
    font-size: clamp(11.5px, 0.98vw, 13.5px) !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    white-space: nowrap !important;
    color: var(--yhn-nav-fg) !important;
    text-decoration: none !important;
    position: relative;
  }

  /* Crisp pure-white top-level menu icons on dark ruby/crimson/ivory nav bar */
  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li > a img.ux-menu-icon {
    width: 17px !important;
    height: 17px !important;
    flex: 0 0 17px;
    object-fit: contain !important;
    margin: 0 !important;
    vertical-align: middle;
    filter: brightness(0) invert(1) !important;
    opacity: 0.94 !important;
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li:hover > a img.ux-menu-icon {
    opacity: 1 !important;
    transform: translateY(-1px);
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li > a::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 5px;
    height: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.92);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--yhn-transition);
  }

  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li:hover > a::after,
  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li.current-menu-item > a::after,
  body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li.current-menu-ancestor > a::after {
    transform: scaleX(1);
  }

  @media (max-width: 1180px) {
    body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li > a img.ux-menu-icon {
      width: 15px !important;
      height: 15px !important;
      flex-basis: 15px;
    }
    body.yhn-redesign-40 #header #wide-nav .header-bottom-nav > li > a {
      font-size: 11.5px !important;
      gap: 4px;
      padding-inline: 5px !important;
    }
  }

  /* =========================================================
     4. MEGA-MENU & DROPDOWN EFFECTS (Eliminates empty center gap)
     ========================================================= */
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown {
    background: var(--yhn-bg) !important;
    border: 1px solid var(--yhn-line) !important;
    border-radius: 0 0 var(--yhn-radius-lg) var(--yhn-radius-lg) !important;
    box-shadow: 0 22px 48px rgba(26, 23, 21, 0.14) !important;
    padding: 14px 16px !important;
    width: auto !important;
    min-width: 240px !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown.nav-dropdown-default {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 18px !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown > li {
    flex: 0 1 220px;
    min-width: 190px;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown img.ux-menu-icon {
    filter: none !important;
    width: 16px !important;
    height: 16px !important;
    object-fit: contain !important;
    opacity: 0.9 !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown > li > a,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown .nav-column > li > a,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li a {
    color: var(--yhn-ink) !important;
    font-size: 13px !important;
    padding: 7px 10px !important;
    border-radius: var(--yhn-radius-sm);
    transition: background-color 0.16s ease, color 0.16s ease, padding-left 0.16s ease;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown > li > a:hover,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown .nav-column > li > a:hover,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li a:hover {
    background-color: var(--yhn-brand-soft) !important;
    color: var(--yhn-brand) !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li a:hover span {
    color: var(--yhn-brand) !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li.current-menu-item > a,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li.current_page_item > a,
  body.yhn-redesign-40 #header #wide-nav .nav-dropdown li.current-menu-parent > a {
    background-color: var(--yhn-brand-soft) !important;
    color: var(--yhn-brand) !important;
    box-shadow: inset 3px 0 0 var(--yhn-brand) !important;
  }

  body.yhn-redesign-40 #header #wide-nav .nav-dropdown .menu-item-has-children > a {
    font-weight: 700 !important;
    color: var(--yhn-brand) !important;
    border-bottom: 1px solid var(--yhn-line);
    border-radius: 0;
    margin-bottom: 6px;
  }
}

/* Mobile Header & Topbar Clipping Fix */
@media (max-width: 849px) {
  body.yhn-redesign-40 #header #top-bar {
    height: auto !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    overflow: visible !important;
  }

  body.yhn-redesign-40 #header #top-bar .flex-col,
  body.yhn-redesign-40 #header #top-bar .nav {
    height: auto !important;
    line-height: 1.4 !important;
  }

  body.yhn-redesign-40 #header #top-bar .nav > li.html {
    padding-block: 2px !important;
    white-space: normal !important;
    text-align: center !important;
    font-size: 11.5px !important;
    line-height: 1.4 !important;
  }
}

/* =========================================================
   5. FOOTER HARMONIZATION (Quiet Premium Dark Editorial)
   Preserves the locked 4-column structure & accessibility targets.
   ========================================================= */
body.yhn-redesign-40 #footer {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: clip;
  background: var(--yhn-footer-bg) !important;
}

body.yhn-redesign-40 #footer .footer-widgets.footer.footer-2 {
  background: var(--yhn-footer-bg) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 40px 0 32px !important;
}

body.yhn-redesign-40 #footer .footer-widgets.footer.footer-2 .is-divider.small {
  background: var(--yhn-brand) !important;
  width: 28px !important;
  max-width: 28px !important;
  border-radius: 2px !important;
}

body.yhn-redesign-40 #footer .yhn-footer-classic-links a,
body.yhn-redesign-40 #footer .yhn-footer-more a {
  transition: color 0.16s ease, transform 0.16s ease;
}

body.yhn-redesign-40 #footer .yhn-footer-classic-links a:hover,
body.yhn-redesign-40 #footer .yhn-footer-more a:hover {
  color: var(--yhn-footer-accent) !important;
}

body.yhn-redesign-40 #footer .yhn-footer-classic-links a:hover .yhn-footer-leading-icon,
body.yhn-redesign-40 #footer .yhn-footer-more a:hover .yhn-footer-leading-icon {
  color: var(--yhn-footer-accent) !important;
  transform: translateX(3px) !important;
  opacity: 1 !important;
}

body.yhn-redesign-40 #footer .absolute-footer {
  background: var(--yhn-footer-bottom-bg) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.07) !important;
}

/* =========================================================
   6. FLOATING CONTACT + BACK-TO-TOP COLLISION GUARD
   ========================================================= */
body.yhn-redesign-40 .yhn-contact {
  --yhn-contact-color: var(--yhn-brand);
  left: auto !important;
  right: 16px !important;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

body.yhn-redesign-40 .yhn-contact summary {
  background: linear-gradient(145deg, var(--yhn-brand) 0%, var(--yhn-brand-hover) 100%) !important;
  box-shadow: var(--yhn-shadow-brand) !important;
}

body.yhn-redesign-40 .yhn-contact__header {
  background: linear-gradient(135deg, var(--yhn-brand-hover) 0%, var(--yhn-brand) 100%) !important;
}

body.yhn-redesign-40 .yhn-contact .yhn-contact__panel {
  left: auto !important;
  right: 0 !important;
  transform-origin: bottom right !important;
}

/* Keep Flatsome back-to-top cleanly stacked ABOVE the chat button (zero overlap) */
body.yhn-redesign-40 .back-to-top {
  left: auto !important;
  right: 19px !important;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  border-color: var(--yhn-line) !important;
  background-color: var(--yhn-bg) !important;
  color: var(--yhn-ink) !important;
  box-shadow: var(--yhn-shadow-sm) !important;
}

body.yhn-redesign-40 .back-to-top:hover {
  background-color: var(--yhn-brand) !important;
  border-color: var(--yhn-brand) !important;
  color: #ffffff !important;
}

@media (max-width: 849px) {
  body.yhn-redesign-40 .yhn-contact {
    right: 12px !important;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.yhn-redesign-40 .yhn-contact summary {
    width: 44px !important;
    height: 44px !important;
  }

  body.yhn-redesign-40 .yhn-contact summary svg {
    width: 20px !important;
    height: 20px !important;
  }

  body.yhn-redesign-40 .back-to-top {
    right: 14px !important;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Clear sticky add-to-cart or bottom checkout bars on single product & cart */
  body.yhn-redesign-40.single-product .yhn-contact,
  body.yhn-redesign-40.woocommerce-cart .yhn-contact {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.yhn-redesign-40.single-product .back-to-top,
  body.yhn-redesign-40.woocommerce-cart .back-to-top {
    bottom: calc(130px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Honor yhn-footer-safezone-395563.js across BOTH Desktop & Mobile so floating controls never overlap Footer links/COD badge */
html.yhn-footer-safezone-active body.yhn-redesign-40 .yhn-contact:not([open]),
html.yhn-footer-safezone-active body.yhn-redesign-40 .back-to-top {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(8px) scale(0.92) !important;
}
