/**
 * Magical Splash Screen – GSAP-powered cinematic intro
 * Supports fullscreen (preloader) and inline (footer widget) modes
 */

/* ============================================
   BASE CONTAINER
   ============================================ */
.magical-splash {
    position: relative;
    overflow: hidden;
    font-family: 'Amiri', 'Tajawal', serif;
    direction: rtl;
    -webkit-user-select: none;
    user-select: none;
}

.magical-splash--fullscreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease-in-out, visibility 0.6s ease-in-out;
}

.magical-splash--fullscreen[style*="display: none"],
.magical-splash--fullscreen[style*="opacity: 0"],
.magical-splash[style*="display: none"],
.magical-splash[style*="pointer-events: none"] {
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    display: none !important;
}

.magical-splash--inline {
    width: 100%;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}

/* ============================================
   BACKGROUND LAYERS
   ============================================ */
.ms-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.ms-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(197, 160, 89, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
        linear-gradient(160deg, #1a0f0a 0%, #2c1810 30%, #1e1215 60%, #0f172a 100%);
}

.ms-noise {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    pointer-events: none;
}

/* ============================================
   FLOATING ORBS
   ============================================ */
.ms-orbs {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.ms-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0;
    will-change: transform, opacity;
}

.ms-orb--1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(197, 160, 89, 0.4) 0%, transparent 70%);
    top: -80px;
    right: -60px;
}

.ms-orb--2 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, transparent 70%);
    bottom: -60px;
    left: -40px;
}

.ms-orb--3 {
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.2) 0%, transparent 70%);
    top: 40%;
    left: 20%;
}

.ms-orb--4 {
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.25) 0%, transparent 70%);
    bottom: 30%;
    right: 15%;
}

/* ============================================
   STARS CANVAS
   ============================================ */
.ms-stars-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* ============================================
   CENTRAL CONTENT
   ============================================ */
.ms-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

/* ============================================
   RING SYSTEM
   ============================================ */
.ms-rings {
    position: absolute;
    width: 260px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-ring {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.ms-ring--outer {
    width: 240px;
    height: 240px;
}

.ms-ring--outer svg {
    width: 100%;
    height: 100%;
}

.ms-ring--inner {
    width: 180px;
    height: 180px;
}

.ms-ring--inner svg {
    width: 100%;
    height: 100%;
}

.ms-ring--accent {
    width: 280px;
    height: 280px;
}

.ms-ring--accent svg {
    width: 100%;
    height: 100%;
}

/* ============================================
   LOGO
   ============================================ */
.ms-logo-wrap {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
}

.ms-logo {
    position: relative;
    z-index: 5;
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(197, 160, 89, 0.5));
    will-change: transform;
}

.ms-logo-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(197, 160, 89, 0.35) 0%, transparent 70%);
    z-index: 1;
    opacity: 0;
    will-change: transform, opacity;
}

.ms-logo-glow--secondary {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
    inset: -30px;
    z-index: 0;
}

/* ============================================
   SPARKLES
   ============================================ */
.ms-sparkles {
    position: absolute;
    width: 300px;
    height: 300px;
    z-index: 6;
    pointer-events: none;
}

.ms-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 6px 2px rgba(255, 215, 0, 0.6);
    opacity: 0;
    will-change: transform, opacity;
}

/* ============================================
   TEXT
   ============================================ */
.ms-text {
    text-align: center;
    margin-top: 2rem;
    z-index: 10;
}

.ms-title {
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    font-weight: 700;
    color: transparent;
    background: linear-gradient(135deg, #ffd700 0%, #c5a059 40%, #fff8dc 60%, #c5a059 100%);
    -webkit-background-clip: text;
    background-clip: text;
    letter-spacing: 2px;
    margin: 0;
    line-height: 1.4;
    overflow: hidden;
}

.ms-title-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px) rotateX(90deg);
    will-change: transform, opacity;
}

.ms-subtitle {
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: rgba(197, 160, 89, 0.7);
    letter-spacing: 3px;
    margin: 0.5rem 0 0;
    opacity: 0;
    transform: translateY(15px);
    will-change: transform, opacity;
}

/* ============================================
   CRESCENT MOON
   ============================================ */
.ms-crescent {
    position: absolute;
    top: -30px;
    right: -40px;
    width: 60px;
    height: 60px;
    opacity: 0;
    transform: rotate(-20deg) scale(0.5);
    will-change: transform, opacity;
}

.ms-crescent svg {
    width: 100%;
    height: 100%;
}

/* ============================================
   LIGHT BEAMS
   ============================================ */
.ms-beams {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.ms-beam {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 0;
    opacity: 0;
    will-change: transform, opacity, height;
}

.ms-beam--1 {
    background: linear-gradient(to bottom, transparent, rgba(197, 160, 89, 0.3), transparent);
    transform: translate(-50%, -50%) rotate(25deg);
}

.ms-beam--2 {
    background: linear-gradient(to bottom, transparent, rgba(16, 185, 129, 0.2), transparent);
    transform: translate(-50%, -50%) rotate(-35deg);
}

.ms-beam--3 {
    background: linear-gradient(to bottom, transparent, rgba(255, 215, 0, 0.15), transparent);
    transform: translate(-50%, -50%) rotate(70deg);
}

.ms-beam--4 {
    background: linear-gradient(to bottom, transparent, rgba(197, 160, 89, 0.1), transparent);
    transform: translate(-50%, -50%) rotate(-60deg);
}

/* ============================================
   INLINE MODE OVERRIDES
   ============================================ */
.magical-splash--inline .ms-rings {
    width: 160px;
    height: 160px;
}

.magical-splash--inline .ms-ring--outer {
    width: 150px;
    height: 150px;
}

.magical-splash--inline .ms-ring--inner {
    width: 110px;
    height: 110px;
}

.magical-splash--inline .ms-ring--accent {
    width: 170px;
    height: 170px;
}

.magical-splash--inline .ms-logo-wrap {
    width: 100px;
    height: 100px;
}

.magical-splash--inline .ms-logo {
    width: 70px;
    height: 70px;
}

.magical-splash--inline .ms-orb {
    filter: blur(40px);
}

.magical-splash--inline .ms-orb--1 { width: 150px; height: 150px; }
.magical-splash--inline .ms-orb--2 { width: 120px; height: 120px; }
.magical-splash--inline .ms-orb--3 { width: 100px; height: 100px; }
.magical-splash--inline .ms-orb--4 { width: 80px; height: 80px; }

.magical-splash--inline .ms-crescent {
    top: -15px;
    right: -20px;
    width: 35px;
    height: 35px;
}

.magical-splash--inline .ms-sparkles {
    width: 180px;
    height: 180px;
}

.magical-splash--inline .ms-beams {
    display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .ms-rings {
        width: 200px;
        height: 200px;
    }

    .ms-ring--outer { width: 190px; height: 190px; }
    .ms-ring--inner { width: 140px; height: 140px; }
    .ms-ring--accent { width: 220px; height: 220px; }

    .ms-logo-wrap {
        width: 120px;
        height: 120px;
    }

    .ms-logo {
        width: 90px;
        height: 90px;
    }
}

@media (max-width: 480px) {
    .ms-rings {
        width: 160px;
        height: 160px;
    }

    .ms-ring--outer { width: 150px; height: 150px; }
    .ms-ring--inner { width: 110px; height: 110px; }
    .ms-ring--accent { width: 180px; height: 180px; }

    .ms-logo-wrap {
        width: 100px;
        height: 100px;
    }

    .ms-logo {
        width: 70px;
        height: 70px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .magical-splash * {
        animation: none !important;
        transition: none !important;
    }

    .ms-logo-wrap {
        opacity: 1 !important;
        transform: none !important;
    }

    .ms-title-char {
        opacity: 1 !important;
        transform: none !important;
    }

    .ms-subtitle {
        opacity: 1 !important;
        transform: none !important;
    }

    .ms-ring {
        opacity: 0.5 !important;
    }
}
