/* Boutique Emmanuel Menswear: construction (how each section is put together).

   CONSTRUCTION
   Every section is put together as it scrolls into view, and no two are put
   together the same way. scripts/build.js names the move on each element
   (data-build="..."), assets/js/main.js sets it going (.is-prepped, then
   .is-built, then .is-done for photographs), and this file holds the look and
   the timing.

   The resting state is always the finished page. Every hidden state below sits
   under html.can-build, which assets/js/early.js sets only when the build can
   run to the end: not in the CMS editor, not for reduced motion, not without
   JavaScript, and it takes the class back off if main.js never arrives.
   Timing is in time, not tied to the scrollbar, so a line forms the same way
   however fast the page is scrolled. */

/* ---------- pieces made by main.js ---------- */
.bw { display: inline-block; white-space: nowrap; }
.bw__i, .bl { display: inline-block; }
.pc { position: absolute; z-index: 2; overflow: hidden; pointer-events: none; display: block; }
.pc__p {
  position: absolute; inset: 0; display: block; will-change: transform;
  transition: transform 1000ms var(--ease-out-slow), opacity 700ms var(--ease-out);
}
.pc__p > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.is-done > .pc { opacity: 0; transition: opacity 420ms var(--ease-out); }

/* The stitch under a heading: always there, drawn in when JS runs. */
[data-build="t-stitch"]::after {
  content: ""; display: block; height: 2px; width: min(100%, 4.6em); margin-top: 0.3em;
  background: repeating-linear-gradient(90deg, var(--brass-000) 0 12px, transparent 12px 21px);
  transform-origin: left center;
}
.close__h[data-build="t-stitch"]::after { margin-inline: auto; transform-origin: center; }

@media screen {

  /* ---------- text ---------- */

  /* Hidden until main.js has split it, so it never flashes in whole first. */
  html.can-build [data-build^="t-"]:not(.is-prepped) { opacity: 0; }

  /* t-rise: each word rises out of its own slot */
  html.can-build [data-build="t-rise"] .bw { overflow: clip; overflow-clip-margin: 0.04em; padding-bottom: 0.1em; margin-bottom: -0.1em; vertical-align: top; }
  html.can-build [data-build="t-rise"] .bw__i { transition: transform 950ms var(--ease-out-slow) calc(var(--i, 0) * 60ms); }
  html.can-build [data-build="t-rise"]:not(.is-built) .bw__i { transform: translate3d(0, 112%, 0); }

  /* t-focus: words sharpen out of a blur */
  html.can-build [data-build="t-focus"] .bw {
    transition: opacity 800ms var(--ease-out) calc(var(--i, 0) * 80ms),
                filter 1000ms var(--ease-out-slow) calc(var(--i, 0) * 80ms),
                transform 1000ms var(--ease-out-slow) calc(var(--i, 0) * 80ms);
  }
  html.can-build [data-build="t-focus"]:not(.is-built) .bw { opacity: 0; filter: blur(14px); transform: scale(1.08); }

  /* t-assemble: words fly in from scattered and lock into the line */
  html.can-build [data-build="t-assemble"] .bw {
    transition: transform 1150ms var(--ease-out-slow) calc(var(--i, 0) * 45ms),
                opacity 650ms var(--ease-out) calc(var(--i, 0) * 45ms);
  }
  html.can-build [data-build="t-assemble"]:not(.is-built) .bw {
    opacity: 0; transform: translate3d(var(--dx, 0), var(--dy, 0), 0) rotate(var(--r, 0deg));
  }

  /* t-tailor: the letters start let out and are taken in to fit */
  html.can-build [data-build="t-tailor"] .bl {
    transition: transform 1250ms var(--ease-out-slow), opacity 800ms var(--ease-out);
  }
  html.can-build [data-build="t-tailor"]:not(.is-built) .bl { opacity: 0; transform: translate3d(var(--x, 0), 0, 0); }

  /* t-stitch: letters land in order, then the stitch runs under the line */
  html.can-build [data-build="t-stitch"] .bl {
    transition: opacity 320ms var(--ease-out) calc(var(--i, 0) * 24ms),
                transform 560ms var(--ease-out-slow) calc(var(--i, 0) * 24ms);
  }
  html.can-build [data-build="t-stitch"]:not(.is-built) .bl { opacity: 0; transform: translate3d(0, 0.4em, 0); }
  html.can-build [data-build="t-stitch"]::after { transition: transform 1500ms var(--ease-out-slow) calc(var(--n, 12) * 18ms); }
  html.can-build [data-build="t-stitch"]:not(.is-built)::after { transform: scaleX(0); }

  /* ---------- blocks ---------- */

  html.can-build :is([data-build="b-up"], [data-build="b-left"], [data-build="b-right"], [data-build="b-deal"]) {
    transition: opacity 750ms var(--ease-out) calc(var(--i, 0) * 95ms),
                transform 1000ms var(--ease-out-slow) calc(var(--i, 0) * 95ms);
  }
  html.can-build [data-build="b-up"]:not(.is-built) { opacity: 0; transform: translate3d(0, 30px, 0); }
  html.can-build [data-build="b-left"]:not(.is-built) { opacity: 0; transform: translate3d(-56px, 0, 0); }
  html.can-build [data-build="b-right"]:not(.is-built) { opacity: 0; transform: translate3d(56px, 0, 0); }

  /* b-deal: a card dealt off the top of the stack */
  html.can-build [data-build="b-deal"] { transform-origin: 50% 100%; transition-delay: calc(var(--i, 0) * 140ms); }
  html.can-build [data-build="b-deal"]:not(.is-built) {
    opacity: 0; transform: translate3d(0, 70px, 0) rotate(calc(-3deg + var(--i, 0) * 3deg)) scale(0.95);
  }

  /* b-deck: the same, for every card in a list */
  html.can-build [data-build="b-deck"] > * {
    transform-origin: 50% 100%;
    transition: opacity 750ms var(--ease-out) calc(var(--i, 0) * 130ms),
                transform 1000ms var(--ease-out-slow) calc(var(--i, 0) * 130ms);
  }
  html.can-build [data-build="b-deck"]:not(.is-built) > * {
    opacity: 0; transform: translate3d(0, 60px, 0) rotate(calc(-2.5deg + var(--i, 0) * 1.6deg));
  }

  /* b-rows: the rule draws, then label and value close in from both sides */
  html.can-build [data-build="b-rows"] > * { position: relative; border-bottom-color: transparent; }
  html.can-build [data-build="b-rows"] > :not(:last-child)::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: var(--brass-200); transform-origin: left center;
    transition: transform 900ms var(--ease-out-slow) calc(var(--i, 0) * 90ms);
  }
  html.can-build [data-build="b-rows"]:not(.is-built) > ::after { transform: scaleX(0); }
  html.can-build [data-build="b-rows"] > * > *, html.can-build [data-build="b-rows"] > .row-solo {
    transition: opacity 650ms var(--ease-out) calc(120ms + var(--i, 0) * 90ms),
                transform 850ms var(--ease-out-slow) calc(120ms + var(--i, 0) * 90ms);
  }
  html.can-build [data-build="b-rows"]:not(.is-built) > * > :first-child,
  html.can-build [data-build="b-rows"]:not(.is-built) > .row-solo { opacity: 0; transform: translate3d(-28px, 0, 0); }
  html.can-build [data-build="b-rows"]:not(.is-built) > * > :last-child:not(:first-child) { opacity: 0; transform: translate3d(28px, 0, 0); }
  html.can-build [data-build="b-rows"] > * > :last-child:not(:first-child) { display: inline-block; }

  /* b-cascade: a grid fills in a diagonal wave (main.js reads row plus column) */
  html.can-build [data-build="b-cascade"] > * {
    transition: opacity 700ms var(--ease-out) calc(var(--w, var(--i, 0)) * 85ms),
                transform 1000ms var(--ease-out-slow) calc(var(--w, var(--i, 0)) * 85ms);
  }
  html.can-build [data-build="b-cascade"]:not(.is-built) > * { opacity: 0; transform: translate3d(0, 44px, 0) scale(0.94); }

  /* b-slide: a rail of cards slides in from the right */
  html.can-build [data-build="b-slide"] > * {
    transition: opacity 700ms var(--ease-out) calc(var(--i, 0) * 70ms),
                transform 1100ms var(--ease-out-slow) calc(var(--i, 0) * 70ms);
  }
  html.can-build [data-build="b-slide"]:not(.is-built) > * { opacity: 0; transform: translate3d(120px, 0, 0); }

  /* ---------- photographs and video ---------- */

  /* zero specificity, so a layout rule that places the element absolutely wins */
  :where([data-build^="i-"]) { position: relative; overflow: hidden; }

  /* Pieced together: the real picture waits under its pieces (main.js). */
  html.can-build :is([data-build="i-strips"], [data-build="i-tiles"], [data-build="i-shutter"]):not(.is-done) > :is(img, .vid, .frame) { opacity: 0; }
  html.can-build :is([data-build="i-strips"], [data-build="i-tiles"], [data-build="i-shutter"]) > :is(img, .vid, .frame) { transition: opacity 300ms linear; }

  /* i-wipe: a brass edge pulls the picture across */
  html.can-build [data-build="i-wipe"] { transition: clip-path 1250ms var(--ease-out-slow) 120ms; }
  html.can-build [data-build="i-wipe"]:not(.is-built) { clip-path: inset(0 100% 0 0); }
  html.can-build [data-build="i-wipe"]::after {
    content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background: linear-gradient(to left, var(--brass-000) 0 3px, transparent 3px);
    transition: transform 1250ms var(--ease-out-slow) 120ms, opacity 500ms var(--ease-out) 1250ms;
  }
  html.can-build [data-build="i-wipe"]:not(.is-built)::after { transform: translate3d(-100%, 0, 0); }
  html.can-build [data-build="i-wipe"].is-built::after { opacity: 0; }

  /* i-curtain: opens from the center */
  html.can-build [data-build="i-curtain"] { transition: clip-path 1400ms var(--ease-out-slow) 80ms; }
  html.can-build [data-build="i-curtain"]:not(.is-built) { clip-path: inset(0 50% 0 50%); }
  html.can-build [data-build="i-curtain"] > :is(img, .vid, .kb) { transition: transform 1900ms var(--ease-out-slow) 80ms; }
  html.can-build [data-build="i-curtain"]:not(.is-built) > :is(img, .vid, .kb) { transform: scale(1.14); }

  /* i-zoom: settles from a slight scale */
  html.can-build [data-build="i-zoom"] > * { transition: transform 1600ms var(--ease-out-slow), opacity 900ms var(--ease-out); }
  html.can-build [data-build="i-zoom"]:not(.is-built) > * { opacity: 0; transform: scale(1.12); }
}
