/**
 * Secure PDF Flipbook Reader — Animation Design System
 * 
 * Hardware-accelerated keyframe layouts for loaders, pulses, card errors,
 * padlock unlocking, and amber light sweeps.
 */

/* 1. Shimmering Skeleton Loader Effect */
.loading-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f1f5f9;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.idle-placeholder {
    background-color: #1e293b;
    opacity: 0.8;
}

.skeleton-shimmer {
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.45) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.8s infinite;
    z-index: 1;
}

.idle-placeholder .skeleton-shimmer {
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0) 100%
    );
}

.skeleton-icon {
    font-size: 2.5rem;
    z-index: 2;
    opacity: 0.35;
    animation: bounceSlow 2.5s infinite ease-in-out;
}

@keyframes shimmer {
    0% { left: -150%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

@keyframes bounceSlow {
    0%, 100% { transform: translateY(0) scale(1.0); }
    50% { transform: translateY(-8px) scale(1.05); }
}

/* 2. Main App Loader Ring Spinner */
#app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #090d16;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#app-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.spinner-ring {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.spinner-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 64px;
    height: 64px;
    margin: 8px;
    border: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spinnerRotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--accent-color) transparent transparent transparent;
}

.spinner-ring div:nth-child(1) { animation-delay: -0.45s; }
.spinner-ring div:nth-child(2) { animation-delay: -0.3s; }
.spinner-ring div:nth-child(3) { animation-delay: -0.15s; }

@keyframes spinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-message {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.loader-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-retry {
    margin-top: 1.5rem;
    padding: 0.6rem 1.25rem;
    background-color: var(--accent-color);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.4);
    transition: all 0.25s ease;
}

.btn-retry:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.6);
}

/* 3. Login Dialogue Shakes (Error Feedback) */
@keyframes shakeCard {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-8px); }
    30%, 60% { transform: translateX(8px); }
}

.shake-card {
    animation: shakeCard 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* 4. Gold Light Sweep Animation across Book on Success */
@keyframes lightSweep {
    0% {
        left: -120%;
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    80% {
        opacity: 0.6;
    }
    100% {
        left: 220%;
        opacity: 0;
    }
}

.sweep-active::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -120%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(217, 119, 6, 0.45) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-30deg);
    animation: lightSweep 1.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    z-index: 60;
    pointer-events: none;
}

/* 5. Security Pulse Alerts & WhatsApp Glows */
@keyframes alertPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 0 0 5px rgba(217, 119, 6, 0.5);
    }
    50% {
        transform: scale(1.1);
        text-shadow: 0 0 15px rgba(217, 119, 6, 0.9);
    }
}

@keyframes whatsappPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(34, 197, 94, 0));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.5));
    }
}

.forgot-password-link .whatsapp-icon {
    animation: whatsappPulse 3s infinite ease-in-out;
}

.security-overlay {
    animation: overlayFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(12px);
    }
}

#book-container::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    background: radial-gradient(circle, rgba(217, 119, 6, 0.04) 0%, rgba(0, 0, 0, 0) 75%);
    pointer-events: none;
    z-index: 1;
    border-radius: 50%;
    opacity: 0.8;
}
