/* The Footer: The Name Arrives.

   How to mount it: load this after styles.css, on every page. It changes no size, gap or colour of the approved footer. It adds
     1. one entrance, played once as the footer comes into view: the rule draws across, the three words of the name rise from behind
        their own foot one after another, a pool of ultramarine passes through the letters, and the blue square drops and lands;
     2. after that, a pool of ultramarine inside the letters that follows a mouse or a finger, and passes once when the keyboard reaches the name.
   Everything that moves is a transform or an opacity. The layers are built by foot-show.js; without it none of this exists. */

[data-show-foot] { --fm-ease: cubic-bezier(0.16, 1, 0.3, 1); }

/* the top rule becomes a line that can be drawn. Same place, same colour, same 1 pixel. */
[data-show-foot] .foot__in { position: relative; border-top-color: transparent; }
[data-show-foot] .foot__in::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--rule); transform-origin: 0 50%; }

/* each word: the outer span is the mask and never moves, the inner one rises. The mask leaves room for the tail of the g. */
[data-show-foot] .brand__name { position: relative; }
.fm-w { display: inline-block; clip-path: inset(-0.2em -0.1em -0.26em -0.1em); }
.fm-up { display: inline-block; }

/* the pool: a round window that travels over the name; inside it one copy of the name in the accent, moved back by the same amount,
   so the copy lies exactly on the letters and only its colour shows through the window */
/* the pool lives in a box the size of the name (a little taller, for the tail of the g), so it can never reach past the name and widen the page */
.fm-clip { position: absolute; inset: -0.4em 0; overflow: hidden; pointer-events: none; }
.fm-org { position: absolute; left: 0; top: 0.4em; width: 0; height: 0; }
.fm-pool {
  position: absolute; left: 0; top: 0; width: 2.8em; height: 2.8em; margin: -1.4em 0 0 -1.4em; border-radius: 50%; overflow: hidden; pointer-events: none;
  opacity: 0; transition: opacity 0.35s ease; will-change: transform, opacity;
  -webkit-mask: radial-gradient(closest-side, #000 0, #000 38%, transparent 100%); mask: radial-gradient(closest-side, #000 0, #000 38%, transparent 100%);
}
.fm-blue { position: absolute; left: 1.4em; top: 1.4em; color: var(--accent); white-space: nowrap; will-change: transform; }
.is-lit .fm-pool { opacity: 1; transition-duration: 0.2s; }

/* The entrance. Nothing here applies unless foot-show.js has put .fm-ready on <html>, which it does only when movement is allowed. */
@media (prefers-reduced-motion: no-preference) {
  .fm-ready [data-show-foot]:not(.is-in) .foot__in::before { transform: scaleX(0); }
  .fm-ready [data-show-foot]:not(.is-in) .fm-up { transform: translateY(125%); }
  .fm-ready [data-show-foot]:not(.is-in) .brand__name .pt,
  .fm-ready [data-show-foot]:not(.is-in) .foot__mail,
  .fm-ready [data-show-foot]:not(.is-in) .foot__base { opacity: 0; }

  [data-show-foot].is-in .foot__in::before { animation: fm-rule 1.1s var(--fm-ease) both; }
  [data-show-foot].is-in .fm-up { animation: fm-up 1s var(--fm-ease) both; animation-delay: calc(120ms + var(--i, 0) * 110ms); }
  [data-show-foot].is-in .brand__name .pt { animation: fm-drop 0.62s linear 0.86s both; }
  [data-show-foot].is-in .foot__mail { animation: fm-rise 0.7s var(--fm-ease) 0.5s both; }
  [data-show-foot].is-in .foot__base { animation: fm-rise 0.7s var(--fm-ease) 0.62s both; }
  [data-show-foot].is-in.is-done .foot__in::before, [data-show-foot].is-in.is-done .fm-up, [data-show-foot].is-in.is-done .pt,
  [data-show-foot].is-in.is-done .foot__mail, [data-show-foot].is-in.is-done .foot__base { animation: none; }

  @keyframes fm-rule { from { transform: scaleX(0); } to { transform: none; } }
  @keyframes fm-up { from { transform: translateY(125%); } to { transform: none; } }
  @keyframes fm-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  /* the square falls from above the capitals, lands, gives once, and is still */
  @keyframes fm-drop {
    0% { opacity: 0; transform: translateY(-0.95em); animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.5); }
    14% { opacity: 1; }
    58% { opacity: 1; transform: translateY(0); animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
    76% { transform: translateY(-0.06em); animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.5); }
    100% { opacity: 1; transform: translateY(0); }
  }
}
