/* =========================================================
   Header / navigation / language switcher / mini-cart popup.
   =========================================================
   Historically the most fragile, most frequently patched part of this
   theme (menu wrapping to 2 rows, logo splitting onto its own row,
   mini-cart popup staying open, a corrupted media-query block) — split
   out of the old monolithic style.css into its own small, lintable file
   so future edits stay scoped and are easier to review/diff.

   Markup for the nav row (logo + menu) and the language switcher now
   lives in template-parts/header/site-nav.php and
   template-parts/header/language-switcher.php (see the render functions
   in inc/navigation.php) — this file only handles presentation. The
   mini-cart itself is still rendered by Storefront/WooCommerce's own
   `storefront_header_cart` hook (kept untouched so its AJAX cart-fragment
   refresh keeps working); we only style it here.

   Storefront's own Header Text Color (Customize > Colors) is meant to
   handle text contrast, but if it's left on the default dark text while
   the header background is set dark, the primary menu becomes
   unreadable. These rules fix text/icon colors without changing the
   header's background color itself (that stays whatever is set in
   Customize > Colors > Header Background).
   ========================================================= */
.site-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding-top: 0;
}
/*
 * #masthead (the <header> element) renders several independent blocks as
 * DIRECT children — the top .col-full (skip links, hidden legacy
 * branding/search), .storefront-primary-navigation (menu), the language
 * switcher <details>, and .site-header-cart — each hooked onto
 * `storefront_header` at a different priority (see inc/navigation.php).
 * None of those hooks nest inside a shared wrapper, so #masthead itself
 * has to be the flex container that lines all of them up in one row;
 * without this rule each block renders as its own full-width row
 * regardless of any `flex:`/`order` set on the children themselves (that
 * was the actual root cause behind the header repeatedly ending up on
 * more than one row / the cart button rendering an oddly wide box).
 */
#masthead {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}
#masthead > .col-full {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0 24px;
}
.site-header .col-full {
  max-width: none;
}
#masthead .pharm-header-lang-switcher {
  flex: 0 0 auto;
}
#masthead .site-header-cart {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
#masthead .storefront-primary-navigation {
  display: flex !important;
  flex: 1 1 auto;
  min-width: 0;
}
#masthead .storefront-primary-navigation > .col-full {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px 0 10px;
  flex-wrap: nowrap;
}
.main-navigation {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
}
#masthead #site-navigation {
  flex: 1 1 auto;
  min-width: 0;
}
.main-navigation .primary-navigation {
  flex: 0 1 auto;
  min-width: 0;
}
#primary-menu {
  justify-content: flex-start;
  flex-wrap: nowrap;
  white-space: nowrap;
}
#masthead .secondary-navigation,
#masthead .site-search,
#masthead .widget_product_search,
#masthead .storefront-product-search {
  display: none !important;
}
.main-navigation a,
.main-navigation .menu-toggle,
#primary-menu > li > a,
#primary-menu li a,
.primary-navigation a,
.handheld-navigation a {
  color: var(--pharm-white) !important;
}
.site-header-cart .cart-contents,
.site-header-cart .cart-contents .amount,
.site-header-cart .cart-contents .count,
.site-header-cart .widget_shopping_cart a,
.site-header-cart .widget_shopping_cart .amount,
.site-header-cart .widget_shopping_cart .quantity,
.site-header-cart .widget_shopping_cart .total,
.site-header-cart .widget_shopping_cart .buttons a,
.site-header-cart .widget_shopping_cart li,
.site-header-cart .widget_shopping_cart p,
.site-header-cart .widget_shopping_cart span {
  color: var(--pharm-white) !important;
}
.site-header-cart .cart-contents::after,
.site-header-cart .cart-contents:before,
.site-header-cart .widget_shopping_cart::before {
  color: var(--pharm-white) !important;
}
.main-navigation a:hover,
.main-navigation .menu-toggle:hover,
.primary-navigation a:hover,
.handheld-navigation a:hover,
.site-header-cart .cart-contents:hover,
.site-header-cart .widget_shopping_cart a:hover {
  color: var(--pharm-accent) !important;
}

/* ---- Header product search: rounded pill matching the dark header ---- */
.header-widget-region .search-field,
.site-header input[type='search'] {
  border-radius: 999px !important;
  border: 1px solid transparent;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.header-widget-region .search-field:focus,
.site-header input[type='search']:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 143, 95, 0.25);
  transform: translateY(-1px);
}

/* ---- Modern nav links: proper spacing + animated underline ---- */
#primary-menu,
.primary-navigation ul.menu {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}
#primary-menu > li > a,
.primary-navigation a {
  position: relative;
  display: inline-block;
  padding: 8px 16px;
  transition: color 0.2s ease, transform 0.2s ease;
}
#primary-menu > li > a::after,
.primary-navigation a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--pharm-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
#primary-menu > li > a:hover,
.primary-navigation a:hover {
  transform: translateY(-1px);
}
#primary-menu > li > a:hover::after,
.primary-navigation a:hover::after,
#primary-menu > li.current-menu-item > a::after,
.primary-navigation .current-menu-item > a::after {
  transform: scaleX(1);
}

/* ---- Modern animated hamburger toggle (no markup changes needed) ---- */
.main-navigation .menu-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--pharm-white);
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.main-navigation .menu-toggle::before,
.main-navigation .menu-toggle::after {
  content: '';
  position: absolute;
  left: 16px;
  width: 16px;
  height: 2px;
  background: var(--pharm-white);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
}
.main-navigation .menu-toggle::before {
  top: 14px;
  box-shadow: 0 5px 0 var(--pharm-white);
}
.main-navigation .menu-toggle::after {
  top: 24px;
}
.main-navigation .menu-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--pharm-white);
  transform: translateY(-1px);
}
.main-navigation .menu-toggle:active {
  transform: translateY(0) scale(0.97);
}
/* Storefront toggles `.toggled` on #site-navigation and
   `aria-expanded="true"` on the button itself when the mobile menu opens —
   morph the 3 bars into an "X". */
.main-navigation.toggled .menu-toggle::before,
.main-navigation .menu-toggle[aria-expanded='true']::before {
  top: 19px;
  box-shadow: none;
  transform: rotate(45deg);
}
.main-navigation.toggled .menu-toggle::after,
.main-navigation .menu-toggle[aria-expanded='true']::after {
  top: 19px;
  transform: rotate(-45deg);
}
/* IMPORTANT: Storefront itself hides .menu-toggle at desktop widths via
   `@media (min-width: 768px) { .menu-toggle { display: none; } }`, but our
   `.main-navigation .menu-toggle` selector above has higher specificity
   (two classes vs. one) and was winning even on desktop — showing the
   pill "Menu" button at the same time as the full horizontal nav. Re-hide
   it at the same breakpoint, at matching/higher specificity, so desktop
   only ever shows the horizontal menu and mobile only ever shows the
   toggle. */
@media screen and (min-width: 768px) {
  .main-navigation .menu-toggle {
    display: none !important;
  }

  #masthead > .col-full {
    padding: 0 24px;
  }

  #masthead .storefront-primary-navigation > .col-full {
    flex-wrap: nowrap;
  }

  .main-navigation {
    flex-wrap: nowrap;
  }

  .main-navigation .primary-navigation {
    margin-right: auto;
  }
}

/* ---- Mobile dropdown menu: smooth slide/fade instead of a hard cut ---- */
@media (max-width: 768px) {
  #masthead {
    flex-wrap: wrap;
  }

  #masthead > .col-full {
    padding: 0 14px;
  }

  #masthead #site-navigation {
    width: 100%;
  }

  #masthead .storefront-primary-navigation > .col-full {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 0 10px;
  }

  .main-navigation {
    flex-wrap: wrap;
    gap: 10px;
  }

  .main-navigation .primary-navigation {
    order: 3;
    width: 100%;
    flex: 1 1 100%;
  }

  #primary-menu,
  .primary-navigation ul.menu {
    flex-wrap: wrap;
    white-space: normal;
  }

  .handheld-navigation {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease;
  }
  .main-navigation.toggled .handheld-navigation {
    max-height: 1000px;
    opacity: 1;
  }
}

/* =========================================================
   Header language switcher — a floating "flag + name" dropdown card next
   to the main nav (see template-parts/header/language-switcher.php,
   rendered from inc/navigation.php's pharm_render_header_language_
   switcher()), built with a native <details>/<summary> disclosure so no
   custom JavaScript is needed and it degrades gracefully.

   How switching applies: every page renders its OWN copy of this
   switcher, and each entry links straight to THAT page's translation
   (Polylang resolves the URL per-page). So clicking a language always
   applies immediately to the page you're currently viewing — there is no
   separate "site-wide" toggle to keep in sync. As long as a page has been
   translated (via the "+" in wp-admin), switching language on it takes
   you to its translation; if a specific page/post hasn't been translated
   yet, only the languages it currently has a translation for are listed.

   Note: if this only ever shows one language (e.g. "EN" with no dropdown
   arrow), that's a content/config state, not a style bug — Polylang only
   lists languages that have been created under Languages > Languages
   (and, by default, only ones with an existing translation for the
   current page). Add the remaining languages there and translate the
   page/post to make them appear here.
   ========================================================= */
.pharm-header-lang-switcher {
  position: relative;
  display: inline-flex;
}
.pharm-header-lang-switcher--static {
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  color: var(--pharm-white);
  font-size: 13px;
  font-weight: 600;
}
.pharm-lang-switcher__button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  color: var(--pharm-white);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}
.pharm-lang-switcher__button::-webkit-details-marker {
  display: none;
}
.pharm-header-lang-switcher:hover .pharm-lang-switcher__button,
.pharm-header-lang-switcher[open] .pharm-lang-switcher__button {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.pharm-lang-switcher__flag img {
  display: block;
  width: 18px;
  height: auto;
  border-radius: 2px;
}
.pharm-lang-switcher__chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}
.pharm-header-lang-switcher[open] .pharm-lang-switcher__chevron {
  transform: rotate(-135deg) translateY(-1px);
}
.pharm-lang-switcher__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  margin: 0;
  padding: 10px;
  list-style: none;
  background: linear-gradient(165deg, #21362f 0%, #182a24 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(6px);
  animation: pharm-lang-menu-in 0.2s ease;
}
.pharm-lang-switcher__menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--pharm-white) !important;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.pharm-lang-switcher__menu a:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateX(2px);
  color: var(--pharm-white) !important;
}
.pharm-lang-switcher__menu .pharm-lang-switcher__flag img {
  width: 20px;
}

@keyframes pharm-lang-menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Header cart icon: solid elevated "card" (not just an outline pill),
   matching the same distinct-from-menu treatment as the logo mark, plus a
   subtle lift + pulsing count badge ---- */
.site-header-cart {
  transition: transform 0.2s ease;
}
.site-header-cart:hover {
  transform: translateY(-1px);
}
.site-header-cart .cart-contents {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  width: fit-content;
  max-width: 190px;
  gap: 6px;
  padding: 0.7rem !important;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}
.site-header-cart .cart-contents:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.site-header-cart .cart-contents .amount {
  font-weight: 700;
  white-space: nowrap;
}
.site-header-cart .cart-contents .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  margin-right: 0.6rem;
  background: var(--pharm-accent);
  color: var(--pharm-white) !important;
  font-size: 10px;
  font-weight: 700;
  line-height: 20px;
  white-space: nowrap;
  animation: pharm-badge-pop 0.3s ease;
}

/* ---- Mini cart popup: high contrast modern floating panel ---- */
.site-header-cart .widget_shopping_cart {
  display: block !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  right: 0;
  left: auto;
  margin-top: 12px;
  min-width: 280px;
  max-width: 320px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(165deg, #20352d 0%, #172822 100%);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
}

.site-header-cart:hover .widget_shopping_cart,
.site-header-cart:focus-within .widget_shopping_cart {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.site-header-cart .widget_shopping_cart::before {
  border-bottom-color: #1c3029;
}

.site-header-cart .widget_shopping_cart .woocommerce-mini-cart__empty-message,
.site-header-cart .widget_shopping_cart p,
.site-header-cart .widget_shopping_cart li,
.site-header-cart .widget_shopping_cart .quantity,
.site-header-cart .widget_shopping_cart .amount,
.site-header-cart .widget_shopping_cart .total {
  color: rgba(255, 255, 255, 0.96) !important;
}

.site-header-cart .widget_shopping_cart .woocommerce-mini-cart__empty-message {
  margin: 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
  line-height: 1.45;
}

.site-header-cart .widget_shopping_cart .buttons {
  display: flex;
  gap: 10px;
  margin: 12px 0 0;
}

.site-header-cart .widget_shopping_cart .buttons a {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
  text-align: center;
  font-weight: 600;
  padding: 8px 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.site-header-cart .widget_shopping_cart .buttons a:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

@keyframes pharm-badge-pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 782px) {
  .site-header-cart .widget_shopping_cart {
    min-width: min(92vw, 320px);
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #primary-menu > li > a,
  .primary-navigation a,
  .main-navigation .menu-toggle,
  .main-navigation .menu-toggle::before,
  .main-navigation .menu-toggle::after,
  .handheld-navigation,
  .pharm-lang-switcher__button,
  .pharm-lang-switcher__chevron,
  .pharm-lang-switcher__menu,
  .pharm-lang-switcher__menu a,
  .pharm-logo-placeholder,
  .header-widget-region .search-field,
  .site-header input[type='search'],
  .site-header-cart,
  .site-header-cart .cart-contents,
  .site-header-cart .cart-contents .count,
  .site-header-cart .widget_shopping_cart,
  .site-header-cart .widget_shopping_cart .buttons a {
    transition: none !important;
    animation: none !important;
  }
}
