/* CLIENTS-33538: footer matches the marketing site (www.permachink.com) in content, type and geometry.
   Content lives in the area's FooterDesktop / FooterMobile pages; this file only styles it.
   Rows and columns are selected by the paragraph types they hold, not by id.
   The desktop page is the one with Feature paragraphs (CONTACT US / STORE HOURS); the phone page has none.
   Target values are the marketing footer's computed styles (QA rev 2, 2026-10-30). */
footer[data-swift-page-footer] {
  --pcs-footer-line: rgba(255, 255, 255, 0.5);

  /* The marketing footer container: 1356px wide, 15px side gutter (30px from 801px) */
  [data-swift-container] {
    max-width: min(1356px, 100% - 30px);
  }

  /* Empty spacer columns (the editor's alignment fillers) take no room */
  [data-swift-gridcolumn][data-dw-itemtype=""] {
    display: none;
  }

  /* Logo: 219 x 86 */
  [data-dw-itemtype="swift-v2_logo"] img {
    width: 219px !important; /* beats the width the item writes inline */
  }

  /* CONTACT US / STORE HOURS blocks (the column prefix outranks custom.css's 18px text-paragraph rule) */
  [data-swift-gridcolumn] [data-swift-text]:has(> h6) {
    h6 {
      font-size: 16px;
      font-weight: 700;
      line-height: 26px;
      letter-spacing: normal;
      text-transform: uppercase;
      margin: 0 0 24px;
    }

    /* Phone + "Open 8AM - 5PM", hours + "Except major holidays": small lines */
    p {
      font-size: 14px;
      line-height: 21px;
      margin: 0;
    }

    /* The phone is a large link on its own line */
    a[href^="tel:"] {
      display: inline-block;
      vertical-align: top;
      font-size: 20px;
      font-weight: 500;
      line-height: 30px;
      text-decoration: none;
    }

    /* "Monday - Friday 8AM - 5PM" is the first line, before the <br> */
    p:first-of-type:not(:has(a[href^="tel:"]))::first-line {
      font-size: 16px;
      line-height: 30px;
    }

    /* The email line and "Always open online!" */
    p + p {
      font-size: 16px;
      font-weight: 500;
      line-height: 26px;
      margin-top: 24px;
    }

    a[href^="mailto:"] {
      text-decoration: none;
    }
  }

  /* Store Locations / Submit A Project / View Our Free Catalog: 20px on a 48px pitch, 14px arrow */
  [data-dw-itemtype="permachinknavigationlinklist"] {
    a {
      gap: 10px !important; /* beats the gap-2 utility */
    }

    h6 {
      line-height: 28px;
      letter-spacing: normal;
    }

    figure {
      width: 14px;
      height: 14px;
      margin: 0 !important; /* beats the me-4 utility */

      svg {
        width: 100%;
        height: 100%;
      }
    }
  }

  /* Social row: 28px white circles with a dark glyph, 14px apart */
  [data-swift-container]:has(> [data-dw-itemtype="swift-v2_logo"] ~ [data-dw-itemtype="swift-v2_logo"]) {
    column-gap: 14px;

    > [data-dw-itemtype="swift-v2_logo"] {
      flex: none;

      figure {
        display: grid;
        place-items: center;
        width: 28px !important; /* beats the width the item writes inline on the figure */
        height: 28px;
        border-radius: 50%;
        background: #fff;
      }

      svg {
        width: auto;
        height: 18px;
      }

      /* 24px viewBox with padding: size each box so the visible glyph matches marketing (Facebook keeps its own viewBox) */
      &:nth-child(2) svg { width: 23px; height: 23px; }
      &:nth-child(3) svg { width: 22.6px; height: 22.6px; }
      &:nth-child(4) svg { width: 21.3px; height: 21.3px; }
      &:nth-child(5) svg { width: 20px; height: 20px; }

      path {
        fill: #2d2d2d; /* the SVG paths carry fill="white" as an attribute */
      }

      /* The link is an empty stretched-link anchor, so ring the circle when it has keyboard focus */
      &:has(a:focus-visible) figure {
        outline: 2px solid #fff;
        outline-offset: 2px;
      }
    }
  }

  /* Link column headings (PRODUCTS / HOMEOWNER INFO / ABOUT US) */
  [data-dw-itemtype="swift-v2_navigation"] h5 {
    font-size: 15px;
    font-weight: 800;
    line-height: 21px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin: 0 0 28px;
  }

  /* Swift pulls the list out by the link padding (-8px); the links have none now */
  .nav-wrapper {
    margin: 0;
  }

  /* Links: 16px on a 32.4px pitch; long links wrap in their column */
  .nav-link {
    font-size: 16px;
    font-weight: 400;
    line-height: 22px;
    white-space: normal !important; /* beats the text-nowrap utility */
    padding: 0 0 10.4px !important; /* beats the p-2 utility on the link */
  }

  /* Hairline dividers: drawn by the row container, so they span the footer container */
  [data-swift-container]:has(> [data-dw-itemtype="permachinkdivider"]) {
    height: 0;
    border-top: 1px solid var(--pcs-footer-line);
  }

  [data-dw-itemtype="permachinkdivider"] {
    display: none;
  }

  /* Legal links (the one navigation with no title): 14px on a 21px line, both pages */
  [data-dw-itemtype="swift-v2_navigation"]:not(:has(h5)) .nav-link {
    font-size: 14px;
    line-height: 21px;
    padding: 0 !important;
  }

  /* Desktop legal links: 40px apart, beside the copyright */
  [data-dw-itemtype="swift-v2_text"] + [data-dw-itemtype="swift-v2_navigation"] .nav {
    gap: 0 40px !important; /* beats the gap-2 utility on the list */
  }

  /* "Subscribe via Email" -> Name field: 83px; nothing under the button */
  .pc-email-signup-description {
    margin-bottom: 16px;
  }

  .pc-email-signup-form {
    margin-bottom: 0;
  }

  /* Copyright: 14px */
  [data-dw-itemtype="swift-v2_text"] .dw-paragraph-0 {
    font-size: 14px;
    line-height: 22.75px;
    margin: 0;
  }

  /* PRODUCTS / HOMEOWNER INFO / ABOUT US as closed accordions (VerticalAccordion.cshtml), 54px rows with hairlines.
     Both pages use it; the desktop page opens it from 801px wide (see the desktop block). */
  .pcs-nav-accordion {
    border-bottom: 1px solid var(--pcs-footer-line);

    summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 16px 0;
      list-style: none;
      cursor: pointer;

      &::-webkit-details-marker {
        display: none;
      }

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

      h5 {
        margin: 0;
      }

      /* Plus sign at the right; the vertical bar goes when open */
      &::after {
        content: "";
        flex: none;
        width: 16px;
        height: 16px;
        background:
          linear-gradient(currentColor, currentColor) center / 16px 2px no-repeat,
          linear-gradient(currentColor, currentColor) center / 2px 16px no-repeat;
      }
    }

    &[open] summary::after {
      background: linear-gradient(currentColor, currentColor) center / 16px 2px no-repeat;
    }

    .nav-wrapper {
      padding-bottom: 6px;
    }
  }
}

@media (min-width: 801px) {
  footer[data-swift-page-footer] [data-swift-container] {
    max-width: min(1356px, 100% - 60px);
  }
}

/* ---------- Desktop page ----------
   The two layouts depend on the Feature paragraphs (CONTACT US / STORE HOURS): only the desktop footer page has them.
   If an editor removes them or adds one to the phone page, the footer switches layout. */
footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
  /* One column; the social row shares the first cell with the top band, under the logo (as marketing nests it) */
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  --pcs-footer-pad: 60px; /* marketing's footer padding: 60px, 120px from 1261px */

  @media (min-width: 1261px) {
    --pcs-footer-pad: 120px;
  }

  > [data-swift-gridrow] {
    padding-block: 0;
  }

  /* Top band: the footer padding from the footer top */
  > [data-swift-gridrow]:has([data-dw-itemtype="swift-v2_feature"]) {
    grid-area: 1 / 1;
    padding-top: var(--pcs-footer-pad);
  }

  /* Social row: 36px under the 86px logo; the rest of the row lets clicks through to the top band */
  > [data-swift-gridrow]:has([data-dw-itemtype="swift-v2_logo"] ~ [data-dw-itemtype="swift-v2_logo"]) {
    grid-area: 1 / 1;
    align-self: start;
    padding-top: calc(var(--pcs-footer-pad) + 86px + 36px); /* footer padding + logo height + gap, as marketing */
    background: transparent;
    pointer-events: none;

    a {
      pointer-events: auto;
    }
  }

  /* Divider 60px under the top band, link columns 60px under the divider */
  > [data-swift-gridrow]:has([data-dw-itemtype="permachinkdivider"]) {
    padding-top: 60px;
  }

  > [data-swift-gridrow]:has([data-dw-itemtype="permachinkemailsignup"]) {
    padding-block: 60px;
  }

  /* Bottom row: hairline, text 24px under it, the footer padding below.
     Legal links first, at the right; when both do not fit, the copyright drops to the next line, right-aligned. */
  > [data-swift-gridrow]:last-child {
    padding-bottom: var(--pcs-footer-pad);

    [data-swift-container] {
      border-top: 1px solid var(--pcs-footer-line);
      padding-top: 24px;
      align-items: center;
      flex-direction: row-reverse;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 18px 20px;
    }

    [data-dw-itemtype="swift-v2_text"] {
      flex: 0 0 auto !important; /* beats the flex-fill utility */

      @media (min-width: 576px) {
        white-space: nowrap;
      }

      [data-swift-text] {
        margin-inline: 0 !important; /* beats the mx-auto utility that centers the copyright block */
      }

      p {
        text-align: left; /* Swift centers the copyright text */
      }
    }

    [data-dw-itemtype="swift-v2_navigation"] {
      flex: 0 1 auto !important; /* beats the flex-fill utility */
      order: -1;
    }
  }
}

/* Marketing column lines at 801-1260px, from marketing's flex rules (it has no Bootstrap breakpoints):
   top band = logo 219 + 20 gap, then CONTACT US + STORE HOURS over 51.85% of the rest and the links over 32%;
   link columns over 55% of the row (52% from 1025px), the signup on the rest (at least 35%). */
@media (min-width: 801px) and (max-width: 1260px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
    /* STORE HOURS (195px) ends at 51.85%; CONTACT US keeps 162px + 20px gap. The links stop at 607px when the row is tight. */
    [data-swift-container]:has(> [data-dw-itemtype="swift-v2_feature"]) {
      display: grid !important; /* beats the d-flex utility */
      grid-template-columns:
        239px max(182px, (100% - 239px) * 0.5185 - 195px) minmax(0, 1fr)
        min((100% - 239px) * 0.32, 100% - 607px);
      column-gap: 0;
    }

    [data-swift-container]:has(> [data-dw-itemtype="permachinkemailsignup"]) {
      display: grid !important; /* beats the d-flex utility */
      column-gap: 20px;
    }

    /* Legal links 20px apart up to 1200px (40px from 1201px, as above) */
    @media (max-width: 1200px) {
      [data-dw-itemtype="swift-v2_text"] + [data-dw-itemtype="swift-v2_navigation"] .nav {
        gap: 0 20px !important; /* beats the 40px rule above */
      }
    }
  }
}

/* 801-1024px: PRODUCTS 27.8%, ABOUT US 34.45% of the 55% menus; the signup takes the rest, up to its 403px heading, at the right.
   Copyright and legal links 12px, so the copyright line sits 2px closer. */
@media (min-width: 801px) and (max-width: 1024px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
    [data-swift-container]:has(> [data-dw-itemtype="permachinkemailsignup"]) {
      grid-template-columns: 15.29% calc(20.7625% - 40px) 18.9475% minmax(0, 1fr);

      > [data-dw-itemtype="permachinkemailsignup"] {
        justify-self: end;
        width: 100%;
        max-width: 403px;
      }
    }

    [data-dw-itemtype="swift-v2_text"] .dw-paragraph-0,
    [data-dw-itemtype="swift-v2_navigation"]:not(:has(h5)) .nav-link {
      font-size: 12px;
    }

    > [data-swift-gridrow]:last-child [data-swift-container] {
      row-gap: 13px;
    }
  }
}

/* 1025-1260px: PRODUCTS 29.8%, ABOUT US 26.45% of the 52% menus; the signup at the right, 35% wide (403px at least, its heading) */
@media (min-width: 1025px) and (max-width: 1260px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
    [data-swift-container]:has(> [data-dw-itemtype="permachinkemailsignup"]) {
      grid-template-columns: 15.496% calc(22.75% - 40px) 13.754% minmax(0, 1fr) max(35%, 403px);

      > [data-dw-itemtype="permachinkemailsignup"] {
        grid-column: 5;
      }
    }
  }
}

/* Marketing column lines from 1261px, as fractions of the container (measured at 1305 and 1356 wide) */
@media (min-width: 1261px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
    /* Top band: logo 0, CONTACT US 30.34%, STORE HOURS 66.49% - 195px, links 77.71%.
       CONTACT US keeps 170px (the phone line) below about 1100px wide, where marketing changes layout. */
    [data-swift-container]:has(> [data-dw-itemtype="swift-v2_feature"]) {
      display: grid !important; /* beats the d-flex utility */
      grid-template-columns: 30.34% max(170px, 36.15% - 195px) calc(11.22% + 195px) minmax(0, 1fr);
      column-gap: 0;
    }

    /* Link columns: 0, 17%, 38.25%; signup 60.24% and 34.76% wide. The fourth track is the gap before the signup. */
    [data-swift-container]:has(> [data-dw-itemtype="permachinkemailsignup"]) {
      display: grid !important; /* beats the d-flex utility */
      grid-template-columns: calc(17% - 20px) calc(21.25% - 20px) 13.75% calc(8.24% - 40px) 34.76%;
      column-gap: 20px;

      > [data-dw-itemtype="permachinkemailsignup"] {
        grid-column: 5;
      }
    }
  }
}

/* Desktop page from 801px: the link columns are open (VerticalAccordion.cshtml's script) and the summary is only the heading */
@media (min-width: 801px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) .pcs-nav-accordion {
    border-bottom: 0;

    /* Open without the script too (it only sets [open] and makes the summary inert) */
    &::details-content {
      content-visibility: visible;
      display: block;
    }

    summary {
      display: block;
      padding: 0;
      cursor: default;

      h5 {
        margin-bottom: 28px;
      }

      &::after {
        display: none;
      }
    }

    .nav-wrapper {
      padding-bottom: 0;
    }
  }
}

/* Desktop page below 801px: stacked as the phone page (and as marketing), in the desktop page's rows */
@media (max-width: 800px) {
  footer[data-swift-page-footer]:has([data-dw-itemtype="swift-v2_feature"]) {
    /* Top band: logo, social row (overlaid, as above), CONTACT US, STORE HOURS, links - all centered */
    [data-swift-container]:has(> [data-dw-itemtype="swift-v2_feature"]) {
      flex-direction: column;
      gap: 0; /* the 16px gaps below are paddings, as on the phone page */
      align-items: center;

      > * {
        flex: none !important; /* beats the flex-fill utility */
      }
    }

    [data-dw-itemtype="swift-v2_logo"] {
      flex: none !important; /* beats the flex-fill utility */
    }

    /* Room for the social row: 22px gap + the 28px icons */
    [data-swift-container]:has(> [data-dw-itemtype="swift-v2_feature"]) > [data-dw-itemtype="swift-v2_logo"] {
      margin-bottom: 50px;
    }

    > [data-swift-gridrow]:has([data-dw-itemtype="swift-v2_logo"] ~ [data-dw-itemtype="swift-v2_logo"]) {
      padding-top: calc(var(--pcs-footer-pad) + 86px + 22px);

      [data-swift-container] {
        justify-content: center;
      }
    }

    [data-swift-gridcolumn] [data-swift-text]:has(> h6) {
      text-align: center;

      h6 {
        padding: 16px 0 10px;
        margin: 0;
      }

      p + p {
        margin-top: 10px;
      }
    }

    [data-dw-itemtype="permachinknavigationlinklist"] {
      padding-top: 16px;

      > div {
        gap: 10px !important; /* beats the inline 20px gap */
        align-items: center;
      }
    }

    /* The divider is the hairline above the first accordion */
    > [data-swift-gridrow]:has([data-dw-itemtype="permachinkdivider"]) {
      padding-top: 16px;
    }

    /* Accordions, then the signup at full width */
    [data-swift-container]:has(> [data-dw-itemtype="permachinkemailsignup"]) {
      flex-direction: column;
      gap: 0;

      > * {
        flex: none !important; /* beats the flex-fill utility */
      }

      > [data-dw-itemtype="permachinkemailsignup"] {
        padding-top: 16px;
      }
    }

    > [data-swift-gridrow]:has([data-dw-itemtype="permachinkemailsignup"]) {
      padding-block: 0 20px;
    }

    /* Legal links centered and wrapping, 20px apart; the copyright centered 8px below */
    > [data-swift-gridrow]:last-child {
      [data-swift-container] {
        flex-direction: column;
        gap: 8px;
        padding-top: 21px;
      }

      .nav {
        flex-wrap: wrap !important; /* beats the flex-nowrap utility */
        justify-content: center;
        gap: 20px !important; /* beats the 40px rule above */
      }

      .nav-item {
        display: flex; /* the item is as tall as its link, not the 22.4px text line */
      }

      [data-dw-itemtype="swift-v2_text"] p {
        text-align: center;
      }
    }
  }
}

/* ---------- Phone page (no Feature paragraphs; see the desktop note) ---------- */
footer[data-swift-page-footer]:not(:has([data-dw-itemtype="swift-v2_feature"])) {
  > [data-swift-gridrow] {
    padding-block: 0;
  }

  > [data-swift-gridrow]:first-child {
    padding-top: 60px;
  }

  > [data-swift-gridrow]:last-child {
    padding-bottom: 60px;
  }

  /* Logo, social row and the three links: centered */
  [data-swift-container]:has(> [data-dw-itemtype="swift-v2_logo"]),
  [data-swift-container]:has(> [data-dw-itemtype="permachinknavigationlinklist"]) {
    justify-content: center;
  }

  > [data-swift-gridrow]:has([data-dw-itemtype="swift-v2_logo"] ~ [data-dw-itemtype="swift-v2_logo"]) {
    padding-top: 22px;
  }

  [data-dw-itemtype="swift-v2_logo"] {
    flex: none !important; /* beats the flex-fill utility */
  }

  /* CONTACT US / STORE HOURS: centered, heading 16px above and 10px below */
  [data-swift-gridcolumn] [data-swift-text]:has(> h6) {
    text-align: center;

    h6 {
      padding: 16px 0 10px;
      margin: 0;
    }

    p + p {
      margin-top: 10px;
    }
  }

  /* Links: each centered, 38px pitch, 16px under the hours */
  > [data-swift-gridrow]:has([data-dw-itemtype="permachinknavigationlinklist"]) {
    padding-top: 16px;
  }

  [data-dw-itemtype="permachinknavigationlinklist"] {
    flex: none !important; /* beats the flex-fill utility */

    > div {
      gap: 10px !important; /* beats the inline 20px gap */
      align-items: center;
    }
  }

  /* The accordion rows (styles in the shared block): hairline above the first, 16px under the links */
  > [data-swift-gridrow]:not(:has(.pcs-nav-accordion)) + [data-swift-gridrow]:has(.pcs-nav-accordion) {
    padding-top: 16px;

    .pcs-nav-accordion {
      border-top: 1px solid var(--pcs-footer-line);
    }
  }

  > [data-swift-gridrow]:has([data-dw-itemtype="permachinkemailsignup"]) {
    padding-top: 16px;
  }

  /* Legal links: inline, centered, wrapping, 10px apart, hairline above.
     The legal row is the one just before the copyright row (the last row). */
  > [data-swift-gridrow]:has([data-dw-itemtype="swift-v2_navigation"]):nth-last-child(2) {
    padding-top: 16px;

    [data-swift-container] {
      border-top: 1px solid var(--pcs-footer-line);
      padding-top: 21px;
    }

    .nav {
      flex-direction: row !important; /* beats flex-column if the paragraph keeps a vertical template */
      flex-wrap: wrap !important; /* beats the flex-nowrap utility */
      justify-content: center;
      gap: 10px !important; /* beats the gap-2 utility on the list */
    }

    .nav-item {
      display: flex; /* the item is as tall as its link, not the 22.4px text line */
    }
  }

  /* Copyright: centered under the legal links */
  > [data-swift-gridrow]:last-child {
    padding-top: 8px;

    p {
      text-align: center;
    }
  }
}
