/* A hero beside the work: a large, faded portrait that bleeds off the page edge and moves slowly.
   Move over it (or scroll it to the middle on a phone) and it gives way to what they said.
   Photos are openly licensed (credits.html). No generated faces, ever. */

/* Portraits bleed to the page edge; clip there so their slow drift never adds a sideways scroll. */
html, .page { overflow-x: clip; }

.hero {
  --gutter-bleed: var(--gutter, 64px);
  position: relative;
  display: grid;
  align-content: center;
  align-self: stretch;
  min-height: var(--hero-h, 520px);
  margin: 0;
  outline: none;
}
.hero:focus-visible .hero-said { outline: 2px solid var(--accent); outline-offset: 10px; border-radius: 2px; }

/* The portrait: large, pale, printed into the paper. */
.hero-portrait {
  position: absolute;
  top: -14%;
  bottom: 0;
  left: 0;
  right: calc(-1 * var(--gutter-bleed));
  z-index: 0;
  pointer-events: none;
  animation: hero-drift 16s ease-in-out infinite;
  animation-delay: var(--hero-delay, 0s);
}
.hero--left .hero-portrait { left: calc(-1 * var(--gutter-bleed)); right: 0; }

.hero-portrait img {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 100%;
  /* Full box width, so a lazy image off to the left still counts as on screen and loads. */
  width: 100%;
  object-fit: contain;
  object-position: bottom right;
  opacity: 0.46;
  filter: grayscale(1) contrast(1.1) brightness(1.03);
  mix-blend-mode: multiply;
  /* Fade into the paper at the bottom and on the side facing the text. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 34%), linear-gradient(to top, transparent 0, #000 26%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent 0, #000 34%), linear-gradient(to top, transparent 0, #000 26%);
  mask-composite: intersect;
  transition: opacity 700ms var(--ease-out), filter 700ms var(--ease-out), transform 900ms var(--ease-out);
  -webkit-user-drag: none;
  user-select: none;
}
.hero--left .hero-portrait img {
  right: auto;
  left: 0;
  object-position: bottom left;
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 34%), linear-gradient(to top, transparent 0, #000 26%);
  mask-image: linear-gradient(to left, transparent 0, #000 34%), linear-gradient(to top, transparent 0, #000 26%);
}

/* No licensed photo: the words stand in, shown from the start. Never a generated face. */
.hero--type .hero-said { opacity: 1; transform: none; }
.hero--type .hero-cap { display: none; }
.hero-ghost {
  display: none;
  position: absolute;
  bottom: 18%;
  right: 0;
  max-width: 100%;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(3.5rem, 2rem + 5vw, 7rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  text-align: right;
  color: var(--rule);
  transition: opacity 700ms var(--ease-out);
}
.hero--left .hero-ghost { right: auto; left: 0; text-align: left; }

.hero-cap {
  position: absolute;
  bottom: 10px;
  right: 0;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.01em;
  color: var(--slate);
  transition: opacity 400ms var(--ease-out);
}
.hero--left .hero-cap { right: auto; left: 0; }

/* What they said: in front of the portrait, hidden until reached. */
.hero-said {
  position: relative;
  z-index: 1;
  justify-self: center;
  display: grid;
  gap: 14px;
  max-width: 22em;
  margin: 0;
  padding: 8px 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 500ms var(--ease-out), transform 600ms var(--ease-out);
}
.hero-said q,
.hero-said .told {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 1.15rem + 1.1vw, 2.125rem);
  line-height: 1.25;
  letter-spacing: -0.014em;
  color: var(--ink);
  text-wrap: pretty;
}
.hero-said q { quotes: "“" "”"; }
.hero-said .told { font-style: italic; }
.hero-by { font-size: 0.9375rem; color: var(--slate); }
.hero-by b { font-weight: 500; color: var(--ink); }

/* Reached: the portrait steps back, the words come forward. */
.hero.is-open .hero-said { opacity: 1; transform: none; }
.hero.is-open .hero-portrait img { opacity: 0.1; filter: grayscale(1) contrast(1.1) blur(2px); transform: scale(1.02); }
.hero.is-open .hero-ghost { opacity: 0.35; }
.hero.is-open .hero-cap { opacity: 0; }

@media (hover: hover) and (pointer: fine) {
  .hero:hover .hero-said { opacity: 1; transform: none; }
  .hero:hover .hero-portrait img { opacity: 0.1; filter: grayscale(1) contrast(1.1) blur(2px); transform: scale(1.02); }
  .hero:hover .hero-ghost { opacity: 0.35; }
  .hero:hover .hero-cap { opacity: 0; }
}
.hero:focus-visible .hero-said { opacity: 1; transform: none; }
.hero:focus-visible .hero-portrait img { opacity: 0.1; }
.hero:focus-visible .hero-cap { opacity: 0; }

/* A still hero: the portrait and its name, nothing to reveal. */
.hero--still { pointer-events: none; }

/* Drift uses the individual translate/scale properties so it composes with the scroll parallax on transform. */
@keyframes hero-drift {
  0%, 100% { translate: 0 0; scale: 1; }
  50% { translate: 0 -10px; scale: 1.015; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-portrait { animation: none; }
  .hero-said, .hero-portrait img, .hero-cap, .hero-ghost { transition: none; }
  .hero-said, .hero.is-open .hero-said, .hero:hover .hero-said { transform: none; }
  .hero.is-open .hero-portrait img, .hero:hover .hero-portrait img { transform: none; filter: grayscale(1); }
}

@media (max-width: 760px) {
  .hero { min-height: var(--hero-h-sm, 380px); }
  .hero-portrait { top: -6%; }
  .hero-portrait img { opacity: 0.5; }
}
