/* Preloader Styles */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fff5f9, #fff);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-in-out;
    overflow: hidden;
}

.preloader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Book Container */
.book-container {
    position: relative;
    width: 200px;
    height: 150px;
    perspective: 1000px;
    margin-bottom: 30px;
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: bookFlip 4s ease-in-out infinite;
}

.book-cover {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('../IMAGES/candy-logo.jpeg');
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: left;
    backface-visibility: hidden;
}




/* Rotating Accessories */
.accessories {
    position: relative;
    width: 100px;
    height: 100px;
    animation: rotate 8s linear infinite;
    margin: 60px auto;
}

.accessory {
    position: absolute;
    width: 30px;
    height: 30px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.pencil {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="%23ff66b2" d="M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"/></svg>');
}

.ruler {
    top: 50%;
    right: -20px;
    transform: translateY(-50%);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="%239c27b0" d="M509.8 404.6L364.5 259.3l45.3-45.3c6.2-6.2 6.2-16.4 0-22.6L237.4 19c-6.2-6.2-16.4-6.2-22.6 0L167.5 66.3 22.2 221.6c-29.7 29.7-29.7 77.9 0 107.6l180.9 180.9c29.7 29.7 77.9 29.7 107.6 0l155.3-155.3 45.3-45.3c6.2-6.2 6.2-16.4 0-22.6z"/></svg>');
}

.book-open {
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="%23ff66b2" d="M542.2 237.5c-20.3-20.3-47.9-31.7-76.7-31.7h-225c-8.8 0-16 7.2-16 16v368c0 8.8 7.2 16 16 16h225c28.8 0 56.4-11.4 76.7-31.7 20.3-20.3 31.7-47.9 31.7-76.7v-183.9c.1-28.8-11.3-56.4-31.7-76.7zm-41.4 258.5c-10.2 10.2-23.9 15.9-38.3 15.9h-209v-336h209c14.4 0 28.1 5.7 38.3 15.9 10.2 10.2 15.9 23.9 15.9 38.3v183.9c0 14.4-5.7 28.1-15.9 38.3z"/></svg>');
}

.globe {
    top: 50%;
    left: -20px;
    transform: translateY(-50%);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="%239c27b0" d="M248 8C111.03 8 0 119.03 0 256s111.03 248 248 248 248-111.03 248-248S384.97 8 248 8zm160 215.5v6.93c0 5.87-3.32 11.24-8.57 13.86l-15.39 7.7a15.485 15.485 0 0 1-15.53-.97l-18.21-12.14a15.52 15.52 0 0 0-13.5-1.81l-2.65.88c-9.7 3.23-13.66 14.79-7.99 23.3l13.24 19.86c2.87 4.31 7.71 6.9 12.89 6.9h8.21c8.56 0 15.5 6.94 15.5 15.5v11.34c0 3.35-1.09 6.62-3.1 9.3l-18.74 24.98c-1.42 1.9-2.39 4.1-2.83 6.43l-4.3 22.83c-.62 3.29-2.29 6.29-4.76 8.56a159.608 159.608 0 0 0-25 29.16l-13.03 19.55a27.756 27.756 0 0 1-23.09 12.36c-10.51 0-20.12-5.94-24.82-15.34a78.902 78.902 0 0 1-8.33-35.29V367.5c0-8.56-6.94-15.5-15.5-15.5h-25.88c-14.49 0-28.38-5.76-38.63-16a54.659 54.659 0 0 1-16-38.63v-14.06c0-17.19 8.1-33.38 21.85-43.7l27.58-20.69a54.663 54.663 0 0 1 32.78-10.93h.89c8.48 0 16.85 1.97 24.43 5.77l14.72 7.36c3.68 1.84 7.93 2.14 11.83.84l47.31-15.77c6.33-2.11 10.6-8.03 10.6-14.7 0-8.56-6.94-15.5-15.5-15.5h-10.09c-4.11 0-8.05-1.63-10.96-4.54l-6.92-6.92a15.493 15.493 0 0 0-10.96-4.54H199.5c-8.56 0-15.5-6.94-15.5-15.5v-4.4c0-7.11 4.84-13.31 11.74-15.04l14.45-3.61c3.74-.94 7-3.23 9.14-6.44l8.08-12.11c2.87-4.31 7.71-6.9 12.89-6.9h24.21c8.56 0 15.5-6.94 15.5-15.5v-21.7C359.23 71.63 422.86 131.02 441.93 208H423.5c-8.56 0-15.5 6.94-15.5 15.5z"/></svg>');
}

/* Welcome Text */
.preloader-text {
    font-family: 'Dancing Script', cursive;
    font-size: 2.5rem;
    color: var(--primary-600);
    margin-top: 140px;
    text-align: center;
    opacity: 0;
    animation: fadeIn 1s ease-in forwards 0.5s;
    padding: 0 1rem;
}

/* Animations */
@keyframes bookFlip {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(-15deg); }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Media Queries */
@media (max-width: 768px) {
    .book-container {
        width: 150px;
        height: 120px;
        margin-bottom: 20px;
    }

    .accessories {
        width: 80px;
        height: 80px;
        top: 80px;
    }

    .accessory {
        width: 25px;
        height: 25px;
    }

    .pencil { top: -15px; }
    .ruler { right: -15px; }
    .book-open { bottom: -15px; }
    .globe { left: -15px; }

    .preloader-text {
        font-size: 1.8rem;
        padding: 0 1rem;
        margin-top: 190px;
    }
}

@media (max-width: 480px) {
    .book-container {
        width: 120px;
        height: 100px;
        margin-bottom: 15px;
    }

    .accessories {
        width: 60px;
        height: 60px;
        top: 60px;
    }

    .accessory {
        width: 20px;
        height: 20px;
    }

    .pencil { top: -12px; }
    .ruler { right: -12px; }
    .book-open { bottom: -12px; }
    .globe { left: -12px; }

    .preloader-text {
        font-size: 1.5rem;
        padding: 0 0.8rem;
        margin-top: 190px;
    }
}

@media (max-width: 360px) {
    .book-container {
        width: 100px;
        height: 80px;
        margin-bottom: 12px;
    }

    .accessories {
        width: 50px;
        height: 50px;
        top: 50px;
    }

    .accessory {
        width: 16px;
        height: 16px;
    }

    .pencil { top: -10px; }
    .ruler { right: -10px; }
    .book-open { bottom: -10px; }
    .globe { left: -10px; }

    .preloader-text {
        font-size: 1.3rem;
        padding: 0 0.5rem;
        margin-top: 190px;
    }
}
