/* Site footer. Below 1080px: one column, groups split by lines, values
   white. From 1080px: the project grid's 12 columns, headings shown, values
   muted until hover. Column spans are sized so no line wraps at the current
   font; recheck them when the font or sizes change. */
.site-footer {
  display: grid;
  padding: var(--spacing-5) var(--spacing-3) var(--spacing-6);
  /* Keeps the footer reachable on pages that snap (see project-list.css). Its top,
     not its bottom: the footer can be taller than the screen, and the top holds the
     back-to-top link. Below the header, which also applies to #contact links. */
  scroll-snap-align: start;
  scroll-margin-block-start: var(--header-height);
}

/* Scrolled by assets/js/smooth-scroll.js */
.site-footer-back-to-top {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  justify-self: start;
  margin-block-end: calc(var(--spacing-7) + var(--spacing-6));
  color: var(--color-muted);
  text-transform: uppercase;
  transition: color var(--transition), opacity var(--transition-slow);
}

@media (hover: hover) {
  .site-footer-back-to-top:hover {
    color: var(--color-fg);
  }
}

/* Mobile, with JS: faded in by footer-top-link.js */
@media (width < 768px) {
  .js .site-footer-back-to-top:not(.is-in-view) {
    opacity: 0;
    pointer-events: none;
  }
}

/* White icon next to the muted text (the SVG fills with currentColor) */
.site-footer-back-to-top-icon {
  color: var(--color-fg);

  svg {
    width: 1.25em;
  }
}

.site-footer-group {
  /* Long emails wrap instead of running into the next column */
  min-width: 0;
  overflow-wrap: anywhere;
  padding-block: var(--spacing-5);

  & + & {
    border-block-start: 1px solid var(--color-invisible);
  }
}

/* Headings are desktop only; on mobile they stay for screen readers */
.site-footer-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  font: inherit;
}

/* Label | value rows; the label column is as wide as its longest label */
.site-footer-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: var(--spacing-4);
}

.site-footer-address address + .site-footer-company {
  margin-block-start: var(--spacing-4);
}

.site-footer-company div {
  display: flex;
  gap: 0.3em;
}

.site-footer-copyright {
  margin-block-start: var(--spacing-5);
}

/* Same side padding as the header and main. Project pages fill the screen with
   the gallery strip, so "Get in touch" links to the homepage footer there. */
@media (min-width: 768px) {
  .site-footer {
    padding-inline: var(--spacing-5);
  }

  .template-project .site-footer {
    display: none;
  }
}

/* Copyright 1–3, address 4–6, contact 7–9, social 10–12 */
@media (min-width: 1080px) {
  .site-footer {
    grid-template-columns: repeat(12, 1fr);
    column-gap: var(--spacing-4);
    align-items: start;
  }

  .site-footer-back-to-top {
    grid-row: 1;
    grid-column: 4 / span 12;
  }

  .site-footer-group {
    grid-row: 2;
    padding-block: 0;

    & + & {
      border: 0;
    }
  }

  .site-footer-address {
    grid-column: 4 / span 3;
  }

  .site-footer-contact {
    grid-column: 7 / span 3;
  }

  .site-footer-social {
    grid-column: 10 / span 3;
  }

  .site-footer-heading {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    margin-block-end: var(--spacing-4);
  }

  .site-footer-list {
    column-gap: var(--spacing-2);
  }

  .site-footer-list a {
    color: var(--color-muted);
    transition: color var(--transition);

    &:hover {
      color: var(--color-fg);
    }
  }

  /* Bottom of the row, level with the last address line */
  .site-footer-copyright {
    grid-column: 1 / span 3;
    grid-row: 1;
    align-self: end;
    margin: 0;
  }
}

/* Copyright 1–4, address 5–6, contact 7–8, social 9–12 */
@media (min-width: 1600px) {
  .site-footer-back-to-top {
    grid-column: 5 / span 4;
  }

  .site-footer-copyright {
    grid-column: 1 / span 4;
  }

  .site-footer-address {
    grid-column: 5 / span 2;
  }

  .site-footer-contact {
    grid-column: 7 / span 2;
  }

  .site-footer-social {
    grid-column: 9 / span 4;
  }
}
