/* ==========================================================================
   mujun.works — Fairycore Enchanted Museum
   Colors: #1A1028, #E8A0D0, #80D8C8, #C8A848, #F5F0E0, #2A3828, #B888D8
   Fonts: Cinzel 700, Crimson Pro 400/300i, Cinzel Decorative 400
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #1A1028;
    color: #F5F0E0;
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(16px, 1.1vw, 18px);
    line-height: 1.9;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Particle Canvas (Global Background) --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* --- Compass Navigation --- */
.compass-nav {
    position: fixed;
    top: 28px;
    right: 28px;
    z-index: 1000;
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.compass-nav.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.compass-btn {
    width: 52px;
    height: 52px;
    background: rgba(26, 16, 40, 0.85);
    border: 1.5px solid #C8A848;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.compass-btn:hover {
    background: rgba(26, 16, 40, 0.95);
    border-color: #E8A0D0;
    box-shadow: 0 0 20px rgba(232, 160, 208, 0.3);
}

.compass-icon {
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.compass-nav.open .compass-icon {
    transform: rotate(45deg);
}

.radial-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.compass-nav.open .radial-menu {
    pointer-events: auto;
    opacity: 1;
}

.radial-link {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 32px;
    background: rgba(26, 16, 40, 0.92);
    border: 1px solid #C8A848;
    border-radius: 16px;
    color: #F5F0E0;
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, border-color 0.3s ease;
}

.compass-nav.open .radial-link {
    transform: translate(-50%, -50%) scale(1);
}

.compass-nav.open .radial-link:nth-child(1) { top: -70px; left: 0; transition-delay: 0.05s; }
.compass-nav.open .radial-link:nth-child(2) { top: -22px; left: -80px; transition-delay: 0.1s; }
.compass-nav.open .radial-link:nth-child(3) { top: 50px; left: -65px; transition-delay: 0.15s; }
.compass-nav.open .radial-link:nth-child(4) { top: 50px; left: 65px; transition-delay: 0.2s; }
.compass-nav.open .radial-link:nth-child(5) { top: -22px; left: 80px; transition-delay: 0.25s; }

.radial-link:hover {
    background: rgba(200, 168, 72, 0.2);
    border-color: #E8A0D0;
}

/* --- Typography --- */
.cinzel-decorative {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-weight: 400;
}

/* --- Enchanted Gateway --- */
.enchanted-gateway {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

.gateway-content {
    text-align: center;
    z-index: 2;
}

.kinetic-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 64px);
    letter-spacing: 0.02em;
    color: #F5F0E0;
    display: inline-flex;
    gap: 0;
}

.kinetic-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.kinetic-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.kinetic-title .letter.dot {
    color: #C8A848;
}

/* Kinetic oscillation per letter */
@keyframes letterFloat {
    0%, 100% { transform: translateY(-4px); }
    50% { transform: translateY(4px); }
}

.kinetic-title .letter.animate {
    animation: letterFloat 3s ease-in-out infinite;
}

.gateway-subtitle {
    color: #E8A0D0;
    font-size: clamp(14px, 1.5vw, 20px);
    letter-spacing: 0.08em;
    margin-top: 16px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease 2s, transform 1s ease 2s;
}

.gateway-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Scroll Indicator --- */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 1s ease 3s;
    z-index: 2;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-particle-trail {
    width: 2px;
    height: 60px;
    position: relative;
    overflow: hidden;
}

.scroll-particle-trail::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 2px;
    height: 20px;
    background: linear-gradient(to bottom, transparent, #E8A0D0, #80D8C8, transparent);
    border-radius: 1px;
    animation: scrollTrail 2s ease-in-out infinite;
}

@keyframes scrollTrail {
    0% { top: -20px; opacity: 0; }
    30% { opacity: 1; }
    70% { opacity: 1; }
    100% { top: 60px; opacity: 0; }
}

/* --- Relic Gallery --- */
.relic-gallery {
    position: relative;
    z-index: 1;
    padding: 80px 0;
}

/* --- Relic Cards --- */
.relic-card {
    max-width: 580px;
    margin: 0 auto 80px auto;
    padding: 0 20px;
    perspective: 1200px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.relic-card.in-view {
    opacity: 1;
    transform: translateY(0);
}

.ornate-frame {
    position: relative;
    transform: rotateX(2deg) rotateY(-3deg);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.6s ease;
    transform-style: preserve-3d;
    background: rgba(26, 16, 40, 0.6);
    border-radius: 4px;
    padding: 3px;
}

.ornate-frame::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 6px;
    background: linear-gradient(45deg, #E8A0D0, #80D8C8, #C8A848, #B888D8, #E8A0D0);
    background-size: 300% 300%;
    animation: iridescentBorder 20s linear infinite;
    z-index: -1;
    opacity: 0.6;
}

@keyframes iridescentBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.relic-card:hover .ornate-frame {
    transform: rotateX(0deg) rotateY(0deg) scale(1.02);
    box-shadow: 0 20px 60px rgba(232, 160, 208, 0.15), 0 0 40px rgba(128, 216, 200, 0.1);
}

.relic-card:hover .ornate-frame::before {
    animation-duration: 5s;
    opacity: 0.9;
}

.frame-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.relic-content {
    position: relative;
    padding: 40px 32px 36px;
    z-index: 1;
}

/* Relic Illustration (generative mini-scene placeholder rendered by canvas in JS) */
.relic-illustration {
    width: 100%;
    height: 160px;
    margin-bottom: 24px;
    border-radius: 2px;
    overflow: hidden;
    background: radial-gradient(ellipse at center, rgba(184, 136, 216, 0.15), rgba(26, 16, 40, 0.8));
    position: relative;
}

/* Drop Cap */
.drop-cap {
    float: left;
    font-size: 56px;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 4px;
    color: #C8A848;
    transition: transform 0.3s ease;
}

.relic-card:hover .drop-cap {
    transform: scale(1.1);
}

.relic-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(20px, 2.5vw, 28px);
    letter-spacing: 0.02em;
    color: #F5F0E0;
    margin-bottom: 12px;
}

.relic-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(16px, 1.1vw, 18px);
    line-height: 1.9;
    color: #F5F0E0;
    margin-bottom: 20px;
}

.relic-metadata {
    display: block;
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 13px;
    color: #B888D8;
    letter-spacing: 0.03em;
    clear: both;
}

/* --- Story Interludes --- */
.story-interlude {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
    margin: 40px 0;
}

.interlude-scene {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(42, 56, 40, 0.6), rgba(26, 16, 40, 0.95));
    z-index: 0;
}

.interlude-text-wrap {
    position: relative;
    z-index: 2;
    max-width: 480px;
    padding: 0 24px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

.story-interlude.in-view .interlude-text-wrap {
    opacity: 1;
    transform: translateY(0);
}

.interlude-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(18px, 1.4vw, 22px);
    line-height: 2;
    color: #F5F0E0;
    font-style: italic;
    animation: interludeDrift 8s ease-in-out infinite;
    animation-play-state: paused;
}

.story-interlude.in-view .interlude-text {
    animation-play-state: running;
}

@keyframes interludeDrift {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* --- Final Enchantment --- */
.final-enchantment {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

#final-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.final-content {
    position: relative;
    text-align: center;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.final-title {
    font-size: clamp(48px, 8vw, 120px);
    color: #C8A848;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1.5s ease, transform 1.5s ease;
    text-shadow: 0 0 40px rgba(200, 168, 72, 0.4), 0 0 80px rgba(232, 160, 208, 0.2);
}

.final-enchantment.in-view .final-title {
    opacity: 1;
    transform: scale(1);
}

.final-subtitle {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 13px;
    color: #B888D8;
    letter-spacing: 0.08em;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 1.5s ease 0.5s;
}

.final-enchantment.in-view .final-subtitle {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .relic-content {
        padding: 28px 20px 24px;
    }

    .drop-cap {
        font-size: 44px;
    }

    .compass-nav {
        top: 16px;
        right: 16px;
    }

    .compass-btn {
        width: 44px;
        height: 44px;
    }

    .radial-link {
        width: 76px;
        height: 28px;
        font-size: 10px;
    }

    .compass-nav.open .radial-link:nth-child(1) { top: -58px; left: 0; }
    .compass-nav.open .radial-link:nth-child(2) { top: -18px; left: -66px; }
    .compass-nav.open .radial-link:nth-child(3) { top: 42px; left: -54px; }
    .compass-nav.open .radial-link:nth-child(4) { top: 42px; left: 54px; }
    .compass-nav.open .radial-link:nth-child(5) { top: -18px; left: 66px; }

    .relic-card {
        margin-bottom: 60px;
    }

    .story-interlude {
        min-height: 80vh;
    }
}

/* --- Selection style --- */
::selection {
    background: rgba(232, 160, 208, 0.3);
    color: #F5F0E0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #1A1028;
}

::-webkit-scrollbar-thumb {
    background: #C8A848;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #E8A0D0;
}
