/* ═══════════════════════════════════════════════════════════
   COSMIC HORROR EFFECTS
   Subtle Lovecraftian aesthetics, non-Euclidean geometry
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────── */
/* COSMIC VOID BACKGROUND */
/* ─────────────────────────────────────────────────────────── */

.cosmic-void {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    display: none;
}

/* Enable subtle void on reading page with depth layers */
.reading .cosmic-void {
    display: block;
    opacity: 0.2;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(94, 234, 212, 0.02) 0%, transparent 30%),
        radial-gradient(ellipse at 70% 60%, rgba(94, 234, 212, 0.015) 0%, transparent 25%),
        radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
    animation: void-breathe 20s ease-in-out infinite;
}

/* Enable cosmic void on landing page */
.landing .cosmic-void {
    display: block;
    opacity: 0.25;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(94, 234, 212, 0.02) 0%, transparent 30%),
        radial-gradient(ellipse at 70% 60%, rgba(94, 234, 212, 0.015) 0%, transparent 25%),
        radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
    animation: void-breathe 20s ease-in-out infinite;
}

@keyframes void-breathe {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 0.25;
    }
}

#void-canvas {
    width: 100%;
    height: 100%;
}

/* ─────────────────────────────────────────────────────────── */
/* NON-EUCLIDEAN GEOMETRY PATTERNS */
/* ─────────────────────────────────────────────────────────── */

/* Impossible Triangle Divider */
.divider-cosmic::before,
.divider-cosmic::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-cosmic);
    transform: rotate(45deg);
}

.divider-cosmic::before {
    left: -30px;
    top: -9px;
}

.divider-cosmic::after {
    right: -30px;
    top: -9px;
}

/* Warlock Sigil Animation */
.warlock-sigil {
    animation: cosmic-breathe 4s ease-in-out infinite;
    /* Remove white background artifacts from PNG */
    mix-blend-mode: screen;
}

@keyframes cosmic-breathe {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(94, 234, 212, 0.2));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(94, 234, 212, 0.4)) drop-shadow(0 0 45px rgba(94, 234, 212, 0.2));
        transform: scale(1.03);
    }
}

/* Penrose-inspired Chapter Icons */
.chapter-icon {
    display: inline-block;
    position: relative;
    transition: color 0.2s ease;
}

/* Removed rotation effect - too distracting for reading interface */
.chapter-item:hover .chapter-icon {
    color: var(--accent-void);
}

/* ─────────────────────────────────────────────────────────── */
/* VOID PARTICLE EFFECTS */
/* ─────────────────────────────────────────────────────────── */

/* Subtle floating particles */
.landing-container::before,
.landing-container::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--accent-cosmic);
    border-radius: 50%;
    opacity: 0.6;
    animation: float-particle 20s ease-in-out infinite;
}

.landing-container::before {
    top: 20%;
    left: 10%;
    animation-delay: -5s;
}

.landing-container::after {
    top: 60%;
    right: 15%;
    animation-delay: -10s;
}

@keyframes float-particle {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
    25% {
        transform: translate(50px, -30px) scale(1.5);
        opacity: 0.8;
    }
    50% {
        transform: translate(-30px, 40px) scale(0.8);
        opacity: 0.4;
    }
    75% {
        transform: translate(40px, 20px) scale(1.2);
        opacity: 0.6;
    }
}

/* ─────────────────────────────────────────────────────────── */
/* REALITY DISTORTION EFFECTS */
/* ─────────────────────────────────────────────────────────── */

/* Removed text glow - keep reader interface clean */

.btn-portal {
    position: relative;
    overflow: hidden;
}

/* Portal shimmer effect */
.btn-portal::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: portal-shimmer 3s ease-in-out infinite;
}

@keyframes portal-shimmer {
    0%, 100% {
        transform: translateX(-100%) rotate(45deg);
    }
    50% {
        transform: translateX(100%) rotate(45deg);
    }
}

/* ─────────────────────────────────────────────────────────── */
/* COSMIC BORDER EFFECTS */
/* ─────────────────────────────────────────────────────────── */

.warning-box {
    position: relative;
    overflow: hidden;
}

/* Animated cosmic border */
.warning-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(94, 234, 212, 0.1),
        transparent
    );
    animation: cosmic-sweep 8s ease-in-out infinite;
}

@keyframes cosmic-sweep {
    0%, 100% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
}

/* ─────────────────────────────────────────────────────────── */
/* FEATURE CARDS GEOMETRY */
/* ─────────────────────────────────────────────────────────── */

.feature {
    position: relative;
    overflow: hidden;
}

/* Non-Euclidean corner accents */
.feature::before,
.feature::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 1px solid var(--accent-cosmic);
    opacity: 0.3;
    transition: all 0.3s ease;
}

.feature::before {
    top: -15px;
    left: -15px;
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
}

.feature::after {
    bottom: -15px;
    right: -15px;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.feature:hover::before,
.feature:hover::after {
    opacity: 1;
    transform: rotate(225deg);
}

/* Progress bar removed from interface - no longer needed */

/* Removed pulsing sidebar border - distracting during reading */

/* ─────────────────────────────────────────────────────────── */
/* CHAPTER TRANSITION EFFECTS */
/* ─────────────────────────────────────────────────────────── */

/* Removed old chapter-fade-in - replaced with reality-shift (see ATMOSPHERIC COSMIC HORROR section) */

/* ─────────────────────────────────────────────────────────── */
/* THEME TOGGLE COSMIC ROTATION */
/* ─────────────────────────────────────────────────────────── */

.btn-theme {
    position: relative;
    overflow: hidden;
}

.btn-theme::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(94, 234, 212, 0.3),
        transparent
    );
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.btn-theme:hover::before {
    width: 200%;
    height: 200%;
}

/* ─────────────────────────────────────────────────────────── */
/* COSMIC GLOW STATES */
/* ─────────────────────────────────────────────────────────── */

.btn-portal:active {
    animation: reality-breach 0.5s ease-out;
}

@keyframes reality-breach {
    0% {
        box-shadow: 0 4px 16px rgba(94, 234, 212, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(94, 234, 212, 0.8),
                    0 0 60px rgba(94, 234, 212, 0.6);
    }
    100% {
        box-shadow: 0 4px 16px rgba(94, 234, 212, 0.3);
    }
}

/* Removed decorative lines on headings - keep content clean for reading */

/* ─────────────────────────────────────────────────────────── */
/* ATMOSPHERIC COSMIC HORROR ENHANCEMENTS */
/* ─────────────────────────────────────────────────────────── */

/* Subtle void particles - reading page only */
.reading::before,
.reading::after {
    content: '';
    position: fixed;
    width: 3px;
    height: 3px;
    background: var(--accent-cosmic);
    border-radius: 50%;
    opacity: 0;
    animation: void-drift 40s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

.reading::before {
    top: 15%;
    left: 8%;
    animation-delay: -8s;
}

.reading::after {
    top: 65%;
    right: 12%;
    animation-delay: -20s;
}

@keyframes void-drift {
    0%, 100% {
        opacity: 0;
        transform: translate(0, 0) scale(0.8);
    }
    10% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.6;
        transform: translate(30px, -40px) scale(1.2);
    }
    90% {
        opacity: 0.3;
    }
}

/* Subtle text glow on chapter content headings */
.reading .chapter-content h2 {
    text-shadow: 0 0 20px rgba(94, 234, 212, 0.15);
}

.reading .chapter-content h3 {
    text-shadow: 0 0 15px rgba(94, 234, 212, 0.1);
}

/* Enhanced chapter transition with reality shift */
.chapter-content {
    animation: reality-shift 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes reality-shift {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
        filter: blur(4px);
    }
    50% {
        opacity: 0.5;
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}


/* Ambient cosmic glow pulse - very slow, barely perceptible */
.landing-container,
.reading .reader-container {
    position: relative;
}

.landing .landing-container::after,
.reading .reader-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    background: radial-gradient(
        circle at center,
        rgba(94, 234, 212, 0.03) 0%,
        transparent 50%
    );
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    animation: ambient-pulse 12s ease-in-out infinite;
}

@keyframes ambient-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.95);
    }
    50% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Cosmic glow on chapter navigation hover */
.reading .chapter-item:hover .chapter-icon {
    filter: drop-shadow(0 0 8px rgba(94, 234, 212, 0.6));
    animation: cosmic-pulse 2s ease-in-out infinite;
}

@keyframes cosmic-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(94, 234, 212, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(94, 234, 212, 0.8));
    }
}

/* ─────────────────────────────────────────────────────────── */
/* LIGHT MODE ADJUSTMENTS */
/* ─────────────────────────────────────────────────────────── */

.light-mode .cosmic-void {
    opacity: 0.05;
}

.light-mode .warlock-sigil {
    filter: drop-shadow(0 0 20px rgba(20, 184, 166, 0.2));
    mix-blend-mode: multiply;
}

.light-mode .progress-bar {
    box-shadow: 0 0 6px rgba(20, 184, 166, 0.3);
}

/* Disable atmospheric effects in light mode */
.light-mode.reading::before,
.light-mode.reading::after {
    display: none;
}

.light-mode.reading .reader-main::before,
.light-mode.reading .reader-main::after {
    opacity: 0;
}

.light-mode.reading .chapter-content h2,
.light-mode.reading .chapter-content h3 {
    text-shadow: none;
}

.light-mode.reading body::before {
    display: none;
}

.light-mode .landing-container::after,
.light-mode.reading .reader-container::before {
    display: none;
}

/* Disable landing page overlays in light mode */
.light-mode.landing body::before {
    display: none;
}

.light-mode.landing .landing-content::before,
.light-mode.landing .landing-content::after {
    opacity: 0;
}

/* ─────────────────────────────────────────────────────────── */
/* LOVECRAFTIAN ATMOSPHERIC TOUCHES */
/* ─────────────────────────────────────────────────────────── */

/* Subtle non-Euclidean geometry hint - very slow shift */
.landing .cosmic-void::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    border: 1px solid rgba(94, 234, 212, 0.03);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    pointer-events: none;
    z-index: 1;
    animation: non-euclidean-drift 60s linear infinite;
}

@keyframes non-euclidean-drift {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
        border-radius: 50%;
    }
    25% {
        transform: translate(-48%, -52%) rotate(90deg) scale(1.05);
        border-radius: 48% 52% 50% 50%;
    }
    50% {
        transform: translate(-50%, -50%) rotate(180deg) scale(0.95);
        border-radius: 50% 50% 48% 52%;
    }
    75% {
        transform: translate(-52%, -48%) rotate(270deg) scale(1.02);
        border-radius: 52% 48% 50% 50%;
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg) scale(1);
        border-radius: 50%;
    }
}

/* Subtle reality distortion on hover - warlock sigil */
.warlock-sigil:hover {
    animation: reality-distort 0.6s ease-in-out;
}

@keyframes reality-distort {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(94, 234, 212, 0.2));
        transform: scale(1) skewX(0deg);
    }
    25% {
        filter: drop-shadow(0 0 25px rgba(94, 234, 212, 0.4)) hue-rotate(5deg);
        transform: scale(1.02) skewX(1deg);
    }
    75% {
        filter: drop-shadow(0 0 25px rgba(94, 234, 212, 0.4)) hue-rotate(-5deg);
        transform: scale(1.02) skewX(-1deg);
    }
}

/* Impossible geometry accent on chapter items */
.chapter-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 0%;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(94, 234, 212, 0.3),
        transparent
    );
    transform: translateY(-50%);
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-item:hover::before {
    height: 100%;
}

/* Very subtle text distortion on headings - barely perceptible */
.landing-header h1,
.reading .chapter-content h1 {
    text-shadow:
        0 0 20px rgba(94, 234, 212, 0.1),
        1px 1px 0 rgba(94, 234, 212, 0.05),
        -1px -1px 0 rgba(94, 234, 212, 0.05);
    animation: text-breathe 8s ease-in-out infinite;
}

@keyframes text-breathe {
    0%, 100% {
        text-shadow:
            0 0 20px rgba(94, 234, 212, 0.1),
            1px 1px 0 rgba(94, 234, 212, 0.05),
            -1px -1px 0 rgba(94, 234, 212, 0.05);
    }
    50% {
        text-shadow:
            0 0 25px rgba(94, 234, 212, 0.15),
            1.5px 1.5px 0 rgba(94, 234, 212, 0.08),
            -1.5px -1.5px 0 rgba(94, 234, 212, 0.08);
    }
}

/* Disable Lovecraftian effects in light mode */
.light-mode .cosmic-void::before {
    display: none;
}

.light-mode .warlock-sigil:hover {
    animation: none;
}

.light-mode .landing-header h1,
.light-mode.reading .chapter-content h1 {
    animation: none;
    text-shadow: none;
}

/* ─────────────────────────────────────────────────────────── */
/* REDUCED MOTION */
/* ─────────────────────────────────────────────────────────── */

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

    .cosmic-void {
        display: none;
    }
}
