/* mujun.works -- fairycore archive of contradictions
   Palette: retro-futuristic / iridescent
   Twilight deep #1A1028, Fairy pink #E8A0D0, Fairy teal #80D8C8,
   Vintage gold #C8A848, Moth wing cream #F5F0E0, Forest shadow #2A3828,
   Prismatic lilac #B888D8 */

:root {
  --twilight: #1A1028;
  --fairy-pink: #E8A0D0;
  --fairy-teal: #80D8C8;
  --vintage-gold: #C8A848;
  --moth-cream: #F5F0E0;
  --forest-shadow: #2A3828;
  --prismatic-lilac: #B888D8;

  --content-max: 580px;
  --frame-irid-speed: 20s;
  --frame-irid-speed-hover: 5s;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--twilight);
  color: var(--moth-cream);
  font-family: "Crimson Pro", Georgia, serif;
  font-weight: 400;
  font-size: clamp(16px, 1.1vw, 18px);
  line-height: 1.9;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(184,136,216,0.10) 0%, transparent 38%),
    radial-gradient(circle at 82% 78%, rgba(128,216,200,0.07) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(232,160,208,0.04) 0%, transparent 60%),
    var(--twilight);
  position: relative;
}

/* ----- generative particle canvas ----- */
#particle-field {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
}

main {
  position: relative;
  z-index: 1;
  max-width: 100%;
}

/* ----- compass nav ----- */
.compass {
  position: fixed;
  top: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(26, 16, 40, 0.55);
  border: 1px solid rgba(200, 168, 72, 0.4);
  color: var(--vintage-gold);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0) rotate(-180deg);
  animation: compass-bloom 1200ms ease-out 2500ms forwards;
  transition: border-color 380ms ease, color 380ms ease, background 380ms ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.compass:hover {
  color: var(--fairy-pink);
  border-color: rgba(232, 160, 208, 0.7);
  background: rgba(26, 16, 40, 0.75);
}
.compass.is-open {
  color: var(--fairy-teal);
  border-color: var(--fairy-teal);
}
.compass svg { display: block; }
.compass-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Cinzel Decorative", serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--vintage-gold);
  opacity: 0;
  transition: opacity 320ms ease;
  text-transform: uppercase;
}
.compass:hover .compass-label,
.compass.is-open .compass-label { opacity: 0.9; }

@keyframes compass-bloom {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(20deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ----- radial nav ----- */
.radial-nav {
  position: fixed;
  top: 58px;
  right: 58px;
  width: 0;
  height: 0;
  z-index: 9;
  pointer-events: none;
}
.radial-nav.is-open { pointer-events: auto; }

.radial-link {
  position: absolute;
  top: 0; left: 0;
  font-family: "Cinzel Decorative", serif;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--moth-cream);
  background: rgba(26, 16, 40, 0.85);
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid rgba(232, 160, 208, 0.35);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transform: translate(0, 0) scale(0.6);
  transition: opacity 380ms ease, transform 460ms cubic-bezier(.22,1.4,.36,1), color 280ms ease, border-color 280ms ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.radial-nav.is-open .radial-link {
  opacity: 1;
  transform:
    translate(
      calc(cos((var(--ang) - 90) * 1deg) * 130px),
      calc(sin((var(--ang) - 90) * 1deg) * 130px)
    ) scale(1);
}
.radial-link:hover {
  color: var(--fairy-pink);
  border-color: var(--fairy-pink);
}
.radial-link:nth-child(1) { --ang: 0; transition-delay: 60ms; }
.radial-link:nth-child(2) { --ang: 60; transition-delay: 120ms; }
.radial-link:nth-child(3) { --ang: 120; transition-delay: 180ms; }
.radial-link:nth-child(4) { --ang: 180; transition-delay: 240ms; }
.radial-link:nth-child(5) { --ang: 240; transition-delay: 300ms; }
.radial-link:nth-child(6) { --ang: 300; transition-delay: 360ms; }

/* ----- gateway ----- */
.gateway {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 100px;
  position: relative;
}
.gateway-inner {
  max-width: 760px;
}
.gateway-eyebrow {
  font-family: "Cinzel Decorative", serif;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--vintage-gold);
  opacity: 0;
  animation: fade-in 1400ms ease-out 600ms forwards;
  margin-bottom: 28px;
}
.domain-title {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(28px, 7vw, 88px);
  letter-spacing: 0.02em;
  margin: 0 0 18px;
  color: var(--moth-cream);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}
.kinetic-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px);
  animation:
    letter-fade-in 700ms ease-out forwards,
    letter-oscillate 4200ms ease-in-out infinite;
  animation-delay:
    calc(1000ms + var(--i) * 80ms),
    calc(1700ms + var(--i) * 80ms);
}
.kinetic-dot { color: var(--fairy-pink); }

@keyframes letter-fade-in {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes letter-oscillate {
  0%   { transform: translateY(-4px) rotate(-0.6deg); }
  50%  { transform: translateY(4px)  rotate(0.6deg); }
  100% { transform: translateY(-4px) rotate(-0.6deg); }
}

.gateway-translation {
  font-family: "Crimson Pro", serif;
  font-weight: 300;
  font-style: italic;
  font-size: 18px;
  color: var(--fairy-pink);
  margin: 4px 0 26px;
  opacity: 0;
  animation: fade-in 1600ms ease-out 2400ms forwards;
}
.gateway-translation .hanzi {
  font-style: normal;
  font-size: 22px;
  color: var(--fairy-teal);
  letter-spacing: 0.08em;
  margin-right: 8px;
}
.gateway-tagline {
  max-width: 540px;
  margin: 0 auto;
  font-family: "Crimson Pro", serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.85;
  color: rgba(245, 240, 224, 0.82);
  opacity: 0;
  animation: fade-in 1800ms ease-out 3000ms forwards;
}
@keyframes fade-in { to { opacity: 1; } }

.scroll-indicator {
  position: absolute;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  width: 2px;
  height: 80px;
  pointer-events: none;
  opacity: 0;
  animation: fade-in 1400ms ease-out 3000ms forwards;
}
.scroll-indicator .trail {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(to bottom, transparent, var(--fairy-pink));
  animation: trail-fall 2400ms cubic-bezier(.5,.05,.6,1) infinite;
}
.scroll-indicator .trail-1 { animation-delay: 0ms; }
.scroll-indicator .trail-2 { animation-delay: 700ms; background: linear-gradient(to bottom, transparent, var(--fairy-teal)); }
.scroll-indicator .trail-3 { animation-delay: 1400ms; background: linear-gradient(to bottom, transparent, var(--prismatic-lilac)); }
@keyframes trail-fall {
  0%   { top: -10px; opacity: 0; }
  20%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 80px; opacity: 0; }
}

/* ----- gallery ----- */
.relic-gallery {
  padding: 60px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 80px;
}
.gallery-preamble {
  max-width: var(--content-max);
  font-family: "Crimson Pro", serif;
  font-weight: 400;
  font-style: italic;
  font-size: 18px;
  line-height: 1.95;
  text-align: left;
  color: rgba(245, 240, 224, 0.86);
  margin: 40px auto 0;
}

/* drop caps */
.drop-cap {
  font-family: "Cinzel Decorative", serif;
  font-style: normal;
  font-weight: 700;
  font-size: 2.4em;
  line-height: 0.9;
  float: left;
  margin: 6px 10px -2px 0;
  color: var(--vintage-gold);
  transition: transform 340ms ease, color 340ms ease;
}
.relic:hover .drop-cap { transform: scale(1.1); color: var(--fairy-pink); }
.gallery-preamble .drop-cap { color: var(--fairy-pink); }

/* ----- relic ----- */
.relic {
  width: 100%;
  max-width: var(--content-max);
  perspective: 1200px;
  margin: 0 auto;
}
.relic-frame {
  position: relative;
  background: rgba(42, 56, 40, 0.32);
  padding: 48px 40px 44px;
  color: var(--vintage-gold);
  transform: rotateX(8deg) rotateY(-6deg) scale(0.96);
  transform-origin: center center;
  transition:
    transform 600ms cubic-bezier(.22,1,.36,1),
    box-shadow 600ms ease,
    --frame-irid-speed 600ms;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.45),
    inset 0 0 80px rgba(232, 160, 208, 0.04);
  isolation: isolate;
}
.relic.in-view .relic-frame {
  transform: rotateX(2deg) rotateY(-3deg) scale(1);
}
.relic:hover .relic-frame {
  transform: rotateX(0deg) rotateY(0deg) scale(1.02);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.55),
    inset 0 0 90px rgba(232, 160, 208, 0.08);
}

/* iridescent gradient border, animated */
.relic-frame::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  padding: 1.5px;
  background: linear-gradient(
    120deg,
    var(--fairy-pink),
    var(--fairy-teal),
    var(--prismatic-lilac),
    var(--vintage-gold),
    var(--fairy-pink)
  );
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: irid-shift var(--frame-irid-speed) linear infinite;
  pointer-events: none;
}
.relic:hover .relic-frame::before { animation-duration: var(--frame-irid-speed-hover); }
@keyframes irid-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.ornate-frame {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  pointer-events: none;
  color: var(--vintage-gold);
  opacity: 0.85;
}

.relic-illustration {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 28px;
  position: relative;
}
.relic-illustration svg { width: 100%; height: auto; display: block; }
.illust-glow { animation: illust-shimmer 9s ease-in-out infinite; transform-origin: center; }
@keyframes illust-shimmer {
  0%   { opacity: 0.7; transform: scale(1) rotate(0deg); }
  50%  { opacity: 1;   transform: scale(1.04) rotate(0.6deg); }
  100% { opacity: 0.7; transform: scale(1) rotate(0deg); }
}

.relic-content {
  position: relative;
  z-index: 1;
}
.relic-label {
  font-family: "Cinzel Decorative", serif;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--vintage-gold);
  margin: 0 0 10px;
  opacity: 0.85;
}
.relic-title {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.25;
  margin: 0 0 22px;
  color: var(--moth-cream);
  letter-spacing: 0.01em;
}
.relic-text {
  font-family: "Crimson Pro", serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.9;
  color: var(--moth-cream);
  margin: 0 0 22px;
  text-align: justify;
  hyphens: auto;
}
.relic-text::after { content: ""; display: block; clear: both; }
.relic-meta {
  font-family: "Crimson Pro", serif;
  font-weight: 300;
  font-style: italic;
  font-size: 13px;
  color: rgba(232, 160, 208, 0.75);
  margin: 0;
  letter-spacing: 0.02em;
}

/* ----- story interlude ----- */
.story-interlude {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 120px 24px;
  overflow: hidden;
}
.interlude-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  animation: interlude-fade 1500ms ease-out forwards;
  animation-play-state: paused;
}
.story-interlude.in-view .interlude-bg { animation-play-state: running; }
.interlude-bg svg { width: 100%; height: 100%; display: block; }
.interlude-bg svg g { animation: interlude-drift 16s ease-in-out infinite; transform-origin: center; }
@keyframes interlude-drift {
  0%   { transform: translateY(0)   rotate(0deg); }
  50%  { transform: translateY(-12px) rotate(0.5deg); }
  100% { transform: translateY(0)   rotate(0deg); }
}
@keyframes interlude-fade {
  to { opacity: 0.55; }
}
.interlude-text {
  position: relative;
  z-index: 1;
  font-family: "Cinzel", serif;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1.7;
  text-align: center;
  color: var(--moth-cream);
  max-width: 720px;
  letter-spacing: 0.02em;
  animation: interlude-text-drift 8s ease-in-out infinite;
  text-shadow: 0 0 24px rgba(26, 16, 40, 0.8);
}
@keyframes interlude-text-drift {
  0%   { transform: translateY(-4px); }
  50%  { transform: translateY(6px); }
  100% { transform: translateY(-4px); }
}

/* ----- final enchantment ----- */
.final-enchantment {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 100px 24px 120px;
  position: relative;
}
.enchantment-glyph {
  display: flex;
  gap: clamp(20px, 4vw, 60px);
  margin-bottom: 50px;
  font-family: "Cinzel", serif;
}
.hanzi-large {
  font-size: clamp(80px, 14vw, 180px);
  color: var(--fairy-teal);
  text-shadow:
    0 0 28px rgba(128, 216, 200, 0.55),
    0 0 60px rgba(184, 136, 216, 0.35);
  animation: hanzi-pulse 4200ms ease-in-out infinite;
}
.hanzi-mao { animation-delay: 0ms; color: var(--fairy-pink); text-shadow: 0 0 28px rgba(232, 160, 208, 0.55), 0 0 60px rgba(184, 136, 216, 0.35); }
.hanzi-dun { animation-delay: 400ms; }
@keyframes hanzi-pulse {
  0%   { transform: translateY(-6px) scale(1); opacity: 0.9; }
  50%  { transform: translateY(6px)  scale(1.02); opacity: 1; }
  100% { transform: translateY(-6px) scale(1); opacity: 0.9; }
}
.enchantment-text {
  font-family: "Crimson Pro", serif;
  font-style: italic;
  font-size: clamp(17px, 1.6vw, 21px);
  color: var(--moth-cream);
  max-width: 580px;
  line-height: 1.85;
  margin: 0 0 18px;
}
.hanzi-inline {
  font-style: normal;
  color: var(--fairy-teal);
  letter-spacing: 0.05em;
}
.enchantment-sub {
  font-family: "Cinzel Decorative", serif;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--vintage-gold);
  opacity: 0.9;
  margin: 18px 0 0;
}

/* ----- colophon ----- */
.colophon {
  text-align: center;
  padding: 60px 24px 100px;
  color: rgba(245, 240, 224, 0.7);
}
.colophon-rule {
  font-family: "Cinzel Decorative", serif;
  letter-spacing: 0.6em;
  color: var(--vintage-gold);
  margin: 0 0 26px;
  opacity: 0.85;
  font-size: 16px;
}
.colophon-line {
  font-family: "Crimson Pro", serif;
  font-style: italic;
  font-weight: 300;
  font-size: 14px;
  margin: 6px 0;
  letter-spacing: 0.04em;
}
.colophon-line .bullet { color: var(--vintage-gold); margin: 0 6px; }

/* ----- responsive ----- */
@media (max-width: 600px) {
  .compass { top: 18px; right: 18px; width: 52px; height: 52px; }
  .radial-nav { top: 44px; right: 44px; }
  .radial-nav.is-open .radial-link {
    transform:
      translate(
        calc(cos((var(--ang) - 90) * 1deg) * 100px),
        calc(sin((var(--ang) - 90) * 1deg) * 100px)
      ) scale(0.92);
  }
  .relic-frame { padding: 36px 24px 30px; }
  .relic-illustration { max-width: 220px; }
  .gateway { padding: 60px 18px 80px; }
  .relic-gallery { padding: 40px 16px 60px; gap: 60px; }
  .gallery-preamble { font-size: 17px; }
  .relic-text { font-size: 16px; text-align: left; }
  .interlude-text { font-size: 19px; line-height: 1.7; }
}

/* ----- reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .kinetic-letter { opacity: 1; transform: none; }
  .gateway-eyebrow, .gateway-translation, .gateway-tagline, .scroll-indicator { opacity: 1; }
  .relic-frame { transform: none; }
  .compass { transform: scale(1) rotate(0deg); opacity: 1; }
}
