/* ================================================================
   MYSTICAL TECH EFFECTS - AI Community Hub
   Matrix / Cyberpunk / Sci-Fi Dashboard aesthetic
   ================================================================ */

/* --- CSS Variables (mystical palette) --- */
:root {
    --mystical-bg: #02020a;
    --mystical-grid: rgba(0, 217, 146, 0.04);
    --mystical-grid-line: rgba(0, 217, 146, 0.06);
    --mystical-cyan: #00e5ff;
    --mystical-purple: #a855f7;
    --mystical-green: #00d992;
    --mystical-blue: #3b82f6;
    --neon-gradient: linear-gradient(90deg, var(--mystical-green), var(--mystical-cyan), var(--mystical-purple), var(--mystical-green));
}

/* --- Canvas Background (particles / data flow) --- */
#mystical-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.65;
}

/* --- Scanline Overlay --- */
.mystical-scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.mystical-scanlines::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 229, 255, 0.03) 50%,
        rgba(0, 229, 255, 0.06) 51%,
        transparent 100%
    );
    animation: scanline-sweep 6s linear infinite;
}

@keyframes scanline-sweep {
    0%   { top: -100%; }
    100% { top: 100%; }
}

/* Secondary slower scanline for depth */
.mystical-scanlines::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 200%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(168, 85, 247, 0.015) 50%,
        rgba(168, 85, 247, 0.03) 51%,
        transparent 100%
    );
    animation: scanline-sweep-slow 12s linear infinite;
}

@keyframes scanline-sweep-slow {
    0%   { top: -200%; }
    100% { top: 200%; }
}

/* --- Hex Grid Background Pattern --- */
.mystical-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--mystical-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--mystical-grid-line) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: grid-drift 20s linear infinite;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 80%);
}

@keyframes grid-drift {
    0%   { background-position: 0 0; }
    100% { background-position: 60px 60px; }
}

/* --- Mouse Glow Trail --- */
.mystical-mouse-glow {
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(
        circle,
        rgba(0, 229, 255, 0.06) 0%,
        rgba(0, 217, 146, 0.03) 40%,
        transparent 70%
    );
    transform: translate(-50%, -50%);
    transition: transform 0.12s ease-out, opacity 0.3s;
    animation: none;
}

/* --- Breathing Glow Effect --- */
@keyframes breathe-glow {
    0%, 100% {
        box-shadow:
            0 0 8px rgba(0, 229, 255, 0.2),
            0 0 20px rgba(0, 217, 146, 0.1),
            inset 0 0 8px rgba(0, 229, 255, 0.05);
        opacity: 0.85;
    }
    50% {
        box-shadow:
            0 0 16px rgba(0, 229, 255, 0.45),
            0 0 40px rgba(0, 217, 146, 0.2),
            0 0 60px rgba(168, 85, 247, 0.08),
            inset 0 0 12px rgba(0, 229, 255, 0.1);
        opacity: 1;
    }
}

@keyframes breathe-border {
    0%, 100% {
        border-color: rgba(0, 217, 146, 0.15);
        box-shadow: 0 0 8px rgba(0, 217, 146, 0.1);
    }
    50% {
        border-color: rgba(0, 229, 255, 0.35);
        box-shadow: 0 0 18px rgba(0, 229, 255, 0.2), 0 0 30px rgba(0, 217, 146, 0.1);
    }
}

.breathe-glow {
    animation: breathe-glow 3.5s ease-in-out infinite;
}

.breathe-border {
    animation: breathe-border 4s ease-in-out infinite;
}

/* Apply breathing glow to feature icons */
.feature-icon {
    animation: breathe-glow 3.5s ease-in-out infinite;
}

.feature-card:nth-child(1) .feature-icon { animation-delay: 0s; }
.feature-card:nth-child(2) .feature-icon { animation-delay: 0.6s; }
.feature-card:nth-child(3) .feature-icon { animation-delay: 1.2s; }
.feature-card:nth-child(4) .feature-icon { animation-delay: 1.8s; }
.feature-card:nth-child(5) .feature-icon { animation-delay: 2.4s; }
.feature-card:nth-child(6) .feature-icon { animation-delay: 3.0s; }

/* --- Neon Border Effect (flowing gradient) --- */
@keyframes neon-border-flow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.neon-border {
    position: relative;
    border: none !important;
}

.neon-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--neon-gradient);
    background-size: 300% 100%;
    animation: neon-border-flow 4s linear infinite;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.neon-border:hover::before,
.neon-border.active::before {
    opacity: 1;
}

/* Neon border on stat cards */
.stat-card {
    animation: breathe-border 4s ease-in-out infinite;
}

/* Nav logo breathing glow */
.nav-logo-icon {
    animation: breathe-glow 3s ease-in-out infinite;
}

/* --- Typewriter cursor blink --- */
.typewriter-cursor {
    display: inline-block;
    width: 3px;
    height: 0.9em;
    background: var(--mystical-cyan);
    margin-left: 3px;
    vertical-align: text-bottom;
    animation: cursor-blink 0.8s step-end infinite;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* --- Hero text glow on load --- */
.hero h1 .gradient-text {
    text-shadow: 0 0 40px rgba(0, 217, 146, 0.3);
    animation: text-glow-pulse 3s ease-in-out infinite;
}

@keyframes text-glow-pulse {
    0%, 100% { text-shadow: 0 0 40px rgba(0, 217, 146, 0.3); }
    50%       { text-shadow: 0 0 60px rgba(0, 229, 255, 0.5), 0 0 80px rgba(0, 217, 146, 0.3); }
}

/* --- Ambient corner accents --- */
.mystical-corner-tl,
.mystical-corner-br {
    position: fixed;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

.mystical-corner-tl {
    top: 0;
    left: 0;
    background:
        linear-gradient(135deg, rgba(0, 229, 255, 0.08) 0%, transparent 50%),
        linear-gradient(225deg, rgba(168, 85, 247, 0.04) 0%, transparent 50%);
    border-top: 1px solid rgba(0, 229, 255, 0.1);
    border-left: 1px solid rgba(0, 229, 255, 0.1);
}

.mystical-corner-br {
    bottom: 0;
    right: 0;
    background:
        linear-gradient(315deg, rgba(0, 217, 146, 0.08) 0%, transparent 50%),
        linear-gradient(45deg, rgba(168, 85, 247, 0.04) 0%, transparent 50%);
    border-bottom: 1px solid rgba(0, 217, 146, 0.1);
    border-right: 1px solid rgba(0, 217, 146, 0.1);
}

/* --- Ambient data stream decoration lines --- */
.mystical-data-stream {
    position: fixed;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.mystical-data-stream.top-stream {
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 229, 255, 0.6) 20%,
        rgba(0, 217, 146, 0.8) 50%,
        rgba(168, 85, 247, 0.6) 80%,
        transparent 100%
    );
    animation: data-stream-h 8s linear infinite;
    opacity: 0.5;
}

@keyframes data-stream-h {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.mystical-data-stream.left-stream {
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 217, 146, 0.5) 30%,
        rgba(0, 229, 255, 0.7) 60%,
        transparent 100%
    );
    animation: data-stream-v 12s linear infinite;
    opacity: 0.4;
}

@keyframes data-stream-v {
    0%   { transform: translateY(-100%); opacity: 0; }
    10%  { opacity: 0.4; }
    90%  { opacity: 0.4; }
    100% { transform: translateY(100%); opacity: 0; }
}

/* --- Glow pulse on badge --- */
.hero-badge {
    animation: breathe-border 3s ease-in-out infinite;
}

/* --- Card subtle inner glow on hover --- */
.article-card::after,
.feature-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
    background: radial-gradient(
        circle at 50% 0%,
        rgba(0, 229, 255, 0.06) 0%,
        transparent 60%
    );
    pointer-events: none;
}

.article-card:hover::after,
.feature-card:hover::after {
    opacity: 1;
}

.article-card,
.feature-card {
    position: relative;
    overflow: hidden;
}

/* --- Responsive: reduce effects on mobile --- */
@media (max-width: 768px) {
    #mystical-canvas {
        opacity: 0.25;
    }
    .mystical-scanlines::before {
        animation-duration: 10s;
    }
    .mystical-grid-bg {
        background-size: 40px 40px;
    }
    .mystical-data-stream {
        display: none;
    }
    .mystical-mouse-glow {
        display: none;
    }
}
