/* -------------------- FOOTER -------------------- */
/* 993px and above: link columns on the left, logo in the middle, email signup on the right.
   769px to 992px:  logo on the left and signup on the right, centred link columns underneath.
   768px and below: one centred column: signup, logo, Shop and Help side by side, social row. */

.site-footer {
  position: relative;
  /* Lets the wave below be positioned against the top of the footer */
  overflow-x: clip;
  /* Trims the moving wave at the screen's left and right edges, so it never causes sideways scrolling */
  background-color: var(--colour-footer);
  color: var(--colour-text-on-dark);
  margin-top: 4rem;
  line-height: 1.5;
}

/* -------------------- WAVY TOP EDGE -------------------- */
/* A sine wave in the footer's colour, drawn just above the footer, sliding slowly to the left forever */

.site-footer::before {
  --wave-length: 400px;
  /* The length of one wave. Smaller = shorter, more frequent waves */
  --wave-height: 24px;
  /* How tall the waves are */
  --wave-speed: 6s;
  /* How long one wave takes to pass. Bigger number = slower */

  content: "";
  position: absolute;
  left: 0;
  bottom: calc(100% - 1px);
  /* Sits on top of the footer, overlapping by 1px so no thin gap ever shows between them */
  width: calc(100% + var(--wave-length));
  /* One wave wider than the screen, so there's always wave ready to slide into view */
  height: var(--wave-height);
  background-color: var(--colour-footer);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 40' preserveAspectRatio='none'%3E%3Cpath fill='black' d='M0 20C64.94 10.31 127.43 1 200 1S335.06 10.31 400 20S527.43 39 600 39S735.06 29.69 800 20V40H0Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 40' preserveAspectRatio='none'%3E%3Cpath fill='black' d='M0 20C64.94 10.31 127.43 1 200 1S335.06 10.31 400 20S527.43 39 600 39S735.06 29.69 800 20V40H0Z'/%3E%3C/svg%3E");
  /* The wave shape works like a stencil: only the wave-shaped part of the footer colour shows through.
     This way the wave always matches --colour-footer automatically */
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  -webkit-mask-size: var(--wave-length) var(--wave-height);
  mask-size: var(--wave-length) var(--wave-height);
  animation: footer-wave var(--wave-speed) linear infinite;
}

@keyframes footer-wave {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(calc(var(--wave-length) * -1));
    /* Slides left by exactly one wave's length, so the loop is seamless */
  }
}

@media (max-width: 768px) {
  .site-footer::before {
    --wave-length: 250px;
    --wave-height: 16px;
    --wave-speed: 3s;
    /* Smaller waves that move a little faster on mobile and tablet */
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-footer::before {
    animation: none;
    /* Keeps the wave still for anyone who has asked their device to reduce motion */
  }
}

.footer-container {
  max-width: 60rem;
  margin: auto;
  padding: 3rem 1rem 1.5rem;
}

.footer-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  /* Two equal outer columns, so the logo in the middle sits exactly in the centre */
  grid-template-areas: "links brand signup";
  align-items: start;
  column-gap: 2rem;
  padding-bottom: 2.5rem;
}

.site-footer a {
  color: var(--colour-text-on-dark);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer p {
  margin: 0 0 1rem;
}

.footer-heading {
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
}

/* -------------------- LINK COLUMNS -------------------- */

.footer-links {
  grid-area: links;
  display: grid;
  grid-template-columns: repeat(3, auto);
  /* Three columns, each only as wide as its content */
  justify-content: start;
  column-gap: 2rem;
}

.footer-column ul,
.footer-policies {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-column li + li {
  margin-top: 0.6rem;
}

/* -------------------- LOGO -------------------- */

.footer-brand {
  grid-area: brand;
  align-self: center;
}

.footer-logo {
  display: block;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  overflow: hidden;
  /* Rounds the logo into a circle: anything outside the circle is hidden */
}

.footer-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Fills the circle without stretching, even if the image isn't perfectly square */
}

.footer-logo:hover {
  opacity: 0.85;
  /* A subtle fade on hover, so it feels clickable */
}

/* -------------------- EMAIL SIGNUP -------------------- */

.footer-signup {
  grid-area: signup;
  justify-self: end;
  /* Sits against the right edge, mirroring the links on the left */
  width: 100%;
  max-width: 26rem;
}

/* The email box and arrow button, joined into one rounded "pill" */
.newsletter-form {
  display: flex;
  align-items: center;
  max-width: 26rem;
  padding: 0.25rem 0.25rem 0.25rem 1.25rem;
  border-radius: 2rem;
  background-color: var(--colour-surface);
}

.newsletter-form:focus-within {
  outline: 2px solid var(--colour-text-on-dark);
  outline-offset: 3px;
  /* Shows a ring around the whole pill while typing, so keyboard users can see where they are */
}

.newsletter-form input {
  flex-grow: 1;
  min-width: 0;
  padding: 0.75rem 0;
  border: none;
  outline: none;
  /* The pill shows the focus ring instead (above) */
  background: none;
  color: var(--colour-text);
  font-size: 1rem;
  /* 1rem or more stops iPhones zooming in when it's tapped */
}

.newsletter-form button {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--colour-text);
  cursor: pointer;
}

.newsletter-form button:hover {
  background-color: var(--colour-highlight);
}

.newsletter-form button svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------- SOCIAL ROW -------------------- */
/* Hidden above 768px, where "Follow us" is a column instead */

.footer-social {
  display: none;
}

/* -------------------- BOTTOM STRIP -------------------- */

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  /* Lets the policy links drop onto a new line if there isn't room */
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--colour-text-on-dark) 25%, transparent);
  color: color-mix(in srgb, var(--colour-text-on-dark) 80%, var(--colour-footer));
  /* Slightly softer than the main footer text */
  font-size: 0.9rem;
}

.site-footer .footer-bottom p {
  margin: 0;
}

.footer-policies {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.site-footer .footer-psst {
  margin: 1.5rem 0 0;
  text-align: center;
  color: color-mix(in srgb, var(--colour-text-on-dark) 80%, var(--colour-footer));
  font-size: 0.9rem;
}

/* -------------------- POLICY PAGES -------------------- */

.policy-page {
  max-width: 60rem;
  margin: auto;
  padding: 2rem 1rem;
  line-height: 1.6;
}

/* -------------------- HIDDEN LABELS -------------------- */
/* Hides text on screen but keeps it for screen readers, e.g. the email box's label */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* -------------------- 769px TO 992px -------------------- */
/* Logo on the left, signup on the right, centred link columns underneath */

@media(max-width: 992px) and (min-width: 769px) {
  .footer-container {
    padding-left: 2rem;
    padding-right: 2rem;
    /* Extra space at the sides, so content isn't too close to the screen edges */
  }

  .footer-top {
    grid-template-columns: repeat(6, 1fr);
    grid-template-areas:
      "brand brand brand signup signup signup"
      "shop  shop  help  help   follow follow";
    /* Six equal columns: the logo and signup take half each, and the three link columns a third each */
    gap: 2rem;
  }

  .footer-links {
    display: contents;
    /* Lets the three link columns be placed on the map above individually */
  }

  .footer-shop {
    grid-area: shop;
  }

  .footer-help {
    grid-area: help;
  }

  .footer-follow {
    grid-area: follow;
  }

  .footer-column {
    text-align: center;
    /* Centres each column's heading and links within its third of the footer */
  }

  .footer-brand {
    justify-self: center;
    align-self: center;
    /* Centres the logo in the left half, both across and up and down,
       so it sits level with the middle of the signup on the right */
  }

  .footer-signup {
    max-width: none;
  }

  .newsletter-form {
    max-width: none;
    /* Fills its half of the footer, so its right edge lines up with the content edge */
  }
}

/* -------------------- 768px AND BELOW -------------------- */
/* Everything stacked in one centred column:
   signup, logo, Shop and Help side by side, then the social row */

@media(max-width: 768px) {
  .footer-top {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "signup signup"
      "brand  brand"
      "shop   help"
      "social social";
    /* A map of the footer: signup, logo and social row span both columns,
       while Shop and Help sit side by side */
    column-gap: 3rem;
    row-gap: 2.5rem;
  }

  .footer-links {
    display: contents;
    /* Lets Shop and Help be placed on the map above individually */
  }

  .footer-signup {
    justify-self: stretch;
    max-width: none;
    text-align: center;
  }

  .newsletter-form {
    margin: 0 auto;
    /* Centres the pill */
  }

  .footer-brand {
    justify-self: center;
  }

  .footer-shop {
    grid-area: shop;
    justify-self: end;
    /* Sits against the middle, so Shop and Help form a centred pair */
  }

  .footer-help {
    grid-area: help;
    justify-self: start;
  }

  .footer-follow {
    display: none;
    /* Replaced by the social row below */
  }

  .footer-social {
    grid-area: social;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  .footer-policies {
    justify-content: center;
  }
}

/* -------------------- PHONES (576px and below) -------------------- */

@media(max-width: 576px) {
  .footer-top {
    column-gap: 2rem;
    /* A little less space between Shop and Help, as the screen is narrower */
  }
}