/* The portfolio owns its full reading width. The companion floats over the
   viewport and her measured landing anchors never participate in page flow. */
.tour-layout { padding-block: clamp(2rem, 5vw, 4rem) var(--space-6); }
.tour-stop { position: relative; outline-offset: .25rem; }
.tour-stop + .tour-stop { margin-top: clamp(2.4rem, 6vw, 5.4rem); }
.stop-content { min-width: 0; }
.stop-content > :first-child { margin-top: 0; }
.guide {
  --guide-max: 16.2rem;
  --edge: max(-2.35rem, calc((100vw - 78rem) / 2 - var(--guide-max) + 1.25rem));
  position: fixed; z-index: 8; left: var(--edge); bottom: max(1rem, 3svh);
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  width: var(--guide-max); pointer-events: none;
  visibility: hidden;
}
[data-side="right"] > .guide { left: auto; right: var(--edge); }
[data-altitude="middle"] > .guide { bottom: 23svh; }
[data-altitude="high"] > .guide { bottom: auto; top: max(6.7rem, 13svh); }
.guide__perch { line-height: 0; width: 100%; }
.guide__perch svg { display: block; width: 100%; height: auto; overflow: visible; }
[data-landed] > .guide { visibility: visible; }
.flight-ready .guide__perch svg, #room-section .guide__perch { visibility: hidden; }
#room-section .guide__perch { display: none; }
#room-section > .guide { position: absolute; top: auto; bottom: .8rem; left: .8rem; }
#room-section .guide__speech::before { top: 40%; left: auto; right: -.42rem; transform: rotate(135deg); }
#room-section:is([data-studio],[data-furnished]) video { visibility: hidden; }
.fairy-wing { transform-box: fill-box; }
.wing--cyan { transform-origin: 94% 66%; }
.wing--rose { transform-origin: 6% 66%; }
.guide__speech {
  position: relative; width: min(100%, 13rem); padding: .6rem .85rem;
  border: var(--border-width) solid var(--disc-line); border-radius: 1.05rem;
  background: var(--color-surface-raised); box-shadow: var(--shadow-card);
}
.guide__speech::before {
  content: ""; position: absolute; width: .78rem; height: .78rem; background: inherit;
  border-left: inherit; border-top: inherit; left: 54%; top: -.44rem; transform: rotate(45deg);
}
.guide__speech strong { display: block; color: var(--color-primary-deep); font-size: .73rem; letter-spacing: .035em; }
.guide__speech p { margin: .25rem 0 .35rem; font-size: var(--text-sm); line-height: 1.45; }
.guide__speech a { pointer-events: auto; display: inline-flex; align-items: center; gap: .4em; font-size: var(--text-sm); text-underline-offset: .2em; font-weight: 650; }
.guide__speech .icon { width: 1em; height: 1em; }
.contact { max-width: 72rem; }
.flight-layer { position: fixed; z-index: 9; inset: 0; pointer-events: none; overflow: hidden; }
.flight-sky, .flight-veil { position: absolute; inset: 0; }
.flight-sky { overflow: visible; }
.flight-sprite[visibility="hidden"], .flight-title[visibility="hidden"] { display: none; }
.fairy-puppet canvas { display: block; width: 100%; height: 100%; }
.flight-veil { background: var(--stage-ink); opacity: 0; visibility: hidden; transition: opacity .2s ease-out, visibility .2s; }
.flight-layer[data-navigation] .flight-veil { visibility: visible; opacity: .65; }
.masthead { z-index: 10; }
.hero[data-departed] .performer { visibility: hidden; }
.flight-dust { fill: var(--crystal-cyan); }
.flight-dust:nth-child(3n + 1) { fill: var(--crystal-rose); }
.flight-dust:nth-child(3n + 2) { fill: var(--screen-fg); }
.flight-sprite .fairy-wing { transform-box: view-box; transform-origin: 0 0; }
@media (prefers-reduced-motion: no-preference) {
  .flight-layer[data-reading] .flight-sprite { opacity: .18; }
  .flight-sprite { transition: opacity .2s ease; }
}
/* The ink of the heading is the perch. Its anchor takes no layout space. */
#about { scroll-margin-top: max(0rem, calc(44dvh - var(--tour-header-clearance))); }
.about-title { position: relative; width: max-content; }
#about[data-landed] .switcher { position: relative; z-index: 10; }
.about-reader {
  position: absolute; width: min(176%, calc(100vw - 4.75rem)); height: auto; aspect-ratio: 220 / 132;
  left: 79%; top: .04em; transform: translate(-25%, -53.03%);
  pointer-events: none; visibility: hidden; overflow: visible;
}
#about > .guide {
  position: absolute; top: auto; bottom: calc(100% + var(--space-2));
  left: calc(var(--reader-right, 19rem) + var(--space-3)); right: auto; width: max-content; max-width: 13rem;
}
#about[data-bubble-above] > .guide {
  left: auto; right: 0; bottom: calc(100% + var(--reader-rise, 4rem));
}
#about .guide__perch { display: none; }
#about .guide__speech::before { left: -.43rem; top: 55%; transform: rotate(-45deg); }
.flight-upright[data-articulated] :is(.fairy-body,.fairy-puppet) { display: none; }
.studio-landing-shadow { fill: var(--stage-ink); }
.flight-layer[data-navigation] { z-index: 11; }
.flight-layer[data-touchdown] .flight-veil { opacity: 0; }
#room-section[data-bed-approach] video { visibility: hidden; }
.masthead { z-index: 12; }
.studio figure { aspect-ratio: 16/9; }
.studio__world { position: absolute; right: 0; top: 0; height: 100%; aspect-ratio: 16/9; }
.studio-actors { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
@media (max-width: 48rem) {
  html { --tour-header-clearance: 6.55rem; }
  .tour-layout { padding-top: var(--space-4); }
  .tour-stop + .tour-stop { margin-top: clamp(2rem, 9vw, 4rem); }
  .guide { --edge: -.65rem; bottom: max(.5rem, env(safe-area-inset-bottom)); }
  .guide__speech { width: min(9rem, 34vw); max-width: none; align-self: flex-start; padding: .35rem .55rem; }
  [data-side="right"] .guide__speech { align-self: flex-end; }
  [data-side="left"]:not(#about):not(#room-section) .guide__speech { margin-inline-start: var(--space-3); }
  [data-side="right"] .guide__speech { margin-inline-end: var(--space-3); }
  .guide__speech strong { font-size: .65rem; }
  .guide__speech p, .guide__speech a { font-size: .73rem; }
  .guide__speech p { margin: .1rem 0; }
  .studio figure { aspect-ratio: 4/3; }
}
@media (max-width: 34rem) {
  #about .guide__speech { max-width: 8.1rem; }
}
@media (max-height: 36rem) {
  #about { scroll-margin-top: max(0rem, calc(59dvh - var(--tour-header-clearance))); }
  .tour-stop:not(#about):not(#room-section):not(#projects):not(#sakura-connect) > .guide { top: auto; bottom: 0; }
  .tour-stop:not(#about):not(#room-section):not(#projects):not(#sakura-connect) .guide__speech {
    position: absolute; bottom: var(--space-2); left: 83%;
  }
  .tour-stop[data-side="right"] .guide__speech { left: auto; right: 83%; }
}
@media (prefers-reduced-motion: reduce) {
  .flight-ready #about[data-landed] .about-reader { visibility: visible; }
  .flight-layer { display: none; }
  .flight-ready [data-landed] .guide__perch svg { visibility: visible; }
}

/* The Connect companion uses the existing fixed viewport perch. Its size
   follows the available screen width independently of the promo card. */
#sakura-connect > .guide {
  --guide-max: clamp(10rem, 15vw, 15rem);
  right: max(var(--space-1), calc((100vw - 78rem) / 2 - var(--guide-max)));
  flex-direction: row-reverse; align-items: center;
}
#sakura-connect .guide__perch { flex: 0 0 40%; }
#sakura-connect .guide__speech { position: relative; inset: auto; flex: 1; align-self: center; margin: 0; min-width: 0; }
#sakura-connect .guide__speech::before { top: 45%; left: auto; right: -.44rem; transform: rotate(135deg); }
@media (max-width: 60rem) {
  #sakura-connect > .guide { --guide-max: 12rem; }
}
/* Share the cards' row so the final perch stays beside the visible projects
   even when the document ends before the heading reaches the masthead. */
#projects { display: grid; }
#projects > .stop-content, #projects > .guide { grid-area: 1 / 1; }
#projects > .guide {
  position: sticky; align-self: start; justify-self: start;
  inset: max(var(--tour-header-clearance), calc(50dvh - 12rem)) auto auto;
  margin-inline-start: calc(var(--edge) - (100vw - 100%) / 2);
}
@media (max-height: 36rem) {
  #projects > .guide { top: 0; }
  #projects .guide__speech { position: absolute; left: min(83%, 60vw); bottom: var(--space-2); }
}
