:root {
  --scroll-progress: 0;
  --motion-ease: cubic-bezier(.16, 1, .3, 1);
}

body.intro-active {
  height: 100svh;
  overflow: hidden;
}

/* Opening curtain: three museum-palette planes, then the site is revealed. */
.page-intro {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f8f5ef;
  background: var(--night);
  animation: intro-safety-hide 0s 4s forwards;
}

.intro-panel {
  position: absolute;
  inset: 0;
  transform-origin: bottom;
}

.intro-panel-a { background: var(--red); }
.intro-panel-b { background: var(--bronze); transform: translateY(12%); }
.intro-panel-c { background: var(--night); transform: translateY(24%); }

.intro-mark {
  position: relative;
  z-index: 2;
  display: grid;
  gap: .85rem;
  text-align: center;
  animation: intro-mark-in .8s var(--motion-ease) both;
}

.intro-mark::before,
.intro-mark::after {
  position: absolute;
  top: 50%;
  width: 22vw;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(213, 180, 119, .7));
}

.intro-mark::before { right: calc(100% + 2rem); }
.intro-mark::after { left: calc(100% + 2rem); transform: rotate(180deg); }
.intro-mark span { color: #d5b477; font: 700 .62rem/1 var(--mono); letter-spacing: .28em; }
.intro-mark strong { font-family: var(--display); font-size: clamp(2.3rem, 5vw, 5.6rem); font-weight: 400; letter-spacing: .18em; }
.page-intro.is-leaving .intro-mark { animation: intro-mark-out .5s ease-in both; }
.page-intro.is-leaving .intro-panel-a { animation: intro-curtain 1s .3s cubic-bezier(.77, 0, .18, 1) both; }
.page-intro.is-leaving .intro-panel-b { animation: intro-curtain 1s .18s cubic-bezier(.77, 0, .18, 1) both; }
.page-intro.is-leaving .intro-panel-c { animation: intro-curtain 1s cubic-bezier(.77, 0, .18, 1) both; }

/* Header condenses and tracks reading position. */
.site-header {
  position: fixed;
  background: rgba(12, 16, 15, .72);
  transition: height .35s var(--motion-ease), background .35s, border-color .35s,
    transform .45s var(--motion-ease);
}

.site-header.is-scrolled {
  height: 56px;
  border-color: rgba(213, 180, 119, .24);
  background: rgba(12, 16, 15, .96);
}

.site-header.is-hidden:not(:focus-within) { transform: translateY(-110%); }

.scroll-progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
}

.scroll-progress span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--scroll-progress));
  transform-origin: left;
  background: linear-gradient(90deg, var(--red), #d5b477);
}

.site-header nav a { position: relative; overflow: hidden; }
.site-header nav a::after {
  position: absolute;
  right: 30%;
  bottom: 0;
  left: 30%;
  height: 2px;
  content: "";
  transform: scaleX(0);
  background: #d5b477;
  transition: transform .35s var(--motion-ease);
}
.site-header nav a.is-current::after { transform: scaleX(1); }

/* Layered hero motion: scroll depth and split-character entry. */
.hero-image {
  inset: -4%;
  transform: translate3d(0, var(--hero-media-shift, 0px), 0)
    scale(var(--hero-media-scale, 1.025));
  animation: none;
  will-change: transform;
}

.hero-copy {
  transform: translate3d(0, var(--hero-copy-shift, 0px), 0);
  opacity: calc(1 - var(--hero-scroll, 0) * .72);
  will-change: transform, opacity;
}

.motion-char {
  display: inline-block;
  transform-origin: 50% 100%;
}

.hero h1 > span .motion-char,
.hero h1 > em .motion-char {
  display: inline-block;
  padding: 0;
  border: 0;
  color: inherit;
  font-size: inherit;
  font-style: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  white-space: normal;
}

section[id] { scroll-margin-top: 68px; }

.motion-ready .hero h1 .motion-char {
  opacity: 0;
  transform: translateY(55%) rotate(4deg);
  animation: char-rise .75s calc(var(--intro-delay, 1.65s) + var(--char-index) * 42ms) var(--motion-ease) forwards;
}

.motion-ready .hero-copy > .eyebrow,
.motion-ready .hero-deck,
.motion-ready .hero-actions,
.motion-ready .hero-stats,
.motion-ready .hero-credit,
.motion-ready .hero-scroll {
  opacity: 0;
  animation: hero-detail-in .7s calc(var(--intro-delay, 1.65s) + .3s) var(--motion-ease) forwards;
}

.motion-ready .hero-deck { animation-delay: calc(var(--intro-delay, 1.65s) + .42s); }
.motion-ready .hero-actions { animation-delay: calc(var(--intro-delay, 1.65s) + .54s); }
.motion-ready .hero-stats,
.motion-ready .hero-credit { animation-delay: calc(var(--intro-delay, 1.65s) + .72s); }
.motion-ready .hero-scroll { animation-delay: calc(var(--intro-delay, 1.65s) + .84s); }

.hero-scroll span { animation: scroll-pulse 1.7s ease-in-out infinite; }

/* Scroll reveal. Content remains present without JavaScript. */
.has-js .motion-reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity .7s calc(var(--reveal-order, 0) * 70ms),
    transform .85s calc(var(--reveal-order, 0) * 70ms) var(--motion-ease);
}

.has-js .motion-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.motion-ready main h2 .motion-char {
  opacity: 0;
  transform: translateY(65%) rotate(3deg);
  transition: opacity .5s calc(var(--char-index) * 45ms + .08s),
    transform .78s calc(var(--char-index) * 45ms) var(--motion-ease);
}

.motion-ready .is-revealed h2 .motion-char,
.motion-ready h2.is-revealed .motion-char,
.motion-ready .queen-copy.is-revealed h2 .motion-char {
  opacity: 1;
  transform: translateY(0) rotate(0);
}

/* Image reveal. */
.museum-figure {
  position: relative;
  overflow: hidden;
  clip-path: inset(0 99.8% 0 0);
  transition: clip-path 1.15s var(--motion-ease), opacity .7s, transform .85s var(--motion-ease);
}

.museum-figure.is-revealed { clip-path: inset(0 0 0 0); }

.museum-figure.motion-reveal {
  opacity: 1;
  transform: none;
}

.museum-figure img {
  transform: scale(1.025);
}

.queen-image-wrap img {
  height: 100%;
  transform: none;
  transition: filter .6s var(--motion-ease);
}

.queen-image-wrap:hover img { filter: saturate(1.12) contrast(1.04); }

/* Archive: staggered mounting with a small static hover lift. */
.archive-grid.is-refreshing .object-card {
  animation: card-remount .48s calc(var(--card-order) * 28ms) var(--motion-ease) both;
}

.object-card,
.object-card:nth-child(5n+1),
.object-card:nth-child(5n+2) {
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s calc(var(--card-order) * 35ms), border-color .2s,
    transform .35s var(--motion-ease), box-shadow .35s;
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

.object-card.is-mounted {
  opacity: 1;
  transform: translateY(0);
}

.object-card:hover,
.object-card:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(25, 26, 23, .1);
}

.filter-chip {
  position: relative;
  z-index: 0;
  overflow: hidden;
  transition: color .25s, border-color .25s, transform .2s;
}

.filter-chip::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  transform: translateY(105%);
  background: var(--green);
  transition: transform .32s var(--motion-ease);
}

.filter-chip:hover::before,
.filter-chip:focus-visible::before,
.filter-chip.is-active::before { transform: translateY(0); }

.filter-chip:hover,
.filter-chip:focus-visible { color: #fff; }

/* Dialog grows in, thumbnails cascade and image changes dissolve. */
.archive-dialog[open] {
  opacity: 0;
  transform: translateY(28px) scale(.975);
  animation: none;
  transition: opacity .38s, transform .52s var(--motion-ease);
}

.archive-dialog[open].is-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.archive-dialog[open].is-closing {
  opacity: 0;
  transform: translateY(16px) scale(.985);
  transition-duration: .24s;
}

.archive-dialog::backdrop {
  background: rgba(0, 0, 0, 0);
  transition: background .4s;
}

.archive-dialog.is-ready::backdrop {
  background: rgba(0, 0, 0, .8);
}

.dialog-main-image img {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  transition: opacity .34s, transform .5s var(--motion-ease), filter .34s;
}

.dialog-main-image img.is-switching {
  opacity: 0;
  transform: scale(1.025);
  filter: blur(5px);
}

.thumbnail-strip button {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .4s, transform .4s, border-color .2s;
}

.archive-dialog.is-ready .thumbnail-strip button { opacity: 1; transform: translateY(0); }
.archive-dialog.is-ready .thumbnail-strip button:nth-child(2) { transition-delay: .06s; }
.archive-dialog.is-ready .thumbnail-strip button:nth-child(3) { transition-delay: .12s; }
.thumbnail-strip button:hover { border-color: #d5b477; }

@keyframes intro-mark-in { from { opacity: 0; transform: translateY(22px); } }
@keyframes intro-mark-out { to { opacity: 0; transform: translateY(-18px); } }
@keyframes intro-curtain { to { transform: translateY(-110%); } }
@keyframes intro-safety-hide { to { visibility: hidden; pointer-events: none; } }
@keyframes char-rise { to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes hero-detail-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scroll-pulse { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
@keyframes card-remount { from { opacity: 0; transform: translateY(18px) scale(.985); } }

@media (max-width: 820px) {
  .page-intro { display: none; }
  body.intro-active { height: auto; overflow-x: hidden; overflow-y: auto; }
  .site-header { background: rgba(12, 16, 15, .94); }
  .hero-image { inset: 0; transform: none; }
  .hero-copy { transform: none; opacity: 1; }
  .museum-figure img { transform: scale(1.035); }
  .queen-image-wrap img { height: 100%; transform: none; }
  .object-card,
  .object-card:hover,
  .object-card:focus-within,
  .object-card.is-mounted { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .001ms !important;
  }
  .page-intro { display: none !important; }
  body.intro-active { height: auto; overflow: auto; }
  .motion-char,
  .motion-reveal,
  .object-card,
  .archive-dialog[open],
  .thumbnail-strip button { opacity: 1 !important; transform: none !important; }
  .museum-figure { clip-path: none !important; }
  .hero-image,
  .hero-copy,
  .museum-figure img,
  .queen-image-wrap img { transform: none !important; }
}
