/* ================================================
   Dai Jun Showcase — Cosmic Ink Theme
   ================================================ */

:root {
    --bg-abyss: #030310;
    --bg-deep: #0a0a1f;
    --bg-mid: #12102e;
    --gold: #c9a96e;
    --gold-bright: #e0c990;
    --cream: #f0e6d3;
    --cream-white: #faf5ec;
    --lavender: #b4a0d2;
    --deep-purple: #2d1b69;
    --ink-blue: #1a1a4e;
    --font-display: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-abyss);
    cursor: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Noise Overlay ---- */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.025;
    pointer-events: none;
    z-index: 9990;
}

/* ---- Custom Cursor ---- */
#cursor-ring {
    position: fixed;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--gold);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10001;
    transform: translate(-50%, -50%);
    transition: width 0.25s ease, height 0.25s ease, border-color 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    mix-blend-mode: difference;
}

#cursor-ring.visible {
    opacity: 0.6;
}

#cursor-ring.hovering {
    width: 56px;
    height: 56px;
    border-color: var(--gold-bright);
    opacity: 0.9;
}

#cursor-dot {
    position: fixed;
    width: 5px;
    height: 5px;
    background: var(--cream);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10002;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#cursor-dot.visible {
    opacity: 1;
}

/* ---- Loading Screen ---- */
#loader {
    position: fixed;
    inset: 0;
    background: var(--bg-abyss);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loader-visual {
    position: relative;
    width: 100px;
    height: 100px;
}

.loader-ring-outer {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-top-color: var(--gold);
    border-right-color: rgba(201, 169, 110, 0.3);
    border-radius: 50%;
    animation: spin-cw 2s linear infinite;
}

.loader-ring-inner {
    position: absolute;
    inset: 15px;
    border: 1.5px solid transparent;
    border-bottom-color: var(--lavender);
    border-left-color: rgba(180, 160, 210, 0.3);
    border-radius: 50%;
    animation: spin-ccw 1.4s linear infinite;
}

.loader-ink-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ink-pulse 2.2s ease-in-out infinite;
}

.loader-label {
    margin-top: 32px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 6px;
    color: rgba(201, 169, 110, 0.5);
    animation: breathe 2.2s ease-in-out infinite;
}

@keyframes spin-cw {
    to { transform: rotate(360deg); }
}

@keyframes spin-ccw {
    to { transform: rotate(-360deg); }
}

@keyframes ink-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
    50% { transform: translate(-50%, -50%) scale(2.2); opacity: 0.15; }
}

@keyframes breathe {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.75; }
}

/* ---- Canvas ---- */
#main-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ---- Name Reveal Overlay ---- */
#name-reveal {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

#name-text {
    font-family: var(--font-display);
    font-size: clamp(48px, 11vw, 180px);
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1;
    color: transparent;
    -webkit-text-stroke: 2px var(--gold);
    position: relative;
    white-space: nowrap;
    /* Dynamic background for text fill — animated gradient */
    background: linear-gradient(
        135deg,
        var(--cream) 0%,
        var(--gold-bright) 25%,
        var(--cream-white) 50%,
        var(--lavender) 75%,
        var(--cream) 100%
    );
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
}

/* Individual letters */
.letter {
    display: inline-block;
    opacity: 0;
    filter: blur(14px);
    transform: translateY(60px) scale(0.7);
    will-change: opacity, filter, transform, color, -webkit-text-stroke, text-shadow;
    transition: text-shadow 1.5s ease;
    position: relative;
}

.letter.revealed {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
    text-shadow:
        0 0 20px rgba(201, 169, 110, 0.6),
        0 0 40px rgba(201, 169, 110, 0.3),
        0 0 80px rgba(201, 169, 110, 0.15),
        0 0 120px rgba(140, 120, 180, 0.1),
        0 0 200px rgba(140, 120, 180, 0.05);
}

.letter.glow-active {
    animation: letter-glow 3s ease-in-out infinite;
}

.letter.glow-active.revealed {
    animation: letter-glow 3s ease-in-out infinite, gradient-shift 8s ease-in-out infinite;
}

.letter-space {
    display: inline-block;
    width: 0.3em;
}

/* Divider */
.name-divider {
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin-top: clamp(16px, 3vw, 32px);
    opacity: 0;
    transition: width 2s ease, opacity 1.5s ease;
}

.name-divider.visible {
    width: clamp(120px, 25vw, 320px);
    opacity: 0.5;
}

/* Subtitle */
#subtitle {
    font-family: var(--font-body);
    font-size: clamp(12px, 2vw, 20px);
    font-weight: 300;
    letter-spacing: 4px;
    color: rgba(201, 169, 110, 0.55);
    margin-top: clamp(12px, 2vw, 24px);
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

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

/* Ornament Lines */
.ornament-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201, 169, 110, 0.25), transparent);
    opacity: 0;
    transition: opacity 2s ease, width 2s ease;
}

.ornament-left {
    top: 50%;
    right: calc(50% + clamp(120px, 18vw, 320px));
    width: 0;
    transform: translateY(-0.5px);
}

.ornament-right {
    top: 50%;
    left: calc(50% + clamp(120px, 18vw, 320px));
    width: 0;
    transform: translateY(-0.5px);
}

.ornament-line.visible {
    opacity: 1;
    width: clamp(40px, 10vw, 120px);
}

/* Letter Glow Animation — enhanced multi-layer */
@keyframes letter-glow {
    0%, 100% {
        text-shadow:
            0 0 20px rgba(201, 169, 110, 0.6),
            0 0 40px rgba(201, 169, 110, 0.3),
            0 0 80px rgba(201, 169, 110, 0.15),
            0 0 120px rgba(140, 120, 180, 0.1),
            0 0 200px rgba(140, 120, 180, 0.05);
    }
    50% {
        text-shadow:
            0 0 30px rgba(201, 169, 110, 0.8),
            0 0 60px rgba(201, 169, 110, 0.45),
            0 0 100px rgba(201, 169, 110, 0.25),
            0 0 160px rgba(140, 120, 180, 0.18),
            0 0 260px rgba(140, 120, 180, 0.08);
    }
}

/* Gradient shift for text background */
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}



/* ---- Vignette ---- */
.vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(3, 3, 16, 0.35) 75%,
        rgba(3, 3, 16, 0.7) 100%
    );
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 3s ease;
}

.vignette.visible {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    #name-text {
        letter-spacing: 0.03em;
    }
    .letter-space {
        width: 0.2em;
    }
    #subtitle {
        letter-spacing: 2px;
        font-size: 12px;
    }
    #cursor-ring, #cursor-dot {
        display: none;
    }
    html, body {
        cursor: auto;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- SVG Defs (hidden) ---- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}
