/* ============================================================
   LEGACY FIXES — removes dependencies on assets that didn't survive
   the move off WP Engine / Envato:
     1. Montserrat (Enfold custom type font, still served from
        newimageprod.wpengine.com) → Public Sans everywhere.
     2. Custom Fontello icon sets uploaded via Enfold's Iconfont
        Manager (new-image-roof-icons, new_image_icons_2) → the
        design system's own SVG icons.
   Enfold's bundled entypo-fontello set ships with the theme and is
   left alone.
   ============================================================ */

/* 1. Public Sans everywhere, except icon glyph elements */
body.nir-ds#top,
body.nir-ds#top *:not([data-av_icon]):not([data-av_iconfont]):not(.av-icon-char):not([class*="avia-font-"]):not([class*="fa-"]):not(.dashicons):not([class*="gform-icon"]):not([class*="gficon"]):not(svg):not(svg *) {
  font-family: var(--f-body) !important;
}

/* 2. Missing custom Fontello sets → design-system SVG icons (CSS masks) */
body.nir-ds#top .avia-font-new-image-roof-icons,
body.nir-ds#top .avia-font-new_image_icons_2 {
  color: var(--accent);
}
body.nir-ds#top [data-av_iconfont="new-image-roof-icons"]::before,
body.nir-ds#top [data-av_iconfont="new_image_icons_2"]::before {
  content: "" !important;
  font-family: inherit !important;
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  background-color: currentColor;
  -webkit-mask: url("../icons/residential.svg") center / contain no-repeat;
          mask: url("../icons/residential.svg") center / contain no-repeat;
}

/* Pick the icon by the service page the card links to (same URLs on ATL + FL) */
body.nir-ds#top .flex_column:has(a[href*="/commercial-roofing"]) [data-av_iconfont^="new"]::before,
body.nir-ds#top .av_font_icon:has(a[href*="/commercial-roofing"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/commercial.svg");
          mask-image: url("../icons/commercial.svg");
}
body.nir-ds#top .flex_column:has(a[href*="/residential-roofing"]) [data-av_iconfont^="new"]::before,
body.nir-ds#top .av_font_icon:has(a[href*="/residential-roofing"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/residential.svg");
          mask-image: url("../icons/residential.svg");
}
body.nir-ds#top .flex_column:has(a[href*="/roof-maintenance"]) [data-av_iconfont^="new"]::before,
body.nir-ds#top .av_font_icon:has(a[href*="/roof-maintenance"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/maintenance.svg");
          mask-image: url("../icons/maintenance.svg");
}
body.nir-ds#top .flex_column:has(a[href*="/roof-materials"]) [data-av_iconfont^="new"]::before,
body.nir-ds#top .av_font_icon:has(a[href*="/roof-materials"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/materials.svg");
          mask-image: url("../icons/materials.svg");
}

/* Card heading link is the most reliable signal (FL's Commercial/Residential
   icon links are swapped in content). Higher specificity → overrides above. */
body.nir-ds#top .flex_column:has(:is(h1,h2,h3,h4,h5,h6) a[href*="/commercial-roofing"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/commercial.svg");
          mask-image: url("../icons/commercial.svg");
}
body.nir-ds#top .flex_column:has(:is(h1,h2,h3,h4,h5,h6) a[href*="/residential-roofing"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/residential.svg");
          mask-image: url("../icons/residential.svg");
}
body.nir-ds#top .flex_column:has(:is(h1,h2,h3,h4,h5,h6) a[href*="/roof-maintenance"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/maintenance.svg");
          mask-image: url("../icons/maintenance.svg");
}
body.nir-ds#top .flex_column:has(:is(h1,h2,h3,h4,h5,h6) a[href*="/roof-materials"]) [data-av_iconfont^="new"]::before {
  -webkit-mask-image: url("../icons/materials.svg");
          mask-image: url("../icons/materials.svg");
}

/* Icons are brand gold even when they're links (beats the dark-gold link color) */
body.nir-ds#top .main_color .av_font_icon a[data-av_iconfont],
body.nir-ds#top .alternate_color .av_font_icon a[data-av_iconfont],
body.nir-ds#top .av_font_icon a[data-av_iconfont] {
  color: var(--accent);
}
body.nir-ds#top .main_color .av_font_icon a[data-av_iconfont]:hover,
body.nir-ds#top .alternate_color .av_font_icon a[data-av_iconfont]:hover {
  color: var(--accent-press);
}
