/* =========================================
   EXPERTPULSE GRID SYSTEMS
   Templates: Hero, Standard, Zebra, Trending, Master, Bento, Quad
   ========================================= */

/* --- GENERAL CARD & UTILITY STYLES --- */
.article-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex; flex-direction: column; height: 100%;
}
.article-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); border-color: transparent; }

.card-thumb { position: relative; padding-top: 65%; overflow: hidden; background-color: #f0f0f0; }
.card-thumb img, .img-hover-zoom img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.article-card:hover .card-thumb img, .img-hover-zoom:hover img { transform: scale(1.05); }

.card-body { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.card-cat, .category-tag { 
    font-family: var(--font-body, 'Inter', sans-serif); /* FORCE SANS-SERIF */
    font-size: 0.7rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    margin-bottom: 8px; 
    display: inline-block; 
    color: var(--accent); 
}
.card-title, .headline { 
    font-size: 1.1rem; font-weight: 800; margin: 0 0 12px; line-height: 1.4; 
    color: var(--text-main); font-family: var(--font-heading);
}
.card-title a, .headline a { color: var(--text-main); transition: 0.2s; }
.card-title a:hover, .headline:hover { color: var(--accent); }

.abstract { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.6; }

.card-footer { 
    display: flex; justify-content: space-between; font-size: 0.8rem; 
    color: var(--text-muted); padding-top: 15px; border-top: 1px dashed var(--border); 
    margin-top: auto; font-weight: 600; align-items: center;
}

.img-hover-zoom { display: block; overflow: hidden; position: relative; border-radius: 4px; background: var(--bg-section-alt); margin-bottom: 1rem; }

/* NEWS DEMO SPECIFIC UTILITIES */
.section-divider {
    border-top: 4px solid var(--border-heavy);
    border-bottom: 1px solid var(--border-heavy);
    padding: 0.75rem 0;
    margin: 3rem 0 2rem 0;
    display: flex; justify-content: space-between; align-items: center; width: 100%;
}
.section-divider h2 { font-size: 1.75rem; text-transform: uppercase; margin: 0; color: var(--text-main); }

.author-meta { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; display: block; }
.author-meta span { color: var(--text-main); }

.save-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    background: transparent; border: 1px solid var(--border);
    transition: all 0.3s ease; cursor: pointer; padding: 0;
}
.save-btn:hover { background: var(--bg-section-alt); border-color: var(--text-muted); }
.save-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--text-main); stroke-width: 2; transition: all 0.3s ease; }
.save-btn.saved { border-color: var(--accent); background: #EFF6FF; }
.save-btn.saved svg { fill: var(--accent); stroke: var(--accent); }


/* --- NEWS DEMO CARD OVERRIDES --- */
.master-grid .article-card,
.quad-grid .article-card {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

/* Prevent the whole card from lifting on hover (only the image should zoom) */
.master-grid .article-card:hover,
.quad-grid .article-card:hover {
    transform: none;
    box-shadow: none;
}

/* --- 1. HERO GRID (Magazine Standard) --- */
.grid-hero-section { padding: 40px 0; }
.grid-hero-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; min-height: 500px; margin-bottom: 40px; }
.feat-card { position: relative; border-radius: var(--radius); overflow: hidden; height: 100%; box-shadow: var(--shadow); background: #000; }
.feat-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s; }
.feat-card:hover img { transform: scale(1.03); }

.feat-overlay { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    padding: 30px; 
    padding-top: 80px; /* Buffer zone so text never touches the badge */
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0) 100%); 
    color: #ffffff !important; 
    display: flex; 
    flex-direction: column; 
    justify-content: flex-end; 
    z-index: 2; 
    pointer-events: none; 
}
.feat-overlay a { pointer-events: auto; color: #ffffff !important; }

.feat-meta {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 10px;
    display: flex;
    gap: 15px;
    font-weight: 600;
    color: #ffffff !important;
    text-transform: none !important; /* Forces normal text casing */
}
.feat-meta span, .feat-meta i { 
    color: #ffffff !important; 
    text-transform: none !important; 
}

.feat-title { 
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    color: #ffffff !important;
}
.feat-title a { color: #ffffff !important; }
.feat-title a:hover { color: rgba(255, 255, 255, 0.8) !important; }

.side-stack { display: flex; flex-direction: column; gap: 25px; height: 100%; }
.sub-feat { flex: 1; min-height: 0; }
.sub-feat .feat-title { font-size: 1.3rem; margin-bottom: 10px; }

/* Enforce white text on sub-features */
.sub-feat .feat-overlay, 
.sub-feat .feat-title a, 
.sub-feat .feat-meta, 
.sub-feat .feat-meta span, 
.sub-feat .feat-meta i { 
    color: #ffffff !important;
}

/* Fix Save Button visibility on dark image overlays (Hero & Zebra grids) */
.feat-overlay .save-btn {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.3);
}

.feat-overlay .save-btn svg {
    stroke: #ffffff !important;
}

.feat-overlay .save-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.feat-overlay .save-btn.saved {
    background: var(--accent);
    border-color: var(--accent);
}

.feat-overlay .save-btn.saved svg {
    fill: #ffffff !important;
    stroke: #ffffff !important;
}

/* Fix spacing and text color for the top badge in Hero Grid */
.feat-card .badge {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    color: #1a1a1a !important; /* Force dark text on the light badge, even in dark mode */
}

/* Adjustments specifically for mobile to keep it clean */
@media (max-width: 600px) {
    .feat-card .badge {
        top: 15px;
        left: 15px;
    }
    
    .feat-card .feat-overlay {
        padding: 20px 15px 15px 15px;
        padding-top: 60px; /* Maintain buffer on mobile */
    }
    
    /* Ensure the title doesn't get too massive and push everything up */
    .feat-card .feat-title {
        font-size: 1.4rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }
}

/* --- 2. STANDARD GRID --- */
.grid-standard-section { padding: 40px 0; }
.magazine-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 30px; margin-bottom: 40px; }
.seamless-grid { padding-top: 0 !important; margin-top: -55px; z-index: 5; position: relative; }

/* --- 3. ZEBRA GRID --- */
.grid-zebra-section { padding: 60px 0; background: var(--bg-section-alt); }
.zebra-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 50px; }
.zebra-main-post { height: 550px; position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.zebra-list { display: flex; flex-direction: column; gap: 20px; }
.zebra-item { display: flex; gap: 20px; align-items: center; padding: 15px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); transition: 0.2s; }
.zebra-item:hover { border-color: var(--accent); transform: translateX(5px); }
.zebra-thumb { width: 90px; height: 90px; border-radius: 12px; flex-shrink: 0; object-fit: cover; }

/* --- 4. MASTER GRID (News Demo Layout) --- */
.master-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2.5rem; /*margin-top: 2.5rem;*/ margin-bottom: 3rem; }
.hero-section { grid-column: span 9; display: flex; flex-direction: column; gap: 2.5rem; }
.sidebar-section { grid-column: span 3; border-left: 1px solid var(--border); padding-left: 2.5rem; }

/* Lead Story Styling */
.lead-story { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 2.5rem; align-items: center; padding-bottom: 2.5rem; border-bottom: 2px solid var(--border); }
.lead-story .headline { font-size: 2.5rem; letter-spacing: -0.5px; margin-bottom: 1rem; }
.lead-story .img-hover-zoom { margin: 0; aspect-ratio: 16/10; }

.sub-hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.sub-hero-grid .headline { font-size: 1.25rem; }

.sidebar-title { font-size: 1rem; font-weight: 800; text-transform: uppercase; border-top: 3px solid var(--accent); padding-top: 0.75rem; margin-bottom: 1.5rem; color: var(--accent); }
.opinion-item { border-bottom: 1px solid var(--border); padding-bottom: 1.5rem; margin-bottom: 1.5rem; }
.opinion-item .headline { font-size: 1.15rem; font-style: italic; margin-bottom: 0.5rem; }

/* --- 5. BENTO GRID --- */
.bento-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(220px, auto); gap: 2rem; margin-bottom: 4rem; }
.bento-item { background: var(--bg-section-alt); padding: 1.5rem; border-top: 3px solid var(--border-heavy); border-radius: 0 0 4px 4px; display: flex; flex-direction: column; }
.bento-item.tall { grid-row: span 2; }
.bento-item.wide { grid-column: span 2; }
.bento-item.tall .img-hover-zoom { flex-grow: 1; margin-top: 1.5rem; margin-bottom: 0; border-radius: 4px; }
.bento-item .headline { font-size: 1.3rem; margin-top: 5px; }

/* --- 6. MULTIMEDIA GRID --- */
.multimedia-wrapper { background-color: #0B1120; color: white; padding: 4rem 0; margin: 4rem 0; }
.multimedia-wrapper .headline { color: white; }

/* Force the section title and link to be white against the dark background */
.multimedia-wrapper .ep-section-heading { border-color: #334155; }
.multimedia-wrapper .ep-section-heading .title-text { color: #ffffff !important; }
.multimedia-wrapper .ep-section-heading .view-all { color: #cbd5e1 !important; }
.multimedia-wrapper .ep-section-heading .view-all:hover { color: #ffffff !important; }

.cinema-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.5rem; }
.cinema-card { position: relative; overflow: hidden; border-radius: 4px; }
.cinema-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0.75; transition: 0.5s; }
.cinema-card:hover img { opacity: 1; transform: scale(1.03); }
.cinema-card.large { grid-row: span 2; height: 500px; }
.cinema-card .overlay-content { position: absolute; bottom: 0; left: 0; width: 100%; padding: 2rem; background: linear-gradient(transparent, rgba(0,0,0,0.9)); }
/* Make the featured multimedia headline large */
.cinema-card.large .headline { 
    font-size: 2.2rem; 
    line-height: 1.2;
}

/* --- 7. CAROUSEL (FIXED: Contained sliding) --- */
.carousel-cards-section { 
    padding: 20px 0; 
    background: var(--bg-body); 
    border-bottom: 1px solid var(--border); 
}

/* This masks the content to the container width */
.carousel-mask {
    width: 100%;
    overflow: hidden; /* Keeps the sliding track inside the container */
    position: relative;
    /* Optional: Fade edges for professional look */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
}

.carousel-track { 
    display: flex; 
    gap: 40px; 
    width: max-content; /* Allow track to stretch */
    animation: scroll 40s linear infinite; 
}

/* Pause animation on hover for better UX */
.carousel-track:hover {
    animation-play-state: paused;
}

.carousel-card { 
    text-align: center; 
    width: 100px; 
    flex-shrink: 0; 
    cursor: pointer;
    transition: transform 0.2s;
}
.carousel-card:hover { transform: translateY(-5px); }

.carousel-img { 
    width: 80px; height: 80px; border-radius: 50%; 
    margin: 0 auto 12px; border: 2px solid transparent; padding: 2px; 
    object-fit: cover; background: var(--bg-body); 
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); transition: border-color 0.2s;
}
.carousel-card:hover .carousel-img { border-color: var(--accent); }

@keyframes scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* --- 8. QUAD GRID --- */
.quad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem; margin-bottom: 3rem; }
.quad-grid .img-hover-zoom { aspect-ratio: 16/10; }

/* --- 9. TRENDING LIST --- */
.list-trending-section { padding: 60px 0; }
.chart-list { counter-reset: chart-counter; }
.chart-item { display: flex; align-items: center; gap: 25px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.chart-rank { width: 40px; font-size: 2rem; font-weight: 900; color: #e0e0e0; text-align: center; counter-increment: chart-counter; font-style: italic; }
.chart-rank::before { content: counter(chart-counter); } /* Changed this line */
.chart-item:nth-child(-n+3) .chart-rank { color: var(--accent); }
.chart-thumb { width: 70px; height: 70px; border-radius: 12px; object-fit: cover; }

/* --- DYNAMIC SIDEBAR LAYOUTS --- */
.ep-row-layout { display: grid; gap: 40px; align-items: start; }

/* Fixed Sidebar Width of 350px */
.ep-row-layout.pos-right { grid-template-columns: minmax(0, 1fr) 350px; }
.ep-row-layout.pos-left { grid-template-columns: 350px minmax(0, 1fr); }
.ep-row-layout.pos-left > .ep-main-content { order: 2; }
.ep-row-layout.pos-left > .ep-sidebar { order: 1; }

/* Fixed Sidebar Container Size (350x470) */
.ep-sidebar {
    width: 100%;
    max-width: 350px;
    height: 470px;
    overflow-y: auto; /* Allows smooth scrolling inside the strict 470px box */
    scrollbar-width: thin; 
    scrollbar-color: var(--border) transparent;
}

/* Custom Sleek Scrollbar for the Sidebar */
.ep-sidebar::-webkit-scrollbar { width: 4px; }
.ep-sidebar::-webkit-scrollbar-track { background: transparent; }
.ep-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.ep-sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Shrink internal grids when in sidebar mode */
.ep-row-layout .magazine-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
.ep-row-layout .zebra-layout { grid-template-columns: 1fr; }

/* Remove the fixed height restriction on mobile devices so it stacks naturally */
@media (max-width: 992px) {
    .ep-row-layout.pos-right, .ep-row-layout.pos-left { grid-template-columns: 1fr; }
    .ep-sidebar { height: auto; max-width: 100%; overflow-y: visible; }
}

/* --- POST FORMAT ICONS --- */
.ep-format-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 48px; height: 48px; background: rgba(0, 0, 0, 0.6); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; z-index: 15; backdrop-filter: blur(4px); pointer-events: none;
    transition: all 0.3s;
}
.article-card:hover .ep-format-icon { background: var(--accent); transform: translate(-50%, -50%) scale(1.15); }


/* =========================================
   STANDARD RESPONSIVE BREAKPOINTS
   ========================================= */
@media (max-width: 1200px) {
    .master-grid { grid-template-columns: 1fr; }
    .hero-section, .sidebar-section { grid-column: 1 / -1; }
    .sidebar-section { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 2rem; }
    .cinema-grid { grid-template-columns: 1fr 1fr; }
    .cinema-card.large { grid-column: span 2; }
    .lead-story .headline { font-size: 2.2rem; }
}

@media (max-width: 992px) {
    .grid-hero-layout { grid-template-columns: 1fr; }
    .side-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .magazine-grid { grid-template-columns: repeat(2, 1fr); }
    .zebra-layout { grid-template-columns: 1fr; }
    .sub-hero-grid, .bento-grid, .quad-grid, .footer-style-6 .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .ep-row-layout.pos-right, .ep-row-layout.pos-left { grid-template-columns: 1fr; }
    .lead-story { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 600px) {
    .magazine-grid, .sub-hero-grid, .bento-grid, .cinema-grid, .quad-grid, .footer-style-6 .footer-grid { grid-template-columns: 1fr !important; }
    .side-stack { grid-template-columns: 1fr; }
    .feat-card { min-height: 300px; }
    /* Override inline styles from PHP for Bento items on mobile */
    .bento-item[style] { grid-column: span 1 !important; width: 100% !important; }
    .bento-item.tall, .bento-item.wide, .cinema-card.large { grid-column: span 1 !important; grid-row: span 1 !important; }
    .lead-story .headline { font-size: 1.8rem; }
    /* Shrink the large multimedia headline for mobile */
    .cinema-card.large .headline { 
        font-size: 1.75rem; 
    }
}


/* =========================================
   MOBILE LIST LAYOUT OVERRIDES (NEW)
   Handles the Builder Mobile Settings
   ========================================= */
@media (max-width: 600px) {

    /* Define custom CSS Variables for easier sizing control */
    :root {
        --bbc-img-w: 132px;
        --bbc-img-h: 74px;
        --nbc-img-w: 147px;
        --nbc-img-h: 98px;
        --alj-img-w: 147px;
        --alj-img-h: 98px;
    }

    /* Base wrapper reset for mobile lists */
    .ep-mobile-style-list-classic,
    .ep-mobile-style-list-detailed,
    .ep-mobile-style-list-hero-stack,
    .ep-mobile-style-grid-2col {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    /* Sub-grids (like sub-hero-grid in master) */
    .ep-mobile-style-list-classic .sub-hero-grid,
    .ep-mobile-style-list-detailed .sub-hero-grid,
    .ep-mobile-style-list-hero-stack .sub-hero-grid,
    .ep-mobile-style-grid-2col .sub-hero-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* --- Grid: 2 Columns (Music Demo Style) --- */
    .ep-mobile-style-grid-2col {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .ep-mobile-style-grid-2col .article-card {
        border-radius: var(--radius) !important;
        border: 1px solid var(--border) !important;
        background: var(--bg-card) !important;
    }
    .ep-mobile-style-grid-2col .card-body {
        padding: 10px !important;
    }
    .ep-mobile-style-grid-2col .card-title {
        font-size: 0.95rem !important;
        margin-bottom: 5px !important;
        line-height: 1.3 !important;
    }
    .ep-mobile-style-grid-2col .card-cat {
        font-size: 0.6rem !important;
        margin-bottom: 5px !important;
    }
    .ep-mobile-style-grid-2col .card-footer {
        font-size: 0.7rem !important;
        padding-top: 8px !important;
    }

    /* --- List: Image Left (BBC Style) --- */
    .ep-mobile-style-list-classic .article-card,
    .ep-mobile-style-list-classic .lead-story,
    .ep-mobile-style-list-classic .bento-item,
    .ep-mobile-style-list-classic .zebra-main-post,
    .ep-mobile-style-list-classic .zebra-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        border: none !important;
        box-shadow: none !important;
        border-bottom: 1px solid var(--border) !important;
        border-radius: 0 !important;
        padding: 0 0 15px 0 !important;
        background: transparent !important;
        height: auto !important;
    }
    
    .ep-mobile-style-list-classic .card-thumb,
    .ep-mobile-style-list-classic .img-hover-zoom,
    .ep-mobile-style-list-classic .zebra-thumb {
        width: var(--bbc-img-w) !important;
        height: var(--bbc-img-h) !important;
        padding-top: 0 !important;
        border-radius: 4px !important;
        flex-shrink: 0 !important;
        margin: 0 15px 0 0 !important;
        aspect-ratio: auto !important;
    }
    
    .ep-mobile-style-list-classic .zebra-main-post > img {
        width: var(--bbc-img-w) !important; height: var(--bbc-img-h) !important;
        position: static !important; border-radius: 4px !important; margin-right: 15px !important;
    }
    
    .ep-mobile-style-list-classic .card-body,
    .ep-mobile-style-list-classic .lead-content,
    .ep-mobile-style-list-classic .feat-overlay,
    .ep-mobile-style-list-classic .zebra-info {
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important; /* BBC aligns to top */
        position: static !important;
        background: transparent !important;
        width: 100%;
    }
    
    .ep-mobile-style-list-classic .card-title,
    .ep-mobile-style-list-classic .headline,
    .ep-mobile-style-list-classic .feat-title,
    .ep-mobile-style-list-classic .zebra-info h4 {
        font-size: 1rem !important;
        margin-bottom: 5px !important;
        line-height: 1.3 !important;
        color: var(--text-main) !important;
        text-shadow: none !important;
    }
    
    /* Hide unneeded elements to make it look like BBC */
    .ep-mobile-style-list-classic .card-footer,
    .ep-mobile-style-list-classic .badge,
    .ep-mobile-style-list-classic .ep-format-icon,
    .ep-mobile-style-list-classic .feat-meta span:first-child,
    .ep-mobile-style-list-classic .btn,
    .ep-mobile-style-list-classic .ri-arrow-right-line {
        display: none !important;
    }

    /* Excerpt Logic (Data Attribute controlled by block settings) */
    .ep-mobile-style-list-classic[data-mobile-excerpt="0"] .card-excerpt,
    .ep-mobile-style-list-classic[data-mobile-excerpt="0"] .abstract {
        display: none !important;
    }


    /* --- List: Text Left (Al Jazeera Style) --- */
    .ep-mobile-style-list-detailed .article-card,
    .ep-mobile-style-list-detailed .lead-story,
    .ep-mobile-style-list-detailed .bento-item,
    .ep-mobile-style-list-detailed .zebra-main-post,
    .ep-mobile-style-list-detailed .zebra-item {
        display: flex !important;
        flex-direction: row-reverse !important;
        align-items: flex-start !important;
        border: none !important;
        box-shadow: none !important;
        border-bottom: 1px solid var(--border) !important;
        border-radius: 0 !important;
        padding: 0 0 15px 0 !important;
        background: transparent !important;
        height: auto !important;
    }
    
    .ep-mobile-style-list-detailed .card-thumb,
    .ep-mobile-style-list-detailed .img-hover-zoom,
    .ep-mobile-style-list-detailed .zebra-thumb {
        width: var(--alj-img-w) !important;
        height: var(--alj-img-h) !important;
        padding-top: 0 !important;
        border-radius: 4px !important;
        flex-shrink: 0 !important;
        margin: 0 0 0 15px !important;
        aspect-ratio: auto !important;
    }

    .ep-mobile-style-list-detailed .zebra-main-post > img {
        width: var(--alj-img-w) !important; height: var(--alj-img-h) !important;
        position: static !important; border-radius: 4px !important; margin-left: 15px !important;
    }

    .ep-mobile-style-list-detailed .card-body,
    .ep-mobile-style-list-detailed .lead-content,
    .ep-mobile-style-list-detailed .feat-overlay,
    .ep-mobile-style-list-detailed .zebra-info {
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        position: static !important;
        background: transparent !important;
        width: 100%;
    }

    .ep-mobile-style-list-detailed .card-title,
    .ep-mobile-style-list-detailed .headline,
    .ep-mobile-style-list-detailed .feat-title,
    .ep-mobile-style-list-detailed .zebra-info h4 {
        font-size: 1rem !important;
        margin-bottom: 5px !important;
        line-height: 1.3 !important;
        color: var(--text-main) !important;
        text-shadow: none !important;
    }

    .ep-mobile-style-list-detailed .card-footer,
    .ep-mobile-style-list-detailed .badge,
    .ep-mobile-style-list-detailed .ep-format-icon,
    .ep-mobile-style-list-detailed .feat-meta span:first-child,
    .ep-mobile-style-list-detailed .btn,
    .ep-mobile-style-list-detailed .ri-arrow-right-line {
        display: none !important;
    }

    .ep-mobile-style-list-detailed[data-mobile-excerpt="0"] .card-excerpt,
    .ep-mobile-style-list-detailed[data-mobile-excerpt="0"] .abstract {
        display: none !important;
    }


    /* --- List: Hero Stack (NBC Style) --- */
    .ep-mobile-style-list-hero-stack .article-card,
    .ep-mobile-style-list-hero-stack .lead-story,
    .ep-mobile-style-list-hero-stack .bento-item,
    .ep-mobile-style-list-hero-stack .zebra-main-post,
    .ep-mobile-style-list-hero-stack .zebra-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        border: none !important;
        box-shadow: none !important;
        border-bottom: 1px solid var(--border) !important;
        border-radius: 0 !important;
        padding: 0 0 15px 0 !important;
        background: transparent !important;
        height: auto !important;
    }
    
    /* Make first item large */
    .ep-mobile-style-list-hero-stack > *:first-child,
    .ep-mobile-style-list-hero-stack > .sub-hero-grid > *:first-child,
    .ep-mobile-style-list-hero-stack .lead-story,
    .ep-mobile-style-list-hero-stack .zebra-main-post {
        flex-direction: column !important;
        border-bottom: 2px solid var(--text-main) !important;
        margin-bottom: 10px !important;
        align-items: stretch !important;
    }
    
    .ep-mobile-style-list-hero-stack > *:first-child .card-thumb,
    .ep-mobile-style-list-hero-stack > *:first-child .img-hover-zoom,
    .ep-mobile-style-list-hero-stack > .sub-hero-grid > *:first-child .card-thumb,
    .ep-mobile-style-list-hero-stack > .sub-hero-grid > *:first-child .img-hover-zoom,
    .ep-mobile-style-list-hero-stack .lead-story .img-hover-zoom,
    .ep-mobile-style-list-hero-stack .zebra-main-post > img {
        width: 100% !important;
        height: auto !important;
        padding-top: 65% !important; /* Re-establish aspect ratio for hero */
        margin: 0 0 15px 0 !important;
        position: relative !important;
    }
    
    .ep-mobile-style-list-hero-stack > *:first-child .card-title,
    .ep-mobile-style-list-hero-stack > *:first-child .headline,
    .ep-mobile-style-list-hero-stack > .sub-hero-grid > *:first-child .card-title,
    .ep-mobile-style-list-hero-stack > .sub-hero-grid > *:first-child .headline,
    .ep-mobile-style-list-hero-stack .lead-story .headline,
    .ep-mobile-style-list-hero-stack .zebra-main-post .feat-title {
        font-size: 1.4rem !important;
    }

    /* Subsequent items */
    .ep-mobile-style-list-hero-stack .card-thumb,
    .ep-mobile-style-list-hero-stack .img-hover-zoom,
    .ep-mobile-style-list-hero-stack .zebra-thumb {
        width: var(--nbc-img-w) !important;
        height: var(--nbc-img-h) !important;
        padding-top: 0 !important;
        border-radius: 4px !important;
        flex-shrink: 0 !important;
        margin: 0 15px 0 0 !important;
    }
    
    .ep-mobile-style-list-hero-stack .card-body,
    .ep-mobile-style-list-hero-stack .lead-content,
    .ep-mobile-style-list-hero-stack .feat-overlay,
    .ep-mobile-style-list-hero-stack .zebra-info {
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        position: static !important;
        background: transparent !important;
    }
    
    .ep-mobile-style-list-hero-stack .card-title,
    .ep-mobile-style-list-hero-stack .headline,
    .ep-mobile-style-list-hero-stack .feat-title,
    .ep-mobile-style-list-hero-stack .zebra-info h4 {
        font-size: 1rem !important;
        margin-bottom: 0 !important;
        line-height: 1.3 !important;
        color: var(--text-main) !important;
        text-shadow: none !important;
    }
    
    .ep-mobile-style-list-hero-stack .card-footer,
    .ep-mobile-style-list-hero-stack .badge,
    .ep-mobile-style-list-hero-stack .ep-format-icon,
    .ep-mobile-style-list-hero-stack .feat-meta span:first-child,
    .ep-mobile-style-list-hero-stack .btn,
    .ep-mobile-style-list-hero-stack .ri-arrow-right-line {
        display: none !important;
    }

    .ep-mobile-style-list-hero-stack[data-mobile-excerpt="0"] .card-excerpt,
    .ep-mobile-style-list-hero-stack[data-mobile-excerpt="0"] .abstract {
        display: none !important;
    }
}

/* =========================================
   NEW PROFESSIONAL GRIDS
   ========================================= */

/* 10. Classic Wide List */
.classic-article-row {
    display: flex;
    align-items: flex-start;
    padding: 25px 0;
    border-bottom: 1px solid var(--border);
    gap: 25px;
}
.classic-article-row:last-child { border-bottom: none; }
.classic-meta-time {
    flex: 0 0 80px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-top: 5px;
}
.classic-content { flex: 1; display: flex; flex-direction: column; }
.classic-content .headline { font-size: 1.5rem; margin-bottom: 10px; }
.classic-content .abstract { margin-bottom: 0; }
.classic-thumb {
    flex: 0 0 280px;
    border-radius: 0; /* Sharp corners for editorial look */
    margin: 0;
    aspect-ratio: 16/9;
}

/* 11. Split Columns Grid */
.split-cols-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
.split-lead-card { margin-bottom: 25px; padding-bottom: 25px; border-bottom: 2px solid var(--text-main); }
.split-lead-card .img-hover-zoom { aspect-ratio: 16/10; margin-bottom: 15px; border-radius: 0; }
.split-lead-card .headline { font-size: 1.6rem; margin-bottom: 0; }
.split-list-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
}
.split-list-item:last-child { border-bottom: none; padding-bottom: 0; }
.split-list-item .img-hover-zoom { flex: 0 0 120px; aspect-ratio: 16/10; margin: 0; border-radius: 0; }
.split-list-info { flex: 1; }

/* 12. Detailed Large List */
.detailed-large-wrapper { display: flex; flex-direction: column; gap: 35px; }
.detailed-article-card {
    display: flex;
    gap: 30px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 35px;
}
.detailed-article-card:last-child { border-bottom: none; padding-bottom: 0; }
.detailed-thumb {
    flex: 0 0 50%;
    aspect-ratio: 16/10;
    margin: 0;
    border-radius: var(--radius);
}
.detailed-content { flex: 1; padding: 0; }

/* Responsive Adjustments for New Grids */
@media (max-width: 992px) {
    .split-cols-grid { grid-template-columns: 1fr; gap: 30px; }
    .detailed-thumb { flex: 0 0 40%; }
}
@media (max-width: 600px) {
    .classic-article-row { flex-direction: column-reverse; gap: 15px; padding: 20px 0; }
    .classic-meta-time { flex: auto; padding-top: 0; margin-top: -10px; }
    .classic-thumb { flex: auto; width: 100%; margin-bottom: 10px; }
    .detailed-article-card { flex-direction: column; gap: 20px; }
    .detailed-thumb { flex: auto; width: 100%; }
}

/* Detailed Large List Fix */
.detailed-thumb {
    flex: 0 0 38%; /* Reduced from 50% */
    aspect-ratio: 16/10;
    margin: 0;
    border-radius: var(--radius);
}

/* Ensure mobile stacking remains balanced */
@media (max-width: 992px) {
    .detailed-thumb { flex: 0 0 45%; } 
}

/* --- STICKY SIDEBAR UTILITY --- */
.ep-sticky-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 120px; 
    height: max-content; 
    z-index: 50; 
}

/* NEW: Sticking to the bottom so long sidebars stop exactly when the last widget is shown */
.ep-sticky-sidebar-bottom {
    position: -webkit-sticky;
    position: sticky;
    bottom: 20px; /* Provides spacing at the bottom */
    align-self: end; /* Uses grid alignment to attach strictly to the bottom of the container */
    z-index: 50;
}

/* ==========================================================================
   PREMIUM SIDEBAR SEARCH WIDGET
   ========================================================================== */
.ep-premium-search { 
    display: flex; 
    align-items: center; 
    width: 100%; 
    background: var(--bg-card); 
    border-radius: 50px; 
    border: 1px solid var(--border); 
    transition: all 0.3s ease; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    padding: 6px 6px 6px 22px; 
}

/* Sync focus border with custom button color */
.ep-premium-search:focus-within { 
    border-color: var(--search-btn-color, var(--accent)) !important; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); 
}

.ep-premium-search-icon { 
    color: var(--text-muted); 
    font-size: 1.2rem; 
    margin-right: 12px;
    flex-shrink: 0;
    transition: color 0.3s; 
}

/* Sync focus icon with custom button color */
.ep-premium-search:focus-within .ep-premium-search-icon { 
    color: var(--search-btn-color, var(--accent)) !important; 
}

.ep-premium-search input { 
    flex-grow: 1; 
    min-width: 0;
    border: none; 
    background: transparent; 
    color: var(--text-main); 
    font-family: inherit; 
    font-size: 0.95rem; 
    outline: none; 
    -webkit-appearance: none;
    padding: 10px 0; 
}

.ep-premium-search input::placeholder { color: var(--text-muted); opacity: 0.7; }

/* Dynamic color applied via CSS variable */
.ep-premium-search button { 
    flex-shrink: 0;
    margin-left: 10px;
    background-color: var(--search-btn-color, var(--accent)) !important; 
    color: #fff !important; 
    width: 42px; 
    height: 42px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border: none; 
    cursor: pointer; 
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
}

.ep-premium-search button:hover { 
    transform: scale(1.05); 
    box-shadow: 0 6px 15px rgba(0,0,0,0.15); 
}

.ep-premium-search button i { font-size: 1.1rem; }

/* ==========================================================================
   SIDEBAR WIDGETS (Trending, Newsletter, Audio, Ad, Stores)
   ========================================================================== */

/* Trending Widget */
.trending-list { display: flex; flex-direction: column; gap: 15px; }
.trending-item { display: flex; gap: 15px; align-items: center; cursor: pointer; }
.trending-thumb { width: 80px; height: 80px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.trending-thumb-placeholder { width: 80px; height: 80px; background: var(--bg-section-alt); border-radius: 12px; flex-shrink: 0; }
.trending-info { display: flex; flex-direction: column; }
.trending-title { font-size: 0.95rem; font-weight: 700; line-height: 1.4; margin-bottom: 5px; color: var(--text-main); transition: color 0.2s; }
.trending-item:hover .trending-title { color: var(--accent); }
.trending-views { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.no-trending-posts { color: var(--text-muted); font-size: 0.9rem; }

/* Newsletter Widget */
.newsletter-widget-inner { background: var(--bg-section-alt); padding: 25px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center; }
.newsletter-icon { font-size: 2.5rem; color: var(--accent); margin-bottom: 10px; display: block; }
.newsletter-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 10px; }
.newsletter-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; }
.newsletter-form input { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 10px; background: var(--bg-card); color: var(--text-main); outline: none; }
.newsletter-form .subscribe-btn { width: 100%; justify-content: center; padding: 12px 28px; background: var(--accent); color: white; border-radius: 50px; font-weight: 700; border: none; cursor: pointer; transition: opacity 0.2s; }
.newsletter-form .subscribe-btn:hover { opacity: 0.9; }

/* Audio Player Widget */
.audio-player-widget { background: var(--bg-card); border: 1px solid var(--border); border-top: 4px solid #3b82f6; border-radius: var(--radius); padding: 25px; }
.audio-player-header { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; font-weight: 700; color: var(--text-main); }
.audio-player-header i { font-size: 1.2rem; color: #3b82f6; }
.audio-controls { display: flex; align-items: center; gap: 15px; }
.play-btn.ep-tts-btn { width: 45px; height: 45px; border-radius: 50%; background: #3b82f6; color: white; display: flex; align-items: center; justify-content: center; border: none; font-size: 1.2rem; cursor: pointer; transition: transform 0.2s; }
.play-btn.ep-tts-btn:hover { transform: scale(1.05); }
.progress-bar { flex-grow: 1; height: 6px; background: var(--border); border-radius: 3px; position: relative; overflow: hidden; }
.progress-fill.ep-tts-progress { position: absolute; left: 0; top: 0; height: 100%; width: 0%; background: #3b82f6; border-radius: 3px; transition: width 0.1s linear; }
.ep-tts-time { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); min-width: 40px; text-align: right; }

/* Advertisement Widget */
.ad-box.placeholder-ad { background: var(--bg-section-alt); border: 2px dashed var(--border); height: 300px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-weight: 700; border-radius: var(--radius); }
.ad-box.placeholder-ad i { margin-right: 5px; }

/* Digital Stores Widget */
.ep-store-buttons { display: flex; gap: 15px; flex-wrap: wrap; }
.store-btn { flex: 1; justify-content: center; box-shadow: 0 10px 25px rgba(255, 51, 102, 0.15); color: #fff !important; transition: transform 0.2s; }
.store-btn:hover { transform: translateY(-3px); color: #fff !important; }
.store-btn.apple-store { background: #000; }
.store-btn.spotify-store { background: #1db954; }
.store-btn i { font-size: 1.2rem; }

/* ==========================================================================
   DEDICATED TRENDING PAGE (Virtual Template)
   ========================================================================== */
.ep-trending-page-wrapper {
    background-color: var(--bg-body);
    padding: 60px 20px;
}

.ep-trending-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-card);
    /* border-radius: 20px; */
    /* box-shadow: var(--shadow); */
    /* border: 1px solid var(--border); */
    overflow: hidden;
}

.ep-trending-header {
    padding: 40px 40px 20px;
    border-bottom: 2px solid var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.ep-trending-page-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 900;
    letter-spacing: -0.5px;
    color: var(--text-main);
    margin: 0;
    text-transform: uppercase;
}

.live-pulse {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ep-trending-live-dot {
    margin-top: -2px;
}

.ep-trending-list {
    display: flex;
    flex-direction: column;
}

.ep-trending-item {
    display: flex;
    align-items: center;
    gap: 25px;
    padding: 25px 40px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.3s ease;
    background: var(--bg-card);
}

.ep-trending-item:last-child {
    border-bottom: none;
}

.ep-trending-item:hover {
    background: var(--bg-section-alt);
    transform: translateX(8px);
    border-left: 4px solid var(--accent);
    padding-left: 36px;
}

.ep-trending-rank {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--border);
    width: 60px;
    text-align: center;
    font-style: italic;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

/* Dynamically color the top 3 ranks */
.ep-trending-item.ep-rank-top .ep-trending-rank {
    color: var(--accent);
}

.ep-trending-thumb {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: var(--bg-section-alt);
}

.ep-trending-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.ep-trending-item:hover .ep-trending-thumb img {
    transform: scale(1.08);
}

.ep-trending-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: center;
    min-width: 0; /* Prevents flexbox blowouts */
}

.ep-trending-category {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
}

.ep-trending-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.4;
    margin: 0 0 10px;
    transition: color 0.2s ease;
}

.ep-trending-item:hover .ep-trending-title {
    color: var(--accent);
}

.ep-trending-empty {
    padding: 60px 40px;
    text-align: center;
    color: var(--text-muted);
}

.ep-trending-empty i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
    color: var(--border);
}

.ep-trending-empty p {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .ep-trending-header {
        padding: 25px 15px 15px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ep-trending-item {
        padding: 15px;
        gap: 12px;
    }

    .ep-trending-item:hover {
        transform: translateX(4px);
        padding-left: 11px;
    }

    .ep-trending-rank {
        font-size: 1.75rem;
        width: 35px;
    }

    .ep-trending-thumb {
        width: 70px;
        height: 70px;
    }

    .ep-trending-title {
        font-size: 1rem;
        margin-bottom: 5px;
        line-height: 1.4;
        word-wrap: break-word;
        white-space: normal;
    }
}