/* The cover: plate, name, subject. Three planes, so the head passes in front of the name. */

/* --- Arrival. The photograph is simply there; only the words come to it. Each element marked
   data-in carries --k, from 0 (not arrived) to 1, set by js/cover.js. Without scripts it is 1.
   The words are racked into focus, as a lens would. */
[data-in] { --k: 1; }
.js [data-in] { --k: 0; }

.cover {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* --s: how far the page has left the cover. --mx, --my: pointer, from -1 to 1. */
  --s: 0;
  --mx: 0;
  --my: 0;
}

.cover__layer { position: absolute; inset: -60px 0 28% 0; will-change: transform; }
.cover__layer img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0%; }

.cover__plate {
  z-index: 1;
  transform: translate3d(calc(var(--mx) * -9px), calc(var(--s) * 7% + var(--my) * -5px), 0) scale(calc(1.05 + var(--s) * 0.05));
}
/* The plate darkens behind the name, so the letters hold against the lit tower and the head stands out. */
.cover__plate::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(11, 11, 10, 0.8) 0%, rgba(11, 11, 10, 0.68) 30%, rgba(11, 11, 10, 0) 62%);
}

.cover__name {
  position: absolute;
  z-index: 2;
  /* On wider portrait screens the picture is fitted by its width and the head sits lower: the
     name follows it down, so the hair still crosses the letters. */
  top: max(112px, calc(33vw - 40px));
  left: var(--pad);
  right: var(--pad);
  font-size: 18.5vw;
  white-space: nowrap;
  text-align: center;
  transform: translate3d(calc(var(--mx) * 5px), calc(var(--s) * -5svh), 0);
  will-change: transform;
  /* Focus: out of focus and a little loose, then sharp and tight. */
  opacity: calc(0.3 + var(--k) * 0.7);
  letter-spacing: calc((1 - var(--k)) * 0.028em);
}
/* The blur only while the words arrive (js/cover.js sets is-arrived): a blur of nothing is still
   a filter, which a browser may keep redrawing for as long as the cover is on screen. */
.js .cover:not(.is-arrived) .cover__name { filter: blur(calc((1 - var(--k)) * 18px)); }

.cover__subject {
  z-index: 3;
  transform: translate3d(calc(var(--mx) * 15px), calc(var(--s) * -4% + var(--my) * 7px), 0) scale(calc(1.05 + var(--s) * 0.02));
}

.cover__veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(11, 11, 10, 0.4) 0%, rgba(11, 11, 10, 0) 12%, rgba(11, 11, 10, 0) 50%, var(--night) 71%);
}
/* As the next page slides over it, the cover sinks into the dark. */
.cover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: var(--night);
  opacity: calc(var(--s) * 0.82);
}

/* The photograph's credit runs up the edge of the page, as in a magazine. */
.cover__credit {
  position: absolute;
  z-index: 5;
  right: 5px;
  top: 46%;
  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
  white-space: nowrap;
  color: rgba(244, 241, 234, 0.7);
  opacity: var(--k);
}

.cover__foot { position: relative; z-index: 5; margin-top: auto; padding: 0 var(--pad) 20px; }
.cover__foot [data-in] { opacity: var(--k); translate: 0 calc((1 - var(--k)) * 10px); }
.js .cover:not(.is-arrived) .cover__foot [data-in] { filter: blur(calc((1 - var(--k)) * 5px)); }
.cover__line { max-width: 31ch; font-size: 19px; }
.cover__proofs { margin-top: 16px; }
.cover__proofs .row { padding: 10px 0 12px; font-size: 20px; }
.bar[data-in] { opacity: var(--k); }

/* The smallest phones (320 px across): the foot of the cover was so tall that its sentence rose
   over the lit part of the photograph. Smaller, it sits on the dark of the veil again. */
@media (max-width: 359px) {
  .cover__line { font-size: 16px; }
  .cover__proofs { margin-top: 10px; }
  .cover__proofs .row { padding: 8px 0 10px; font-size: 17px; }
}

@media (min-width: 900px) {
  .cover__layer { inset: 0; }
  .cover__layer img { object-position: 50% 37%; }
  .cover__name { top: 92px; font-size: 16.8vw; }
  /* The two lower corners are burned in, as on a darkroom print: that is where the words sit. */
  .cover__veil {
    background:
      radial-gradient(ellipse 44% 50% at 100% 100%, rgba(11, 11, 10, 0.8) 0%, rgba(11, 11, 10, 0) 100%),
      radial-gradient(ellipse 38% 46% at 0% 100%, rgba(11, 11, 10, 0.7) 0%, rgba(11, 11, 10, 0) 100%),
      linear-gradient(to bottom, rgba(11, 11, 10, 0.45) 0%, rgba(11, 11, 10, 0) 14%, rgba(11, 11, 10, 0) 56%, rgba(11, 11, 10, 0.93) 100%);
  }
  .cover__credit { right: 15px; top: 50%; }
  .cover__foot { padding: 0 var(--pad) 34px; display: grid; grid-template-columns: repeat(12, 1fr); column-gap: var(--gap); align-items: end; }
  /* Set for 1440 px; narrower, they follow the width, so that the two corners keep their lines. */
  .cover__line { grid-column: 1 / span 3; font-size: clamp(20px, 1.8vw, 26px); line-height: 1.2; max-width: 17ch; }
  .cover__proofs { grid-column: 10 / span 3; margin: 0; }
  .cover__proofs .row { padding: 11px 0 13px; font-size: clamp(18px, 1.53vw, 22px); }
}
/* Below 1200 px three columns are too narrow for a proof on one line: it takes four, still
   ending under the contact button. */
@media (min-width: 900px) and (max-width: 1199px) {
  .cover__proofs { grid-column: 9 / span 4; }
}
