.masthead {
  position: fixed;
  z-index: 10;
  inset: 0 0 auto;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-inline: var(--gutter);
  background: #090304f5;
  border-bottom: 1px solid #47201d;
}

.masthead__brand {
  position: relative;
  z-index: 2;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 1rem;
  font: 600 clamp(1.025rem, 1rem + .3vw, 1.42rem)/1 var(--serif);
  letter-spacing: .105em;
  text-transform: uppercase;
  text-decoration: none;
}

.masthead__mark {
  position: relative;
  flex: 0 0 13px;
  height: 13px;
  transform: rotate(45deg);
  border: 1px solid #bd4f3a;
}

.masthead__mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: #da664e;
}

.site-nav { display: flex; align-items: center; gap: clamp(1rem, 2.45vw, 2.7rem); }
.site-nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  position: relative;
  color: #cfb4a6;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .155em;
  transition: color .25s;
}

.site-nav a::after {
  content: '';
  position: absolute;
  inset: auto 0 4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .32s var(--ease);
}

.site-nav a:is(:hover, [aria-current]) { color: #fff0e6; }
.site-nav a:is(:hover, [aria-current])::after { transform: scaleX(1); }
.menu-toggle { display: none; }

.reading-progress {
  position: absolute;
  inset: auto 0 -1px;
  height: 1px;
  background: #de563c;
  transform: scaleX(var(--page-progress, 0));
  transform-origin: left;
  pointer-events: none;
}

.hero { width: 100vw; max-width: 100%; min-height: 100svh; scroll-margin: 0; }
.hero[data-k-hero]:not(.k-static) { height: 110svh !important; }
.hero .hero__stage, .hero.k-static .hero__stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  height: 100svh;
  min-height: 0;
  padding: var(--header-height) 0 0;
  gap: 0;
  isolation: isolate;
  background: transparent;
}

.hero__atmosphere, .hero__dust {
  position: absolute;
  inset: -3%;
  z-index: -1;
  pointer-events: none;
}

.hero__atmosphere {
  background:
    radial-gradient(ellipse 38% 63% at 51% -10%, #742718b3, transparent 93%),
    radial-gradient(ellipse 70% 30% at 50% 81%, #360c11a0, transparent 94%),
    linear-gradient(90deg, #080204a0, transparent 24%, transparent 76%, #080204a0);
  /* Fade before the sticky stage clips this oversized, moving layer. */
  mask-image: linear-gradient(to bottom, #000 63%, #000b 78%, #0004 87%, transparent min(94%, calc(100% - 24px)));
}

.hero__stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: #080204;
  opacity: 0;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, #000 82%, transparent);
  animation: stage-opening 2.55s ease-out both;
}

.hero__atmosphere::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 25% 55% at 51% 1%, #e03d205e, transparent 91%);
  opacity: .52;
  animation: stage-light 1.45s .16s ease-out both, stage-breathe 9s ease-in-out 1.61s infinite alternate;
}

.hero__dust { animation: dust-in 1.15s 1.35s ease-out both; }

.hero__dust i {
  position: absolute;
  inset: var(--y) auto auto var(--x);
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fc9a73;
  box-shadow: 0 0 5px #f34d3580;
  opacity: .3;
  animation: drift 7s ease-in-out var(--t) infinite alternate;
}

.hero__dust i:nth-child(1) { --x: 13%; --y: 29%; --t: -5s; }
.hero__dust i:nth-child(2) { --x: 19%; --y: 66%; --t: -2s; }
.hero__dust i:nth-child(3) { --x: 23%; --y: 48%; --t: -1s; }
.hero__dust i:nth-child(4) { --x: 27%; --y: 87%; --t: -5s; }
.hero__dust i:nth-child(5) { --x: 68%; --y: 82%; --t: -2s; }
.hero__dust i:nth-child(6) { --x: 76%; --y: 15%; --t: -4s; }
.hero__dust i:nth-child(7) { --x: 83%; --y: 49%; --t: -3s; }
.hero__dust i:nth-child(8) { --x: 89%; --y: 70%; --t: -1s; }

.hero__composition {
  --hero-band: clamp(32px, 4.1svh, 38px);
  --hero-art-width: min(100%, calc(max(125px, 100svh - var(--header-height) - 2 * var(--hero-band)) * 1491 / 1055));
  align-self: center;
  display: grid;
  grid-template-rows: var(--hero-band) auto var(--hero-band);
  align-items: center;
  justify-items: center;
  width: 100%;
  min-width: 0;
  opacity: calc(1 - var(--k-p, 0) * .85);
  transform: translateY(calc(var(--k-p, 0) * -18px));
}

.hero__title {
  display: flex;
  align-items: center;
  gap: .95rem;
  text-transform: uppercase;
  font: 600 clamp(.75rem, .67rem + .26vw, 1rem)/1.25 var(--serif);
  letter-spacing: .29em;
  color: #e5b6a0;
  animation: hero-title-in .9s .83s var(--ease) both;
}

.hero__title span { width: clamp(14px, 3.5vw, 66px); height: 1px; background: #984634; }
.hero__title span:first-child { mask-image: linear-gradient(90deg, transparent, #000); }
.hero__title span:last-child { mask-image: linear-gradient(270deg, transparent, #000); }

.hero__frame {
  width: 100%;
}

.hero__reveal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--hero-art-width) minmax(0, 1fr);
  mask-image: linear-gradient(to bottom, transparent, #0004 2%, #000c 5%, #000 9%, #000 94%, #000d 96%, #0005 98.4%, transparent);
  animation: hero-image-in 2.5s ease-out both;
}

.hero__wing {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}

/* Reflect only the peripheral background. The feather ends before the subject enters the source. */
.hero__wing::before {
  content: '';
  position: absolute;
  inset-block: 0;
  aspect-ratio: 1491 / 1055;
  background: url('../assets/puppetmaster.png') center / contain no-repeat;
  transform: scaleX(-1);
}

.hero__wing--left::before {
  right: -.5px;
  mask-image: linear-gradient(to right, #0008, #0005 2.3%, #0002 5%, transparent 8.8%);
}

.hero__wing--right::before {
  left: -.5px;
  mask-image: linear-gradient(to left, #0008, #0005 2.3%, #0002 5%, transparent 8.8%);
}

.hero__art {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1491 / 1055;
  mask-image: linear-gradient(to right, #0008, #000c 2.7%, #000 7.8%, #000 92.2%, #000c 97.3%, #0008);
}

.hero__art > :is(img, canvas, video) {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.hero__animation { pointer-events: none; visibility: hidden; }
.hero__art.is-animated > img { opacity: 0; }
.hero__art.is-animated > .hero__animation { visibility: visible; }

.hero__scroll {
  display: inline-grid;
  justify-items: center;
  align-content: center;
  gap: .62rem;
  min-height: 44px;
  padding: 2px .85rem 0;
  color: #dcbeb0;
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .21em;
  text-transform: uppercase;
  text-decoration: none;
  animation: hero-title-in .85s 1.3s var(--ease) both;
}

.hero__scroll-line { width: 1px; height: 17px; background: linear-gradient(#cd503d, #ca4b2760); transition: transform .35s var(--ease); }
.hero__scroll:hover, .hero__scroll:focus-visible { color: var(--bone); }
.hero__scroll:focus-visible { opacity: 1; animation: none; outline-offset: -5px; }
.hero__scroll:hover .hero__scroll-line { transform: translateY(4px); }
.hero.is-away :is(.hero__reveal, .hero__atmosphere::after, .hero__dust i) { animation-play-state: paused; }

@keyframes stage-opening { 0%, 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes stage-light { from { opacity: 0; } to { opacity: .52; } }
@keyframes stage-breathe { from { opacity: .52; } to { opacity: .73; } }
@keyframes dust-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes hero-title-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes hero-image-in { 0%, 24% { opacity: 0; } 66% { opacity: .85; } 100% { opacity: 1; } }
@keyframes drift { from { transform: translate(0, 2px); opacity: .15; } to { transform: translate(5px, -12px); opacity: .48; } }

.chapter { position: relative; padding-block-end: clamp(78px, 11vw, 190px); }
.chapter__lead {
  position: relative;
  isolation: isolate;
  min-height: clamp(310px, 45vw, 540px);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 70px var(--gutter) 50px;
  text-align: center;
  background: radial-gradient(ellipse 53% 50% at 50% 49%, #31090b72, transparent 97%);
}

.chapter__lead::before, .chapter__lead::after {
  content: '';
  position: absolute;
  pointer-events: none;
  left: 50%;
  transform: translateX(-50%);
}

.chapter__lead::before {
  top: 0;
  height: 21%;
  width: 1px;
  background: linear-gradient(transparent, #9f2f25a8 60%, transparent);
  box-shadow: 0 0 38px 1px #961f183d;
}

.chapter__lead::after {
  bottom: 4%;
  height: 1px;
  width: min(75%, 880px);
  background: linear-gradient(90deg, transparent, #9b3029a3, transparent);
}

.chapter__numeral {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 49%;
  transform: translate(-50%, calc(-50% + var(--chapter-drift, 0px)));
  color: #65202155;
  font: 500 clamp(13.5rem, 31vw, 35rem)/.8 var(--serif);
  letter-spacing: -.09em;
  padding-inline-end: .09em;
  user-select: none;
}

.chapter__type { width: 100%; }
.chapter__type::before {
  content: '';
  position: absolute;
  inset: 18% -35%;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 47%, #a62c191f 51%, transparent 56%);
  mask-image: linear-gradient(transparent, black 20%, black 80%, transparent);
  opacity: 0;
  transform: translateX(-38%);
}

.chapter__type:has(h2.is-revealed)::before { animation: chapter-light 1.45s var(--ease) both; }
@keyframes chapter-light {
  0% { opacity: 0; transform: translateX(-38%); }
  42% { opacity: .85; }
  100% { opacity: 0; transform: translateX(36%); }
}

.chapter__type .eyebrow span { margin-inline: .45em; color: #b35447; }
.chapter__type h2 {
  margin-block: .12em .05em;
  color: #efdbca;
  font: 600 clamp(3rem, 10.3vw, 10.75rem)/.92 var(--serif);
  letter-spacing: -.052em;
  text-transform: uppercase;
  text-shadow: 0 2px 30px #8e2a2690;
}

.chapter__subtitle { color: #cfaaa0; font: italic 500 clamp(1.25rem, 1rem + .9vw, 2rem)/1.35 var(--serif); }

.custom-cursor {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  display: grid;
  place-items: center;
  inset: 0 auto auto 0;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border: 1px solid transparent;
  border-radius: 50%;
  color: transparent;
  opacity: 0;
  text-transform: uppercase;
  font-size: .56rem;
  font-weight: 600;
  letter-spacing: .13em;
  transition: opacity .22s, background-color .22s, color .22s, border-color .22s;
}

.custom-cursor.is-visible { opacity: 1; }
.has-cursor, .has-cursor :is([data-cursor="view"], .masthead a) { cursor: none; }
body:has(dialog[open]) .custom-cursor { display: none; }
dialog { cursor: auto; }
.custom-cursor::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #f1765f; position: absolute; }
.custom-cursor.is-view { background: #150605ed; border-color: #ea6f58; color: #f4e0d4; }
.custom-cursor.is-view::after { opacity: 0; }

@media (min-width: 761px) and (max-height: 530px) {
  .hero__composition { --hero-band: 29px; }
  .hero__scroll { min-height: 36px; gap: .35rem; }
  .hero__scroll-line { height: 9px; }
}

@media (max-width: 760px) {
  .masthead { gap: .5rem; }
  .masthead__brand { gap: .75rem; }
  .masthead__mark { flex-basis: 11px; height: 11px; }
  .masthead__mark::after { inset: 2px; }
  .menu-toggle {
    position: relative;
    z-index: 2;
    display: grid;
    justify-content: end;
    align-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0 2px 0 0;
    border: 0;
    background: transparent;
    color: var(--bone);
    cursor: pointer;
  }
  .menu-toggle span { width: 21px; height: 1px; background: currentColor; transition: transform .3s var(--ease); }
  .masthead.is-open .menu-toggle span:first-child { transform: translateY(3px) rotate(45deg); }
  .masthead.is-open .menu-toggle span:last-child { transform: translateY(-3px) rotate(-45deg); }
  .site-nav {
    position: absolute;
    inset: calc(var(--header-height) - 1px) 0 auto;
    display: grid;
    align-content: center;
    align-items: stretch;
    gap: 0;
    padding: clamp(16px, 4svh, 48px) var(--gutter) clamp(24px, 7svh, 72px);
    max-height: calc(100dvh - var(--header-height));
    overflow: auto;
    border-bottom: 1px solid #682e28;
    background: radial-gradient(ellipse at 100% 0%, #26090b, transparent 62%), #0d0305;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: visibility .3s, opacity .3s, transform .3s var(--ease);
  }
  .masthead.is-open .site-nav { visibility: visible; opacity: 1; transform: none; }
  .site-nav a {
    min-height: 46px;
    padding-block: .37em;
    font: 600 clamp(1.55rem, 6vw, 3.05rem)/1.08 var(--serif);
    letter-spacing: .03em;
    border-bottom: 1px solid #47201d;
  }
  .site-nav a::after { bottom: -1px; }
  .masthead.is-open .site-nav a { animation: mobile-link-in .42s var(--ease) both; }
  .site-nav a:nth-child(2) { animation-delay: 35ms !important; }
  .site-nav a:nth-child(3) { animation-delay: 70ms !important; }
  .site-nav a:nth-child(4) { animation-delay: 105ms !important; }
  .site-nav a:nth-child(5) { animation-delay: 140ms !important; }
  .hero__composition { --hero-band: clamp(43px, 7.1svh, 65px); }
  .hero__title { letter-spacing: .23em; }
  .hero__atmosphere {
    background:
      radial-gradient(ellipse 88% 51% at 51% 4%, #6920158c, transparent 91%),
      radial-gradient(ellipse 92% 32% at 50% 70%, #360a0f85, transparent 94%);
  }
  .hero__dust i:nth-child(even) { display: none; }
  .chapter__type h2 { font-size: clamp(2.55rem, 12vw, 6rem); }
}

@media (max-width: 760px) and (max-height: 510px) {
  .hero__composition { --hero-band: 29px; }
  .hero__scroll { min-height: 36px; gap: .35rem; }
  .hero__scroll-line { height: 9px; }
  .site-nav { align-content: start; }
}

@keyframes mobile-link-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

:where(html:not([data-motion="full"])) :is(.hero, .masthead) *,
:where(html:not([data-motion="full"])) .hero *::before,
:where(html:not([data-motion="full"])) :is(.hero, .masthead) *::after {
  animation: none !important;
  transition: none !important;
}
:where(html:not([data-motion="full"])) .hero__composition { opacity: 1; transform: none; }
:where(html:not([data-motion="full"])) :is(.hero__dust, .custom-cursor) { display: none; }
:where(html:not([data-motion="full"])) .chapter__type:has(h2.is-revealed)::before { animation: none; }
