/* =====================================================
   CRITICAL LOADING STYLES - Prevent FOUC
   ===================================================== */

/* Hide content until styles load to prevent flash */
.featured-tours-section {
    opacity: 0;
    transition: opacity var(--motion-base) ease;
}

.featured-tours-section.loaded {
    opacity: 1;
}

/* Loading skeleton for featured tours */
.featured-tours-loading {
    display: flex;
    gap: 1.5rem;
    padding: 2rem 0;
    justify-content: center;
}

.skeleton-card {
    width: 320px;
    height: 240px;
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border-color) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-lg);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Ensure header and hero load first */
.getyourguide-header,
.hero-section {
    position: relative;
    z-index: 1000;
}

/* Prevent layout shift */
.tour-card-skeleton {
    min-height: 350px;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

/* Critical sections stay visible */
.getyourguide-header,
.hero-section,
.search-section {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Homepage: reserve vertical space before JS hydrates (PSI CLS — reviews/blog modules) */
#homepageReviews {
    min-height: 760px;
    contain: layout style;
}
#homepageBlog {
    min-height: 920px;
    contain: layout style;
}

/* Hero shell: CLS reserve before hero-premium hydrates.
   :not(.hero-premium) covers both empty div AND pre-hydration H1 placeholder. */
#heroSection:not(:has(.hero-premium)) {
    min-height: 700px;
}
#heroSection:empty {
    min-height: 700px;
}
@media (max-width: 768px) {
    #heroSection:not(:has(.hero-premium)) {
        min-height: 320px;
        max-height: 380px;
    }
    #heroSection:empty {
        min-height: 320px;
        max-height: 380px;
    }
}

/* SSR first hero slide — replaced on hydrate; reserve box to limit CLS */
#heroSection > .ssr-hero-lcp {
    display: block;
    width: 100%;
    max-height: min(70vh, 640px);
    overflow: hidden;
    margin: 0;
    background: #1a1a1a;
}
#heroSection > .ssr-hero-lcp .ssr-hero-lcp__img {
    width: 100%;
    height: auto;
    aspect-ratio: 1920 / 600;
    object-fit: cover;
    display: block;
    vertical-align: middle;
}
@media (max-width: 768px) {
    #heroSection > .ssr-hero-lcp {
        max-height: 380px;
    }
}
.ssr-hero-placeholder {
    padding: 0.75rem 1.25rem 1rem;
    max-width: 52rem;
}

/* Featured tours + categories: moderate reserve to limit CLS when modules hydrate */
#featuredTours {
    min-height: 260px;
}
@media (min-width: 769px) {
    #featuredTours {
        min-height: 420px;
    }
}

#tourCategories {
    min-height: 180px;
}
@media (min-width: 769px) {
    #tourCategories {
        min-height: 240px;
    }
}

/* About block — align with index placeholder */
#homepageAbout {
    min-height: 300px;
}