/* 11 · Footer: the sign-up and the sign-off in one navy band.
   Pitch on the left, the form and Instagram on the right; a stitched seam, then the brand and the
   copyright. The hero's quilt is sewn across the top edge as a bone patch, like the date patches. */

.site-footer {
  --footer-patch-tile: clamp(26px, 1.2rem + 1.4vw, 40px);
  --footer-patch-gap: 5px;
  position: relative;
  isolation: isolate;
  padding-top: clamp(4.75rem, 3rem + 4vw, 6.5rem);
  padding-bottom: clamp(1.5rem, 1rem + 1vw, 2.25rem);
  background: var(--color-navy);
  color: var(--color-white);
  --stitch-color: color-mix(in oklab, var(--color-white) 40%, transparent);
}

/* Print grain, as on the other jewel surfaces */
.site-footer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--grain);
  background-size: 180px 180px;
  mix-blend-mode: soft-light;
  opacity: 0.55;
  pointer-events: none;
}

/* ---------- The patch on the seam ---------- */

.site-footer__patch {
  position: absolute;
  top: 0;
  right: max(var(--space-gutter), calc((100% - var(--page-max)) / 2 + var(--space-gutter)));
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, var(--footer-patch-tile));
  grid-auto-rows: var(--footer-patch-tile);
  gap: var(--footer-patch-gap);
  padding: 12px;
  background-color: var(--color-bone);
  /* A running stitch just inside the edge */
  --stitch-color: color-mix(in oklab, var(--color-navy) 45%, transparent);
  background-image: var(--stitch), var(--stitch), var(--stitch), var(--stitch);
  background-size:
    var(--stitch-pitch) var(--stitch-dot),
    var(--stitch-pitch) var(--stitch-dot),
    var(--stitch-dot) var(--stitch-pitch),
    var(--stitch-dot) var(--stitch-pitch);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-position: 0 5px, 0 calc(100% - 5px), 5px 0, calc(100% - 5px) 0;
  background-origin: border-box;
  box-shadow: 0 18px 40px -18px color-mix(in oklab, var(--color-navy) 70%, transparent);
  /* Individual properties, so the reveal can own `transform` */
  translate: 0 -58%;
  rotate: -3deg;
}

.site-footer__patch > span {
  color: var(--hue);
}

.site-footer__patch > span:nth-child(1) { grid-area: 1 / 1 / span 2 / span 2; }
.site-footer__patch > span:nth-child(2) { grid-area: 1 / 3; }
.site-footer__patch > span:nth-child(3) { grid-area: 2 / 3 / span 2 / span 2; }
.site-footer__patch > span:nth-child(4) { grid-area: 3 / 2; }
.site-footer__patch > span:nth-child(5) { grid-area: 1 / 5; }
.site-footer__patch > span:nth-child(6) { grid-area: 3 / 5; }

/* ---------- Sign-up ---------- */

.site-footer__main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 2rem clamp(2rem, 1rem + 4vw, 6rem);
  align-items: end;
}

.site-footer__title {
  max-width: 24ch;
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--display-4);
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.site-footer__actions {
  display: grid;
  gap: 1.25rem;
}

.site-footer__form {
  display: grid;
  gap: 0.5rem;
}

.site-footer__label {
  font-size: var(--text-caps);
  font-weight: 700;
  letter-spacing: var(--caps-tracking);
  text-transform: uppercase;
  color: var(--color-bone);
}

.site-footer__field {
  display: flex;
  gap: 0.75rem;
  align-items: end;
}

/* The field: a resting stitch underneath; on focus the accent stitch draws in over it */
.site-footer__input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  --stitch-color: color-mix(in oklab, var(--color-white) 55%, transparent);
  background-image: var(--stitch);
  background-size: var(--stitch-pitch) var(--stitch-dot);
  background-repeat: repeat-x;
  background-position: 0 100%;
}

.site-footer__input-wrap::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: var(--stitch-dot);
  --stitch-color: var(--color-accent-on-dark);
  background-image: var(--stitch);
  background-size: var(--stitch-pitch) var(--stitch-dot);
  background-repeat: repeat-x;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

.site-footer__input-wrap:focus-within::after {
  transform: scaleX(1);
}

.site-footer__input {
  width: 100%;
  height: var(--btn-height);
  padding: 0 0.25rem;
  border: 0;
  background: transparent;
  color: var(--color-white);
  font: inherit;
  font-size: 1.0625rem;
}

.site-footer__input::placeholder {
  color: color-mix(in oklab, var(--color-white) 50%, transparent);
}

.site-footer__input:focus-visible {
  outline: none;
}

.site-footer__field .btn {
  flex: none;
}

.site-footer__status {
  min-height: 1.3em;
  font-size: var(--text-small);
  color: var(--color-bone);
}

.site-footer__status:empty {
  min-height: 0;
}

/* Instagram: one line, the handle in bold; the arrow lifts on hover */
.site-footer__social {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  justify-self: start;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-bone);
  transition: color var(--duration-fast) var(--ease-out-expo);
}

.site-footer__social b {
  font-weight: 700;
  color: var(--color-white);
}

.site-footer__ig {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.site-footer__ig .fill {
  fill: currentColor;
  stroke: none;
}

.site-footer__arrow {
  display: inline-block;
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

.site-footer__social:focus-visible {
  outline-color: var(--color-accent-on-dark);
}

@media (hover: hover) {
  .site-footer__social:hover {
    color: var(--color-accent-on-dark);
  }

  .site-footer__social:hover .site-footer__arrow {
    transform: translate(2px, -2px);
  }
}

/* ---------- Sign-off ---------- */

.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-top: clamp(2.5rem, 1.75rem + 2vw, 3.5rem);
  padding-top: 1.25rem;
  background-image: var(--stitch);
  background-size: var(--stitch-pitch) var(--stitch-dot);
  background-repeat: repeat-x;
  background-position: 0 0;
}

.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--color-bone);
}

.site-footer__mark {
  width: 36px;
  height: 36px;
  background-color: currentColor;
  -webkit-mask: url("../assets/logo-mark.png") center / contain no-repeat;
  mask: url("../assets/logo-mark.png") center / contain no-repeat;
  transition: transform var(--duration-slow) var(--ease-spring);
}

@media (hover: hover) {
  .site-footer__brand:hover .site-footer__mark {
    transform: rotate(-8deg) scale(1.06);
  }
}

.site-footer__brand:focus-visible {
  outline-color: var(--color-accent-on-dark);
}

.dot-text--footer {
  --dot: 4px;
  --dot-gap: 1.5px;
  --hue: var(--color-bone);
}

.site-footer__copy {
  font-size: 0.8125rem;
  color: color-mix(in oklab, var(--color-white) 65%, transparent);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .site-footer__main {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 1.75rem;
  }
}

@media (max-width: 480px) {
  .site-footer__patch {
    padding: 9px;
    --footer-patch-gap: 4px;
  }

  .site-footer__field {
    flex-wrap: wrap;
  }

  .site-footer__field .btn {
    width: 100%;
  }
}

/* Phones: one centred column, the patch sewn on the middle of the seam. The margin gives the
   part of the patch that hangs above the seam clear white, off the last card of the band above. */
@media (max-width: 640px) {
  .site-footer {
    margin-top: 4.5rem;
    text-align: center;
  }

  .site-footer__patch {
    right: auto;
    left: 50%;
    translate: -50% -58%;
  }

  .site-footer__title {
    margin-inline: auto;
  }

  .site-footer__actions,
  .site-footer__form {
    justify-items: center;
  }

  .site-footer__form,
  .site-footer__field {
    width: 100%;
  }

  .site-footer__input {
    text-align: center;
  }

  .site-footer__social {
    justify-self: center;
  }

  .site-footer__base {
    flex-direction: column;
    justify-content: center;
    gap: 0.9rem;
  }
}

