/**
 * CLS (Cumulative Layout Shift) Prevention CSS
 * 
 * Critical fixes to prevent layout shifts across all templates
 * Adds explicit dimensions, min-heights, and aspect-ratios
 * 
 * @package Israel_News_Theme
 * @since 1.0.0
 */

/* ==========================================
   CRITICAL: Single Post Featured Image CLS Prevention
   Fixes 0.125 CLS from featured media loading
   ========================================== */

/* Featured image container - MINIMAL CLS prevention (no visual changes) */
.news-featured-media {
    position: relative !important;
    contain: layout style !important;
    /* Desktop: larger min-height to prevent collapse */
    min-height: 300px !important;
}

.news-featured-image-wrapper {
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    /* Desktop: NO aspect-ratio - let image use natural dimensions */
    /* Desktop: larger min-height for typical image sizes */
    min-height: 300px !important;
    /* Transparent background - only shows during loading, invisible after */
    background: transparent !important;
    contain: layout style paint !important;
}

.news-featured-image {
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Prevent image shift during load - no visual changes */
.news-featured-image-wrapper picture,
.news-featured-image-wrapper img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
}

/* Image overlay - fixed positioning to prevent shift */
.image-overlay {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    contain: layout style !important;
}

/* Mobile-specific - MINIMAL changes (preserve original design) */
@media (max-width: 768px) {
    .news-featured-media {
        /* Very small min-height - just prevents collapse */
        min-height: 200px !important;
    }
    
    .news-featured-image-wrapper {
        /* Keep original aspect ratio - use actual image dimensions */
        aspect-ratio: var(--featured-mobile-aspect, 16/9) !important;
        /* Small min-height - won't force images taller */
        min-height: 200px !important;
        /* Transparent - no visual change */
        background: transparent !important;
    }
}

/* Desktop override: single.php sets mobile aspect-ratio globally - disable on desktop */
@media (min-width: 769px) {
    body.single-post .news-featured-image-wrapper {
        aspect-ratio: auto !important;
        --featured-mobile-aspect: unset !important;
    }
}

/* Tablet specific - minimal */
@media (min-width: 769px) and (max-width: 1024px) {
    .news-featured-media {
        min-height: 200px !important;
    }
    
    .news-featured-image-wrapper {
        min-height: 200px !important;
    }
}

/* ==========================================
   CRITICAL: Content Container Min-Heights
   Prevents shifts during JS content loading
   ========================================== */

/* ==========================================
   UNIVERSAL: All Elementor Shortcode Containers
   Fixes CLS for ALL pages using shortcodes in Elementor
   ========================================== */

/* CRITICAL: Elementor shortcode wrapper - prevents collapse */
.elementor-widget-shortcode,
.elementor-shortcode,
.e-con-inner,
.e-con {
    min-height: 800px !important;
    position: relative !important;
    contain: layout style !important;
}

/* CRITICAL: Specific fixes for lake-kinerret-water-level page */
body[class*="kinneret"] .elementor-widget-shortcode,
body[class*="kinneret"] .elementor-shortcode,
body[class*="kinneret"] .e-con-inner,
body[class*="kinneret"] .e-con,
body[class*="water-level"] .elementor-widget-shortcode,
body[class*="water-level"] .elementor-shortcode,
body[class*="water-level"] .e-con-inner,
body[class*="water-level"] .e-con {
    min-height: 1600px !important; /* Taller for water level page with charts */
}

/* CRITICAL: Specific fixes for israel-partnerships-directory page */
body[class*="partnerships"] .elementor-widget-shortcode,
body[class*="partnerships"] .elementor-shortcode,
body[class*="partnerships"] .e-con-inner,
body[class*="partnerships"] .e-con {
    min-height: 1500px !important; /* Taller for directory with filters and grid */
}

/* CRITICAL: Elementor Container Wrapping Directory Pages */
/* This fixes the 0.578 CLS issue on directory pages */
/* Target specific directory pages by URL/slug */
body[class*="honorary-consuls"] .elementor-widget-shortcode,
body[class*="honorary-consuls"] .elementor-shortcode,
body[class*="honorary-consuls"] .e-con-inner,
body[class*="honorary-consuls"] .e-con,
body[class*="companies"] .elementor-widget-shortcode,
body[class*="companies"] .elementor-shortcode,
body[class*="companies"] .e-con-inner,
body[class*="companies"] .e-con,
body[class*="cryptocurrency"] .elementor-widget-shortcode,
body[class*="cryptocurrency"] .elementor-shortcode,
body[class*="cryptocurrency"] .e-con-inner,
body[class*="cryptocurrency"] .e-con,
body[class*="banks"] .elementor-widget-shortcode,
body[class*="banks"] .elementor-shortcode,
body[class*="banks"] .e-con-inner,
body[class*="banks"] .e-con,
body[class*="beach"] .elementor-widget-shortcode,
body[class*="beach"] .elementor-shortcode,
body[class*="beach"] .e-con-inner,
body[class*="beach"] .e-con,
body[class*="driving-school"] .elementor-widget-shortcode,
body[class*="driving-school"] .elementor-shortcode,
body[class*="driving-school"] .e-con-inner,
body[class*="driving-school"] .e-con,
body[class*="circumciser"] .elementor-widget-shortcode,
body[class*="circumciser"] .elementor-shortcode,
body[class*="circumciser"] .e-con-inner,
body[class*="circumciser"] .e-con,
body[class*="shabbat"] .elementor-widget-shortcode,
body[class*="shabbat"] .elementor-shortcode,
body[class*="shabbat"] .e-con-inner,
body[class*="shabbat"] .e-con,
body[class*="press-release"] .elementor-widget-shortcode,
body[class*="press-release"] .elementor-shortcode,
body[class*="press-release"] .e-con-inner,
body[class*="press-release"] .e-con,
body[class*="public-benefit"] .elementor-widget-shortcode,
body[class*="public-benefit"] .elementor-shortcode,
body[class*="public-benefit"] .e-con-inner,
body[class*="public-benefit"] .e-con,
body[class*="flight-board"] .elementor-widget-shortcode,
body[class*="flight-board"] .elementor-shortcode,
body[class*="flight-board"] .e-con-inner,
body[class*="flight-board"] .e-con,
body[class*="currency-exchange"] .elementor-widget-shortcode,
body[class*="currency-exchange"] .elementor-shortcode,
body[class*="currency-exchange"] .e-con-inner,
body[class*="currency-exchange"] .e-con {
    min-height: 1400px !important; /* Prevent collapse of Elementor containers */
}

/* Mobile - smaller min-height */
@media (max-width: 768px) {
    /* Universal mobile fix */
    .elementor-widget-shortcode,
    .elementor-shortcode,
    .e-con-inner,
    .e-con {
        min-height: 1000px !important;
    }
    
    /* Specific mobile fixes */
    body[class*="kinneret"] .elementor-widget-shortcode,
    body[class*="kinneret"] .elementor-shortcode,
    body[class*="kinneret"] .e-con-inner,
    body[class*="kinneret"] .e-con,
    body[class*="water-level"] .elementor-widget-shortcode,
    body[class*="water-level"] .elementor-shortcode,
    body[class*="water-level"] .e-con-inner,
    body[class*="water-level"] .e-con {
        min-height: 1400px !important;
    }
    
    body[class*="partnerships"] .elementor-widget-shortcode,
    body[class*="partnerships"] .elementor-shortcode,
    body[class*="partnerships"] .e-con-inner,
    body[class*="partnerships"] .e-con {
        min-height: 1300px !important;
    }
    
    body[class*="honorary-consuls"] .elementor-widget-shortcode,
    body[class*="honorary-consuls"] .elementor-shortcode,
    body[class*="honorary-consuls"] .e-con-inner,
    body[class*="honorary-consuls"] .e-con,
    body[class*="companies"] .elementor-widget-shortcode,
    body[class*="companies"] .elementor-shortcode,
    body[class*="companies"] .e-con-inner,
    body[class*="companies"] .e-con,
    body[class*="cryptocurrency"] .elementor-widget-shortcode,
    body[class*="cryptocurrency"] .elementor-shortcode,
    body[class*="cryptocurrency"] .e-con-inner,
    body[class*="cryptocurrency"] .e-con,
    body[class*="banks"] .elementor-widget-shortcode,
    body[class*="banks"] .elementor-shortcode,
    body[class*="banks"] .e-con-inner,
    body[class*="banks"] .e-con,
    body[class*="beach"] .elementor-widget-shortcode,
    body[class*="beach"] .elementor-shortcode,
    body[class*="beach"] .e-con-inner,
    body[class*="beach"] .e-con,
    body[class*="driving-school"] .elementor-widget-shortcode,
    body[class*="driving-school"] .elementor-shortcode,
    body[class*="driving-school"] .e-con-inner,
    body[class*="driving-school"] .e-con,
    body[class*="circumciser"] .elementor-widget-shortcode,
    body[class*="circumciser"] .elementor-shortcode,
    body[class*="circumciser"] .e-con-inner,
    body[class*="circumciser"] .e-con,
    body[class*="shabbat"] .elementor-widget-shortcode,
    body[class*="shabbat"] .elementor-shortcode,
    body[class*="shabbat"] .e-con-inner,
    body[class*="shabbat"] .e-con,
    body[class*="press-release"] .elementor-widget-shortcode,
    body[class*="press-release"] .elementor-shortcode,
    body[class*="press-release"] .e-con-inner,
    body[class*="press-release"] .e-con,
    body[class*="public-benefit"] .elementor-widget-shortcode,
    body[class*="public-benefit"] .elementor-shortcode,
    body[class*="public-benefit"] .e-con-inner,
    body[class*="public-benefit"] .e-con,
    body[class*="flight-board"] .elementor-widget-shortcode,
    body[class*="flight-board"] .elementor-shortcode,
    body[class*="flight-board"] .e-con-inner,
    body[class*="flight-board"] .e-con,
    body[class*="currency-exchange"] .elementor-widget-shortcode,
    body[class*="currency-exchange"] .elementor-shortcode,
    body[class*="currency-exchange"] .e-con-inner,
    body[class*="currency-exchange"] .e-con {
        min-height: 1200px !important;
    }
}

/* Directory Page Containers */
#contentContainer {
    min-height: 800px;
    background: transparent;
    transition: min-height 0.3s ease;
}

#contentContainer.loaded {
    min-height: auto; /* Remove once content is loaded */
}

/* ==========================================
   CRITICAL: Lake Kinneret Water Level Page
   Specific fixes for dynamic content areas
   ========================================== */

/* Main container for water level page */
.lake-kinerret-water-level-page-container,
main:has(#live-level-value) {
    min-height: 1600px !important;
}

/* Live level section - reserve space */
.live-level {
    min-height: 100px !important;
}

.live-level-info {
    min-height: 150px !important;
}

.live-level-value {
    min-height: 80px !important;
    display: flex !important;
    align-items: center !important;
}

.live-level-bar {
    min-height: 30px !important;
    width: 100% !important;
}

.live-level-bar-inner {
    min-height: 30px !important;
    transition: width 0.3s ease !important;
}

/* Chart placeholder - reserve space */
#chart-placeholder,
.chart-responsive {
    min-height: 400px !important;
}

#levelChart {
    min-height: 400px !important;
}

/* Table container - reserve space */
#history-table {
    min-height: 500px !important;
}

#history-table tbody {
    min-height: 400px !important;
}

.table-controls {
    min-height: 80px !important;
}

/* Mobile water level page */
@media (max-width: 768px) {
    .lake-kinerret-water-level-page-container,
    main:has(#live-level-value) {
        min-height: 1400px !important;
    }
    
    .live-level {
        min-height: 250px !important;
    }
    
    #chart-placeholder,
    .chart-responsive {
        min-height: 350px !important;
    }
    
    #history-table {
        min-height: 400px !important;
    }
}

/* ==========================================
   DESKTOP ONLY: Archive Page CLS Prevention
   Fixes 0.017 CLS on archive.php for desktop
   ========================================== */

@media (min-width: 769px) {
    /* Main archive page container - prevent layout shift */
    .israel-archive-page {
        min-height: 1200px !important;
        contain: layout style !important;
    }
    
    /* Archive header - reserve space */
    .israel-archive-header {
        min-height: 120px !important;
        contain: layout !important;
    }
    
    /* Archive title wrapper */
    .israel-archive-title-wrap {
        min-height: 80px !important;
    }
    
    /* Archive hero section */
    .israel-archive-hero,
    .israel-archive-hero-inner {
        min-height: 400px !important;
    }
    
    /* Archive dynamic layouts section */
    .israel-archive-dynamic-layouts {
        min-height: 600px !important;
    }
    
    /* Latest coverage section */
    .israel-archive-latest-coverage,
    .breaking-archive__list {
        min-height: 800px !important;
    }
    
    /* Bootstrap container - prevent shift on desktop */
    .container {
        min-height: 80px !important;
        contain: layout style !important;
    }
    
    /* Header section containers */
    .header_section_wrapper {
        min-height: 90px !important;
        contain: layout !important;
    }
    
    .header-section {
        min-height: 70px !important;
    }
    
    /* Navigation section - prevent menu shift */
    .navigation-section {
        min-height: 50px !important;
        contain: layout !important;
    }
    
    .navigation-section .container {
        min-height: 50px !important;
    }
    
    /* Navbar - reserve space for menu */
    .navbar-default {
        min-height: 48px !important;
    }
    
    .navbar-nav.main-nav {
        min-height: 48px !important;
    }
    
    /* Time and date elements - reserve space */
    .header-section .time,
    .header-section .date {
        min-height: 20px !important;
        contain: layout !important;
    }
    
    /* Archive meta bar */
    .israel-archive-meta-bar {
        min-height: 30px !important;
    }
    
    /* Archive subnav */
    .israel-archive-subnav {
        min-height: 50px !important;
    }
    
    /* Breaking cards in archive - prevent shift */
    .breaking-card,
    .breaking-card--compact {
        min-height: 200px !important;
        contain: layout style !important;
    }
    
    .breaking-card--with-image {
        min-height: 250px !important;
    }
    
    /* Breaking card image containers */
    .breaking-card__image {
        min-width: 200px !important;
        min-height: 150px !important;
        contain: layout size !important;
    }
    
    .breaking-card__image img {
        aspect-ratio: 4/3 !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* Breaking card body */
    .breaking-card__body,
    .breaking-card__body--with-image {
        min-height: 180px !important;
    }
    
    /* Archive date and time in header */
    .israel-archive-date {
        min-height: 20px !important;
        line-height: 20px !important;
    }
    
    /* Search archive page fixes */
    body.search .container {
        min-height: 100px !important;
    }
    
    /* Archive section containers */
    .israel-archive-section {
        min-height: 400px !important;
    }
    
    /* Layout containers in archives */
    .israel-layout1-container,
    .israel-layout2-container,
    .israel-layout3-container,
    .israel-layout4-container,
    .israel-layout5-container,
    .israel-layout6-container,
    .israel-layout7-container,
    .israel-layout9-container,
    .israel-layout10-container,
    .israel-layout11-container {
        min-height: 400px !important;
        contain: layout style !important;
    }
}

/* ==========================================
   CRITICAL: Israel Partnerships Directory Page
   Specific fixes for dynamic content areas
   ========================================== */

/* Hero section - reserve space */
.israel-hero-section {
    min-height: 260px !important;
}

.israel-hero-stats {
    min-height: 150px !important;
}

.israel-stat-card {
    min-height: 120px !important;
}

/* Stats numbers - prevent shift */
.israel-stat-number {
    min-height: 40px !important;
    display: inline-block !important;
    font-size: 2rem !important;
    line-height: 1.2 !important;
}

/* Filters section - reserve space */
.israel-filters {
    min-height: 50px !important;
}

.israel-filters-grid {
    min-height: 70px  !important;
}

/* Content container - reserve space */
#contentContainer:has(.israel-partnerships-grid) {
    min-height: 1000px !important;
}

/* Partnerships grid - reserve space */
.israel-partnerships-grid {
    min-height: 800px !important;
}

/* Loading state - reserve space */
.israel-loading {
    min-height: 300px !important;
}

/* Mobile partnerships directory */
@media (max-width: 768px) {
    .israel-hero-section {
        min-height: 260px !important;
    }
    
    .israel-hero-stats {
        min-height: 120px !important;
    }
    
    .israel-stat-card {
        min-height: 100px !important;
    }
    
    .israel-filters {
        min-height: 180px !important;
    }
    
    #contentContainer:has(.israel-partnerships-grid) {
        min-height: 800px !important;
    }
    
    .israel-partnerships-grid {
        min-height: 600px !important;
    }
}

/* Grid Layouts */
.israel-consuls-grid,
.israel-companies-grid,
.israel-beaches-grid,
.israel-schools-grid,
.israel-crypto-grid,
.israel-partnerships-grid,
.israel-shabbat-grid,
.israel-circumcisers-grid,
.israel-banks-grid,
.israel-exchange-grid,
.israel-releases-grid {
    min-height: 600px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

/* ==========================================
   Card Containers - Fixed Heights
   Prevents shifts as cards load
   ========================================== */

.israel-consul-card,
.israel-company-card,
.israel-beach-card,
.israel-school-card,
.israel-crypto-card,
.israel-partnership-card,
.israel-shabbat-card,
.israel-circumciser-card,
.israel-bank-card,
.israel-exchange-card,
.israel-release-card {
    min-height: 320px;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Mobile Card Heights */
@media (max-width: 768px) {
    .israel-consul-card,
    .israel-company-card,
    .israel-beach-card,
    .israel-school-card,
    .israel-crypto-card,
    .israel-partnership-card,
    .israel-shabbat-card,
    .israel-circumciser-card,
    .israel-bank-card,
    .israel-exchange-card,
    .israel-release-card {
        min-height: 280px;
    }
    
    /* CRITICAL: Archive/Category Pages - Mobile CLS Fix */
    .israel-archive-page {
        min-height: 2000px !important; /* Prevent collapse on mobile */
    }
    
    .israel-archive-header {
        min-height: 90px !important; /* Prevent header shift */
    }
    
    .israel-archive-title-wrap {
        min-height: 40px !important;
    }
    
    .israel-archive-hero,
    .israel-archive-section {
        min-height: 500px !important; /* Reserve space for content */
    }
    
    /* Archive card containers */
    .israel-archive-grid,
    .israel-archive-list {
        min-height: 1200px !important;
    }
    
    /* Individual archive cards - fixed height */
    .israel-archive-card {
        min-height: 380px !important; /* Taller on mobile */
        margin-bottom: 2rem;
    }
    
    /* Archive card media (image container) */
    .israel-archive-card-media {
        min-height: 200px !important;
        aspect-ratio: 16 / 9 !important;
        background: #f0f0f0;
    }
    
    /* Archive card images - explicit mobile dimensions */
    .israel-archive-card-image {
        aspect-ratio: 16 / 9 !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
    }
}

/* ==========================================
   Image Containers - Aspect Ratios
   Prevents shifts during image loading
   ========================================== */

/* Logo/Icon Containers */
.company-logo-container,
.crypto-logo-container,
.partner-logo-container {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.company-logo-container img,
.crypto-logo-container img,
.partner-logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    aspect-ratio: 1 / 1;
}

/* Press Release Images */
.nw-release-img {
    width: 110px !important;
    height: 70px !important;
    aspect-ratio: 110 / 70 !important;
    object-fit: cover !important;
}

/* Flag Images */
.boi-flag-img {
    width: 24px !important;
    height: 16px !important;
    aspect-ratio: 3 / 2 !important;
    object-fit: cover !important;
}

/* Cryptocurrency Logos */
.trending-logo,
.coin-logo {
    width: 28px !important;
    height: 28px !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    border-radius: 50%;
}

/* ==========================================
   Hero Section - Prevent Header Shifts
   ========================================== */

.israel-hero-section {
    min-height: 260px;
    background: #ffffff;
    padding: 3rem 1rem 2rem;
    margin-bottom: 2rem;
}

.israel-hero-content {
    max-width: 900px;
    margin: 0 auto;
}

.israel-hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
    min-height: 120px;
}

.israel-stat-card {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    min-height: 100px;
}

/* Mobile Hero */
@media (max-width: 768px) {
    .israel-hero-section {
        min-height: 260px;
        padding: 2rem 1rem 1.5rem;
    }
    .israel-hero-stats {
        min-height: 100px;
    }
    .israel-stat-card {
        min-height: 80px;
    }
}

/* ==========================================
   Loading States - Skeleton Loaders
   ========================================== */

.israel-loading {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.israel-loading-spinner {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   Filter Sections - Prevent Collapse
   ========================================== */

.israel-filters {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    min-height: 100px;
}

.israel-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ==========================================
   Table Containers - Prevent Shift
   ========================================== */

.israel-table-container {
    min-height: 400px;
    overflow-x: auto;
}

.israel-table-container table {
    width: 100%;
    border-collapse: collapse;
}

/* ==========================================
   Single Page Templates - Content Areas
   ========================================== */

.single-consul-container,
.single-company-container,
.single-beach-container,
.single-school-container,
.single-crypto-container,
.single-partnership-container,
.single-shabbat-container,
.single-circumciser-container,
.single-benefit-container {
    min-height: 600px;
}

.single-hero-section {
    min-height: 300px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 1rem;
}

.single-content-area {
    min-height: 400px;
    padding: 2rem 1rem;
}

/* Mobile Single Pages */
@media (max-width: 768px) {
    .single-consul-container,
    .single-company-container,
    .single-beach-container,
    .single-school-container,
    .single-crypto-container,
    .single-partnership-container,
    .single-shabbat-container,
    .single-circumciser-container,
    .single-benefit-container {
        min-height: 500px;
    }
    .single-hero-section {
        min-height: 250px;
        padding: 2rem 1rem;
    }
    .single-content-area {
        min-height: 350px;
    }
}

/* ==========================================
   Info Cards - Consistent Sizing
   ========================================== */

.israel-info-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 150px;
}

.israel-detail-card {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    min-height: 120px;
}

/* ==========================================
   Responsive Grid Adjustments
   ========================================== */

@media (max-width: 1200px) {
    .israel-consuls-grid,
    .israel-companies-grid,
    .israel-beaches-grid,
    .israel-schools-grid,
    .israel-crypto-grid,
    .israel-partnerships-grid,
    .israel-shabbat-grid,
    .israel-circumcisers-grid,
    .israel-banks-grid,
    .israel-exchange-grid,
    .israel-releases-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    #contentContainer {
        min-height: 600px;
    }
    
    .israel-consuls-grid,
    .israel-companies-grid,
    .israel-beaches-grid,
    .israel-schools-grid,
    .israel-crypto-grid,
    .israel-partnerships-grid,
    .israel-shabbat-grid,
    .israel-circumcisers-grid,
    .israel-banks-grid,
    .israel-exchange-grid,
    .israel-releases-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        min-height: 500px;
    }
}

/* ==========================================
   CRITICAL: Additional Page-Specific Fixes
   ========================================== */

/* Flight Board Page */
.flight-board-container {
    min-height: 1200px !important;
}

.flight-results {
    min-height: 600px !important;
}

.flight-table {
    min-height: 500px !important;
}

.flight-table tbody {
    min-height: 400px !important;
}

/* Currency Exchange Page */
.boi-widget {
    min-height: 1200px !important;
}

.boi-container {
    min-height: 1000px !important;
}

.boi-table {
    min-height: 500px !important;
}

.boi-table tbody {
    min-height: 400px !important;
}

.boi-converter-container {
    min-height: 300px !important;
}

/* Police Units Page */
.police-page-wrapper {
    min-height: 1200px !important;
}

#map {
    min-height: 600px !important;
}

.sidebar-list {
    min-height: 500px !important;
}

.quick-stats {
    min-height: 100px !important;
}

/* Banks Directory Specific */
.isb-content-wrapper {
    min-height: 1200px !important;
}

.isb-banks-grid {
    min-height: 800px !important;
}

.isb-loading {
    min-height: 300px !important;
}

/* All Directory Grids - Universal Fix */
.israel-consuls-grid,
.israel-companies-grid,
.israel-beaches-grid,
.israel-schools-grid,
.israel-crypto-grid,
.israel-shabbat-grid,
.israel-circumcisers-grid,
.israel-exchange-grid,
.israel-releases-grid,
.isb-banks-grid {
    min-height: 800px !important;
}

/* Single Page Templates - Reserve Space */
.single-consul-container,
.single-company-container,
.single-beach-container,
.single-school-container,
.single-crypto-container,
.single-partnership-container,
.single-shabbat-container,
.single-circumciser-container,
.single-benefit-container {
    min-height: 800px !important;
}

/* Mobile fixes for all pages */
@media (max-width: 768px) {
    .flight-board-container { min-height: 1000px !important; }
    .flight-results { min-height: 500px !important; }
    .boi-widget { min-height: 1000px !important; }
    .boi-container { min-height: 800px !important; }
    .police-page-wrapper { min-height: 1000px !important; }
    #map { min-height: 500px !important; }
    .isb-content-wrapper { min-height: 1000px !important; }
    .isb-banks-grid { min-height: 600px !important; }
    
    .israel-consuls-grid,
    .israel-companies-grid,
    .israel-beaches-grid,
    .israel-schools-grid,
    .israel-crypto-grid,
    .israel-shabbat-grid,
    .israel-circumcisers-grid,
    .israel-exchange-grid,
    .israel-releases-grid {
        min-height: 600px !important;
    }
    
    .single-consul-container,
    .single-company-container,
    .single-beach-container,
    .single-school-container,
    .single-crypto-container,
    .single-partnership-container,
    .single-shabbat-container,
    .single-circumciser-container,
    .single-benefit-container {
        min-height: 600px !important;
    }
}

/* ==========================================
   Prevent FOUC - Ensure Visibility
   ========================================== */

html, body {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================
   CRITICAL: Front Page CLS Prevention
   Fixes layout shifts on homepage banner
   ========================================== */

/* Main banner - ensure proper min-height on mobile */
.israel-news-banner {
    contain: layout style paint !important;
}

@media (max-width: 768px) {
    .israel-news-banner {
        min-height: 3200px !important;
    }
    
    .israel-news-container {
        min-height: 3150px !important;
    }
    
    .israel-news-grid {
        min-height: 3100px !important;
    }
    
    .israel-story-media {
        min-height: 280px !important;
        aspect-ratio: 4/3 !important;
    }
    
    .israel-story-image {
        aspect-ratio: 4/3 !important;
        min-height: 280px !important;
    }
    
    .israel-main-story {
        min-height: 700px !important;
    }
    
    .israel-live-sidebar {
        min-height: 1100px !important;
    }
    
    .israel-related-stories {
        min-height: 1100px !important;
    }
    
    .israel-timeline-item {
        min-height: 280px !important;
    }
    
    .israel-related-story {
        min-height: 280px !important;
    }
}

/* Story content - prevent summary shift */
.israel-story-content {
    contain: layout !important;
}

.israel-story-headline {
    contain: layout !important;
}

.israel-story-summary {
    contain: layout !important;
    min-height: 48px !important;
    line-height: 1.5 !important;
}

@media (max-width: 768px) {
    .israel-story-content {
        min-height: 140px !important;
    }
    
    .israel-story-headline {
        min-height: 60px !important;
    }
    
    .israel-story-summary {
        min-height: 60px !important;
    }
}

/* ==========================================
   Performance: Contain Layout Changes
   ========================================== */

.israel-consul-card,
.israel-company-card,
.israel-beach-card,
.israel-school-card,
.israel-crypto-card,
.israel-partnership-card,
.israel-shabbat-card,
.israel-circumciser-card,
.israel-bank-card,
.israel-exchange-card,
.israel-release-card {
    contain: layout style;
    content-visibility: auto;
}

/* ==========================================
   Image Placeholders
   ========================================== */

.image-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

