/* The backward walk: certainty recedes; challengeability comes closer. */
.greet-mark--door .door-delay-1 { animation-delay: 0.45s; }
.greet-mark--door .door-delay-2 { animation-delay: 0.8s; }
.greet-mark--door .door-delay-3 { animation-delay: 1.15s; }
.greet-mark--door .door-thread { animation-delay: 1.5s; }
.greet-mark--door .a-fade { animation: wk-fadeIn 0.8s ease 2s forwards; }
.greet-mark--door .loop-mark {
  fill: #493b2e;
  font: 600 5.2px/1 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.55px;
  opacity: 0.58;
  transition: fill 0.8s ease, opacity 0.8s ease;
}
.greet-mark--door .loop-scar,
.greet-mark--door .loop-seal {
  fill: none;
  stroke: #b85c43;
  stroke-width: 1.2;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.greet-mark--door .loop-seal { stroke-dasharray: 2 2.6; }
.greet-copy [data-loop-solution],
.greet-copy [data-loop-lead],
.greet-mark--door figcaption {
  transition: opacity 0.35s ease, color 0.7s ease;
}
body[data-loop-returned="true"] .greet-mark--door .door-delay-2 {
  stroke-dasharray: 24 10;
}
body[data-loop-returned="true"] .greet-mark--door .loop-scar,
body[data-loop-returned="true"] .greet-mark--door .loop-seal {
  opacity: 0.82;
}
body[data-loop-returned="true"] .greet-mark--door .loop-mark {
  fill: #8b412f;
  opacity: 0.92;
}
body[data-loop-returned="true"] .greet-mark--door .fill-d {
  opacity: 0.12;
}
body[data-loop-returned="true"] .greet-mark--door figcaption {
  color: #8b412f;
}

.backward-walk {
  --walk-progress: 0;
  position: relative;
  z-index: 13;
  height: 650vh;
  min-height: 360rem;
  scroll-margin-top: 0;
  color: #eee5d6;
  background: #080b0d;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.08);
}

.backward-stage {
  position: sticky;
  top: 0;
  box-sizing: border-box;
  height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 72% 47%, rgba(47, 88, 112, 0.2), transparent 42%),
    linear-gradient(135deg, #11171c 0%, #090c0f 54%, #060809 100%);
}

.backward-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6, 8, 9, 0.98) 0%, rgba(6, 8, 9, 0.91) 23%, rgba(6, 8, 9, 0.42) 46%, transparent 72%),
    linear-gradient(0deg, rgba(6, 8, 9, 0.78) 0%, transparent 28%, transparent 78%, rgba(6, 8, 9, 0.42) 100%);
}

.gate-cinema {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: clamp(-8rem, -4vw, -2rem);
  width: min(67vw, 69rem);
  aspect-ratio: 1.1849;
  transform: translateY(-50%);
  filter: drop-shadow(0 2rem 5rem rgba(0, 0, 0, 0.65));
}

.gate-scene {
  --scene-opacity: 0;
  --scene-scale: 1.055;
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
  opacity: var(--scene-opacity);
  transform: scale(var(--scene-scale));
  transform-origin: 58% 52%;
  transition: opacity 0.42s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: opacity, transform;
}

.gate-scene:first-child { --scene-opacity: 1; --scene-scale: 1; }
.gate-scene__image,
.gate-scene__vignette {
  position: absolute;
  inset: 0;
}
.gate-scene__image {
  background-image: url("../assets/gate-film-storyboard-v1.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
}
.gate-scene__vignette {
  box-shadow: inset 0 0 5rem 1.5rem rgba(4, 6, 8, 0.55);
  background: linear-gradient(90deg, rgba(6, 8, 9, 0.48), transparent 40%);
}
.gate-scene--surface .gate-scene__image { background-position: 0% 0%; }
.gate-scene--form .gate-scene__image { background-position: 50% 0%; }
.gate-scene--finds .gate-scene__image { background-position: 100% 0%; }
.gate-scene--scar .gate-scene__image { background-position: 0% 100%; }
.gate-scene--glass .gate-scene__image { background-position: 50% 100%; }
.gate-scene--gap .gate-scene__image { background-position: 100% 100%; }

.gate-cinema__thread {
  position: absolute;
  z-index: 8;
  left: -13%;
  right: -3%;
  bottom: 8.4%;
  height: 1px;
  opacity: 0.64;
  background: linear-gradient(90deg, transparent, #b77145 16%, #f1c77c 49%, #b77145 82%, transparent);
  box-shadow: 0 0 1.15rem rgba(236, 164, 91, 0.34);
  transform: rotate(-1.8deg) scaleX(calc(0.24 + var(--walk-progress) * 0.76));
  transform-origin: left;
}
.backward-walk[data-step="5"] .gate-cinema__thread {
  background: linear-gradient(90deg, transparent, #b77145 16%, #f1c77c 54%, transparent 54.4%, transparent 61%, #b77145 61.4%, transparent);
}
.gate-cinema__caption {
  position: absolute;
  z-index: 9;
  right: 4%;
  bottom: 2.5%;
  margin: 0;
  color: rgba(238, 229, 214, 0.56);
  font: 0.57rem/1.4 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.backward-copy {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: clamp(1.25rem, 6vw, 6.5rem);
  width: min(34vw, 31rem);
  transform: translateY(-58%);
}
.backward-copy .sheet-kicker {
  margin-bottom: 0.85rem;
  color: #db8b68;
}
.backward-copy h2 {
  max-width: 10.5ch;
  min-height: 1.85em;
  margin: 0;
  color: #f3eadb;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 5.25vw, 5.9rem);
  font-weight: 400;
  letter-spacing: -0.058em;
  line-height: 0.91;
  text-wrap: balance;
  text-shadow: 0 0.2rem 2rem rgba(0, 0, 0, 0.7);
}
.backward-walk[data-step="5"] .backward-copy h2 {
  max-width: 11ch;
  font-size: clamp(2.45rem, 4.7vw, 5.2rem);
}
.backward-lead {
  max-width: 28rem;
  min-height: 4.8em;
  margin: 1.1rem 0 0;
  color: #bbb3a7;
  font-size: clamp(0.97rem, 1.35vw, 1.14rem);
  line-height: 1.6;
  text-shadow: 0 0.15rem 1rem #050708;
}
.backward-status {
  margin: 0.9rem 0 0;
  color: #788b93;
  font: 0.61rem/1.5 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.backward-arrival {
  min-height: 2.8rem;
  display: inline-flex;
  align-items: center;
  margin-top: 1.5rem;
  padding: 0.68rem 1rem;
  border: 1px solid rgba(228, 183, 116, 0.5);
  border-radius: 99px;
  color: #e8bd7e;
  background: rgba(228, 183, 116, 0.07);
  font: 0.66rem/1.2 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 0.25s ease, background 0.25s ease;
}
.backward-arrival:hover,
.backward-arrival:focus-visible {
  outline: none;
  background: rgba(228, 183, 116, 0.14);
  transform: translateY(-2px);
}
.backward-arrival[hidden] { display: none; }

.gate-index {
  position: absolute;
  z-index: 7;
  top: 50%;
  right: clamp(0.65rem, 1.8vw, 2rem);
  display: grid;
  gap: 0.18rem;
  transform: translateY(-50%);
}
.gate-index button {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  width: 7.6rem;
  min-height: 2rem;
  padding: 0.35rem 0;
  border: 0;
  color: rgba(232, 223, 207, 0.38);
  background: transparent;
  font: 0.56rem/1 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s ease, transform 0.25s ease;
}
.gate-index button span {
  width: 1.55rem;
  color: rgba(232, 223, 207, 0.24);
}
.gate-index button::before {
  content: "";
  width: 0.9rem;
  height: 1px;
  background: currentColor;
  transition: width 0.25s ease;
}
.gate-index button[aria-current="step"] {
  color: #efc47e;
  transform: translateX(-0.4rem);
}
.gate-index button[aria-current="step"]::before { width: 1.8rem; }
.gate-index button:hover,
.gate-index button:focus-visible { color: #f2eadc; outline: none; }

.backward-receipt {
  position: absolute;
  z-index: 6;
  right: clamp(2rem, 8.5vw, 9.5rem);
  bottom: clamp(1.2rem, 4vh, 3.5rem);
  width: min(58vw, 49rem);
  padding-top: 0.65rem;
  border-top: 1px solid rgba(232, 220, 200, 0.2);
  opacity: calc(0.5 + var(--walk-progress) * 0.46);
  backdrop-filter: blur(2px);
}
.backward-receipt__kicker {
  margin: 0 0 0.5rem;
  color: #d98b72;
  font: 0.54rem/1.4 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.backward-receipt dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}
.backward-receipt dl div { min-width: 0; }
.backward-receipt dt {
  color: #70858d;
  font: 0.54rem/1.4 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.backward-receipt dd {
  margin: 0.22rem 0 0;
  color: #cfc6b9;
  font-size: 0.69rem;
  line-height: 1.4;
}

.gate-scroll-cue {
  position: absolute;
  z-index: 7;
  left: clamp(1.25rem, 6vw, 6.5rem);
  bottom: clamp(1.4rem, 4vh, 3.5rem);
  margin: 0;
  color: rgba(232, 223, 207, 0.42);
  font: 0.56rem/1 "IBM Plex Mono", Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: opacity 0.35s ease;
}
.gate-scroll-cue span {
  display: inline-block;
  margin-left: 0.45rem;
  color: #d98b72;
  animation: gate-drift 1.8s ease-in-out infinite;
}
.backward-walk[data-step="5"] .gate-scroll-cue { opacity: 0; }

@keyframes gate-drift {
  0%, 100% { transform: translateY(-0.12rem); opacity: 0.5; }
  50% { transform: translateY(0.22rem); opacity: 1; }
}

@media (max-width: 900px) {
  .backward-walk { height: 610vh; min-height: 300rem; }
  .gate-cinema {
    top: 5.2rem;
    right: auto;
    left: 50%;
    width: min(96vw, 47rem);
    transform: translateX(-50%);
  }
  .backward-stage::after {
    background:
      linear-gradient(0deg, rgba(6, 8, 9, 0.98) 0%, rgba(6, 8, 9, 0.93) 34%, rgba(6, 8, 9, 0.24) 67%, rgba(6, 8, 9, 0.35) 100%);
  }
  .backward-copy {
    top: auto;
    right: 1.25rem;
    bottom: 9.6rem;
    left: 1.25rem;
    width: auto;
    transform: none;
  }
  .backward-copy h2 {
    max-width: 12ch;
    min-height: 0;
    font-size: clamp(2.25rem, 8.7vw, 4.3rem);
  }
  .backward-walk[data-step="5"] .backward-copy h2 { font-size: clamp(2.15rem, 8.2vw, 4rem); }
  .backward-lead { min-height: 3.2em; max-width: 34rem; }
  .gate-index {
    top: auto;
    right: 1.25rem;
    bottom: 6.3rem;
    left: 1.25rem;
    display: flex;
    justify-content: space-between;
    transform: none;
  }
  .gate-index button {
    width: auto;
    gap: 0;
    font-size: 0;
  }
  .gate-index button::before { width: 1.15rem; }
  .gate-index button span { width: auto; font-size: 0.54rem; }
  .gate-index button[aria-current="step"] { transform: translateY(-0.2rem); }
  .gate-index button[aria-current="step"]::before { width: 2rem; }
  .backward-receipt { right: 1.25rem; bottom: 1rem; left: 1.25rem; width: auto; }
  .backward-receipt dd { font-size: 0.62rem; }
  .gate-scroll-cue { display: none; }
}

@media (max-width: 600px) {
  .gate-cinema { top: 4.6rem; width: 108vw; }
  .gate-cinema__caption { display: none; }
  .backward-copy { bottom: 8.6rem; }
  .backward-copy h2 { font-size: clamp(2.08rem, 10.8vw, 3.4rem); }
  .backward-lead { font-size: 0.9rem; line-height: 1.48; }
  .backward-status { font-size: 0.54rem; }
  .backward-receipt { bottom: 0.75rem; }
  .backward-receipt dl { grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem; }
  .backward-receipt dl div:nth-child(2),
  .backward-receipt dl div:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gate-scene,
  .backward-arrival,
  .gate-index button { transition: none; }
  .gate-scroll-cue span { animation: none; }
}
