:root {
  --chapter-inset: 125px;
  --chapter-min-height: 500px;
  --chapter-hand-width: 8%;
  --intro-hand-inset: 100px;
}

/* The same stage contains every trigger and the full-height DESIGN columns. */
.sequence {
  width: min(100%, var(--stage-width));
  position: relative;
  isolation: isolate;
  margin: 0 auto;
  overflow: clip;
}
.ticker {
  position: absolute;
  inset: 0 auto 0 57.75%;
  display: flex;
  gap: 15px;
  width: 19%;
  overflow: hidden;
  opacity: var(--ticker-opacity, 0);
  pointer-events: none;
}
.ticker-column { flex: 1 1 0; min-width: 0; overflow: hidden; }
.ticker-track {
  animation: ticker-scroll var(--ticker-duration, 20s) linear infinite;
}
.ticker-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 15px;
  padding-bottom: 15px;
}
.ticker-tile img { width: 100%; height: auto; }
@keyframes ticker-scroll { to { transform: translateY(var(--ticker-shift, 0px)); } }

.intro {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 500px;
}
.intro-title {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62%;
  aspect-ratio: 740 / 220;
  margin: 0;
  display: flex;
  gap: 5%;
  align-items: center;
  transform: translate(-50%, -50%) scale(var(--intro-scale, 1));
  opacity: var(--intro-opacity, 1);
}
.intro-letter { width: 16%; display: block; flex: none; }
.intro-letter span {
  display: block;
  animation: letter-enter var(--entrance-time) cubic-bezier(.36, .52, 0, 1) both;
}
.intro-letter img {
  width: 100%;
  height: auto;
  aspect-ratio: 116 / 220;
  animation: letter-float var(--float-time) var(--float) infinite alternate;
}
.intro-b { --entrance-time: 2s; --float-time: 2s; --x: 11%; --y: 25%; }
.intro-a { --entrance-time: 2.4s; --float-time: 2.5s; --x: 25%; --y: 55%; }
.intro-s { --entrance-time: 2.8s; --float-time: 3s; --x: 51%; --y: 37%; }
.intro-i { --entrance-time: 3.2s; --float-time: 3.5s; --x: 63%; --y: 65%; }
.intro-l { --entrance-time: 3.6s; --float-time: 4s; --x: 89%; --y: 48%; }
@keyframes letter-enter { from { transform: perspective(1200px) rotateX(90deg) scale(0); } }
@keyframes letter-float { to { transform: translateY(var(--letter-drift, 30px)); } }
.intro-hand {
  position: absolute;
  bottom: 75px;
  right: var(--intro-hand-inset);
  width: 34px;
  opacity: var(--intro-hand-opacity, 1);
}
.intro-hand img {
  width: 100%;
  animation: hand-enter 1s var(--float) 1s both, hand-bob 2s var(--float) 2s infinite alternate;
}
@keyframes hand-enter { from { opacity: 0; translate: 0 -200px; } }
@keyframes hand-bob { to { transform: translateY(20px); } }

.chapter {
  position: relative;
  z-index: 1;
  min-height: var(--chapter-min-height);
  height: 100vh;
  padding-right: var(--chapter-inset);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--accent);
  pointer-events: none;
}
.chapter-uiux { --heading-width: 40%; --separation: 40%; }
.chapter-web { --heading-width: 48%; --separation: 37%; }
.chapter-logo, .chapter-about { --heading-width: 46%; --separation: 39%; }
.chapter-skills { --heading-width: 44%; --separation: 39%; }
.chapter::before {
  content: "";
  order: 2;
  flex: 0 0 var(--separation);
}
.chapter-heading {
  order: 1;
  flex: 0 0 var(--heading-width);
  min-width: 0;
  position: sticky;
  top: 200px;
  container-type: inline-size;
  transform: perspective(1200px) rotateY(30deg) scale(var(--chapter-scale, 1));
  pointer-events: auto;
}
.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  animation: wordmark-float 2.6s var(--float) infinite alternate;
}
@keyframes wordmark-float { to { transform: scale(1.07); } }
.wordmark img { width: 100%; height: auto; object-fit: contain; }
.wordmark-pair .wordmark-secondary {
  display: flex;
  flex-direction: column;
  gap: var(--pair-gap, 0);
  justify-content: center;
}
.wordmark-pair { gap: var(--mark-gap); }
.wordmark .wordmark-primary { flex: none; width: var(--primary-width); aspect-ratio: var(--primary-ratio); }
.wordmark-secondary { flex: none; width: var(--secondary-width); }
.wordmark-pair .wordmark-secondary { aspect-ratio: var(--secondary-ratio); }
.wordmark-pair .wordmark-secondary img { flex: none; aspect-ratio: var(--letter-ratio); }
.chapter-uiux .wordmark {
  --mark-gap: 7%;
  --primary-width: 64%;
  --primary-ratio: .834356;
  --secondary-width: 29%;
  --secondary-ratio: .386503;
  --pair-gap: calc(29cqw / 4.2);
  --letter-ratio: .851351;
}
.chapter-web .wordmark {
  --mark-gap: 6%;
  --primary-width: 74%;
  --primary-ratio: 1.17178;
  --secondary-width: 21%;
  --secondary-ratio: .328221;
  --pair-gap: calc(20.58cqw / 3.5);
  --letter-ratio: .722973;
}
.chapter-logo .wordmark {
  --mark-gap: 6%;
  --primary-width: 66%;
  --primary-ratio: 1;
  --secondary-width: 28%;
  --secondary-ratio: .423313;
  --pair-gap: calc(28cqw / 4.6);
  --letter-ratio: .932432;
}
.wordmark-skills {
  display: grid;
  grid-template-columns: repeat(3, 29%);
  column-gap: 6%;
  row-gap: calc(100cqw / 15.8);
}
.wordmark-skills img { aspect-ratio: .932432; }
.wordmark-about {
  --primary-width: 29%;
  --primary-ratio: .423313;
  --secondary-width: 65%;
  gap: 6%;
  align-items: flex-start;
}
.wordmark-about .wordmark-secondary {
  display: grid;
  grid-template-columns: repeat(2, 45%);
  grid-auto-rows: calc(6.5cqw / .202703);
  align-items: center;
  column-gap: 10%;
  row-gap: calc(65cqw / 10.2);
}
.wordmark-about .wordmark-secondary img { aspect-ratio: .932432; }
.chapter-hand {
  order: 3;
  flex: 0 0 var(--chapter-hand-width);
  aspect-ratio: 89 / 60;
  opacity: var(--gesture-opacity, 1);
  pointer-events: auto;
  position: relative;
}
.chapter-gesture {
  height: 100%;
  display: block;
  position: relative;
  animation: point-to-wordmark 2s var(--float) infinite alternate;
  animation-play-state: paused;
}
.chapter.is-visible .chapter-gesture { animation-play-state: running; }
.chapter-gesture img { width: 100%; height: 100%; object-fit: contain; }
@keyframes point-to-wordmark { to { transform: translateX(20px); } }
.gesture-label {
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  margin-top: 10px;
  text-align: center;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
}
.chapter-uiux .gesture-label { font-size: 18px; }
.motion-ready .gesture-label { opacity: 0; transform: translateY(-20px); }
.motion-ready .chapter.is-visible .gesture-label {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .5s var(--float), transform .5s var(--float);
}

@media (900px <= width < 1200px) {
  :root {
    --chapter-inset: 75px;
    --chapter-min-height: 400px;
    --chapter-hand-width: 9%;
    --intro-hand-inset: 70px;
  }
  .chapter-uiux { --separation: 39%; }
  .chapter-web { --separation: 35%; }
  .chapter-logo, .chapter-skills, .chapter-about { --separation: 36%; }
}

@media (600px <= width < 900px) {
  :root {
    --chapter-inset: 50px;
    --chapter-hand-width: 11%;
    --intro-hand-inset: 50px;
  }
  .chapter-uiux { --separation: 38%; }
  .chapter-web { --separation: 34%; }
  .chapter-logo, .chapter-skills, .chapter-about { --separation: 35%; }
}

@media (width < 600px) {
  :root {
    --chapter-inset: 30px;
    --chapter-hand-width: 16%;
    --intro-hand-inset: 30px;
    --letter-drift: 15px;
  }
  .ticker {
    left: 62.25%;
    width: 10%;
    gap: 0;
    --ticker-fade: linear-gradient(to bottom, black calc(100% - 200vh), transparent calc(100% - 100vh));
    -webkit-mask-image: var(--ticker-fade);
    mask-image: var(--ticker-fade);
  }
  .ticker-column:first-child, .ticker-column:last-child { display: none; }
  .intro { height: 95vh; }
  .intro-title {
    left: 9.375%;
    top: 9.5%;
    width: 81%;
    height: 80%;
    display: block;
    aspect-ratio: auto;
    transform: scale(var(--intro-scale, 1));
  }
  .intro-letter {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 22%;
    transform: translate(-50%, -50%);
  }
  .intro-hand { bottom: 100px; }
  .chapter-uiux { --separation: 29%; }
  .chapter-web, .chapter-logo, .chapter-skills, .chapter-about { --separation: 27%; }
  .wordmark-pair {
    display: grid;
    grid-template-columns: 100%;
    row-gap: var(--mobile-gap);
  }
  .wordmark-pair .wordmark-secondary {
    width: 100%;
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(2, var(--mini-width, 47%));
    justify-content: center;
    gap: var(--mini-gap, 6%);
  }
  .chapter-uiux .wordmark { --primary-width: 100%; --primary-ratio: .835938; --mobile-gap: calc(100cqw / 10.625); --mini-width: 46%; --mini-gap: 7%; }
  .chapter-web .wordmark { --primary-width: 100%; --mobile-gap: calc(100cqw / 12.95); --letter-ratio: .721894; }
  .chapter-logo .wordmark { --primary-width: 100%; --mobile-gap: calc(100cqw / 12.35); --letter-ratio: .935484; }
  .wordmark-skills {
    grid-template-columns: repeat(2, 47%);
    row-gap: calc(100cqw / 11.85);
  }
  .wordmark-about {
    --primary-width: 63%;
    --primary-ratio: .423754;
    --secondary-width: 30%;
    gap: 7%;
    min-height: calc(7cqw / .0439883);
  }
  .wordmark-about .wordmark-secondary {
    grid-template-columns: 100%;
    grid-auto-rows: auto;
    row-gap: calc(30cqw / 4.6);
  }
  .gesture-label { font-size: 12px; }
  .chapter-uiux .gesture-label { font-size: 14px; }

}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .motion-ready .gesture-label {
    opacity: 1;
    transform: none;
  }
  .intro, .chapter-heading { position: relative; top: auto; }
}

.intro-past .intro-hand:not(:focus-visible), .chapter.is-past .chapter-hand:not(:focus-visible) {
  pointer-events: none;
}
.intro-hand:focus-visible, .chapter-hand:focus-visible { opacity: 1; }
