/* ══════════════════════════════════════════════════════════════════════
   Homepage — sigil sanctum with alchemical orbit
   ══════════════════════════════════════════════════════════════════════ */

.stage__home-anchor {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  opacity: 0;
}

/* Fullscreen shell — centered mandala */
html.is-home .stage.stage--alive {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left)) !important;
  overflow: hidden !important;
  background: #010101;
}

/* Ouroboros ring around the central seal */
html.is-home .stage.stage--alive .stage__living {
  display: block;
  inset: -18%;
  z-index: 2;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
}

html.is-home .stage.stage--alive .living__cross {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  margin: 0;
}

html.is-home .stage.stage--alive .living__axis {
  display: none;
}

html.is-home .stage.stage--alive .living__ouroboros {
  inset: 0;
  display: grid;
  place-items: center;
  animation: none !important;
  opacity: 1;
  transform: none !important;
}

html.is-home .stage.stage--alive .living__ouroboros-canvas {
  top: 50%;
  left: 50%;
  width: 118%;
  height: 118%;
  transform: translate(-50%, -50%);
}

/* Menu shell — hosts the centered sigil + orbit */
html.is-home .stage.stage--alive .stage__menu {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  z-index: 6;
  padding: 0;
}

/* Sigil disc + orbital ring of inscriptions */
html.is-home .stage.stage--alive .stage__sigil-wrap {
  position: relative;
  width: var(--home-sigil);
  height: var(--home-sigil);
  --home-sigil: min(40vmin, 360px);
  --home-runes: calc(var(--home-sigil) * 1.14);
  /* Rune ring radius + clearance = the circle the phrases sit on */
  --home-radius: calc(var(--home-sigil) * 0.58);
  --home-gutter: clamp(1.6rem, 3.4vmin, 2.6rem);
  --home-orbit: calc(var(--home-radius) + var(--home-gutter));
  /* Whatever room is left between that circle and the viewport edge */
  --home-phrase: min(12rem, 50vw - var(--home-orbit) - 1.5rem);
  --living-runes: var(--home-runes);
  --living-runes-r: calc(var(--home-runes) / 2);
  flex-shrink: 0;
}

html.is-home .stage.stage--alive .stage__composition {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  animation: none !important;
  overflow: visible;
  z-index: 2;
}

html.is-home .stage.stage--alive .stage__inscriptions {
  inset: 50%;
  width: var(--home-runes);
  height: var(--home-runes);
  margin: calc(var(--home-runes) / -2);
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  z-index: 5;
}

html.is-home .stage.stage--alive .living__script--runes {
  width: 100%;
  height: 100%;
}

html.is-home .stage.stage--alive .stage__composition .eye--requiem {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  transform: translate(-50%, -50%);
  z-index: 4;
}

html.is-home .stage.stage--alive .stage__sigil {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  opacity: 1;
  visibility: visible;
  z-index: 6;
}

/* Eye decorations belong to the intro only. They are merely faded out when the
   stage awakens, and their `forwards` animations (white iris rays, seal glow)
   can win over that fade and flash a pale box behind the seal — so drop them
   from the layout entirely once we are home. */
html.is-home .stage.stage--alive .eye__halo,
html.is-home .stage.stage--alive .eye__orbit,
html.is-home .stage.stage--alive .eye__sclera,
html.is-home .stage.stage--alive .eye__sclera-depth,
html.is-home .stage.stage--alive .eye__iris,
html.is-home .stage.stage--alive .eye__iris-rays,
html.is-home .stage.stage--alive .eye__cornea,
html.is-home .stage.stage--alive .eye__shine,
html.is-home .stage.stage--alive .eye__shutter,
html.is-home .stage.stage--alive .stage__sigil-glow {
  display: none !important;
}

html.is-home .stage.stage--alive .stage__sigil-reveal,
html.is-home .stage.stage--alive .stage__sigil-img {
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
  transform: none !important;
  animation: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

/* ── Alchemical orbit around the seal ── */
html.is-home .stage.stage--alive .stage__orbit {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

html.is-home .stage.stage--alive .stage__orbit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  inset: 0;
}

/* Every phrase puts its inner edge on the orbit circle, at its own clock angle,
   and grows outwards from there — evenly spaced, never over the sigil. */
html.is-home .stage.stage--alive .stage__orbit-item {
  position: absolute;
  top: calc(50% - var(--home-orbit) * var(--cy, 0));
  width: max-content;
  max-width: var(--home-phrase);
  margin: 0;
  transform: translateY(-50%);
  pointer-events: auto;
}

html.is-home .stage.stage--alive .stage__orbit-item--left {
  right: calc(50% + var(--home-orbit) * var(--sx, 1));
  text-align: right;
}

html.is-home .stage.stage--alive .stage__orbit-item--right {
  left: calc(50% + var(--home-orbit) * var(--sx, 1));
  text-align: left;
}

html.is-home .stage.stage--alive .stage__orbit-item--left .stage__menu-item {
  text-align: right;
}

html.is-home .stage.stage--alive .stage__orbit-item--right .stage__menu-item {
  text-align: left;
}

html.is-home .stage.stage--alive .stage__menu-item {
  position: relative;
  display: inline-block;
  max-width: 100%;
  font-family: var(--font-elegant);
  font-size: clamp(0.68rem, 1.15vw, 0.92rem);
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(210, 200, 188, 0.72);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  transition:
    color 280ms var(--ease-open),
    text-shadow 280ms var(--ease-open),
    letter-spacing 280ms var(--ease-open),
    transform 280ms var(--ease-open);
  outline: none;
  cursor: pointer;
}

html.is-home .stage.stage--alive .stage__menu-item:hover,
html.is-home .stage.stage--alive .stage__menu-item:focus-visible,
html.is-home .stage.stage--alive .stage__menu-item.is-selected {
  color: #ffffff;
  letter-spacing: 0.16em;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.7),
    0 0 28px rgba(255, 255, 255, 0.28);
  transform: scale(1.04);
}

html.is-home .stage.stage--alive .stage__menu-item:focus-visible::before,
html.is-home .stage.stage--alive .stage__menu-item.is-selected::before {
  content: '·';
  position: absolute;
  left: 50%;
  top: -0.85em;
  font-style: normal;
  font-size: 1.25em;
  color: rgba(255, 255, 255, 0.8);
  transform: translateX(-50%);
}

/* Footer — tagline / Enter / social */
html.is-home .stage.stage--alive .stage__footer {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  transform: translateY(-1cm);
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.5rem 1rem 0.25rem;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cm;
}

html.is-home .stage.stage--alive .stage__tagline {
  opacity: 1;
  animation: none;
  margin: 0;
}

html.is-home .stage.stage--alive .stage__enter {
  margin: 0;
}

html.is-home .stage.stage--alive .stage__social {
  margin: 0;
}

/* Staged entrance */
html.is-home .stage--home-enter {
  background: #0a0a0f;
}

html.is-home .stage--home-enter .stage__orbit-item,
html.is-home .stage--home-enter .stage__living,
html.is-home .stage--home-enter .stage__inscriptions,
html.is-home .stage--home-enter .stage__tagline,
html.is-home .stage--home-enter .stage__enter,
html.is-home .stage--home-enter .stage__social {
  opacity: 0;
  will-change: transform, opacity;
}

html.is-home .stage--home-enter .stage__sigil,
html.is-home .stage--home-enter .stage__sigil-img {
  opacity: 1 !important;
  visibility: visible !important;
}

html.is-home .stage--home-enter .stage__composition .eye--requiem,
html.is-home .stage--home-enter .living__cross {
  transform: translate(-50%, -50%) scale(0.92);
}

html.is-home .stage--home-enter .stage__inscriptions {
  transform: rotate(-3deg);
}

html.is-home .stage--home-enter .stage__tagline,
html.is-home .stage--home-enter .stage__enter,
html.is-home .stage--home-enter .stage__social {
  transform: translate3d(0, 10px, 0);
}

/* 1. Sigil / ouroboros */
html.is-home .stage--home-visible.stage--home-enter .stage__living {
  opacity: 1;
  transition: opacity 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html.is-home .stage--home-visible.stage--home-enter .stage__composition .eye--requiem,
html.is-home .stage--home-visible.stage--home-enter .living__cross {
  transform: translate(-50%, -50%) scale(1);
  transition: transform 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html.is-home .stage--home-visible.stage--home-enter .stage__sigil {
  opacity: 1;
  transition: opacity 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 2. Runic circle */
html.is-home .stage--home-visible.stage--home-enter .stage__inscriptions {
  opacity: 1;
  transform: rotate(0deg);
  transition:
    opacity 1000ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 400ms,
    transform 1000ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 400ms;
}

/* 3. Alchemical orbit — staggered around the seal */
html.is-home .stage--home-visible.stage--home-enter .stage__orbit-item {
  opacity: 1;
  transition:
    opacity 700ms cubic-bezier(0.25, 0.46, 0.45, 0.94) calc(650ms + var(--d, 0) * 70ms);
}

html.is-home .stage--home-visible.stage--home-enter .stage__tagline {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 700ms,
    transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 700ms;
}

/* 4. Library CTA */
html.is-home .stage--home-visible.stage--home-enter .stage__enter,
html.is-home .stage--home-visible.stage--home-enter .stage__social {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 600ms ease-out 1000ms,
    transform 600ms ease-out 1000ms;
}

/* Idle breath */
html.is-home .stage--home-visible.stage--alive .stage__composition .eye--requiem {
  animation: home-sigil-breathe 5s ease-in-out 1.3s infinite;
}

html.is-home .stage--home-visible.stage--alive .living__cross {
  animation: home-cross-breathe 5s ease-in-out 1.3s infinite;
}

@keyframes home-sigil-breathe {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.012);
  }
}

@keyframes home-cross-breathe {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.012);
  }
}

html.is-home .stage--alive .living__script--runes {
  animation: home-runes-drift 90s linear infinite;
}

@keyframes home-runes-drift {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

.stage__enter-label--tap {
  display: none;
}

@media (max-width: 767px), (pointer: coarse) {
  .stage__enter-label--desk {
    display: none;
  }
  .stage__enter-label--tap {
    display: inline;
  }
}

/* Tablet / phone — tighter orbit, smaller type, more vertical clearance */
@media (max-width: 820px) {
  html.is-home .stage.stage--alive {
    padding:
      max(0.65rem, env(safe-area-inset-top))
      max(0.65rem, env(safe-area-inset-right))
      max(0.65rem, env(safe-area-inset-bottom))
      max(0.65rem, env(safe-area-inset-left)) !important;
    justify-content: space-between !important;
  }

  html.is-home .stage.stage--alive .stage__menu {
    flex: 1 1 auto;
  }

  html.is-home .stage.stage--alive .stage__sigil-wrap {
    --home-sigil: min(34vmin, 220px);
    --home-gutter: clamp(0.85rem, 2.6vw, 1.4rem);
    --home-phrase: min(8.6rem, 50vw - var(--home-orbit) - 0.9rem);
  }

  html.is-home .stage.stage--alive .stage__menu-item {
    font-size: clamp(0.58rem, 2.7vw, 0.78rem);
    letter-spacing: 0.08em;
    line-height: 1.25;
  }

  html.is-home .stage.stage--alive .stage__menu-item:hover,
  html.is-home .stage.stage--alive .stage__menu-item:focus-visible,
  html.is-home .stage.stage--alive .stage__menu-item.is-selected {
    transform: scale(1.03);
    letter-spacing: 0.1em;
  }

  html.is-home .stage.stage--alive .stage__footer {
    gap: 1cm;
    transform: translateY(-1cm);
    padding-top: 0.25rem;
  }
}

/* Narrow phones — smaller seal so the two phrase columns keep their margins */
@media (max-width: 480px) {
  html.is-home .stage.stage--alive .stage__sigil-wrap {
    --home-sigil: min(34vmin, 170px);
    --home-gutter: 0.9rem;
    --home-phrase: min(7.6rem, 50vw - var(--home-orbit) - 0.7rem);
  }

  html.is-home .stage.stage--alive .stage__menu-item {
    font-size: clamp(0.54rem, 2.9vw, 0.72rem);
    letter-spacing: 0.06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.is-home .stage--home-visible.stage--alive .stage__composition .eye--requiem,
  html.is-home .stage--alive .living__script--runes {
    animation: none !important;
  }

  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__orbit-item,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__inscriptions,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__tagline,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__enter,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__social {
    opacity: 1 !important;
  }

  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__orbit-item {
    transform: translateY(-50%) !important;
  }

  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__tagline,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__enter,
  html.is-home .stage--home-enter:not(.is-diving):not(.is-leaving) .stage__social {
    transform: none !important;
  }

  html.is-home .stage--home-enter .stage__composition .eye--requiem {
    transform: translate(-50%, -50%) scale(1) !important;
  }
}
