/* =========================================================
   CINEMATIC SPLIT PRELOADER (FINAL REVISED)
   ========================================================= */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0f1720; /* Background Gelap */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Efek tirai naik saat selesai */
    transition: transform 1s cubic-bezier(0.77, 0, 0.175, 1);
}

/* Container Teks & Gambar */
.split-text-container {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; 
}

/* Teks ADIMARA STUDIO */
.brand-text {
    font-family: var(--font-heading, serif);
    font-size: clamp(2rem, 5vw, 4rem); /* Responsif besar */
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: 2px;
    z-index: 2;
}

/* Jendela Gambar di Tengah */
.reveal-window {
    width: 0; /* Mulai dari tertutup */
    height: clamp(2rem, 5vw, 4rem); /* Tinggi menyesuaikan teks */
    overflow: hidden;
    margin: 0;
    opacity: 0;
    
    /* Animasi Loop: Buka - Tahan - Tutup */
    animation: splitReveal 4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.reveal-window img {
    height: 100%;
    width: 90px; /* Base width */
    min-width: 90px;
    object-fit: cover;
    filter: sepia(20%) contrast(1.1);
}

/* Loading Footer (Bawah) */
.loader-footer {
    position: absolute;
    bottom: 50px;
    width: 100%;
    text-align: center;
}

.loader-bar-bg {
    width: 200px;
    height: 2px;
    background: rgba(255,255,255,0.1);
    margin: 0 auto 10px;
    border-radius: 2px;
    overflow: hidden;
}

.loader-bar-fill {
    width: 0%;
    height: 100%;
    background: #B39A6A; /* Warna Emas */
    animation: fillBar 3.8s linear infinite; /* Sinkron dengan durasi split */
}

.loader-percent {
    font-family: var(--font-body, sans-serif);
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.5);
    animation: blinkText 1s infinite alternate;
}

/* Class saat preloader selesai (JS adds this class) */
body.loaded #preloader {
    transform: translateY(-100%); 
}

/* ===============================
   KEYFRAMES ANIMATION
   =============================== */

@keyframes splitReveal {
    0%, 15% { 
        width: 0; 
        opacity: 0; 
        margin: 0;
    }
    35%, 75% { 
        width: 90px; 
        opacity: 1;
        margin-left: 10px; 
        margin-right: 2px; 
    }
    90%, 100% { 
        width: 0; 
        opacity: 0; 
        margin: 0;
    }
}

@keyframes fillBar {
    0% { width: 0%; }
    100% { width: 100%; }
}

@keyframes blinkText {
    from { opacity: 0.3; }
    to { opacity: 0.8; }
}

/* ===============================
   HURUF 'A' YANG HILANG & MUNCUL
   =============================== */
.magic-a {
    display: inline-block; 
    overflow: hidden;
    vertical-align: bottom; 
    animation: vanishLetter 4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes vanishLetter {
    0%, 15% {
        opacity: 1;
        width: 0.8em; 
        transform: scale(1);
    }
    30% {
        opacity: 0;
        width: 0; 
        transform: scale(0);
    }
    35%, 75% {
        opacity: 0;
        width: 0; 
        transform: scale(0);
        margin: 0;
    }
    90%, 100% {
        opacity: 1;
        width: 0.8em;
        transform: scale(1);
    }
}

/* =========================================================
   RESPONSIVE MOBILE FIX (LOGO MEPET & RAPAT)
   ========================================================= */

@media (max-width: 768px) {
    
    /* 1. Atur Wrapper Utama */
    #preloader {
        padding: 0 5%;
    }

    /* 2. Container Teks & Logo */
    .split-text-container {
        width: 100%;
        display: flex;
        flex-direction: row; 
        align-items: center;
        justify-content: center;
        flex-wrap: nowrap; 
        gap: 0; /* Pastikan gap container 0 */
    }

    /* 3. Kecilkan Teks agar muat */
    .brand-text {
        font-size: clamp(1.4rem, 5vw, 2rem); /* Sedikit diperbesar agar imbang */
        letter-spacing: 0.5px; /* Spacing dirapatkan */
        white-space: nowrap; 
    }

    /* 4. Fix Window Logo */
    .reveal-window {
        height: clamp(30px, 8vw, 50px);
        flex-shrink: 0; 
        /* Margin dihapus di sini, diatur via animasi */
    }

    /* 5. Fix Gambar Logo */
    .reveal-window img {
        width: 100%;
        height: 100%;
        min-width: unset; 
        object-fit: contain; 
        transform: scale(1.1); /* Zoom dikit biar logo makin mengisi ruang */
    }
    
    /* 6. ANIMASI KHUSUS MOBILE (DIBUAT MEPET) */
    @keyframes splitReveal {
        0%, 15% { 
            width: 0; 
            opacity: 0; 
            margin: 0;
        }
        35%, 75% { 
            /* REVISI PENTING DI SINI: */
            /* Lebar dikurangi drastis (misal 40px) agar teks kiri-kanan nempel */
            width: 40px; 
            opacity: 1;
            /* Margin dinolkan atau sangat tipis */
            margin-left: 2px; 
            margin-right: 2px;
        }
        90%, 100% { 
            width: 0; 
            opacity: 0; 
            margin: 0;
        }
    }

    /* Loader Percentage di bawah */
    .loader-footer {
        bottom: 40px; /* Naikkan sedikit */
        width: 90%;
    }
}

/* Khusus HP Sangat Kecil (iPhone SE / Galaxy Fold Cover) */
@media (max-width: 360px) {
    .brand-text {
        font-size: 1.1rem;
    }
    /* Logo makin kecil dan rapat */
    @keyframes splitReveal {
        35%, 75% { width: 32px; margin-left: 2px; margin-right: 0; }
    }
}