/* CLIENTS-33540: header matches the marketing site.
   Content (bars, button, nav pages) lives in the area's HeaderDesktop / HeaderMobile pages; this file only styles it.
   Marketing: edges 30px (full width), burgundy bar 36px + blue bar 40px with 15px / 800 / ls 2px uppercase text,
   #fafafa logo row, pill search with the icon on the right, burgundy pill button 16px / 700.
   Nav link and dropdown styles: main-menu.css. */
header[data-swift-page-header] {
  /* Rows run full width with a 30px edge, centered in 1440px like marketing's 1500px logo row with 30px padding;
     this beats the page-margin rule in Assets/css/custom.css */
  [data-swift-container] {
    max-width: 1440px;
    --dw-container-gutter: 0px;
    width: calc(100% - 60px);
    margin-inline: auto;
  }

  /* Top bars: both rows share one look, only the color scheme differs */
  section[data-dw-colorscheme="pcs_topbar"],
  section[data-dw-colorscheme="pcs_blue"] {
    padding-block: 6px;

    p,
    strong {
      margin: 0;
      font-size: 15px;
      font-weight: 800;
      line-height: 1.625;
      letter-spacing: 2px;
      text-transform: uppercase;
    }
  }

  /* Blue bar: 40px like marketing; the text uses the full column (Swift's Text paragraph caps it at 752px) */
  &.pcs-header-desktop section[data-dw-colorscheme="pcs_blue"] {
    padding-block: 0;

    /* The container fills the 40px so its centered text sits mid-bar (a min-height on the section left it at the top) */
    [data-swift-container] {
      align-items: center;
      min-height: 40px;
      max-width: 1552px; /* marketing's 1600px announce container less 24px padding each side */
      width: calc(100% - 48px); /* marketing's 24px edge: icons start at x = 24 (or (vw - 1552) / 2 above 1600px) */
    }

    /* Social icon group: five 28px boxes (like marketing) with a 12px gap = 188px. Keep these two in step with the boxes below. */
    --pcs-social-width: 188px;
    --pcs-social-gap: 12px;

    /* Center the text on the page, not in the space right of the icons: the right margin mirrors the icon group
       (188px + 12px = 200px). The text still wraps where narrow. */
    [data-dw-itemtype="swift-v2_text"] {
      margin-inline-end: calc(var(--pcs-social-width) + var(--pcs-social-gap));
    }

    .mx-auto {
      max-width: none !important; /* beats the 752px cap on the Text paragraph */
    }

    /* Social icons: the measured marketing size of each one (Facebook, Instagram, YouTube, LinkedIn, X), centered in a 28px box
       with a 12px gap; the logo figure carries an inline width:25px */
    [data-swift-container] {
      column-gap: var(--pcs-social-gap);
    }

    [data-dw-itemtype="swift-v2_logo"] {
      flex: 0 0 28px !important; /* beats flex-fill */
      width: 28px;

      figure {
        width: 28px !important; /* beats the inline width */
        display: flex;
        justify-content: center;
      }

      &:nth-child(1) svg { width: 10px; height: 18px; }
      /* The store's icons draw inside a 24px viewBox with padding, so each box is sized up until the visible glyph
         matches marketing; the negative margin gives the padding back to the layout (keeps the gaps) */
      &:nth-child(2) svg { width: 23px; height: 23px; margin: -3.85px; }
      /* YouTube and X: the glyphs sit off-center in their viewBox, so these margins are asymmetric on purpose */
      &:nth-child(3) svg { width: 22.6px; height: 22.6px; margin: -4.7px 0.4px -4.7px -4.2px; }
      &:nth-child(4) svg { width: 26.7px; height: 26.7px; margin: -3.35px; }
      &:nth-child(5) svg { width: 20px; height: 20px; margin: -4px -2.1px -4px -4.9px; }
    }
  }

  /* Logo row */
  section[data-dw-colorscheme="light"] {
    background: #fafafa !important; /* beats the light color scheme background */

    /* Tighter column gap and no gap for the empty My Account slot (signed-out), so the search pill keeps 364px at 1440 */
    [data-swift-container] {
      column-gap: 4px;
    }

    [data-dw-itemtype="swift-v2_myaccount"]:not(:has(*)),
    /* signed in: SignIn renders nothing, but its column would still add 12px + a gap (desktop only, the phone row stays as it is) */
    [data-dw-itemtype="swift-v2_signin"]:not(:has(*)):not(.pcs-header-mobile *) {
      display: none;
    }

    /* 12px + the 4px column gap = the 16px of the phone header, before the account and cart icons (desktop only: the phone header has its own spacing) */
    > [data-swift-container] > :is([data-dw-itemtype="swift-v2_signin"], [data-dw-itemtype="swift-v2_myaccount"], [data-dw-itemtype="swift-v2_minicart"]):not(.pcs-header-mobile *) {
      margin-left: 12px;
    }

    /* Empty placeholder columns would take a share of the row */
    [data-swift-gridcolumn][data-dw-itemtype=""] {
      display: none;
    }

    [data-dw-itemtype="swift-v2_logo"],
    [data-dw-itemtype="swift-v2_myaccount"],
    [data-dw-itemtype="swift-v2_signin"],
    [data-dw-itemtype="swift-v2_minicart"],
    [data-dw-itemtype="swift-v2_button"] {
      flex: 0 0 auto !important; /* beats flex-fill */
    }

    /* No "Cart" word next to the icon (marketing has no cart); the link's aria-label (MiniCart Clean.cshtml) is its name */
    > [data-swift-container] > [data-dw-itemtype="swift-v2_minicart"] .nav-link > span:not(.icon-3):not(.mini-cart-quantity) {
      display: none;
    }

    /* Account icon only, like the cart (the link's aria-label in MyAccount Clean.cshtml is its name); the phone header keeps its label */
    > [data-swift-container] > [data-dw-itemtype="swift-v2_myaccount"]:not(.pcs-header-mobile *) .nav-link > span:not(.icon-3) {
      display: none;
    }

    /* Phone, email and store hours take the space the fixed columns leave */
    [data-dw-itemtype="swift-v2_navigation"] {
      flex: 1 4 auto; /* gives up space before the search pill does */
      .pcs-stacked-nav {
        font-size: 14px;
      }

      nav {
        justify-content: space-evenly !important; /* beats justify-content-end on the nav */
      }
    }

    /* Find a Contractor: one line, marketing size. Its light_pcs_red scheme paints a white box behind the button. */
    [data-dw-itemtype="swift-v2_button"] {
      background: transparent !important; /* beats the color scheme background */
    }

    [data-dw-itemtype="swift-v2_button"] .btn {
      padding: 6px 15.2px;
      font-size: 16px;
      font-weight: 700;
      white-space: nowrap;
      border-radius: 32px;

      @media (max-width: 1400px) {
        font-size: 13px; /* marketing steps 16px -> 13px at 1400 */
      }

      &:focus-visible {
        outline: 2px solid #741012;
        outline-offset: 2px;
      }
    }
  }

  /* Desktop only (the phone header's row must fit five icons): visible space from the search pill and from Find a Contractor.
     The padding is the gap minus the space the column already shows, measured: 12px on the pill side, 4px on the button side.
     Only the pill shrinks to pay for it. */
  &.pcs-header-desktop [data-dw-itemtype="swift-v2_navigation"] {
    --pcs-contact-gap: 24px;
    padding-left: calc(var(--pcs-contact-gap) - 12px);
    padding-right: calc(var(--pcs-contact-gap) - 4px);

    @media (min-width: 1400px) {
      --pcs-contact-gap: 32px;
    }
  }

  /* Desktop only (the phone menu panel has its own search): logo -> pill = 3.17% of the row like marketing's column gap;
     4px is the space the column already has */
  &.pcs-header-desktop [data-dw-itemtype="swift-v2_searchfield"] {
    margin-left: calc(3.1713% - 4px);
  }

  /* Search pill: icon on the right, 26.4% of the row (364px at 1920), shrinks before anything wraps. At 1440 the contact gaps
     leave it about 308px. */
  [data-dw-itemtype="swift-v2_searchfield"] {
    flex: 0 1 26.4% !important; /* beats flex-fill; the pill fills its column, so the gap to the phone icon is real */
    min-width: 160px;
    align-self: center; /* beats the row's stretch: the pill is centered in the logo row */

    @media (max-width: 1260.98px) {
      flex-basis: 20% !important; /* marketing's 1261 step */
    }

    /* Swift default: each search wrapper has an 8px left margin; stacked they pushed the pill 24px right, out of its column */
    .search-modal,
    .js-async-fetch-placeholder,
    .type-ahead-dropdown {
      margin-left: 0 !important; /* beats the wrapper margins */
    }

    > div > .js-async-fetch-placeholder > div > form {
      position: relative;
      margin-bottom: 0 !important; /* beats mb-3: the form is only as tall as the pill, so the pill centers in the row */
    }

    .js-type-ahead-field {
      padding: 10px 48px 10px 14px !important; /* beats ps-5 / pe-3 */
      border: 1px solid #e5e4e2;
      border-radius: 50px;
      font-size: 17px;
      line-height: 20px;
      color: #606060;
      background: #fff;

      &::placeholder {
        color: #606060;
        opacity: 1;
      }
    }

    .search-icon {
      color: #741012;
      inset: 0 0 0 auto !important; /* beats top-0 and moves the icon from left to right */
    }

    .reset-search {
      right: 40px !important; /* the clear button sits left of the icon */
    }
  }
}

/* Marketing's steps for phone, email and store hours (items 1-3 of the nav; the nth-child rules assume that order: phone, email, hours): all labels above 1200px; 1025-1200px phone and
   email icons only, hours keeps its label; 1024px and below hours is hidden too. The phone header (below) drops hours at every width. */
@media (max-width: 1400px) {
  header.pcs-header-desktop[data-swift-page-header] section[data-dw-colorscheme="light"] [data-dw-itemtype="swift-v2_navigation"] .pcs-stacked-nav {
    font-size: 12px; /* marketing's labels are 12px up to 1400px; this leaves the search pill its width */
  }
}

@media (max-width: 1200.98px) {
  header.pcs-header-desktop section[data-dw-colorscheme="light"] .pcs-header-nav {
    > li:nth-child(-n + 2) .pcs-stacked-nav {
      display: none !important; /* beats d-xl-flex */
    }

    > li:nth-child(3) .pcs-stacked-nav {
      display: flex !important; /* d-xl-flex hides it below 1200px */
    }
  }
}

@media (max-width: 1024.98px) {
  header.pcs-header-desktop section[data-dw-colorscheme="light"] .pcs-header-nav > li:nth-child(3) {
    display: none;
  }
}

/* Mobile header: same bars, the logo row keeps its icons on one line */
header.pcs-header-mobile {
  [data-swift-container] {
    width: calc(100% - 30px);
  }

  section[data-dw-colorscheme="pcs_topbar"],
  section[data-dw-colorscheme="pcs_blue"] {
    p,
    strong {
      font-size: 15px;
      letter-spacing: 2px;
    }
  }

  /* Phones: the red bar is 13px with normal spacing, one line (marketing) */
  @media (max-width: 575.98px) {
    section[data-dw-colorscheme="pcs_topbar"] {
      p,
      strong {
        font-size: 13px;
        letter-spacing: normal;
      }
    }
  }

  section[data-dw-colorscheme="light"] [data-swift-container] {
    flex-wrap: nowrap;
    align-items: center;
  }

  /* Logo row only: direct children, so nothing reaches the menu panel (offcanvas) that lives inside this header.
     Hamburger and logo on the left, contact icons, account and cart pushed to the right edge. */
  section[data-dw-colorscheme="light"] > [data-swift-container] > [data-dw-itemtype] {
    &[data-dw-itemtype="swift-v2_logo"] {
      margin-left: 16px; /* gap after the menu icon */

      img {
        height: auto;

        @media (max-width: 399.98px) {
          max-width: 110px; /* keeps all five icons on one line at 360-390px */
        }

        @media (max-width: 369.98px) {
          max-width: 96px;
        }
      }
    }

    &[data-dw-itemtype="swift-v2_navigation"] {
      flex: 0 0 auto !important; /* beats flex-fill, so margin-left: auto has free space */
      margin-left: auto;

      /* The 32px circles are the tap targets here (the desktop p-2 box is 48px and would not fit at 360px) */
      .pcs-header-nav {
        gap: 4px !important; /* beats gap-2 */
        padding: 0;

        .nav-link {
          padding: 0 !important; /* beats p-2 */
        }

        > li:nth-child(3) {
          display: none; /* store hours: the label never shows in this header, and the icon is not a link */
        }
      }
    }

    &[data-dw-itemtype="swift-v2_signin"] {
      margin-left: auto;
    }

    &[data-dw-itemtype="swift-v2_navigation"] ~ &[data-dw-itemtype="swift-v2_signin"] {
      margin-left: 12px;
    }

    /* 16px between the columns: the 36px tap boxes of the two icons (20px column + 8px each side) do not overlap */
    &[data-dw-itemtype="swift-v2_minicart"] {
      margin-left: 12px;
    }
  }
}
