/* ============================================
   PRELOADER â€” Animated loading screen
   Shows "My Forte" with staggered letter reveal
   and a smooth progress bar before site loads
   ============================================ */

.preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader__inner {
    text-align: center;
    width: 100%;
    padding: 0 var(--space-md);
}

/* ---- Animated Letters ---- */
.preloader__logo {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(2.5rem, 7vw, 4rem);
    margin-bottom: var(--space-xl);
    display: flex;
    justify-content: center;
    gap: 2px;
}

.preloader__letter {
    display: inline-block;
    background: linear-gradient(135deg, var(--purple-deep), var(--purple-vivid), var(--purple-glow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    animation: preloaderLetterIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Stagger each letter */
.preloader__letter:nth-child(1) {
    animation-delay: 0.1s;
}

.preloader__letter:nth-child(2) {
    animation-delay: 0.17s;
}

.preloader__letter:nth-child(3) {
    animation-delay: 0.24s;
}

.preloader__letter:nth-child(4) {
    animation-delay: 0.31s;
}

.preloader__letter:nth-child(5) {
    animation-delay: 0.38s;
}

.preloader__letter:nth-child(6) {
    animation-delay: 0.45s;
}

.preloader__letter:nth-child(7) {
    animation-delay: 0.52s;
}

.preloader__letter:nth-child(8) {
    animation-delay: 0.59s;
}

@keyframes preloaderLetterIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
        filter: blur(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* ---- Pulse glow after letters appear ---- */
.preloader__logo {
    animation: preloaderPulse 2s ease-in-out 0.8s infinite;
}

@keyframes preloaderPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 0px transparent);
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.3));
    }
}

/* ---- Progress Bar ---- */
.preloader__bar {
    width: 180px;
    height: 3px;
    background: var(--border-default);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0 auto;
}

.preloader__bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--purple-deep), var(--purple-vivid), var(--purple-glow));
    border-radius: var(--radius-full);
    animation: preloaderProgress 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
}

@keyframes preloaderProgress {
    0% {
        width: 0%;
    }

    30% {
        width: 45%;
    }

    60% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .preloader__letter {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .preloader__logo {
        animation: none;
    }

    .preloader__bar-fill {
        width: 100%;
        animation: none;
    }
}