/* --- THEME VARIABLES --- */
:root {
    /* LIGHT MODE (Default) */
    --pew-bg: #ffffff;
    --pew-text: #333333;
    --pew-text-muted: #666666;
    --pew-primary: #d32f2f;
    --pew-card-bg: #ffffff;
    --pew-border: #eaeaea;
    --pew-panel-bg: #ffffff;
    --pew-input-bg: #ffffff;
    --pew-shadow: 0 4px 20px rgba(0,0,0,0.06);
    --pew-shadow-hover: 0 10px 25px rgba(0,0,0,0.12);
    --pew-btn-bg: #1a1a1a;
    --pew-btn-text: #ffffff;
    --pew-radius: 12px;
}

/* DARK MODE OVERRIDES */
body.pew-dark-mode {
    --pew-bg: #121212;
    --pew-text: #e0e0e0;
    --pew-text-muted: #a0a0a0;
    --pew-primary: #ff5252;
    --pew-card-bg: #1e1e1e;
    --pew-border: #333333;
    --pew-panel-bg: #1e1e1e;
    --pew-input-bg: #2d2d2d;
    --pew-shadow: 0 4px 20px rgba(0,0,0,0.3);
    --pew-shadow-hover: 0 10px 25px rgba(0,0,0,0.5);
    --pew-btn-bg: #ffffff;
    --pew-btn-text: #121212;
}

/* --- NEW: GLOBAL SITE APPLICATION --- */
/* This forces the whole page to respect the variable */
body.pew-dark-mode {
    background-color: var(--pew-bg) !important;
    color: var(--pew-text) !important;
}

/* --- Container & Layout --- */
.pew-feed-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--pew-text);
}

/* --- Top Bar & Controls --- */
.pew-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

/* LEFT: Filter Button */
.pew-btn-primary {
    background: var(--pew-btn-bg);
    color: var(--pew-btn-text);
    border: none;
    height: 42px;
    padding: 0 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center; /* Vertically centers content */
    justify-content: center; /* Horizontally centers content */
    gap: 10px; /* Space between icon and text */
    transition: background 0.3s, transform 0.1s;
    /* Reset Elementor Defaults */
    line-height: 0 !important; /* Kills ghost spacing */
    margin: 0 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Fix for Filter Icon & Text Alignment */
.pew-btn-primary svg {
    display: block; /* Removes inline spacing */
    position: relative;
    top: -1px; /* Subtle nudge if icon looks too low */
    flex-shrink: 0;
}

.pew-btn-primary:active {
    transform: translateY(1px);
}

/* RIGHT: Display Controls Pill */
.pew-view-toggles {
    display: flex;
    align-items: center;
    background: var(--pew-card-bg);
    padding: 4px;
    border-radius: 30px;
    border: 1px solid var(--pew-border);
    height: 42px;
    box-sizing: border-box;
    /* Force Right Alignment */
    margin-left: auto;
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Icons inside the pill */
.pew-view-btn {
    background: transparent;
    border: none;
    width: 34px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--pew-text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0 !important;
}

/* Fix for the Moon/Sun Spans */
.pew-icon-moon,
.pew-icon-sun {
    display: flex; /* Makes the span a flex container */
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 0;
}

.pew-view-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
    display: block;
}

.pew-view-btn.active {
    background: var(--pew-border);
    color: var(--pew-text);
}

.pew-view-btn:hover {
    color: var(--pew-text);
}

.pew-divider {
    width: 1px;
    height: 18px;
    background: var(--pew-border);
    margin: 0 8px;
}

/* Toggle Logic */
body.pew-dark-mode .pew-icon-moon { display: none; }
body.pew-dark-mode .pew-icon-sun { display: flex; } /* Changed to flex to keep alignment */
body:not(.pew-dark-mode) .pew-icon-moon { display: flex; } /* Changed to flex to keep alignment */
body:not(.pew-dark-mode) .pew-icon-sun { display: none; }


/* --- Collapsible Panel --- */
.pew-controls-panel {
    background: var(--pew-panel-bg);
    border: 1px solid var(--pew-border);
    padding: 25px;
    border-radius: var(--pew-radius);
    margin-bottom: 30px;
    box-shadow: var(--pew-shadow);
}

.pew-search-row input {
    width: 100%;
    padding: 14px;
    background: var(--pew-input-bg);
    color: var(--pew-text);
    border: 2px solid var(--pew-border);
    border-radius: 8px;
    font-size: 16px;
    transition: border 0.3s;
}

.pew-search-row input:focus {
    border-color: var(--pew-primary);
    outline: none;
}

.pew-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--pew-border);
}

.pew-filter-column h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--pew-text-muted);
}

/* FIXED: Compact Spacing */
.pew-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove default flex gap */
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

.pew-checkbox-card {
    display: flex;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
    color: var(--pew-text);
    /* Strict spacing control */
    margin: 0 !important;
    padding: 6px 0 !important;
    border-bottom: 1px solid transparent;
}

.pew-checkbox-card:hover {
    color: var(--pew-primary);
}

.pew-checkbox-card input {
    margin: 0 10px 0 0 !important;
    accent-color: var(--pew-primary);
    transform: scale(1.1);
    cursor: pointer;
}

/* --- Grid Layout --- */
.pew-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    transition: opacity 0.2s;
}

/* --- Card Design --- */
.pew-card {
    background: var(--pew-card-bg);
    border-radius: var(--pew-radius);
    /* FIXED: Allow popups to escape the card boundaries */
    overflow: visible;
    border: 1px solid var(--pew-border);
    box-shadow: var(--pew-shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative; /* Anchor for absolute elements if needed */
}

.pew-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--pew-shadow-hover);
    z-index: 10; /* Ensure hovered card (and its popup) sits on top of neighbors */
}

.pew-card-media {
    position: relative;
    padding-top: 56.25%;
    /* FIXED: Clip the image zoom here, not on the parent card */
    overflow: hidden;
    /* FIXED: Manually round top corners */
    border-radius: var(--pew-radius) var(--pew-radius) 0 0;
}

.pew-card-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.pew-card:hover .pew-card-media img {
    transform: scale(1.05);
}

.pew-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}

.pew-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* ... title, date, excerpt styles remain the same ... */
.pew-date {
    font-size: 12px;
    color: var(--pew-text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.pew-title {
    font-size: 18px;
    line-height: 1.4;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.pew-title a {
    text-decoration: none;
    color: var(--pew-text);
    transition: color 0.2s;
}

.pew-title a:hover {
    color: var(--pew-primary);
}

.pew-excerpt {
    font-size: 14px;
    color: var(--pew-text-muted);
    line-height: 1.6;
    margin-bottom: 15px;
}

.pew-card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--pew-border);
    background: var(--pew-bg);
    margin-top: auto;
    /* FIXED: Manually round bottom corners */
    border-radius: 0 0 var(--pew-radius) var(--pew-radius);
}

.pew-link-arrow {
    font-size: 13px;
    font-weight: 700;
    color: var(--pew-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pew-link-arrow:hover svg {
    transform: translateX(4px);
}

/* --- List View Overrides --- */
.pew-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pew-list .pew-card {
    flex-direction: row;
    height: 220px;
    align-items: stretch;
}

.pew-list .pew-card-media {
    width: 35%;
    padding-top: 0;
    flex-shrink: 0;
    border-radius: var(--pew-radius) 0 0 var(--pew-radius);
}

.pew-list .pew-card-body {
    padding: 25px;
    justify-content: center;
}

.pew-list .pew-card-footer {
    display: none;
}

/* --- Pagination & Loading --- */
.pew-pagination {
    text-align: center;
    margin-top: 40px;
}

#pew-load-more {
    background: var(--pew-card-bg);
    border: 2px solid var(--pew-border);
    padding: 12px 40px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    color: var(--pew-text);
    cursor: pointer;
    transition: all 0.3s;
}

#pew-load-more:hover {
    border-color: var(--pew-text);
    background: var(--pew-text);
    color: var(--pew-bg);
}

/* --- SAFETY FIX --- */
/* Hide auto-generated breaks in Top Bar AND Filters */
.pew-top-bar br,
.pew-filter-column br {
    display: none !important;
}

/* Ensure nothing inherits bottom margin */
.pew-view-toggles * {
    margin-bottom: 0 !important;
}

/* --- TOOLBAR STYLES --- */
.pew-card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Pushes to bottom of body if flex */
    padding-top: 15px;
    border-top: 1px dashed var(--pew-border);
    gap: 10px;
}

.pew-tools-admin,
.pew-tools-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Base style for tool buttons/icons */
.pew-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: var(--pew-text-muted);
    transition: all 0.2s;
    background: transparent;
    cursor: pointer;
}

.pew-tool-btn:hover {
    color: var(--pew-primary);
    background: rgba(0,0,0,0.03);
}

/* Specific Styles for the X Icon */
.pew-x-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.pew-x-icon:hover {
    color: #000; /* X brand color (black) */
    background: rgba(0,0,0,0.05);
}

/* Dark mode fix for X icon */
body.pew-dark-mode .pew-x-icon:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* Shortcode Content Handling */
/* Since we don't know exactly what HTML the shortcodes output (usually <a> tags),
   we try to force them to fit neatly in our toolbar */
.pew-tool-btn a,
.pew-tool-btn button,
.pew-tool-btn i,
.pew-tool-btn svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit; /* Inherit hover color from parent */
    border: none;
    background: none;
    font-size: 16px; /* Adjust icon size */
}

/* Specific spacing tweaks for list view */
.pew-list .pew-card-toolbar {
    margin-top: 15px;
    padding-top: 0;
    border-top: none;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid rgba(0,0,0,0.1);
    border-left-color: var(--pew-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pew-no-results {
    text-align: center;
    padding: 50px;
    background: var(--pew-card-bg);
    border-radius: var(--pew-radius);
    color: var(--pew-text);
    border: 1px dashed var(--pew-border);
    grid-column: 1 / -1;
}

/* --- AD CARD STYLING --- */
.pew-ad-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px; /* Aligns with standard news cards */
    background: #f9f9f9;
    border-style: dashed;
    border-color: #ddd;
}

/* --- FULL WIDTH AD --- */
.pew-full-width-ad {
    width: 100%;
    margin: 40px 0; /* Space above and below the ad row */
    text-align: center;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    clear: both;
}

/* Ensure the ad doesn't overflow horizontally */
.pew-full-width-ad img,
.pew-full-width-ad iframe,
.pew-full-width-ad div {
    max-width: 100%;
    height: auto;
}

/* Hide empty grids if the loop ends weirdly */
.pew-grid:empty {
    display: none;
}

/* Dark mode */
body.pew-dark-mode .pew-ad-card {
    background: #252525;
    border-color: #444;
}

/* =========================================
   GLOBAL SITE OVERRIDES (Outside the Feed)
   ========================================= */

/* 1. Handle Elementor Headings (e.g., "Hottest Stories") */
/* We use !important to ensure we override Elementor's specific coloring */
body.pew-dark-mode .elementor-widget-heading .elementor-heading-title {
    color: var(--pew-text) !important;
    transition: color 0.3s ease;
}

/* 2. Handle the Site Logo */
/* This inverts the black logo colors to make it white when dark mode is active.
   Adding brightness(2) ensures it is a crisp, bright white. */
body.pew-dark-mode img.wp-image-60979 {
    filter: invert(1) brightness(2);
    transition: filter 0.3s ease;
}

/* 3. Footer Background Override */
/* Targets the Elementor Footer container specifically */
body.pew-dark-mode [data-elementor-type="footer"] {
    background-color: var(--pew-bg) !important;
    background-image: none !important; /* Removes any background images/gradients */
}

/* Ensure inner containers in the footer don't hold onto white backgrounds */
body.pew-dark-mode [data-elementor-type="footer"] .elementor-element {
    background-color: transparent !important;
}

/* 4. High Contrast Links (Global) */
/* Forces all links and Elementor menu items to pure white in Night Mode */
body.pew-dark-mode a,
body.pew-dark-mode .elementor-item,
body.pew-dark-mode .elementor-icon-list-text,
body.pew-dark-mode .elementor-social-icon i {
    color: #ffffff !important;
}

/* Link Hover State - uses your Primary Red for pop */
body.pew-dark-mode a:hover,
body.pew-dark-mode .elementor-item:hover,
body.pew-dark-mode .elementor-social-icon:hover i {
    color: var(--pew-primary) !important;
}

/* 5. Fix Social Icon Bubbles */
/* Ensures social icons have a dark background so they don't disappear */
body.pew-dark-mode .elementor-social-icon {
    background-color: #333 !important;
    border: 1px solid #555;
}

.pew-ad-inner {
    text-align: center;
    width: 100%;
}
/* Responsive */
@media (max-width: 768px) {
    .pew-list .pew-card {
        flex-direction: column;
        height: auto;
    }
    .pew-list .pew-card-media {
        width: 100%;
        height: 200px;
    }
    .pew-top-bar {
        flex-direction: row;
    }
    .pew-filters-grid {
        grid-template-columns: 1fr;
    }
}