/* Section handoffs and navigation shared by the public reading route. */
.journey-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap: .65rem;
  padding: .45rem .85rem;
  color: inherit;
  border: 1px solid currentColor;
  text-decoration: none;
}
.journey-link:focus-visible, .puzzle-continue:focus-visible, .realm-route a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.realm-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding: .65rem max(1rem, calc((100% - 60rem) / 2));
  background: #10272b;
  color: #eddbba;
  border-block: 1px solid #d8b27a44;
}
.realm-route-name { font: 400 1.25rem/1.2 Painting, "Songti SC", serif; white-space: nowrap; }
.realm-route ol { display: flex; gap: clamp(.3rem, 2vw, 1.25rem); list-style: none; padding: 0; margin: 0; }
.realm-route a {
  display: inline-block;
  padding: .35rem .55rem;
  font-size: .85rem;
  letter-spacing: .06em;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: .3em;
  text-decoration-color: #e3be7f80;
  white-space: nowrap;
}
.realm-route a:hover { text-decoration-color: currentColor; }
.explore-location h2, .decode-list > li { scroll-margin-top: 6rem; }

.realm-repair { position: relative; }
.realm-repair::before {
  content: "";
  position: absolute;
  inset: -1px 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--repair-gold), transparent);
  transform-origin: center;
  pointer-events: none;
}

.puzzle-progress-row { display: flex; align-items: baseline; justify-content: space-between; gap: .3rem; }
.puzzle-continue {
  display: none;
  color: #f0d29b;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.puzzle-inner:not(:has(.puzzle-fit:not(:checked))) .puzzle-continue { display: inline-block; }
body:has(.silk-puzzle:target, .puzzle-entry:target) .chapter-rail a[href="#silk-puzzle"] span { opacity: 1; color: #e6bb80; }
body:has(.silk-puzzle:target, .puzzle-entry:target) .chapter-rail a[href="#silk-puzzle"] i { width: 30px; background: #e6bb80; }

#decode {
  position: relative;
  isolation: isolate;
}
#decode::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0 0 auto;
  height: clamp(1rem, 7vw, 4rem);
  background: linear-gradient(#0e2023, #0e202323 65%, transparent);
}
.decode-inner .decode-card { grid-template-columns: clamp(2.4rem, 12vw, 4rem) minmax(0, 1fr) auto; }
.decode-inner .decode-card img { width: 100%; }
.decode-label { display: grid; min-width: 0; gap: .1rem; }
.decode-label small { color: #74542e; font-size: .7rem; letter-spacing: .11em; line-height: 1.25; }
.decode-list > li:target .decode-card { border-color: #805c2d; }
.decode-end .decode-realm-link { color: var(--gold); font-size: .85rem; }

#epilogue { border-top: 1px solid #8b663c48; }
#epilogue .epilogue-banner {
  box-shadow: 0 0 0 1px #ad895b65, 0 0 0 .45rem #fff4d554;
  padding: .5rem;
  background: #d3b88138;
}

@media (max-width: 760px), (orientation: portrait) {
  .puzzle-continue { font-size: .72rem; }
}
@media (max-width: 620px) {
  .decode-inner .decode-card { gap: .5rem; padding-inline: .65rem; }
  .decode-inner .decode-q { font-size: clamp(1rem, 4vw, 1.25rem); }
}

/* Position, then emphasis. Text and links remain legible before activation. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .realm-repair::before {
      animation: journey-thread ease-out both;
      animation-timeline: view();
      animation-range: entry 0% cover 23%;
    }
    .decode-list > li:not(:target):not(:focus-within) {
      animation: journey-annotation ease-out both;
      animation-timeline: view();
      animation-range: entry 0% cover 24%;
    }
    #epilogue .epilogue-banner {
      animation: journey-unroll ease-out both;
      animation-timeline: view();
      animation-range: entry 0% cover 45%;
    }
  }
}

@keyframes journey-thread {
  from { transform: scaleX(.25); opacity: .35; }
  to { transform: scaleX(1); opacity: 1; }
}
@keyframes journey-annotation {
  from { translate: 0 .55rem; opacity: .63; }
  to { translate: none; opacity: 1; }
}
@keyframes journey-unroll {
  from { scale: .92; opacity: .52; clip-path: inset(0 9% 18% 9%); }
  to { scale: 1; opacity: 1; clip-path: inset(-1rem); }
}

/* Keep the fixed controls legible over both ink and light paper. */
.site-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 -.65rem;
  background: linear-gradient(180deg, #0a1a1be6 0%, #0a1a1bd9 61%, transparent);
  pointer-events: none;
}
