/* Graceful Loading Styles - Industry Standard Approach */
/* Progressive loading with skeleton screens and smooth transitions */

/* ========================================= */
/* INITIAL CRITICAL STYLES OVERRIDE */
/* ========================================= */

/* Override the inline CSS once external CSS loads */
body.css-loaded {
    opacity: 1;
}

/* Show hero background when ready (support image element or fallback div) */
.hero-bg-img.loaded,
.hero-background.ready,
.page-loaded .hero-bg-img,
.page-loaded .hero-background {
    opacity: 1 !important;
}

/* Show main content when ready */
.main-content.ready {
    visibility: visible;
}

/* Show content containers when ready */
.gallery-grid.ready {
    display: grid;
}

.menu-items.ready {
    display: block;
}

/* ========================================= */
/* PAGE LOADING OVERLAY */
/* ========================================= */

/* Initial loading state - content hidden until ready */
.page-loading .main-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Content ready state */
.page-loaded .main-content {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

/* Header loads first for immediate brand presence */
.header {
    opacity: 1;
    transform: none;
    transition: none;
}

/* ========================================= */
/* LOADING INDICATOR */
/* ========================================= */

.page-loading-indicator {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ========================================= */
/* SKELETON SCREENS */
/* ========================================= */

/* Base skeleton animation */
@keyframes skeleton-pulse {
    0% {
        background-color: #f0f0f0;
    }
    50% {
        background-color: #e0e0e0;
    }
    100% {
        background-color: #f0f0f0;
    }
}

.skeleton {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
    background-color: #f0f0f0;
}

/* Skeleton for hero section */
.skeleton-hero {
    height: 60vh;
    min-height: 400px;
    margin-bottom: 2rem;
    border-radius: 8px;
}

/* Skeleton for text content */
.skeleton-text {
    height: 1.2em;
    margin-bottom: 0.5em;
    border-radius: 3px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-text.long {
    width: 95%;
}

/* Skeleton for menu items */
.skeleton-menu-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    background-color: transparent;
}

.skeleton-menu-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    margin-right: 1rem;
    flex-shrink: 0;
}

.skeleton-menu-content {
    flex: 1;
}

.skeleton-menu-title {
    height: 1.4em;
    width: 70%;
    margin-bottom: 0.5rem;
}

.skeleton-menu-description {
    height: 1em;
    width: 90%;
    margin-bottom: 0.3rem;
}

.skeleton-menu-price {
    height: 1.2em;
    width: 40%;
}

/* ========================================= */
/* PROGRESSIVE DISCLOSURE */
/* ========================================= */

/* Content sections fade in progressively */
.content-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) var(--delay, 0s), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) var(--delay, 0s);
}

.content-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered delays for different sections */
.hero-section {
    --delay: 0.1s;
}

.about-section {
    --delay: 0.3s;
}

.menu-section {
    --delay: 0.5s;
}

.events-section {
    --delay: 0.7s;
}

.contact-section {
    --delay: 0.9s;
}

/* ========================================= */
/* SMOOTH IMAGE LOADING */
/* ========================================= */

/* Enhanced image loading with better transitions */
img {
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

img.loaded {
    opacity: 1;
}

/* Hero images get special treatment */
.hero img {
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1.05);
}

.hero img.loaded {
    transform: scale(1);
}

/* ========================================= */
/* NAVIGATION LOADING */
/* ========================================= */

/* Navigation items fade in individually */
.nav-menu li {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) var(--nav-delay, 0s),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) var(--nav-delay, 0s);
}

.nav-loaded .nav-menu li {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered navigation loading */
.nav-menu li:nth-child(1) { --nav-delay: 0.1s; }
.nav-menu li:nth-child(2) { --nav-delay: 0.2s; }
.nav-menu li:nth-child(3) { --nav-delay: 0.3s; }
.nav-menu li:nth-child(4) { --nav-delay: 0.4s; }
.nav-menu li:nth-child(5) { --nav-delay: 0.5s; }
.nav-menu li:nth-child(6) { --nav-delay: 0.6s; }

/* ========================================= */
/* LOADING STATES FOR INTERACTIVE ELEMENTS */
/* ========================================= */

/* Buttons start subtle and become prominent */
.btn {
    opacity: 0.7;
    transform: translateY(5px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-loaded .btn {
    opacity: 1;
    transform: translateY(0);
}

/* Form elements load gracefully */
.form-group {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1) var(--form-delay, 0s),
                transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) var(--form-delay, 0s);
}

.form-loaded .form-group {
    opacity: 1;
    transform: translateX(0);
}

.form-group:nth-child(1) { --form-delay: 0.1s; }
.form-group:nth-child(2) { --form-delay: 0.2s; }
.form-group:nth-child(3) { --form-delay: 0.3s; }

/* ========================================= */
/* PERFORMANCE OPTIMIZATIONS */
/* ========================================= */

/* Ensure smooth animations with hardware acceleration */
.content-section,
.nav-menu li,
.form-group,
img {
    will-change: opacity, transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Keep mascot animation always active */
.rooster-mascot-img {
    animation: float 3s ease-in-out infinite !important;
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .content-section,
    .nav-menu li,
    .form-group,
    img,
    .btn {
        transition: none;
        animation: none;
        transform: none;
    }
    
    /* Keep mascot animation even for reduced motion users (subtle) */
    .rooster-mascot-img {
        animation: float-subtle 4s ease-in-out infinite !important;
    }
    
    .skeleton {
        animation: none;
        background-color: #f0f0f0;
    }
}

/* Subtle version of float animation for reduced motion */
@keyframes float-subtle {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* ========================================= */
/* MOBILE OPTIMIZATIONS */
/* ========================================= */

@media (max-width: 768px) {
    /* Faster transitions on mobile for better performance */
    .content-section {
        transition-duration: 0.4s;
    }
    
    .nav-menu li {
        transition-duration: 0.3s;
    }
    
    /* Reduce transform amounts on mobile */
    .main-content {
        transform: translateY(10px);
    }
    
    .content-section {
        transform: translateY(15px);
    }
}

/* ========================================= */
/* ACCESSIBILITY ENHANCEMENTS */
/* ========================================= */

/* Ensure loading states are announced to screen readers */
.loading-state[aria-busy="true"]::after {
    content: "Loading content...";
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Focus management during loading */
.page-loading *:focus {
    outline: none;
}

.page-loaded *:focus {
    outline: 2px solid var(--accent-gold, #d4af37);
    outline-offset: 2px;
}
