/* ============================================================================
   FOOTER: the finale, "give me a ring" (js/modules/footer.js). Homepage only.
   Fixed underneath the page (.is-reveal) with #footer-root as its spacer, or in the flow when
   it is taller than the screen. It sits below the page in the stacking order (z-index -1);
   <main> has an opaque background, so it only shows once the page has lifted away.
   Colour and paper: css/atelier.css (FINALE).
   ============================================================================ */

/* the spacer is see-through for clicks; the footer inside takes them */
#footer-root {
  pointer-events: none;
}

.contact-anchor {
  height: 0;
}

.footer {
  position: relative;
  pointer-events: auto;
}

.footer.is-reveal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
}

.footer__inner {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1.5rem, 4svh, 3.5rem);
  max-width: var(--container-max);
  margin-inline: auto;
  /* clear of the corner logo, which stays over the footer */
  padding: max(calc(var(--nav-h) + 2.5rem), 14svh) var(--edge) clamp(1rem, 3svh, 2rem);
}

/* ---- the call to action (left); the telephone hangs on the right ---- */
.footer__main {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gutter);
  align-items: center;
  flex: 1;
}

.footer__cta {
  grid-column: 1 / span 7;
}

.footer__line {
  max-width: 11em;
  margin-top: clamp(1rem, 2.5svh, 1.75rem);
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 0.8rem + 2.9vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.footer__contact {
  margin-top: clamp(1.25rem, 3.5svh, 2.5rem);
}

/* the email: large enough to be the obvious way in; an underline draws in on hover */
.footer__email {
  display: inline-block;
  margin-top: 0.6rem;
  padding-bottom: 0.2em;
  font-size: clamp(1.1rem, 0.9rem + 0.7vw, 1.6rem);
  font-weight: 400;
  letter-spacing: 0.005em;
  color: inherit;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0% 1px no-repeat;
  transition: background-size 0.6s var(--ease-out), color 0.4s var(--ease-out);
}

.footer__email:hover,
.footer__email:focus-visible {
  background-size: 100% 1px;
}

.footer__social {
  display: flex;
  gap: var(--space-md);
  margin-top: clamp(1.25rem, 3svh, 2rem);
}

/* ---- the telephone: a photograph, hanging from the top edge ---- */
.footer__phone {
  position: absolute;
  top: 0;
  right: calc(var(--edge) + 7vw);
  /* the cord meets the top edge; the handset ends a little above the label row */
  height: min(84svh, 58rem);
  aspect-ratio: 941 / 1670;
  margin: 0;
}

.phone {
  display: block;
  height: 100%;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.phone:focus-visible {
  outline: none;
}

.phone__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* the photograph's white becomes the footer's paper */
  mix-blend-mode: multiply;
  /* it hangs from the top of its cord: it swings about that point */
  transform-origin: 45.4% 0;
  transition: transform 1.6s cubic-bezier(0.3, 1.25, 0.45, 1);
}

/* touched (the cursor arrives, a tap, keyboard focus): the receiver springs on its coiled cord. It
   hops up and sways, the swings dying away, then settles where it hung. It only ever rises (the
   cord's top never leaves the edge of the page) and keeps its shape. footer.js restarts it on each
   new touch and lets it finish even when the cursor has left, so it always comes home smoothly. */
.phone.is-bouncing .phone__img {
  animation: phone-bounce 1.25s linear;
}

@keyframes phone-bounce {
  0% { transform: translateY(0) rotate(0); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
  14% { transform: translateY(-22px) rotate(-3.4deg); animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4); }
  27% { transform: translateY(0) rotate(2.6deg); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
  38% { transform: translateY(-10px) rotate(-1.8deg); animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4); }
  49% { transform: translateY(0) rotate(1.2deg); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
  59% { transform: translateY(-4px) rotate(-0.7deg); animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4); }
  69% { transform: translateY(0) rotate(0.4deg); }
  80% { transform: translateY(-1px) rotate(-0.2deg); }
  100% { transform: translateY(0) rotate(0); }
}

/* the ring: a small jolt on its cord, twice */
.phone.is-ringing .phone__img {
  animation: phone-ring 1.3s ease-in-out 2;
}

@keyframes phone-ring {
  0%, 56%, 100% { transform: rotate(0); }
  6% { transform: rotate(-1.6deg) translateY(-3px); }
  12% { transform: rotate(1.6deg) translateY(-3px); }
  18% { transform: rotate(-1.4deg) translateY(-2px); }
  24% { transform: rotate(1.2deg) translateY(-2px); }
  32% { transform: rotate(-0.7deg); }
  42% { transform: rotate(0.3deg); }
}

/* the caption sits beside the handset's lower end (the handset fills the middle third of the
   photograph: 33-68 % of its width) */
.footer__phone-caption {
  position: absolute;
  right: 72%;
  bottom: 9%;
  display: block;
  width: 14em;
  height: 1.4em;
  margin-right: 0.75rem;
  text-align: right;
  white-space: nowrap;
}

.footer__phone-idle,
.footer__phone-live {
  position: absolute;
  inset: 0;
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.footer__phone-live {
  opacity: 0;
  transform: translateY(6px);
}

.footer__phone:has(.phone:hover) .footer__phone-idle,
.footer__phone:has(.phone:focus-visible) .footer__phone-idle {
  opacity: 0;
  transform: translateY(-6px);
}

.footer__phone:has(.phone:hover) .footer__phone-live,
.footer__phone:has(.phone:focus-visible) .footer__phone-live {
  opacity: 1;
  transform: none;
}

/* ---- the label row ---- */
.footer__bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  padding-top: var(--space-md);
}

.footer__rule {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}

.footer__item {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}

/* Open for work: a small dot, breathing */
.footer__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-burgundy-bright);
  box-shadow: 0 0 0 0 rgba(140, 28, 46, 0.7);
  animation: footer-pulse 2.4s var(--ease-in-out) infinite;
}

@keyframes footer-pulse {
  0% { box-shadow: 0 0 0 0 rgba(160, 40, 60, 0.6); }
  70% { box-shadow: 0 0 0 7px rgba(160, 40, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(160, 40, 60, 0); }
}

.footer__link {
  padding-bottom: 0.15em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0% 1px no-repeat;
  transition: background-size 0.6s var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.footer__link:hover,
.footer__link:focus-visible {
  background-size: 100% 1px;
}

/* ---- narrower: the telephone hangs above the words, from the same top edge ---- */
@media (max-width: 900px) {
  .footer__inner {
    padding-top: 0;
  }
  .footer__main {
    grid-template-columns: 1fr;
    row-gap: var(--space-md);
  }
  .footer__cta {
    grid-column: 1;
  }
  .footer__phone {
    position: relative;
    top: auto;
    right: auto;
    grid-row: 1;
    justify-self: end;
    height: min(44svh, 24rem);
    /* the corner logo needs the top-left: the cord drops right of centre. (No transform or
       opacity here: either would isolate the picture and its white would show.) */
    margin-right: 12%;
  }
}

@media (max-width: 700px) {
  .footer__bar {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .footer__dot,
  .phone.is-ringing .phone__img,
  .phone.is-bouncing .phone__img {
    animation: none;
  }
  .phone__img {
    transition: none;
  }
}
