/* Layout Fix CSS - Prevents Cumulative Layout Shift (CLS) */

/* Root variables for consistent spacing */
:root {
    --nav-height-mobile: 70px;
    --nav-height-desktop: 120px;
    --nav-height-scrolled: 80px;
    --nav-transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Prevent layout shifts during page load */
html {
    scroll-behavior: smooth;
}

body {
    /* Reserve space for navigation immediately */
    padding-top: var(--nav-height-desktop);
    transition: var(--nav-transition);
    /* Prevent horizontal scrolling that can cause shifts */
    overflow-x: hidden;
}

/* Mobile navigation spacing */
@media (max-width: 768px) {
    body {
        padding-top: 200px;
    }
}

/* Navigation component fixes */
nav-bar {
    /* Ensure nav bar takes up consistent space */
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    /* Reserve minimum height to prevent shifts */
    min-height: var(--nav-height-desktop);
    transition: var(--nav-transition);
}

@media (max-width: 768px) {
    nav-bar {
        min-height: var(--nav-height-mobile);
    }
}

/* Skeleton loaders to prevent content shifts */
.skeleton {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Auth status skeleton */
.auth-skeleton {
    width: 120px;
    height: 40px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
}

/* Game card skeleton */
.game-skeleton {
    width: 280px;
    height: 80px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
}

/* Only target very specific images that need layout shift protection */
.testimonial-image-container img,
.team-photo {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Navigation logo only */
nav-bar .logo img {
    width: auto;
    height: auto;
    max-width: 100%;
    transition: var(--nav-transition);
}

/* Prevent font loading from causing shifts */
@font-face {
    font-display: swap;
}

/* Smooth transitions for dynamic content */
.fade-in {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-in.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Prevent scroll-based layout shifts */
.scroll-transition {
    transition: var(--nav-transition);
}

/* Container width fixes to prevent horizontal shifts */
.container, .team-container {
    max-width: 100%;
    box-sizing: border-box;
    /* overflow-x: hidden; */
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
    /* Prevent mobile orientation changes from causing shifts */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        min-height: 100vh;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix mobile navigation issues */
    nav-bar {
        min-height: var(--nav-height-mobile);
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }
    
    /* Ensure mobile menu doesn't cause shifts */
    #mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    #mobile-menu.show {
        transform: translateX(0);
    }
    
    /* Simplified mobile fixes */
    body {
        padding-top: 230px !important;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Loading states */
.loading-placeholder {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.loading-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: skeleton-loading 1.5s infinite;
}

/* Prevent table content from causing shifts */
.roster-table {
    table-layout: fixed;
    width: 100%;
}

/* Improve roster column widths */
.roster-table th.numeric-col,
.roster-table td.numeric-col {
    width: 50px; /* Compact numeric columns */
}

/* Allow player name column to expand */
.roster-table th:first-child,
.roster-table td:first-child {
    width: auto;
}

/* Fix for Vue.js cloak to prevent template flashing */
[v-cloak] {
    display: none !important;
}

/* Optimized image loading */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

/* Prevent form elements from causing shifts */
input, select, textarea, button {
    box-sizing: border-box;
}

/* Stable grid layouts */
.grid-container {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Prevent flex container shifts */
.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.flex-container > * {
    flex: 1 1 auto;
    min-width: 0;
}