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

  background-color:
    light-dark(
        /** Domain footer surface without JS for light scheme */
        var(--rh-color-surface-lighter, #f2f2f2),
        /** Domain footer surface without JS for dark scheme */
        var(--rh-color-surface-darker, #1f1f1f)
      );
  width: 100%;
  display: grid;
  grid-template-areas:
    'footer'
    'global';
  grid-template-rows: 1fr auto;

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

  [slot='logo'] {
    /** Footer vertical spacing */
    padding-block: var(--rh-space-2xl, 32px);
  }

  ul[slot='links'] {
    display: flex;
    flex-direction: column;
    gap:
      /** No-JS link stack gap override */
      var(--rh-footer-links-gap,
        /** No-JS link stack gap */
        var(--rh-space-md, 8px));

    /** Link list bottom margin without JS */
    margin-block-end: var(--rh-space-3xl, 48px);
  }

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

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

rh-footer-block:not(:defined) {
  :is(h1, h2, h3, h4, h5, h6) {
    font-size:
      /** Footer block header size override */
      var(--rh-footer-link-header-font-size,
        /** Footer block header size */
        var(--rh-font-size-body-text-sm, 0.875rem));

    /** Footer font weight */
    font-weight: var(--rh-font-weight-heading-medium, 500);

    /** Footer bottom margin */
    margin-block-end: var(--rh-space-lg, 16px);

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

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

/* (min-width: --rh-breakpoint-sm) */
@media screen and (min-width: 768px) {
  rh-footer:not(:defined) {
    /** No-JS section horizontal inset at viewport >= md */
    --_section-side-gap: var(--rh-space-2xl, 32px);
  }
}

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

    [slot='logo'] {
      position: relative;
      grid-column-start: span 12;

      &:before {
        background-color:
          /** Logo divider color at viewport >= lg; theme-adaptive */
          var(--rh-color-border-subtle,
            light-dark(
              /** Logo divider color for light scheme at viewport >= lg */
              var(--rh-color-border-subtle-on-light, #c7c7c7),
              /** Logo divider color for dark scheme at viewport >= lg */
              var(--rh-color-border-subtle-on-dark, #707070)
            ));

        /** Logo divider thickness at viewport >= lg */
        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;
    }

    [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:
        /** No-JS link column gap override at viewport >= lg */
        var(--rh-footer-links-gap,
          /** No-JS link column gap at viewport >= lg */
          var(--rh-space-lg, 16px));
      grid-row: 3 / span 2;
      margin: 0;
    }
  }

  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 {
    /** Link column header top margin at viewport >= lg */
    margin-block-start: var(--rh-space-lg, 16px);
  }
}

/* (min-width: --rh-breakpoint-xl) */
@media screen and (min-width: 1440px) {
  rh-footer:not(:defined) {
    /** No-JS section horizontal inset at viewport >= 2xl */
    --_section-side-gap: var(--rh-space-4xl, 64px);
  }
}
