/* Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    pointer-events: none;
}

/* Loader Halves */
.loader-half {
    width: 50%;
    height: 100%;
    background-color: #050505;
    /* Deep black */
    position: relative;
    transition: transform 1.5s cubic-bezier(0.8, 0, 0.2, 1);
    /* Dramatic ease */
    will-change: transform;
    overflow: hidden;
}

/* Cyber Grid Background Pattern */
.loader-half::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    /* Ensure coverage */
    height: 100%;
    background-image:
        linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
}

/* Left Half */
.loader-half.left {
    border-right: 1px solid rgba(0, 243, 255, 0.3);
    /* Cyan split line */
    box-shadow: inset -5px 0 20px rgba(0, 243, 255, 0.1);
    /* Inner glow */
}

/* Right Half */
.loader-half.right {
    border-left: 1px solid rgba(0, 243, 255, 0.3);
    /* Cyan split line */
    box-shadow: inset 5px 0 20px rgba(0, 243, 255, 0.1);
    /* Inner glow */
}

/* Animation State: Active */
.loader-overlay.active {
    pointer-events: auto;
}

/* Animation State: Loaded (Split) */
.loader-overlay.loaded .loader-half.left {
    transform: translateX(-100%);
}

.loader-overlay.loaded .loader-half.right {
    transform: translateX(100%);
}

.loader-overlay.loaded {
    transition: opacity 0.5s ease 1.5s, visibility 0s linear 2s;
    opacity: 0;
    visibility: hidden;
}

/* Content inside loader */
.loader-text {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10000;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    opacity: 1;
    transition: opacity 0.3s ease;
    text-shadow: 0 0 15px rgba(0, 243, 255, 0.6);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* Position text relative to the split line */
.loader-half.left .loader-text {
    right: 0;
    padding-right: 15px;
}

.loader-half.right .loader-text {
    left: 0;
    padding-left: 15px;
}

.loader-text .highlight {
    color: #00f3ff;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.9);
}

/* Glitch/Scanline Effect on Text */
.loader-text::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(transparent 50%, rgba(0, 243, 255, 0.05) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    animation: scanline 4s linear infinite;
}

@keyframes scanline {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 100%;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .loader-text {
        font-size: 1.5rem;
        letter-spacing: 0.1em;
    }

    .loader-half.left .loader-text {
        padding-right: 10px;
    }

    .loader-half.right .loader-text {
        padding-left: 10px;
    }

    .loader-half::before {
        background-size: 20px 20px;
    }
}