/*---*\
Flexible Content Header
Sticky header for the Flexible Content page template (header-flexible.php).

KEY FEATURES:
- Mobile: logo bar with menu toggle, search and eStore actions; menu opens as a drop-down panel
- Desktop (1200px+): teal utility bar above a logo, primary nav and search row
- Single grid layout shared by both breakpoints, so no markup is duplicated

IMPLEMENTATION NOTES:
- Loads after base.css; selectors use header.fxh to out-rank the global header rules
- Utility icons are white artwork; the cart icon is recoloured with a mask on mobile
\*---*/

:root {
  --fx-teal: #0289bf;
  --fx-border: #d7dbdd;
  --fx-placeholder: #b1b6bb;
}

.fxh .screen-reader-text,
.fxf .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fx-skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100000;
  padding: 1em;
  background: var(--blue);
  color: var(--white);
}

.fx-skip-link:focus {
  top: 0;
  left: 0;
}

header.fxh {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: 59px auto auto;
  grid-template-areas:
    "toggle logo actions"
    "panel panel panel"
    "util util util";
  align-items: center;
  opacity: 1;
  transform: none;
  background: var(--white);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Kill base.css white gradient overlay that covers the teal utility bar */
header.fxh::after {
  content: none;
  display: none;
}

header.fxh.is-open {
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
}

.fxh a,
.fxh button,
.fxh input {
  font-family: AeonikRegular, sans-serif;
}

.fxh a:focus-visible,
.fxh button:focus-visible,
.fxh input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.fxh__toggle,
.fxh__action,
.fxh__sub-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--black);
  cursor: pointer;
}

.fxh__toggle {
  grid-area: toggle;
  justify-self: start;
  width: 59px;
  height: 59px;
}

.fxh__burger {
  display: block;
  position: relative;
  width: 22px;
  height: 16px;
}

.fxh__burger span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease, top 0.25s ease;
}

.fxh__burger span:nth-child(1) {
  top: 0;
}

.fxh__burger span:nth-child(2) {
  top: 7px;
}

.fxh__burger span:nth-child(3) {
  top: 14px;
}

.fxh.is-open .fxh__burger span:nth-child(1) {
  top: 7px;
  transform: rotate(45deg);
}

.fxh.is-open .fxh__burger span:nth-child(2) {
  opacity: 0;
}

.fxh.is-open .fxh__burger span:nth-child(3) {
  top: 7px;
  transform: rotate(-45deg);
}

.fxh__logo {
  grid-area: logo;
  display: block;
  width: 144px;
  line-height: 0;
}

.fxh__logo img {
  display: block;
  width: 100%;
  height: auto;
}

.fxh__actions {
  grid-area: actions;
  display: flex;
  justify-self: end;
  gap: 16px;
  padding-right: 15px;
}

.fxh__action {
  width: 24px;
  height: 24px;
}

.fxh__icon {
  display: block;
  width: 24px;
  height: 24px;
}

.fxh__icon--cart {
  background: currentColor;
  -webkit-mask: url('../assets/images/flexible/header-icon-catalog.svg') center / contain no-repeat;
  mask: url('../assets/images/flexible/header-icon-catalog.svg') center / contain no-repeat;
}

.fxh__action:hover,
.fxh__toggle:hover {
  color: var(--blue);
}

.fxh__panel {
  grid-area: panel;
  display: none;
  flex-direction: column;
  gap: 20px;
  padding: 16px 20px 24px;
  border-top: 1px solid var(--grey);
}

.fxh.is-open .fxh__panel {
  display: flex;
}

.fxh__search {
  position: relative;
  order: -1;
  width: 100%;
  height: 44px;
}

.fxh__search-input {
  width: 100%;
  height: 100%;
  padding: 0 16px 0 52px;
  border: 1px solid var(--fx-border);
  border-radius: 34.56px;
  background: transparent;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  color: var(--black);
  font-size: 16px;
  appearance: none;
}

.fxh__search-input::placeholder {
  color: var(--fx-placeholder);
  opacity: 1;
}

.fxh__search-submit {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}

.fxh__search-submit img {
  display: block;
  width: 15px;
  height: 15px;
}

.fxh__menu,
.fxh__menu .sub-menu,
.fxh__utility-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.fxh__menu > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--grey);
}

.fxh__menu a {
  display: block;
  flex: 1;
  padding: 14px 0;
  color: var(--black);
  font-family: AeonikMedium, sans-serif;
  font-size: 18px;
  line-height: 1.3;
  text-decoration: none;
}

.fxh__menu a:hover {
  color: var(--blue);
}

.fxh__sub-toggle {
  width: 44px;
  height: 44px;
}

.fxh__chevron {
  display: block;
  flex: none;
  width: 5.667px;
  height: 10.6px;
  margin: 0 2.47px;
  background: url('../assets/images/flexible/header-chevron.svg') center / 100% 100% no-repeat;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.fxh__menu > li > .fxh__chevron {
  margin-right: 17px;
}

.fxh__sub-toggle[aria-expanded="true"] .fxh__chevron {
  transform: rotate(-90deg);
}

.fxh__menu .sub-menu {
  display: none;
  flex-basis: 100%;
  padding: 0 0 8px 16px;
}

.fxh__menu li.is-open > .sub-menu {
  display: block;
}

.fxh__menu .sub-menu a {
  padding: 10px 0;
  font-family: AeonikRegular, sans-serif;
  font-size: 16px;
}

.fxh__utility {
  grid-area: util;
  align-self: stretch;
  display: none;
  padding: 16px 20px;
  background: var(--fx-teal);
}

.fxh.is-open .fxh__utility {
  display: block;
}

.fxh__utility-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.fxh__utility-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
}

.fxh__utility-link:hover span {
  text-decoration: underline;
}

.fxh__utility a:focus-visible {
  outline-color: var(--white);
}

@media (max-width: 1199px) {
  body.fxh-menu-open {
    overflow: hidden;
  }
}

@media (min-width: 1200px) {
  header.fxh {
    grid-template-columns: auto 1fr;
    grid-template-rows: 44px 76px;
    grid-template-areas:
      "util util"
      "logo panel";
    max-height: none;
    overflow: visible;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  }

  header.fxh.is-open {
    max-height: none;
    overflow: visible;
  }

  .fxh__toggle,
  .fxh__actions {
    display: none;
  }

  .fxh__logo {
    width: clamp(140px, 9.3vw, 179px);
    margin-left: clamp(20px, 2.6vw, 50px);
  }

  .fxh__utility,
  .fxh.is-open .fxh__utility {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 clamp(20px, 3vw, 58px);
  }

  .fxh__utility-list {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .fxh__utility-item {
    display: flex;
    align-items: center;
    height: 20px;
    padding-right: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
  }

  .fxh__utility-item:last-child {
    padding-right: 0;
    border-right: 0;
  }

  .fxh__panel,
  .fxh.is-open .fxh__panel {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(16px, 1.56vw, 30px);
    padding: 0 clamp(20px, 3vw, 58px) 0 24px;
    border-top: 0;
  }

  .fxh__search {
    order: 0;
    flex: none;
    width: clamp(220px, 22.5vw, 431px);
    height: 32px;
  }

  .fxh__search-input {
    padding: 0 16px 0 36.48px;
    font-size: 15px;
  }

  .fxh__search-submit {
    top: 4.22px;
    left: 4.22px;
    width: 23.04px;
    height: 23.04px;
  }

  .fxh__menu {
    display: flex;
    align-items: center;
    gap: clamp(16px, 1.56vw, 30px);
  }

  .fxh__menu > li {
    position: relative;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 27px 0;
    border-bottom: 0;
  }

  .fxh__menu a {
    flex: none;
    padding: 0;
    font-size: 16px;
    line-height: 1.32;
    white-space: nowrap;
  }

  .fxh__sub-toggle {
    width: auto;
    height: auto;
  }

  .fxh__menu > li > .fxh__chevron {
    margin-right: 2.47px;
  }

  .fxh__menu .sub-menu {
    position: absolute;
    top: 100%;
    left: -16px;
    z-index: 10;
    min-width: 220px;
    padding: 12px 0;
    border-radius: 0 0 12px 12px;
    background: var(--white);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  }

  .fxh__menu li:hover > .sub-menu,
  .fxh__menu li:focus-within > .sub-menu,
  .fxh__menu li.is-open > .sub-menu {
    display: block;
  }

  .fxh__menu .sub-menu a {
    padding: 8px 16px;
    white-space: normal;
  }

  .fxh__menu li:hover > .fxh__sub-toggle .fxh__chevron,
  .fxh__menu li.is-open > .fxh__sub-toggle .fxh__chevron {
    transform: rotate(-90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fxh__burger span,
  .fxh__chevron {
    transition: none;
  }
}
