.castle {
  isolation: isolate;
  position: relative;
  background: #15131c;
}

.castle-stage {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.castle-backdrop {
  position: absolute;
  inset: -20px 0;
  opacity: 0;
  transform: translate3d(0, var(--castle-scroll, 0px), 0) scale(1.035);
  background-position: var(--castle-position, center);
  background-size: cover;
  transition: opacity .72s ease;
}

.castle-backdrop.is-active { opacity: 1; }

.castle-backdrop--gate {
  --castle-position: 65% center;
  background-image: url("castle-gate.webp");
}

.castle-backdrop--hall { background-image: url("castle-hall.webp"); }
.castle-backdrop--tower { background-image: url("castle-tower.webp"); }
.castle-backdrop--vault { background-image: url("castle-vault.webp"); }

.castle-stage::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #100f18e8 0%, #17131cb0 34%, #19152341 67%, #15121c35 100%),
    linear-gradient(0deg, #0b0a12a8, transparent 45%);
  content: "";
}

.castle-floor {
  position: relative;
  z-index: 1;
}

.castle-floor > section {
  background-color: transparent;
}

.castle-floor > .hero {
  background:
    radial-gradient(ellipse at 79% 42%, #392a4673, transparent 52%),
    linear-gradient(0deg, #15131c94, transparent 33%);
}

.castle-floor > .about {
  background: linear-gradient(180deg, #1d17247d, #221a215e);
}

.castle-floor > .experience {
  background: linear-gradient(180deg, #20192166, #120e16a8);
}

.castle-floor > .winter-section {
  background: linear-gradient(90deg, #13111cb8, #21152d2b 85%);
}

.castle-floor > .dates { background: #141521a8; }
.castle-floor > .atmosphere { background: #1b172196; }
.castle-floor > .faq { background: #14121bd4; }
.castle-floor > .closing-cta { background: #15121cb8; }

.site-footer { position: relative; z-index: 1; }

.castle-nav {
  position: fixed;
  z-index: 5;
  top: 50%;
  right: 13px;
  display: grid;
  gap: 2px;
  transform: translateY(-50%);
}

.castle-nav a {
  justify-self: end;
  display: grid;
  min-width: 25px;
  min-height: 30px;
  place-content: center end;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 7px;
  color: #f5d5a2;
  font-size: 0;
  text-decoration: none;
}

.castle-nav a::after {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border: 1px solid #dfb781;
  border-radius: 50%;
  background: #1b1823;
  content: "";
}

.castle-nav a[aria-current="location"]::after {
  background: #f3cd9b;
  box-shadow: 0 0 12px #ffcf8d;
}

.castle-nav a:hover,
.castle-nav a:focus-visible {
  display: flex;
  align-items: center;
  gap: 9px;
  border-color: #cfaa7b82;
  background: #1a1624;
  font-size: 11px;
}

.castle-nav a:focus-visible { outline: 2px solid #f5d5a2; }
body:has(dialog[open]) .castle-nav { visibility: hidden; }

.feature-card--bard {
  position: relative;
  isolation: isolate;
  overflow: visible;
  background-image: radial-gradient(ellipse at 84% 9%, #b87a4e3b, transparent 63%);
}

.bard-character {
  position: absolute;
  z-index: 1;
  top: -62px;
  right: 5%;
  width: clamp(116px, 14vw, 185px);
  height: auto;
  filter: drop-shadow(0 10px 16px #09070db5);
  transform: rotate(8deg);
  pointer-events: none;
}

.feature-card--bard :is(h3, p) {
  position: relative;
  z-index: 2;
}

.guide-spark,
.bard-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffe1a6;
  box-shadow: 0 0 11px 3px #ffd09c8a, 18px -11px 0 -2px #ffc487, 35px 6px 0 -2px #a7d4ff;
  pointer-events: none;
}

.guide-spark { top: 38%; left: 29%; }
.bard-spark { top: 10%; right: 24%; }

.spell-portal {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 430px;
  place-items: center;
  perspective: 850px;
}

.portal-ring,
.portal-frame {
  position: absolute;
  width: min(76%, 355px);
  aspect-ratio: .86;
  border-radius: 50% 50% 44% 44%;
  pointer-events: none;
}

.portal-ring {
  z-index: -1;
  border: 1px solid #d0a8ff9e;
  background: radial-gradient(ellipse, #804bd271, #382054b0 63%, #20182b 90%);
  box-shadow: inset 0 0 34px #d09fff7a, 0 0 28px #a46dff8c, 0 0 100px #7738caa0;
  transform: rotate(-12deg) rotateY(-20deg);
}

.portal-frame {
  z-index: 2;
  border: 3px double #d2b0ddc0;
  border-top-color: transparent;
  border-left-color: transparent;
  clip-path: polygon(100% 45%, 100% 100%, 25% 100%, 25% 84%, 68% 77%);
  transform: translate(8px, 11px) rotate(-12deg) rotateY(-20deg);
}

.portal-character {
  position: relative;
  z-index: 1;
  width: min(92%, 445px);
  height: auto;
  margin: -32px 0 0;
  transform: translateX(1%) rotate(4deg);
  filter: drop-shadow(0 19px 21px #10091dbb) drop-shadow(0 0 12px #b07afa70);
  pointer-events: none;
}

.portal-flare {
  position: absolute;
  z-index: 2;
  top: 27%;
  right: 16%;
  width: 100px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #d46bff95, #b471ff4d 40%, transparent 68%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.portal-spark {
  position: absolute;
  z-index: 3;
  top: 21%;
  right: 20%;
  width: 7px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f2dbff;
  box-shadow: 0 0 12px 4px #c987ff;
  pointer-events: none;
}

.portal-spark:nth-of-type(2) { top: 31%; right: 9%; width: 5px; }
.portal-spark:nth-of-type(3) { top: 35%; right: 27%; width: 4px; }

[data-magic].is-in-view :is(.portal-spark, .guide-spark, .bard-spark) {
  animation: castle-cast-rise 2.9s ease-out infinite;
}

[data-magic].is-in-view .portal-spark:nth-of-type(2) { animation-delay: .8s; }
[data-magic].is-in-view .portal-spark:nth-of-type(3) { animation-delay: 1.6s; }

[data-magic].is-in-view .portal-flare { animation: castle-cast-glow 2.8s ease-in-out infinite alternate; }

@keyframes castle-cast-rise {
  0% { opacity: 0; transform: translate3d(0, 8px, 0) scale(.65); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(-16px, -32px, 0) scale(1.12); }
}

@keyframes castle-cast-glow {
  from { opacity: .45; transform: scale(.84); }
  to { opacity: .95; transform: scale(1.15); }
}

@media (max-width: 1050px) {
  .castle-nav { right: 4px; }
  .castle-nav a { min-width: 19px; padding-inline: 5px; }
}

@media (max-width: 850px) {
  .castle-nav { display: none; }
  .castle-stage::after {
    background: linear-gradient(180deg, #15121ac9, #15121a8a 54%, #15121ac9);
  }
  .feature-card--bard .bard-character { top: -15px; right: 2%; width: 122px; }
  .spell-portal { min-height: 320px; max-width: 465px; margin: 0 auto; }
  .portal-character { width: min(92%, 345px); }
  .portal-ring, .portal-frame { width: min(74%, 280px); }
}

@media (max-width: 580px) {
  .spell-portal { min-height: 268px; }
  .portal-character { width: min(83%, 300px); }
  .portal-ring, .portal-frame { width: min(69%, 230px); }
  .portal-flare { width: 74px; right: 16%; }
  .bard-character { max-width: 122px; }
}

@media (prefers-reduced-motion: reduce) {
  .castle-backdrop { transform: none; transition: none; }
  [data-magic].is-in-view :is(.portal-character, .portal-spark, .portal-flare, .guide-spark, .bard-spark) {
    animation: none;
  }
}
