/* ============================================================
   Court Mage Bishop Dowser
   Palette: deep void indigo → amethyst → pale star-gold
   ============================================================ */

@font-face {
  font-family: 'Varnyx';
  src: url('../fonts/varnyx-regular.woff2') format('woff2'),
       url('../fonts/varnyx-regular.ttf')   format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --void:        #06040f;
  --void-2:      #0d0822;
  --indigo:      #1b1140;
  --amethyst:    #6d4bd6;
  --amethyst-lt: #a98cff;
  --azure:       #4a7dff;
  --star:        #f2e6c8;
  --star-dim:    #cbb994;
  --ink:         #e8e2f5;
  --ink-soft:    #b9aed4;

  --edge:        rgba(169, 140, 255, 0.22);
  --edge-hot:    rgba(169, 140, 255, 0.55);
  --glass:       rgba(20, 13, 48, 0.42);

  --font-display: 'Varnyx', 'Cinzel', 'Baskerville', 'Bookerly',
                  'Libre Baskerville', 'Palatino Linotype', Palatino,
                  'Times New Roman', serif;
  --font-body:    'Cinzel', 'Baskerville', 'Bookerly', 'Libre Baskerville',
                  'Palatino Linotype', Palatino, 'Times New Roman', serif;

  --gutter: clamp(1.25rem, 5vw, 3.5rem);
  --ease:   cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Parallax offsets, written by JS. Default 0 = no motion. */
  --px: 0px;
  --py: 0px;
}

/* ---------------- reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

svg { display: block; }

:focus-visible {
  outline: 2px solid var(--amethyst-lt);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Masked SVG so icons inherit their button's colour. */
.ui-icon {
  display: block;
  background: currentColor;
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
}
.ui-icon--close { --icon: url('../img/icon/close.svg'); }
.ui-icon--prev  { --icon: url('../img/icon/chevron-left.svg'); }
.ui-icon--next  { --icon: url('../img/icon/chevron-right.svg'); }

/* ============================================================
   BACKDROP
   Fixed, GPU-composited. Nothing here repaints on scroll.
   ============================================================ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Pre-blurred bitmap — no runtime CSS filter, so no repaint cost.
   Oversized 108% so parallax translation never exposes an edge. */
.backdrop__img {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  background-image: image-set(
      url('../img/bg/bigwah-blur.webp') type('image/webp'),
      url('../img/bg/bigwah-blur.jpg')  type('image/jpeg'));
  background-image: -webkit-image-set(
      url('../img/bg/bigwah-blur.webp') type('image/webp'),
      url('../img/bg/bigwah-blur.jpg')  type('image/jpeg'));
  background-size: cover;
  background-position: center 32%;
  transform: translate3d(var(--px), var(--py), 0) scale(1.04);
  will-change: transform;
  opacity: 0;
  animation: bg-in 1.6s var(--ease) 0.1s forwards;
}

@keyframes bg-in { to { opacity: 0.8; } }

/* Colour grade + vignette so text always has contrast */
.backdrop__veil {
  position: absolute;
  inset: 0;
  background:
    /* soft dark pool centred behind the crest so type stays legible
       without muddying the whole image */
    radial-gradient(66% 46% at 50% 42%,
      rgba(6, 4, 15, 0.72) 0%,
      rgba(6, 4, 15, 0.46) 55%,
      rgba(6, 4, 15, 0.00) 100%),
    /* amethyst grade + vignette */
    radial-gradient(126% 92% at 50% 10%,
      rgba(109, 75, 214, 0.22) 0%,
      rgba(27, 17, 64, 0.34)   40%,
      rgba(6, 4, 15, 0.80)     80%,
      rgba(6, 4, 15, 0.94)     100%),
    linear-gradient(180deg,
      rgba(6, 4, 15, 0.58) 0%,
      rgba(6, 4, 15, 0.14) 36%,
      rgba(6, 4, 15, 0.66) 84%,
      rgba(6, 4, 15, 0.92) 100%);
}

/* ---------------- starfield ----------------
   Stars are painted as radial-gradients on ONE element per layer, so
   the whole sky is a few composited layers and zero DOM nodes per star.
   Brightness "breathes": opacity interpolates on long, mismatched
   cycles rather than snapping, which avoids a marquee/blink feel. */
.starfield {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  transform: translate3d(var(--px), var(--py), 0);
  will-change: transform, opacity;
  background-repeat: repeat;
}

.starfield--far {
  opacity: 0.45;
  background-image:
    radial-gradient(1.1px 1.1px at 12% 18%,  #fff 50%, transparent 100%),
    radial-gradient(1px 1px     at 63% 8%,   #e6dcff 50%, transparent 100%),
    radial-gradient(1.2px 1.2px at 84% 42%,  #fff 50%, transparent 100%),
    radial-gradient(1px 1px     at 27% 63%,  #d8e6ff 50%, transparent 100%),
    radial-gradient(1.1px 1.1px at 47% 88%,  #fff 50%, transparent 100%),
    radial-gradient(1px 1px     at 91% 76%,  #efe6ff 50%, transparent 100%),
    radial-gradient(1.2px 1.2px at 6%  47%,  #fff 50%, transparent 100%),
    radial-gradient(1px 1px     at 73% 29%,  #dbe8ff 50%, transparent 100%);
  background-size: 340px 340px;
  animation: twinkle-a 9s ease-in-out infinite;
}

/* Sparse middle layer on a third cycle length, so the sky never
   resolves into two obviously-synchronised groups. */
.starfield--mid {
  opacity: 0.55;
  background-image:
    radial-gradient(1.5px 1.5px at 38% 22%, #fff 48%, transparent 100%),
    radial-gradient(1.3px 1.3px at 71% 52%, #e8dcff 48%, transparent 100%),
    radial-gradient(1.4px 1.4px at 17% 74%, #fff 48%, transparent 100%),
    radial-gradient(1.2px 1.2px at 88% 12%, #dce8ff 48%, transparent 100%),
    radial-gradient(1.5px 1.5px at 57% 91%, #fff 48%, transparent 100%);
  background-size: 430px 430px;
  animation: twinkle-c 12.5s ease-in-out infinite;
}

.starfield--near {
  opacity: 0.72;
  background-image:
    radial-gradient(1.9px 1.9px at 22% 34%, #fff 45%, transparent 100%),
    radial-gradient(1.6px 1.6px at 78% 66%, #f2e6c8 45%, transparent 100%),
    radial-gradient(2.1px 2.1px at 55% 14%, #fff 45%, transparent 100%),
    radial-gradient(1.7px 1.7px at 9%  81%, #cddcff 45%, transparent 100%),
    radial-gradient(1.8px 1.8px at 95% 23%, #fff 45%, transparent 100%);
  background-size: 520px 520px;
  animation: twinkle-b 7s ease-in-out infinite;
}

/* A slow swell rather than a blink: opacity interpolates smoothly and
   the two layers run on 9s / 7s so their peaks drift in and out of
   phase instead of pulsing together. Still opacity-only → compositor. */
@keyframes twinkle-a {
  0%, 100% { opacity: 0.30; }
  50%      { opacity: 0.58; }
}
@keyframes twinkle-b {
  0%, 100% { opacity: 0.80; }
  50%      { opacity: 0.46; }
}
/* offset peak so this layer crests between the other two */
@keyframes twinkle-c {
  0%, 100% { opacity: 0.58; }
  35%      { opacity: 0.34; }
  70%      { opacity: 0.62; }
}

/* ---------------- celestial bodies ---------------- */
.bodies {
  position: absolute;
  inset: 0;
  transform: translate3d(var(--px), var(--py), 0);
  will-change: transform;
}

.body {
  position: absolute;
  opacity: 0.5;
  overflow: visible;
}

.body__disc {
  fill: none;
  stroke: var(--amethyst-lt);
  stroke-width: 1.1;
}
.body__ring {
  fill: none;
  stroke: var(--star-dim);
  stroke-width: 0.9;
  opacity: 0.85;
}
.body__crater {
  fill: none;
  stroke: var(--amethyst-lt);
  stroke-width: 0.8;
  opacity: 0.55;
}
.body__orbitline {
  fill: none;
  stroke: var(--azure);
  stroke-width: 0.7;
  stroke-dasharray: 3 5;
  opacity: 0.7;
}

.body--ringed {
  width: clamp(120px, 20vw, 260px);
  aspect-ratio: 1;
  top: 9%;
  right: -3%;
  animation: drift-a 34s ease-in-out infinite alternate;
}
.body--moon {
  width: clamp(74px, 11vw, 140px);
  aspect-ratio: 1;
  bottom: 13%;
  left: 5%;
  opacity: 0.38;
  animation: drift-b 27s ease-in-out infinite alternate;
}
.body--orbit {
  width: clamp(60px, 9vw, 116px);
  aspect-ratio: 1;
  top: 26%;
  left: 11%;
  opacity: 0.3;
  animation: spin 62s linear infinite;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0)      rotate(0deg); }
  to   { transform: translate3d(-14px, 18px, 0) rotate(7deg); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(16px, -14px, 0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Hide the smaller ornaments on narrow screens — they crowd the text */
@media (max-width: 34rem) {
  .body--moon, .body--orbit { display: none; }
  .body--ringed { opacity: 0.32; top: 5%; right: -14%; }
}

/* ============================================================
   STAGE
   ============================================================ */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2rem, 6vh, 3.5rem);
  padding: clamp(3rem, 10vh, 6rem) var(--gutter)
           calc(clamp(3rem, 10vh, 6rem) + env(safe-area-inset-bottom, 0px));
  text-align: center;
}

/* ---------------- crest ---------------- */
.crest {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* generous vertical breathing room between title / rule / name */
  gap: clamp(1.1rem, 3.4vh, 2rem);
  /* the epithet stacks, so this only needs to clear the longest
     single line; never wider than the viewport allows */
  max-width: min(100%, 40ch);
}

.crest__title {
  margin: 0;
  /* Always one line. 5.2vw would overflow the 24ch crest on narrow
     screens once tracking is added, so cap it at 4.6vw — that keeps
     "Cosmic Mage" + 0.3em tracking inside the viewport down to ~320px. */
  font-size: clamp(1.05rem, 4.6vw, 2.1rem);
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-indent: 0.3em;    /* optical centring against the tracking */
  text-transform: uppercase;
  color: var(--star-dim);
  text-shadow: 0 0 22px rgba(169, 140, 255, 0.28),
               0 1px 2px rgba(0, 0, 0, 0.5);
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.25s forwards;
}

.crest__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  /* Varnyx is letters-only — no punctuation glyphs. Keep it to the name. */
  font-size: clamp(2.9rem, 15vw, 8.5rem);
  line-height: 0.94;
  letter-spacing: 0.012em;
  color: var(--star);
  text-shadow:
    0 0 18px rgba(169, 140, 255, 0.34),
    0 0 52px rgba(109, 75, 214, 0.24),
    0 2px 3px rgba(0, 0, 0, 0.55);
  opacity: 0;
  animation: rise 1.05s var(--ease) 0.42s forwards;
  text-wrap: balance;
}

.crest__epithet {
  margin: 0;
  font-size: clamp(0.7rem, 2.5vw, 0.88rem);
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.72s forwards;
  /* two stacked lines, each kept whole on its own row */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
}

.crest__epithet span { white-space: nowrap; }

/* divider */
.rule {
  position: relative;
  width: min(78vw, 21rem);
  height: 1px;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg,
      transparent, var(--edge) 22%, var(--edge-hot) 50%, var(--edge) 78%, transparent);
  opacity: 0;
  animation: widen 1.15s var(--ease) 0.55s forwards;
}
/* Masked rather than inlined so the shape lives in img/icon/star8.svg
   but colour and glow still come from CSS. */
.rule__star {
  position: absolute;
  width: 1.55rem;
  height: 1.55rem;
  background: var(--star-dim);
  mask: url('../img/icon/star8.svg') center / contain no-repeat;
  -webkit-mask: url('../img/icon/star8.svg') center / contain no-repeat;
  filter: drop-shadow(0 0 7px rgba(169, 140, 255, 0.75));
}

/* second divider, below the epithet — slightly narrower and later */
.rule--lower {
  width: min(58vw, 15rem);
  animation-delay: 0.86s;
}
.rule--lower .rule__star {
  width: 1.15rem;
  height: 1.15rem;
}

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes widen {
  from { opacity: 0; transform: scaleX(0.3); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   LINKS
   ============================================================ */
.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.6rem, 2.2vw, 1rem);
  width: 100%;
  max-width: 34rem;
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.9s forwards;
}

.link {
  flex: 1 1 9rem;
  min-width: 8.5rem;
  /* 48px min touch target */
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 1.15rem;
  font-family: inherit;
  font-size: clamp(0.74rem, 2.3vw, 0.86rem);
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 2px;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  transition: color 0.28s var(--ease),
              border-color 0.28s var(--ease),
              background-color 0.28s var(--ease),
              transform 0.28s var(--ease),
              box-shadow 0.28s var(--ease);
}

/* Masked so each brand mark takes the link's own colour on hover.
   Sources are the official Simple Icons paths (CC0). */
.link__icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  background: currentColor;
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
  opacity: 0.78;
  transition: opacity 0.28s var(--ease);
}

.link__icon--kofi     { --icon: url('../img/icon/kofi.svg'); }
.link__icon--gallery  { --icon: url('../img/icon/gallery.svg'); }
.link__icon--fa       { --icon: url('../img/icon/furaffinity.svg'); }
.link__icon--bluesky  { --icon: url('../img/icon/bluesky.svg'); }

.link__label { white-space: nowrap; }

/* The headline action — wider, taller, brighter than its neighbours.
   flex-basis pushes it onto its own row once the others have wrapped. */
.link--primary {
  flex: 1 1 100%;
  min-height: 3.6rem;
  order: -1;                     /* leads the row visually */
  padding: 1.15rem 1.5rem;
  font-size: clamp(0.86rem, 3vw, 1.05rem);
  letter-spacing: 0.2em;
  border-color: var(--edge-hot);
  background: rgba(109, 75, 214, 0.26);
  color: var(--star);
  box-shadow: 0 0 34px -12px rgba(109, 75, 214, 0.8);
}
.link--primary .link__icon {
  width: 1.25em;
  height: 1.25em;
  opacity: 0.95;
}

@media (hover: hover) and (pointer: fine) {
  .link--primary:hover {
    background: rgba(109, 75, 214, 0.4);
    box-shadow: 0 8px 34px -8px rgba(109, 75, 214, 0.85);
  }
}

/* Hover only where a real pointer exists — avoids sticky states on touch */
@media (hover: hover) and (pointer: fine) {
  .link:hover {
    color: var(--star);
    border-color: var(--edge-hot);
    background: rgba(109, 75, 214, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 26px -8px rgba(109, 75, 214, 0.65);
  }
  .link:hover .link__icon { opacity: 1; }
}

.link:active { transform: translateY(0) scale(0.985); }


/* ============================================================
   DECREE — "Perish not before thou witness:"
   ============================================================ */
.decree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 30rem;
  opacity: 0;
  animation: rise 0.9s var(--ease) 1.05s forwards;
}

.decree__heading {
  margin: 0;
  font-size: clamp(0.68rem, 2.4vw, 0.82rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  opacity: 0.82;
  text-wrap: balance;
}

.decree__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem clamp(0.9rem, 4vw, 1.8rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* hairline separator between items, skipped on the first */
.decree__list li { position: relative; }
.decree__list li + li::before {
  content: '';
  position: absolute;
  left: calc(clamp(0.9rem, 4vw, 1.8rem) / -2);
  top: 50%;
  width: 1px;
  height: 0.9em;
  transform: translateY(-50%);
  background: var(--edge);
}

.decree__link {
  display: inline-block;
  padding: 0.35rem 0.1rem;
  font-size: clamp(0.74rem, 2.5vw, 0.88rem);
  letter-spacing: 0.1em;
  color: var(--star-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--edge);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.decree__link:hover {
  color: var(--star);
  border-color: var(--edge-hot);
  text-shadow: 0 0 14px rgba(169, 140, 255, 0.5);
}

@media (max-width: 30rem) {
  /* stack cleanly on narrow screens; drop the separator */
  .decree__list li + li::before { display: none; }
}

/* ============================================================
   SIGIL — the star that summons the dance
   Same 8-pointed form as the rule stars, considerably larger.
   ============================================================ */
.sigil-slot {
  display: grid;
  place-items: center;
  opacity: 0;
  animation: rise 0.9s var(--ease) 1.25s forwards;
}

.sigil {
  display: grid;
  place-items: center;
  width: 4.75rem;
  height: 4.75rem;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* JS spins this via --sigil-rot and brightens it via --sigil-charge
   as the click combo builds. */
.sigil__star {
  display: block;
  width: 100%;
  height: 100%;
  rotate: var(--sigil-rot, 0deg);
  background: color-mix(in srgb,
        var(--star) calc(var(--sigil-charge, 0) * 100%),
        var(--star-dim));
  mask: url('../img/icon/star8.svg') center / contain no-repeat;
  -webkit-mask: url('../img/icon/star8.svg') center / contain no-repeat;
  animation: sigil-glow 4.5s ease-in-out infinite;
  will-change: transform, filter;
}

@keyframes sigil-glow {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(169, 140, 255, 0.55))
            drop-shadow(0 0 16px rgba(109, 75, 214, 0.3));
  }
  50% {
    filter: drop-shadow(0 0 13px rgba(169, 140, 255, 0.95))
            drop-shadow(0 0 34px rgba(109, 75, 214, 0.6));
  }
}

@media (hover: hover) and (pointer: fine) {
  .sigil:hover { filter: brightness(1.25); }
}

/* Each press kicks the star bigger for a moment. JS re-triggers this
   by removing/re-adding the class with a reflow between. */
.sigil.is-kicked .sigil__star {
  animation:
    sigil-glow 4.5s ease-in-out infinite,
    sigil-kick 0.34s var(--ease);
}

@keyframes sigil-kick {
  from { scale: 1; }
  40%  { scale: 1.18; }
  to   { scale: 1; }
}

.sigil:active .sigil__star { scale: 0.94; }

/* the release, once the combo completes */
.sigil.is-released .sigil__star {
  animation:
    sigil-glow 4.5s ease-in-out infinite,
    sigil-burst 0.6s var(--ease);
}

@keyframes sigil-burst {
  from { scale: 1;    filter: drop-shadow(0 0 12px rgba(169,140,255,0.9)); }
  45%  { scale: 1.45; filter: drop-shadow(0 0 40px rgba(242,230,200,1))
                              drop-shadow(0 0 70px rgba(169,140,255,0.9)); }
  to   { scale: 1;    filter: drop-shadow(0 0 12px rgba(169,140,255,0.55)); }
}

/* ============================================================
   DANCE FLYOUT — small floating player
   ============================================================ */
.flyout {
  position: fixed;
  right: clamp(0.75rem, 3vw, 2rem);
  bottom: clamp(0.75rem, 3vw, 2rem);
  bottom: calc(clamp(0.75rem, 3vw, 2rem) + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: clamp(190px, 30vw, 310px);
}
.flyout[hidden] { display: none; }

.flyout__panel {
  position: relative;
  border: 1px solid var(--edge-hot);
  border-radius: 3px;
  background: var(--void-2);
  box-shadow: 0 18px 54px -14px rgba(0, 0, 0, 0.85),
              0 0 30px -8px rgba(109, 75, 214, 0.5);
  overflow: hidden;
  /* fly out from the sigil: rise + settle */
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.9);
  transform-origin: 100% 100%;
  transition: opacity 0.3s var(--ease), transform 0.36s var(--ease);
}
.flyout.is-open .flyout__panel {
  opacity: 1;
  transform: none;
}

.flyout__video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;   /* source is square */
  background: #000;
}

.flyout__close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  color: var(--ink);
  background: rgba(6, 4, 15, 0.72);
  border: 1px solid var(--edge);
  border-radius: 50%;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.flyout__close .ui-icon { width: 0.8rem; height: 0.8rem; }
.flyout__close:hover {
  color: var(--star);
  border-color: var(--edge-hot);
}

@media (max-width: 30rem) {
  /* centre it on small screens rather than crowding a corner */
  .flyout {
    right: 50%;
    transform: translateX(50%);
    width: min(78vw, 300px);
  }
}

/* ============================================================
   EASTER EGG · SHOPPING MAJOR
   Drifts across the window behind the text, bobbing and turning.
   ============================================================ */
/* Sits BEHIND the text (stage is z-index 1) but above the backdrop.
   JS drives the crossing via --mx / --my; CSS owns the bob and spin,
   so the drift and the idle motion never fight over one transform. */
.major {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: clamp(90px, 17vw, 165px);
  transform: translate3d(var(--mx, -50vw), var(--my, 50vh), 0);
  will-change: transform;
  /* purely decorative — never intercepts the cursor */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}
.major[hidden] { display: none; }
.major.is-lit  { opacity: 0.92; }

/* Bob + spin live on the inner wrapper so JS can own the outer
   transform outright. Two composited layers, no layout work. */
.major__bob {
  animation:
    major-bob  3.4s ease-in-out infinite,
    major-spin 9s  ease-in-out infinite;
  will-change: transform;
}

@keyframes major-bob {
  0%, 100% { transform: translateY(-7px); }
  50%      { transform: translateY(7px); }
}

/* a slow, loose turn — swings well past level in both directions */
@keyframes major-spin {
  0%   { rotate: -22deg; }
  25%  { rotate:  14deg; }
  50%  { rotate:  26deg; }
  75%  { rotate:  -9deg; }
  100% { rotate: -22deg; }
}

.major__img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.55));
  user-select: none;
  -webkit-user-drag: none;
}

@media (max-width: 30rem) {
  .major { width: clamp(76px, 26vw, 118px); }
}

/* ============================================================
   EASTER EGG · SHOOTING STAR → "the couch"
   A moving link. JS drives position via --wx / --wy.
   ============================================================ */
.wisp {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 31;
  display: block;
  /* hit area — JS shrinks this once you're done testing */
  width: var(--wisp-hit, 42px);
  height: var(--wisp-hit, 42px);
  margin: calc(var(--wisp-hit, 42px) / -2) 0 0 calc(var(--wisp-hit, 42px) / -2);
  transform: translate3d(var(--wx, -200px), var(--wy, -200px), 0);
  will-change: transform;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity 0.3s linear;
  /* An <a href> is draggable by default. Because this one moves under
     the cursor, mousedown reads as the start of a drag and the browser
     shows the no-drop cursor instead of following the link. */
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* the inner marks must never become the drag source either */
.wisp__head,
.wisp__tail {
  pointer-events: none;
  -webkit-user-drag: none;
}
.wisp[hidden]  { display: none; }
.wisp.is-lit   { opacity: 1; }

/* visible core */
.wisp__head {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--star);
  box-shadow:
    0 0 6px 1px rgba(242, 230, 200, 0.95),
    0 0 16px 3px rgba(169, 140, 255, 0.75),
    0 0 34px 8px rgba(109, 75, 214, 0.4);
}

/* trailing streak, rotated by JS to face the direction of travel */
.wisp__tail {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--wisp-tail, 74px);
  height: 2px;
  margin-top: -1px;
  transform-origin: 0 50%;
  transform: rotate(var(--wisp-angle, 0deg));
  background: linear-gradient(90deg,
      rgba(242, 230, 200, 0.85) 0%,
      rgba(169, 140, 255, 0.45) 42%,
      rgba(169, 140, 255, 0) 100%);
  border-radius: 2px;
  pointer-events: none;
}

/* testing aid — body.wisp-debug shows the clickable area */
body.wisp-debug .wisp {
  outline: 1px dashed rgba(169, 140, 255, 0.7);
  outline-offset: 0;
  background: rgba(169, 140, 255, 0.1);
  border-radius: 50%;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2.5vw, 2rem);
  padding-bottom: calc(clamp(0.5rem, 2.5vw, 2rem) + env(safe-area-inset-bottom, 0px));
}
.lightbox[hidden] { display: none; }

.lightbox__scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 10, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
}
.lightbox.is-open .lightbox__scrim { opacity: 1; }

.lightbox__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 78rem);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  transform: scale(0.975);
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease);
}
.lightbox.is-open .lightbox__panel { opacity: 1; transform: none; }

.lightbox__figure {
  position: relative;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--edge);
  border-radius: 2px;
  background: var(--void-2);
  box-shadow: 0 24px 80px -24px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.lightbox__img.is-ready { opacity: 1; }

.lightbox__spinner {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 2px solid var(--edge);
  border-top-color: var(--amethyst-lt);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}
.lightbox__spinner.is-busy { opacity: 1; }

/* ---------------- caption bar ---------------- */
.lightbox__bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.55rem 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.lightbox__meta {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-width: 0;
}
.lightbox__title { color: var(--star); }
.lightbox__count { color: var(--ink-soft); opacity: 0.7; font-size: 0.66rem; }

.lightbox__credit {
  color: var(--ink-soft);
  opacity: 0.55;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
}
.lightbox__credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--edge);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.lightbox__credit:hover { opacity: 0.9; }
.lightbox__credit a:hover {
  color: var(--star);
  border-color: var(--edge-hot);
}

@media (max-width: 40rem) {
  /* let the meta row stack rather than squeezing the title */
  .lightbox__meta { flex-wrap: wrap; justify-content: center; gap: 0.35rem 0.7rem; }
}

.lightbox__full {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid var(--edge);
  border-radius: 2px;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.lightbox__full:hover { color: var(--star); border-color: var(--edge-hot); }
.lightbox__size { opacity: 0.6; font-size: 0.64rem; letter-spacing: 0.08em; }

/* ---------------- controls ---------------- */
.lightbox__nav,
.lightbox__close {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  color: var(--ink-soft);
  background: rgba(13, 8, 34, 0.72);
  border: 1px solid var(--edge);
  border-radius: 50%;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease),
              background-color 0.25s var(--ease);
}
.lightbox__nav .ui-icon,
.lightbox__close .ui-icon { width: 1.05rem; height: 1.05rem; }
.lightbox__nav:hover,
.lightbox__close:hover {
  color: var(--star);
  border-color: var(--edge-hot);
  background: rgba(27, 17, 64, 0.92);
}

.lightbox__nav--prev { left: 0.4rem; top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 0.4rem; top: 50%; transform: translateY(-50%); }
.lightbox__close     { top: -0.2rem; right: -0.2rem; }

.lightbox__nav[disabled] { opacity: 0.25; cursor: default; pointer-events: none; }

/* ---------------- thumb strip ---------------- */
.lightbox__thumbs {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.15rem;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.thumb {
  flex: 0 0 auto;
  width: clamp(3.6rem, 12vw, 5.6rem);
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--void-2);
  border: 1px solid var(--edge);
  border-radius: 2px;
  opacity: 0.5;
  transition: opacity 0.25s var(--ease), border-color 0.25s var(--ease);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { opacity: 0.85; }
.thumb[aria-selected='true'] { opacity: 1; border-color: var(--edge-hot); }

/* Single-image galleries don't need chrome */
.lightbox.is-single .lightbox__nav,
.lightbox.is-single .lightbox__thumbs,
.lightbox.is-single .lightbox__count { display: none; }

@media (max-width: 40rem) {
  .lightbox__bar {
    justify-content: center;
    text-align: center;
    font-size: 0.66rem;
  }
  .lightbox__nav { width: 2.5rem; height: 2.5rem; }
  .lightbox__nav--prev { left: 0.1rem; }
  .lightbox__nav--next { right: 0.1rem; }
  .lightbox__close { top: 0.1rem; right: 0.1rem; }
  .lightbox__full { width: 100%; justify-content: center; }
}

/* body scroll lock while the lightbox is up */
body.is-locked { overflow: hidden; }

/* ============================================================
   SHORT / LANDSCAPE PHONES
   ============================================================ */
@media (max-height: 34rem) and (orientation: landscape) {
  .stage { gap: 1.25rem; padding-block: 2rem; }
  .crest__name { font-size: clamp(2.2rem, 9vh, 4rem); }
  .crest__epithet { display: none; }
}

/* ============================================================
   REDUCED MOTION — kill every loop, keep the layout intact
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .backdrop__img { opacity: 0.62; }
  .crest__title,
  .crest__name,
  .crest__epithet,
  .links,
  .rule,
  .decree,
  .sigil-slot { opacity: 1; transform: none; }

  /* the sigil stays, it just stops turning and pulsing */
  .sigil__star { animation: none !important; }
  .flyout__panel { opacity: 1; transform: none; }

  /* Easter eggs are motion-driven by definition — JS skips scheduling
     them entirely under this preference, but belt-and-braces here. */
  .major, .wisp { display: none !important; }

  /* JS also skips parallax entirely under this preference. */
}

/* Older/low-end devices: skip backdrop-filter, it is the expensive one */
@media (max-width: 30rem) {
  .link { -webkit-backdrop-filter: none; backdrop-filter: none;
          background: rgba(20, 13, 48, 0.62); }
}

@media print {
  .backdrop, .links, .lightbox, .flyout { display: none !important; }
  body { background: #fff; color: #000; }
  .crest__name { color: #000; text-shadow: none; }
}
