/* ==========================================================================
   NELDRA STORY — the gallery walk that opens the homepage (inc/story.php)

   Two states:
   - still: the markup as a normal page. The hero comes first, then the
     chapters and photos in reading order. This is what shows without
     JavaScript, with reduced motion, or with Motion switched off;
   - live (.is-live, added by assets/js/story.js): one screen that holds
     while scrolling walks the visitor from the logo to the hero.

   Sizes are rem / viewport units like the rest of the theme, so the
   "Overall size on desktop" setting applies here too.
   ========================================================================== */

.story { position: relative; }
/* Arriving from another page of the site: the page opens on the hero (the
   walk's last page). Until it has been moved there, the walk stays out of
   sight, so its first frame does not flash (functions.php, neldra.js). */
.to-hero .story { visibility: hidden; }
.story__rail,
.story__skip { display: none; }

/* --------------------------------------------------------------------------
   Still
   -------------------------------------------------------------------------- */
.story--walk { padding-bottom: var(--section-y); }
.walk {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
  justify-items: center;
  text-align: center;
}
.walk__item { margin: 0; max-width: 60rem; padding-inline: var(--gutter); }
/* the hero leads; the walk's own logo is not needed (the header carries it) */
.walk__item--hero { order: -1; width: 100%; max-width: none; padding: 0; text-align: left; } /* the hero keeps its own alignment */
.walk__logo { display: none; margin: 0; line-height: 1; }
.walk__item--title { padding-top: clamp(2rem, 5vw, 4rem); }
.walk__tagline {
  max-width: 18ch;
  margin-inline: auto;
  font-family: var(--font-display);
  font-size: calc(var(--fs-display) * var(--type-scale));
  font-weight: 200;
  letter-spacing: .01em;
  line-height: 1.02;
  color: var(--c-text);
}
.walk__item--img img { width: min(44rem, 100%); height: auto; }
.walk__word {
  margin-top: .6rem;
  font-size: calc(var(--fs-display) * var(--type-scale));
  letter-spacing: .04em;
  text-transform: uppercase;
}
.walk__text { max-width: 32ch; margin: 1rem auto 0; color: var(--c-text-soft); font-size: var(--fs-small); }

/* --------------------------------------------------------------------------
   Live: one screen; everything hangs from its centre and story.js places it
   (transform = place on the wall × distance, opacity = fog, z-index = order)
   -------------------------------------------------------------------------- */
/* The section is as tall as the walk is long; inside it the stage (one screen)
   sticks to the top while the section scrolls past. The browser does the
   holding (position: sticky), so nothing jumps when scrolling starts.
   --bar: the WordPress admin bar when logged in (it covers the top of the
   screen, so the stage starts under it and is that much shorter).
   --walk-len: screens of scrolling, set by story.js from the walk's depth. */
.story--walk.is-live {
  --bar: var(--wp-admin--admin-bar--height, 0px);
  height: calc(100vh - var(--bar) + var(--walk-len, 4.7) * 100vh);
  height: calc(100svh - var(--bar) + var(--walk-len, 4.7) * 100svh);
  padding: 0;
}
.is-live > .story__stage {
  position: -webkit-sticky; position: sticky;
  top: var(--bar);
  height: calc(100vh - var(--bar));
  height: calc(100svh - var(--bar));
  overflow: hidden;
  background: var(--c-bg);
}
.is-live .walk { display: block; position: absolute; inset: 0; }
.is-live .walk__item {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(64rem, 86vw);
  max-width: none;
  padding: 0;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}

/* first frame: the logo, with the studio line under it */
.is-live .walk__logo { display: block; }
.walk__logo .walk__brand {
  display: inline-block;
  overflow: visible;
  font-size: clamp(2.4rem, 11vw, 9rem);
  letter-spacing: .42em;
  padding-left: .42em; /* optically centres the tracked wordmark */
  line-height: 1;
}
.walk__mark { position: relative; display: block; width: min(64vw, 72rem); max-width: 100%; margin-inline: auto; }
.walk__mark img { display: block; width: 100%; height: auto; }

.is-live .walk__tagline {
  max-width: none;
  margin-top: clamp(1.4rem, 3.5vh, 2.6rem);
  /* back to the quiet label style of .meta */
  font-family: var(--font-body);
  font-size: var(--fs-meta);
  font-weight: 400;
  letter-spacing: .18em;
  line-height: 1.7;
  color: var(--c-text-soft);
}

/* photographs on white lose their white: the pieces float, and words behind
   them stay readable */
.is-live .walk__item--img { width: min(46vw, 56rem); mix-blend-mode: multiply; pointer-events: none; }
.is-live .walk__item--img img { display: block; width: 100%; }

.is-live .walk__item--word { width: min(36rem, 80vw); text-align: left; }
.is-live .walk__word { font-size: calc(clamp(2.4rem, 6.4vw, 6.4rem) * var(--type-scale)); line-height: .98; }
.is-live .walk__text { margin-inline: 0; font-size: var(--fs-body); }

/* the destination: the hero, exactly the stage when the walk arrives */
.is-live .walk__item--hero { width: 100vw; height: 100%; }
.is-live .walk__item--hero .hero { height: 100%; min-height: 0; }

/* The walk opens with its own large logo, so the header's logo steps back for
   the whole walk (hero included); story.js brings it back when the page moves
   on to the next section. Only with the motion layer on (.motion is set in
   <head>, so there is no flash on load). */
.site-header .brand,
.site-header .brand-logo { transition: opacity .4s ease, visibility 0s linear 0s; }
.motion .site-header.is-brandless .brand,
.motion .site-header.is-brandless .brand-logo {
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s ease, visibility 0s linear .4s;
}

@media (max-width: 860px) {
  /* phones: one centred column, words above the middle, pictures below */
  .walk__mark { width: 76vw; }
  .is-live .walk__item--img { width: 76vw; }
  .is-live .walk__item--word { text-align: center; }
  .is-live .walk__text { margin-inline: auto; }
  /* the stacked hero shares the one screen: two halves */
  .is-live .walk__item--hero .panel { flex: 1 1 0; height: auto; min-height: 0; }
  .is-live .walk__item--hero .panel.is-active { height: auto; flex-grow: 1.5 !important; }
}

/* the way past the intro: centred under the studio line, part of the first
   frame (it passes and fades with the logo) */
.is-live .story__skip {
  display: inline-flex;
  align-items: center;
  margin-top: clamp(1.5rem, 4.5vh, 3.25rem);
  padding: .5rem 0 .5rem 1.1em; /* = the chevron and its gap, so the words themselves sit centred */
  transition: color var(--dur-fast) ease;
}
@media (hover: hover) { .is-live .story__skip:hover { color: var(--c-text); } }

/* progress hairline; it fades as the hero arrives */
.is-live .story__rail {
  display: block;
  position: absolute;
  left: 50%;
  bottom: clamp(1.25rem, 4vh, 2.5rem);
  z-index: 2100;
  width: 7rem;
  height: 1px;
  margin-left: -3.5rem;
  background: var(--c-line);
}
.story__rail i {
  display: block;
  height: 100%;
  background: var(--c-text);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
