:is(rh-footer, rh-footer-universal) a {
  color: var(--rh-color-interactive-primary-default);
  text-decoration: none;
}

:is(rh-footer, rh-footer-universal) :is(rh-footer-block) a {
  text-decoration: underline var(--rh-border-width-sm, 1px) dashed;
  text-decoration-color: light-dark(var(--rh-color-gray-50), var(--rh-color-gray-40)) !important;
  text-underline-offset: max(5px, 0.28em);
  transition-timing-function: ease;
  transition-property: text-underline-offset, color, text-decoration-color;
  transition-duration: 0.3s;
}

rh-footer [slot^='links'] a {
  gap: var(--rh-footer-links-gap, var(--rh-space-md, 8px));
}

:is(rh-footer, rh-footer-universal) [slot^='links'] a {
  display: block;
  color: var(--rh-color-text-primary) !important;
  font-size: var(--rh-footer-link-font-size, var(--rh-font-size-body-text-sm, 0.875rem));
  width: fit-content;
}

rh-footer-universal [slot^='links'] a {
  font-size: inherit;
}

:is(rh-footer, rh-footer-universal) a:hover {
  color: var(--rh-color-interactive-primary-hover);
  text-decoration: underline var(--rh-border-width-sm, 1px) dashed;
  text-decoration-color: inherit;
  text-underline-offset: max(5px, 0.28em);
  transition-timing-function: ease;
  transition-property: text-underline-offset, color, text-decoration-color;
  transition-duration: 0.3s;
}

:is(rh-footer, rh-footer-universal) a:is(:focus, :focus-within) {
  color: var(--rh-color-interactive-primary-hover);
  text-decoration: underline dashed var(--rh-border-width-sm, 1px);
  text-decoration-color: inherit;
  text-underline-offset: max(5px, 0.28em);
  transition-timing-function: ease;
  transition-property: text-underline-offset, color, text-decoration-color;
  transition-duration: 0.3s;
}

:is(rh-footer, rh-footer-universal) a:visited {
  color: var(--rh-color-interactive-primary-hover);
  text-decoration: none;
}

/* adds underlines to inline links in rh-footer-block only */

:is(rh-footer, rh-footer-universal) :is(rh-footer-block) a:hover {
  text-decoration-color: inherit !important;
  text-underline-offset: max(6px, 0.33em);
}

:is(rh-footer, rh-footer-universal) :is(rh-footer-block) a:is(:focus, :focus-within) {
  text-decoration-color: inherit !important;
  text-underline-offset: max(6px, 0.33em);
}

:is(rh-footer, rh-footer-universal) :is(rh-footer-block) a:visited {
  text-decoration-color: inherit;
}

/* ensure links fully wrap img tags */
:is(rh-footer, rh-footer-universal) a[slot^='logo'] {
  display: block;
}

:is(rh-footer) a[slot^='logo'] > img {
  display: block;
  width: auto;
  height: 100%;
  height: var(--rh-size-icon-04, 40px);
}

:is(rh-footer, rh-footer-universal) :is(h1, h2, h3, h4, h5, h6) {
  color: var(--rh-color-text-primary);
  font-family: var(--rh-font-family-heading, RedHatDisplay, 'Red Hat Display', Helvetica, Arial, sans-serif);
  line-height: var(--rh-line-height-heading, 1.3);
}

rh-footer [slot='links']:is(h1, h2, h3, h4, h5):nth-of-type(n+5) {
  --_link-header-margin: calc(var(--rh-space-2xl, 32px) - var(--rh-space-lg, 16px));
}

:is(rh-footer, rh-footer-universal) [slot^='links'] li {
  margin: 0;
  padding: 0;
  display: contents;
}

/**
 * Section side gap
 */
:is(rh-footer, rh-footer-universal) {
  --rh-footer-section-side-gap: var(--rh-space-lg, 16px);

  color-scheme: only dark;
  overflow-y: auto;
}

/* (min-width: --rh-breakpoint-sm) */
@media screen and (min-width: 768px) {
  :is(rh-footer, rh-footer-universal) {
    --rh-footer-section-side-gap: var(--rh-space-2xl, 32px);
  }
}

/* (min-width: --rh-breakpoint-xl) */
@media screen and (min-width: 1440px) {
  :is(rh-footer, rh-footer-universal) {
    --rh-footer-section-side-gap: var(--rh-space-4xl, 64px);
  }
}

/**
 * No JS Experience
 */
rh-footer:not(:defined) {
  --_section-side-gap: var(--rh-space-lg, 16px);

  background-color: var(--rh-color-surface-darker, #1f1f1f);
  width: 100%;
  display: grid;
  grid-template-areas:
    'footer'
    'global';
  grid-template-rows: 1fr auto;

  /** @deprecated  target `rh-footer:not(:defined) directly */
  min-height: var(--rh-footer-nojs-min-height);

  & > *:not(rh-footer-universal) {
    padding-inline: var(--_section-side-gap);
  }

  a[slot='logo'] {
    padding-block: var(--rh-space-2xl, 32px);
  }

  ul[slot='links'] {
    display: flex;
    flex-direction: column;
    gap: var(--rh-footer-links-gap, var(--rh-space-md, 8px));
    margin-block-end: var(--rh-space-3xl, 48px);
  }

  [slot='links'] a {
    font-size: var(--rh-footer-link-font-size, var(--rh-font-size-body-text-sm, 0.875rem));
  }
}

rh-footer-social-link:not(:defined),
rh-footer:not(:defined) [slot='social-links'] {
  display: none; /* Hide footer-social-link before/sans JS */
}

:is(rh-footer, rh-footer-universal):not(:defined) {
  p {
    color: var(--rh-color-text-secondary-on-dark, #c7c7c7);
  }

  & :is(h1, h2, h3, h4, h5, h6) {
    &[slot='links'],
    &[slot='header'] {
      font-size: var(--rh-footer-link-header-font-size, var(--rh-font-size-body-text-sm, 0.875rem));
      font-weight: var(--rh-font-weight-heading-medium, 500);
    }
  }
}

rh-footer-universal:not(:defined) {
  background-color: var(--rh-color-surface-darkest, #151515);
  display: block;
  width: 100%;
  padding: var(--rh-space-2xl, 32px) var(--rh-space-lg, 16px);

  &:before {
    grid-area: global;
  }

  & [slot='links-primary'],
  & [slot='links-secondary'] {
    display: flex;
    flex-flow: column wrap;
    gap: var(--rh-space-md, 8px);
    font-size: var(--rh-font-size-body-text-xs, 0.75rem);
    margin: 0;
    padding: 0;
  }

  /* No JS + DSD: */
  &[ssr-hint-has-slotted] :is(h2, h3, h4)[hidden] {
    border: 0;
    clip: rect(0, 0, 0, 0);
    block-size: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    inline-size: 1px;
  }

  & rh-footer-copyright:not(:defined) {
    grid-column: -1/1;
    padding-block: var(--rh-space-2xl, 32px) var(--rh-space-md, 8px);
    font-size: var(--rh-font-size-body-text-xs, 0.75rem);
    color: var(--rh-color-text-secondary-on-dark, #c7c7c7);
  }
}

rh-footer-block:not(:defined) {
  :is(h1, h2, h3, h4, h5, h6) {
    font-size: var(--rh-footer-link-header-font-size, var(--rh-font-size-body-text-sm, 0.875rem));
    font-weight: var(--rh-font-weight-heading-medium, 500);
    margin-block-end: var(--rh-space-lg, 16px);

    &:not(:first-of-type) {
      margin-block-start: var(--rh-space-lg, 16px);
    }
  }

  &:not(:first-of-type) {
    margin-block-start: var(--rh-space-2xl, 32px);
  }
}

rh-footer:not(:defined) rh-footer-universal:not(:defined) {
  /* Only apply space when universal footer is inside rh-footer */
  margin-block-start: var(--rh-space-2xl, 32px);
}

/* (min-width: --rh-breakpoint-sm) */
@media screen and (min-width: 768px) {
  rh-footer:not(:defined) {
    --_section-side-gap: var(--rh-space-2xl, 32px);
  }
}

/* (min-width: --rh-breakpoint-md) */
@media screen and (min-width: 992px) {
  rh-footer:not(:defined) {
    gap: var(--rh-space-lg, 16px) var(--rh-space-2xl, 32px);
    grid-template-columns: repeat(12, minmax(0, 1fr));

    a[slot='logo'] {
      position: relative;

      &:before {
        background-color: var(--rh-color-border-subtle-on-dark, #707070);
        block-size: var(--rh-length-4xs, 1px);
        content: '';
        inline-size: calc(100% - var(--_section-side-gap) * 2);
        inset-block-end: 0;
        position: absolute;
      }
    }

    & > *:not(rh-footer-universal) {
      padding: 0;
    }

    a[slot='logo'],
    :is(h2, h3)[slot='links']:first-of-type,
    ul[slot='links']:first-of-type {
      padding-inline-start: var(--_section-side-gap);
    }

    :is(h2, h3)[slot='links'] {
      grid-row-start: 2;
    }

    :is(h2, h3)[slot='links'],
    ul[slot='links'] {
      grid-column-start: span 2;
    }

    ul[slot='links'] {
      gap: var(--rh-footer-links-gap, var(--rh-space-lg, 16px));
      grid-row: 3 / span 2;
      margin: 0;
    }
  }

  rh-footer:not(:defined) a[slot='logo'],
  rh-footer-universal:not(:defined) {
    grid-column-start: span 12;
  }

  rh-footer-block:not(:defined) {
    grid-column: 9 / span 4;
    grid-row: 2 / 4;

    &:not(:first-of-type) {
      margin-block-start: 0;
    }

    &[slot='main-secondary'] {
      padding-inline-end: var(--_section-side-gap);
    }

    &:nth-of-type(2) {
      --_grid-row-max: 5;

      grid-row: 4 / 5;
    }

    &:nth-of-type(3) {
      --_grid-row-max: 7;

      grid-row: 6 / 7;
    }

    &:nth-of-type(4) {
      --_grid-row-max: 8;

      grid-row: 7 / 8;
    }
  }

  rh-footer:not(:defined) :is(h2, h3)[slot='links'],
  rh-footer-block:not(:defined):first-of-type {
    margin-block-start: var(--rh-space-lg, 16px);
  }

  rh-footer-universal:not(:defined) {
    padding-block: var(--rh-space-2xl, 32px);
    padding-inline: var(--rh-space-7xl, 128px) var(--rh-space-4xl, 64px);

    &[ssr-hint-has-slotted] {
      padding-inline: 0;
    }

    & ul[slot='links-primary'],
    & ul[slot='links-secondary'] {
      flex-direction: row;
      gap: var(--rh-space-md, 8px) var(--rh-space-xl, 24px);
    }

    & ul[slot='links-primary'] {
      margin-block-end: var(--rh-space-xl, 24px);
    }

    & rh-footer-copyright:not(:defined) {
      padding-block: var(--rh-space-md, 8px);
    }
  }

  rh-footer:not(:defined) rh-footer-universal:not(:defined) {
    --_grid-row-max: 8;

    grid-row: var(--_grid-row-max) / var(--_grid-row-max);
  }
}

/* (min-width: --rh-breakpoint-xl) */
@media screen and (min-width: 1440px) {
  rh-footer:not(:defined) {
    --_section-side-gap: var(--rh-space-4xl, 64px);
  }
}
