/*
 * MOONWALKER — Grand Neoclassical Anime layer
 *
 * This file is intentionally additive.  The existing sanctuary, archive and
 * cinematic styles remain the source of truth for layout; this layer supplies
 * the shared visual language, restrained motion and reading-room polish.
 */
:root{
  --epic-ease:cubic-bezier(.16,1,.3,1);
  --epic-gold:#ecd49b;
  --epic-ivory:#fff9ee;
  --epic-blue:#8fd4ff;
  --epic-red:#ff789e;
  --epic-violet:#bd9cff;
  --epic-halo:1;
}

body{overflow-x:clip}
body::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:180;
  pointer-events:none;
  opacity:.075;
  mix-blend-mode:screen;
  background-image:radial-gradient(circle at 14% 19%,#fff 0 .55px,transparent .8px),radial-gradient(circle at 74% 68%,#fff 0 .45px,transparent .75px),radial-gradient(circle at 38% 82%,#fff 0 .4px,transparent .7px),repeating-linear-gradient(0deg,transparent 0 3px,#fff1 4px 5px);
  background-size:83px 97px,121px 139px,167px 181px,100% 7px;
  animation:epicGrain 8s steps(2,end) infinite;
}
@keyframes epicGrain{0%{transform:translate(0,0)}25%{transform:translate(1px,-1px)}50%{transform:translate(-1px,1px)}75%{transform:translate(1px,1px)}100%{transform:translate(0,0)}}
/* Preserve a faint painted texture in the archive without compositing motion
   across the entire reading surface on every frame. */
body.reader-open::before{animation-play-state:paused!important;opacity:.035}

/* The first threshold should feel like a painted anime title card. */
.welcome::before{
  content:"";
  position:absolute;
  inset:-10%;
  pointer-events:none;
  background:radial-gradient(ellipse at 50% 42%,#e7dcff16 0 18%,transparent 48%),radial-gradient(ellipse at 50% 82%,#080a1dd0 0 26%,transparent 67%);
  mix-blend-mode:screen;
  opacity:calc(.82 * var(--epic-halo));
}
.welcome-art{filter:saturate(1.06) contrast(1.035) brightness(.93);transform:translate3d(calc(var(--welcome-parallax-x,0px) * -.35),calc(var(--welcome-parallax-y,0px) * -.35),0) scale(1.015);transition:filter 1.2s ease,transform 1.2s var(--epic-ease)}
.welcome-title{filter:drop-shadow(0 0 14px #fff8) drop-shadow(0 0 45px #c6a8ff50)}
.welcome-title span{background:linear-gradient(110deg,#fff 16%,#fff8e8 43%,#f1dcff 55%,#fff 76%);background-size:220% auto;background-clip:text;-webkit-background-clip:text;color:#fff8e9;-webkit-text-fill-color:#fff8e9;animation:titleSheen 8s ease-in-out infinite}
@keyframes titleSheen{0%,20%{background-position:0% 50%}55%,100%{background-position:100% 50%}}
.welcome-celestial{filter:drop-shadow(0 0 20px #b7a7ff22)}
.welcome-lunar-aura{opacity:.8!important;box-shadow:0 0 80px 24px #ebe1ff22,inset 0 0 60px #fff5!important}
.moon-touch-ring{animation:moonTouchPulse 4.6s ease-in-out infinite}
@keyframes moonTouchPulse{0%,100%{opacity:.18;transform:scale(.99)}50%{opacity:.62;transform:scale(1.015)}}
.welcome-bottom .enter-button{filter:drop-shadow(0 0 13px #eddaae42)}
.welcome.exiting .welcome-art{filter:saturate(.2) brightness(.35) blur(1px);transform:scale(1.07)}

/* A restrained film-stage layer behind the procedural eclipse. */
#eclipse .cinematic-camera::before,
#eclipse .cinematic-camera::after{
  content:"";
  position:absolute;
  pointer-events:none;
  z-index:3;
}
#eclipse .cinematic-camera::before{inset:-18%;background:radial-gradient(ellipse at 50% 48%,transparent 0 25%,#0008 65%,#000 100%);mix-blend-mode:multiply;animation:epicCameraBreath var(--cinema-ms,18000ms) var(--epic-ease) both}
#eclipse .cinematic-camera::after{inset:0;background:radial-gradient(circle at 50% 46%,#fff0 0 24%,#f7eaff08 30%,transparent 58%);mix-blend-mode:screen;opacity:0;animation:epicCoronaPulse var(--cinema-ms,18000ms) var(--epic-ease) both}
@keyframes epicCameraBreath{0%,22%{transform:scale(.92);opacity:.25}45%,68%{transform:scale(1);opacity:.72}100%{transform:scale(1.06);opacity:.94}}
@keyframes epicCoronaPulse{0%,38%{opacity:0}53%{opacity:.18}68%{opacity:.04}100%{opacity:.28}}
#eclipse .lunar-stage{filter:drop-shadow(0 0 30px #c7b4ff35)}
#eclipse .lunar-stage::before,
#eclipse .lunar-stage::after{content:"";position:absolute;inset:-13%;border-radius:50%;pointer-events:none;border:1px solid #eadbff28;box-shadow:0 0 38px #9d8cff18,inset 0 0 26px #fff1;transform:rotate(-11deg) scaleX(1.7);animation:epicOrbitDrift 16s linear infinite}
#eclipse .lunar-stage::after{inset:-22%;opacity:.38;transform:rotate(61deg) scaleX(1.32);animation-direction:reverse;animation-duration:23s}
@keyframes epicOrbitDrift{to{rotate:360deg}}
#eclipse .cinematic-line{letter-spacing:.015em;text-shadow:0 3px 32px #000,0 0 16px #c9b5ff28}
#eclipse .cinematic-names strong{text-shadow:0 0 18px currentColor}
#eclipse .cinematic-names>div{filter:drop-shadow(0 0 12px #000)}

/* Sanctuary as a triune temple: three altars, one shared horizon. */
.sanctuary::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:-2;
  pointer-events:none;
  opacity:.7;
  background:radial-gradient(ellipse at 50% 23%,#fff8e81b 0 12%,transparent 38%),radial-gradient(ellipse at 25% 52%,#5aa8ff18 0 8%,transparent 33%),radial-gradient(ellipse at 50% 52%,#ffd36b18 0 9%,transparent 33%),radial-gradient(ellipse at 75% 52%,#ff4e7c17 0 8%,transparent 33%);
  animation:templeHalo 13s ease-in-out infinite alternate;
}
.sanctuary::after{
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  pointer-events:none;
  opacity:.28;
  background:linear-gradient(90deg,transparent 0 24.8%,#c9b88f18 25%,transparent 25.2% 49.8%,#c9b88f18 50%,transparent 50.2% 74.8%,#c9b88f18 75%,transparent 75.2%),linear-gradient(180deg,transparent 0 68%,#0a0d19b0 100%);
  mask-image:linear-gradient(180deg,#000,transparent 90%);
}
@keyframes templeHalo{from{transform:scale(.985);opacity:.45}to{transform:scale(1.02);opacity:.78}}
.sanctuary-heading{filter:drop-shadow(0 8px 28px #0007)}
.sanctuary-heading h1{letter-spacing:-.045em;text-shadow:0 3px 28px #000,0 0 30px #d9bf8122}
.landing-moons{filter:drop-shadow(0 0 22px #e5d7a958)}
.landing-moons>span{transition:filter .5s var(--epic-ease),transform .5s var(--epic-ease)}
.landing-moons>span:hover{filter:brightness(1.18) saturate(1.18);transform:translateY(-5px) scale(1.045)}
.portal{isolation:isolate;border-top:1px solid color-mix(in srgb,var(--accent) 75%,transparent);box-shadow:inset 0 1px 0 #fff2,0 18px 50px #0007;transition:transform .45s var(--epic-ease),filter .45s ease,box-shadow .45s ease,border-color .45s ease}
.portal::after{height:2px;box-shadow:0 0 18px color-mix(in srgb,var(--accent) 80%,transparent)}
.portal.azure{clip-path:polygon(16px 0,100% 0,calc(100% - 16px) 100%,0 100%)}
.portal.golden{border-radius:2px}
.portal.crimson{clip-path:polygon(0 0,calc(100% - 16px) 0,100% 100%,16px 100%)}
.portal:hover{box-shadow:inset 0 1px 0 #fff3,0 25px 70px color-mix(in srgb,var(--accent) 24%,#000)}
.sanctuary-foot blockquote{filter:drop-shadow(0 0 10px #d6bc8325)}
.grand-home-section{scroll-margin-top:90px}

/* Route rooms carry their faction’s material language. */
.faction-world{background:radial-gradient(ellipse at 50% 0,#ffffff0a,transparent 44%),var(--bg)}
.faction-world.azure .faction-scene{box-shadow:inset 0 0 120px #66b5ff15}
.faction-world.golden .faction-scene{box-shadow:inset 0 0 120px #ffca681c}
.faction-world.crimson .faction-scene{box-shadow:inset 0 0 120px #ff3f731b}
.faction-world .faction-scene-copy{backdrop-filter:blur(4px);border-image:linear-gradient(180deg,var(--room-accent,var(--gold)),transparent) 1}
.faction-world .faction-chapter,.faction-world .faction-cast{scroll-margin-top:80px}
.faction-world .grand-person{transition:transform .45s var(--epic-ease),border-color .35s ease,box-shadow .35s ease}
.faction-world .grand-person:hover{box-shadow:0 20px 65px color-mix(in srgb,var(--room-accent,var(--gold)) 22%,transparent)}

/* Hollow is deliberately heavier, narrower and more industrial. */
.hollow-world{background:radial-gradient(ellipse at 88% 0,#ff41651a,transparent 44%),#08060b}
.hollow-scene::before{content:"";position:absolute;inset:0;pointer-events:none;z-index:0;background:repeating-linear-gradient(118deg,transparent 0 53px,#ff719b08 54px 55px),radial-gradient(circle at 80% 30%,#f64b7816,transparent 31%);mix-blend-mode:screen}
.hollow-scene-copy{box-shadow:12px 0 80px #0008}
.hollow-scar{mix-blend-mode:screen;filter:blur(.2px)}
.hollow-chapter,.hollow-cast,.hollow-lore{background-image:linear-gradient(90deg,#ff477d06 1px,transparent 1px),linear-gradient(#ff477d06 1px,transparent 1px);background-size:48px 48px}
.hollow-king{box-shadow:inset 0 0 100px #ff356b10}
.hollow-lore-grid a{transition:transform .45s var(--epic-ease),border-color .35s ease,box-shadow .35s ease}
.hollow-lore-grid a:hover{box-shadow:0 20px 50px #e93f6e25}

/* Reading room: editorial status, reveal choreography and generous measure. */
#reader-content{scrollbar-gutter:stable;overscroll-behavior:contain}
#reader .reader-heading{scroll-margin-top:84px}
.epic-status-badge{display:inline-flex;align-items:center;gap:7px;width:max-content;max-width:100%;margin-top:16px;padding:7px 10px;border:1px solid color-mix(in srgb,var(--room-accent,var(--gold)) 55%,transparent);color:var(--room-accent,var(--gold));font:600 10px/1.2 Body,sans-serif;letter-spacing:.14em;text-transform:uppercase;background:color-mix(in srgb,var(--room-accent,var(--gold)) 8%,transparent)}
.epic-status-badge::before{content:"✦";font-size:11px}
.epic-route-in #reader-content{animation:epicRouteIn .62s var(--epic-ease) both}
@keyframes epicRouteIn{from{opacity:.2;transform:translateY(12px);filter:blur(3px)}to{opacity:1;transform:none;filter:none}}
.epic-reveal{opacity:0;transform:translateY(18px);transition:opacity .7s var(--epic-ease),transform .7s var(--epic-ease)}
.epic-reveal.is-visible{opacity:1;transform:none}
.epic-tilt{transform:perspective(1000px) rotateX(var(--epic-rx,0deg)) rotateY(var(--epic-ry,0deg)) translateZ(0);transition:transform .55s var(--epic-ease),box-shadow .45s ease}
.epic-tilt:hover{transition-duration:.18s}
.epic-scroll-progress{position:fixed;inset:0 0 auto 0;height:2px;z-index:160;transform-origin:0 50%;transform:scaleX(var(--epic-scroll,0));background:linear-gradient(90deg,var(--room-accent,var(--gold)),#fff);box-shadow:0 0 14px var(--room-accent,var(--gold));pointer-events:none}
.epic-daybreak .sanctuary::before{animation:daybreakBloom 1.35s var(--epic-ease) both}
@keyframes daybreakBloom{from{filter:brightness(.55) saturate(.7);opacity:.2}to{filter:none;opacity:.8}}

/* Keep the grand treatment readable and still on small screens. */
@media(max-width:760px){
  body::before{opacity:.045;background-size:107px 121px,151px 173px,197px 211px,100% 9px}
  .welcome-art{transform:scale(1.015)}
  .welcome-title{filter:drop-shadow(0 0 10px #fff7)}
  .sanctuary::after{opacity:.14;background:linear-gradient(90deg,transparent 33%,#c9b88f14 33.2% 33.4%,transparent 33.6% 66.4%,#c9b88f14 66.6% 66.8%,transparent 67%)}
  .portal{clip-path:none!important;border-radius:2px}
  .portal:hover{transform:translateY(-3px)}
  .faction-world .faction-scene-copy{backdrop-filter:none}
  .epic-status-badge{margin-top:10px}
  .epic-route-in #reader-content{animation-name:epicRouteMobile}
  .epic-tilt{transform:none!important}
  .epic-scroll-progress{height:3px}
}
@keyframes epicRouteMobile{
  from{opacity:.2;transform:translateY(12px)}
  to{opacity:1;transform:none}
}
@media(prefers-reduced-motion:reduce){
  body::before,.welcome-title span,.moon-touch-ring,#eclipse .cinematic-camera::before,#eclipse .cinematic-camera::after,#eclipse .lunar-stage::before,#eclipse .lunar-stage::after,.sanctuary::before,.epic-route-in #reader-content{animation:none!important}
  .welcome-art,.epic-reveal,.epic-tilt{transition:none!important;transform:none!important;filter:none}
  .epic-reveal{opacity:1!important}
}
body.reduced-motion::before,body.reduced-motion .welcome-title span,body.reduced-motion .moon-touch-ring,body.reduced-motion #eclipse .cinematic-camera::before{animation:none!important}
body.reduced-motion.epic-route-in #reader-content{animation:none!important}
body.reduced-motion .epic-reveal{opacity:1!important;transform:none!important;transition:none!important}
body.quality-lite::before,body.quality-lite .sanctuary::before,body.quality-lite .sanctuary::after,body.quality-lite #eclipse .lunar-stage::before,body.quality-lite #eclipse .lunar-stage::after{display:none}
.quality-lite .welcome-art{transform:none;filter:none}
body.quality-lite .epic-tilt{transform:none!important;transition:none!important}
body.quality-lite.epic-route-in #reader-content{animation:epicRouteLite .28s ease-out both}
@keyframes epicRouteLite{from{opacity:.5}to{opacity:1}}
