/* ==========================================================================
   HOME HERO
   The community, full screen. Photographs of members fill the screen and
   change one into the next while each drifts slowly closer, under a fall of
   ink that carries the words at the foot. The four things members get run
   as chapters, by name only: on a phone a row of bars under the bar, like
   stories; from 900px the four names at the lower right. The line of the
   chapter on screen fills as it plays (HomeHero.js moves on when it is
   full).

   After the launch screen the heading waits for the logo to land
   (.is-launched).
   ========================================================================== */

.home-hero {
  --focus-color: var(--secondary-color);
  --hero-delay: 0ms;
  --chapter-time: 6s;
  position: relative;
  overflow: hidden;
  min-height: 100svh;
  background-color: var(--ink);
  color: var(--white);
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero {
    min-height: min(100svh, 1000px);
  }
}

.is-launched .home-hero {
  --hero-delay: 1250ms;
}

/* FILM */

.home-hero__film {
  position: absolute;
  inset: 0;
}

/* The fall of ink: deep at the foot for the words, a breath at the top for
   the bars. */
.home-hero__film::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to top, color-mix(in srgb, var(--ink) 92%, transparent) 0%, color-mix(in srgb, var(--ink) 70%, transparent) 30%, transparent 62%),
    linear-gradient(to bottom, color-mix(in srgb, var(--ink) 55%, transparent) 0%, transparent 24%);
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__film::after {
    background-image:
      linear-gradient(to top, color-mix(in srgb, var(--ink) 94%, transparent) 0%, color-mix(in srgb, var(--ink) 78%, transparent) 30%, color-mix(in srgb, var(--ink) 30%, transparent) 58%, transparent 78%),
      linear-gradient(to bottom, color-mix(in srgb, var(--ink) 50%, transparent) 0%, transparent 22%),
      linear-gradient(color-mix(in srgb, var(--ink) 16%, transparent), color-mix(in srgb, var(--ink) 16%, transparent));
  }
}

.home-hero__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1400ms var(--ease-in-out);
}

.home-hero__slide.is-current {
  opacity: 1;
}

.home-hero__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}

/* Each photograph drifts slowly closer and back, all the time, so a change of
   picture never interrupts the movement. Paused with the montage. */
@media (prefers-reduced-motion: no-preference) {
  .home-hero__slide img {
    animation: home-hero-drift 16s var(--ease-in-out) infinite alternate;
  }
}

.home-hero__slide:nth-child(2) img {
  animation-delay: -5s;
  transform-origin: 30% 40%;
}

.home-hero__slide:nth-child(3) img {
  animation-delay: -10s;
  transform-origin: 70% 30%;
}

.home-hero__slide:nth-child(4) img {
  animation-delay: -3s;
  transform-origin: 40% 60%;
}

.home-hero.is-paused .home-hero__slide img {
  animation-play-state: paused;
}

/* WRAPPER */

.home-hero__wrapper {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1280px;
  min-height: 100svh;
  margin-left: auto;
  margin-right: auto;
  padding-top: calc(env(safe-area-inset-top) + 5rem);
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  padding-bottom: calc(env(safe-area-inset-bottom) + 5.75rem); /* clear of the tab bar */
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__wrapper {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr auto;
    column-gap: 4rem;
    padding-top: 7rem;
    padding-left: 3rem;
    padding-right: 3rem;
    padding-bottom: 4rem;
  }
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero__wrapper {
    min-height: min(100svh, 1000px);
    padding-left: 4rem;
    padding-right: 4rem;
  }
}

/* Big Desktop Up - Min 1800px */
@media (min-width: 1800px) {
  .home-hero__wrapper {
    max-width: 1480px;
  }
}

/* CHAPTERS */

/* The four things members get, by name only. On a phone: a row of four bars
   under the bar, like stories, with the name of the one on screen under
   them. From 900px: the four names at the lower right, the one on screen
   underlined by a line that fills while it plays. */
.home-hero__chapters {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__chapters {
    grid-column: 2;
    grid-row: 2;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
  }
}

.home-hero__chapters ol {
  position: relative;
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.375rem;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__chapters ol {
    flex: none;
    grid-template-columns: none;
    justify-items: end;
    gap: 0;
  }
}

.home-hero__chapters ol button {
  display: grid;
  align-content: start;
  width: 100%;
  min-height: 44px;
  padding-top: 0.25rem;
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 0;
  border: 0;
  background-color: transparent;
  color: color-mix(in srgb, var(--white) 62%, transparent);
  text-align: left;
  transition: color var(--duration-md) ease;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__chapters ol button {
    gap: 0.5rem;
    width: auto;
    min-height: 0;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    text-align: right;
  }
}

.home-hero__chapters ol button[aria-pressed="true"] {
  color: var(--white);
}

.home-hero__chapters ol button:hover {
  color: var(--white);
}

/* The bar: a hairline that fills while its chapter plays. */
.home-hero__progress {
  position: relative;
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--white) 26%, transparent);
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__progress {
    order: 2;
    height: 2px;
    background-color: transparent;
  }
}

.home-hero__progress::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: var(--white);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.home-hero__chapters [aria-pressed="true"] > .home-hero__progress::after {
  transform: scaleX(1);
}

@media (prefers-reduced-motion: no-preference) {
  .is-scripted .home-hero:not(.is-still) [aria-pressed="true"] > .home-hero__progress::after {
    animation: home-hero-progress var(--chapter-time) linear both;
  }
}

.home-hero.is-paused [aria-pressed="true"] > .home-hero__progress::after {
  animation-play-state: paused;
}

/* On a phone the names share one place under the bars, and only the one on
   screen shows; presses go through them to the bars. */
.home-hero__label {
  position: absolute;
  top: 1.125rem;
  left: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
  color: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-md) ease;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__label {
    position: static;
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: inherit;
    opacity: 1;
  }
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero__label {
    font-size: 20px;
  }
}

.home-hero__chapters [aria-pressed="true"] > .home-hero__label {
  opacity: 1;
}

/* PAUSE */

.home-hero__pause {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin-top: -0.25rem;
  border: 0;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--ink) 40%, transparent);
  color: var(--white);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__pause {
    order: -1;
    align-self: flex-end;
    width: 40px;
    height: 40px;
    margin-top: 0;
    margin-bottom: 0.5rem;
  }
}

.home-hero__pause .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.home-hero__pause .icon:last-child {
  display: none;
}

.home-hero.is-paused .home-hero__pause .icon:first-child {
  display: none;
}

.home-hero.is-paused .home-hero__pause .icon:last-child {
  display: block;
}

.no-js .home-hero__pause {
  display: none;
}

.home-hero.is-still .home-hero__pause {
  display: none;
}

/* WORDS */

.home-hero__words {
  grid-row: 3;
  container-type: inline-size;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__words {
    grid-column: 1;
    grid-row: 2;
  }
}

.home-hero__words h1 {
  font-size: 42px;
  font-weight: 790;
  line-height: 0.94;
  letter-spacing: -0.045em;
}

/* The heading's lines never break, so under 300px of room (phones narrower
   than 340px) it steps down to stay whole. */
@container (max-width: 300px) {
  .home-hero__words h1 {
    font-size: 37px;
  }
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .home-hero__words h1 {
    font-size: 76px;
  }
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .home-hero__words h1 {
    font-size: 72px;
  }
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero__words h1 {
    font-size: 96px;
  }
}

/* Each line rises from behind its own edge. */
.home-hero__words h1 > span {
  display: block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.home-hero__words h1 > span > span {
  display: block;
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .is-scripted .home-hero__words h1 > span > span {
    animation: home-hero-line 1000ms var(--ease-out) backwards;
    animation-delay: calc(var(--hero-delay) + 200ms);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .is-scripted .home-hero__words h1 > span:nth-child(2) > span {
    animation-delay: calc(var(--hero-delay) + 300ms);
  }
}

.home-hero__words p {
  max-width: 26em;
  margin-top: 0.875rem;
  font-size: 17px;
  font-weight: 460;
  line-height: 1.4;
  color: color-mix(in srgb, var(--white) 84%, transparent);
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero__words p {
    margin-top: 1.5rem;
    font-size: 20px;
  }
}

.home-hero__words footer {
  margin-top: 1.25rem;
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .home-hero__words footer {
    margin-top: 2rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .is-scripted .home-hero__words p {
    animation: home-hero-fade 900ms var(--ease-out) backwards;
    animation-delay: calc(var(--hero-delay) + 480ms);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .is-scripted .home-hero__words footer {
    animation: home-hero-fade 900ms var(--ease-out) backwards;
    animation-delay: calc(var(--hero-delay) + 580ms);
  }
}

/* KEYFRAMES */

@keyframes home-hero-drift {
  from {
    transform: scale(1.02);
  }
  to {
    transform: scale(1.14);
  }
}

@keyframes home-hero-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes home-hero-line {
  from {
    transform: translateY(105%);
  }
}

@keyframes home-hero-fade {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
