/*
 * Footer on background/strong (sand-300, like header and page head). Mobile: brand block, link groups as accordion, newsletter, social,
 * then a white band (funding logos, copyright, privacy note) separated from the sand part by a wave.
 * Desktop: four columns (brand, Entdecken, Service, Newsletter) aligned with the top of the logo, band below.
 * The wave above the footer is drawn by the section before it (the footer carries data-bg); the wave inside the footer
 * is the band's own top edge (sand mask over white, same mask system as sections).
 */
@layer components {
  .footer.section {
    padding-block: var(--space-64) 0;
    font-size: var(--type-text-small-size);
    line-height: var(--type-text-small-line-height);
  }

  /* Short pages: the last section grows to the footer, so its wave sits right above it. */
  main {
    display: flex;
    flex-direction: column;
  }

  main > .section:last-child {
    flex: 1 0 auto;
  }

  .footer a {
    color: var(--color-text-default);
  }

  .footer__top {
    display: grid;
    gap: var(--space-24);
  }

  .footer__brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-16);
    min-inline-size: 0;
  }

  .footer__address,
  .footer__contact {
    display: flex;
    flex-direction: column;
    margin: 0;
  }

  .footer__contact a {
    text-decoration: none;
  }

  .footer__contact a:hover,
  .footer__link:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  /* Groups: mobile = accordion rows between lines. */
  .footer__groups {
    border-block-start: var(--border-width-thin) solid var(--color-border-strong);
  }

  .footer__group {
    border-block-end: var(--border-width-thin) solid var(--color-border-strong);
  }

  .footer__heading {
    margin: 0;
    padding-block: var(--space-16);
    font-family: var(--font-family-base), system-ui, sans-serif;
    font-size: var(--type-label-m-size);
    line-height: var(--type-label-m-line-height);
    font-weight: var(--font-weight-bold);
    text-wrap: wrap;
  }

  .footer__nav {
    padding-block-end: var(--space-8);
  }

  .footer__links {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .footer__link {
    text-decoration: none;
  }

  .footer__social {
    display: flex;
    gap: 0;
    margin: var(--space-16) 0 0;
    padding: 0;
    list-style: none;
  }

  .footer__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: var(--component-control-height-s);
    block-size: var(--component-control-height-s);
    margin-inline-start: calc(var(--space-8) * -1);
  }

  .footer__social li + li .footer__social-link {
    margin-inline-start: 0;
  }

  /* White band at the end of the footer; its top edge is a wave in the footer colour. */
  .footer__band {
    position: relative;
    margin-block-start: var(--space-64);
    padding-block: calc(var(--layout-wave-height) + var(--space-40)) var(--space-48);
    background-color: var(--color-background-default);
    color: var(--color-text-default);
  }

  .footer__band::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: -1px;
    height: calc(var(--layout-wave-height) + 1px);
    background-color: var(--color-background-strong);
    pointer-events: none;
    -webkit-mask: var(--wave-mask) center / 100% 100% no-repeat;
    mask: var(--wave-mask) center / 100% 100% no-repeat;
  }

  .footer__funding {
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
  }

  .footer__funding-label {
    margin: 0;
    font-size: var(--type-label-m-size);
    line-height: var(--type-label-m-line-height);
    font-weight: var(--font-weight-bold);
  }

  /* Mobile: two funders per row; a funder with two logos takes a full row. Logos all at one height. */
  .footer__funding-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: var(--space-24) var(--space-16);
    margin: 0;
    padding: 0;
    list-style: none;
    /* Logo height = per-logo --logo-height (unitless px on desktop, from the Panel) or the base 48, times the scale:
       phones show 40/48 of the desktop height, so the default is 40 px and custom heights shrink in proportion. */
    --footer-logo-base: 48;
    --footer-logo-scale: calc(40 / 48);
  }

  .footer__funding-item {
    display: flex;
    align-items: center;
    min-inline-size: 0;
  }

  .footer__funding-item--group {
    grid-column: 1 / -1;
  }

  .footer__funding-link {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-8) var(--space-16);
    max-inline-size: 100%;
    color: var(--color-text-default);
    text-decoration: none;
  }

  .footer a.footer__funding-link {
    color: var(--color-text-default);
  }

  a.footer__funding-link:hover .footer__funding-logo {
    opacity: 0.8;
  }

  .footer__funding-link:focus-visible {
    outline-offset: 4px;
    border-radius: var(--radius-xs);
  }

  /* Per-logo height from the Panel (data-height, 24 to 80 in steps of 4; no inline style because of the CSP). */
  .footer__funding-logo[data-height="24"] { --logo-height: 24; }
  .footer__funding-logo[data-height="28"] { --logo-height: 28; }
  .footer__funding-logo[data-height="32"] { --logo-height: 32; }
  .footer__funding-logo[data-height="36"] { --logo-height: 36; }
  .footer__funding-logo[data-height="40"] { --logo-height: 40; }
  .footer__funding-logo[data-height="44"] { --logo-height: 44; }
  .footer__funding-logo[data-height="48"] { --logo-height: 48; }
  .footer__funding-logo[data-height="52"] { --logo-height: 52; }
  .footer__funding-logo[data-height="56"] { --logo-height: 56; }
  .footer__funding-logo[data-height="60"] { --logo-height: 60; }
  .footer__funding-logo[data-height="64"] { --logo-height: 64; }
  .footer__funding-logo[data-height="68"] { --logo-height: 68; }
  .footer__funding-logo[data-height="72"] { --logo-height: 72; }
  .footer__funding-logo[data-height="76"] { --logo-height: 76; }
  .footer__funding-logo[data-height="80"] { --logo-height: 80; }

  .footer__funding-logo {
    block-size: calc(var(--logo-height, var(--footer-logo-base)) * var(--footer-logo-scale) * 1px);
    inline-size: auto;
    max-inline-size: min(100%, 240px);
    object-fit: contain;
    object-position: left center;
  }

  .footer__bottom {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    color: var(--color-text-subtle);
  }

  .footer__funding + .footer__bottom {
    margin-block-start: var(--space-24);
  }

  .footer__copyright {
    margin: 0;
  }

  .footer__privacy {
    display: block;
    margin-block-start: var(--space-4, 4px);
  }

  /* Pause switch for the page motion (WCAG 2.2.2): looks like the privacy link beside it. Shown by motion/index.js. */
  .footer__motion {
    display: block;
    margin-block-start: var(--space-4, 4px);
  }

  .footer__motion[hidden] {
    display: none;
  }

  .footer__motion-toggle {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--color-text-link);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
    min-block-size: 24px;
  }

  .footer__motion-toggle:hover {
    color: var(--color-text-default);
  }

  @media (min-width: 1024px) {
    .footer.section {
      padding-block-start: var(--space-96);
    }

    .footer__top {
      grid-template-columns: minmax(0, 400fr) minmax(0, 188fr) minmax(0, 188fr) minmax(0, 400fr);
      column-gap: var(--layout-grid-gap);
      align-items: start;
    }

    .footer__groups {
      display: contents;
    }

    .footer__newsletter {
      grid-column: 4;
    }

    .footer__group {
      border: 0;
      min-inline-size: 0;
    }

    .footer__heading {
      padding-block: 0 var(--space-8);
    }

    .footer__nav {
      padding-block-end: 0;
    }

    .footer__links {
      gap: var(--space-8);
    }

    .footer__funding {
      gap: var(--space-24);
    }

    .footer__funding-list {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: var(--space-32) var(--space-24);
      --footer-logo-scale: 1;
    }

    .footer__funding-link {
      column-gap: var(--space-24);
    }

    .footer__funding-item--group {
      grid-column: auto;
    }

    .footer__bottom {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: baseline;
      justify-content: space-between;
      gap: var(--space-8) var(--space-32);
    }

    .footer__funding + .footer__bottom {
      margin-block-start: var(--space-32);
    }

    .footer__band {
      margin-block-start: var(--space-80);
      padding-block: calc(var(--layout-wave-height) + var(--space-56)) var(--space-64);
    }

    /* Optical alignment: headings start at the vertical middle of the logo (logo height / 2). */
    .footer__groups .footer__group,
    .footer__newsletter {
      padding-block-start: calc(var(--layout-logo-height) / 2);
    }

    .footer__privacy,
    .footer__motion {
      display: inline;
      margin: 0 0 0 var(--space-24);
    }

    .footer__motion[hidden] {
      display: none;
    }
  }
}
