/* CLS Prevention Styles */

.site-main {
    min-height: 100vh;
    width: 100%;
    contain: layout style;
    overflow: visible;
}

/* Services Section - Fix Layout Shift */
.services-section {
    min-height: 500px;
    width: 100%;
    position: relative;
    contain: layout style;
}

/* Top Bar Contact - Fix Layout Shift */
.top-bar-contact {
    min-height: 60px;
    height: auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
}

.top-bar-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    position: relative;
}

/* Contact Items - Fix Layout Shift */
.contact-item {
    width: auto;
    min-width: 150px;
    height: auto;
    min-height: 50px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* Font Loading CLS Prevention */
.contact-label,
.contact-value,
.brand-name,
.brand-tagline,
.menu-text,
.countdown-timer,
.announcement-badge strong {
    max-width: 100%;
    display: block;
    white-space: nowrap;
    overflow: visible;
    text-overflow: ellipsis;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .top-bar-contact {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        width: 100%;
    }

    .contact-item {
        min-width: auto;
        flex: 0 1 auto;
        margin: 0 5px;
    }

    .top-bar-inner {
        flex-direction: column;
        align-items: center;
    }

    .announcement-badge {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }
}

/* Ensure Content Width Containment */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Additional fixes for countdown and header spacing to avoid CLS */
.top-bar {
    min-height: var(--topbar-height, 60px);
}

.top-bar-inner {
    min-height: var(--topbar-height, 60px);
}

.announcement-badge {
    min-width: 280px;
    max-width: 100%;
}

.countdown-timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 120px; /* reserve space while numbers load */
}

#countdownText {
    display: inline-block;
    min-width: 120px; /* reserve width for final time text (increased to avoid shifts) */
    text-align: center;
    /* use tabular-nums so digits don't reflow when font changes */
    font-variant-numeric: tabular-nums;
    -webkit-font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Ensure contact icons and items have fixed visual sizes */
.contact-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

/* Keep header height stable; main margin-top will be set by JS as a backup */
#site-header {
    box-sizing: border-box;
}

/* Default reserved header height (used immediately on first paint to avoid jump).
   JS will overwrite --site-header-height with the real measured value when available. */
:root {
    --site-header-height: 107px; /* tuned to measured header height to avoid first-paint jump */
}

/* Fixed margin-top for main content */
main.site-main, 
.site-main {
    margin-top: 1px !important;
}

/* Breakpoint-specific defaults to further reduce jumps on first paint */
@media (max-width: 480px) {
    :root { --site-header-height: 107px; }
    .announcement-badge { min-width: 180px; }
    .countdown-timer { min-width: 100px; }
}

@media (min-width: 481px) and (max-width: 1023px) {
    :root { --site-header-height: 107px; }
}

@media (min-width: 1024px) {
    :root { --site-header-height: 107px; }
}

@media (max-width: 768px) {
    .announcement-badge { min-width: 200px; }
    .countdown-timer { min-width: 100px; }
}