/*
Theme Name: Weekly Ad Theme
Theme URI: https://example.com/weekly-ad-theme
Author: Flyersday.com
Author URI: https://example.com
Description: 
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: weeklyad
*/

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: #fff;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    position: relative;
    z-index: 99999;
    /* Highest priority */
}

footer {
    background: #fff;
    padding: 20px 0;
    border-bottom: none;
    border-top: 1px solid #eee;
    margin-top: 40px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.site-content {
    position: relative;
    z-index: 10;
    /* Lower than header */
}

h1,
h2,
h3 {
    color: #111;
}

.site-title a {
    text-decoration: none;
    color: #000;
    font-size: 24px;
    font-weight: bold;
}

/* Post & Card Styling */
.post,
.archive-grid-item {
    background: #fff;
    border-radius: 8px;
    /* Softer corners */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    /* Soft shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    /* Ensure content stays inside rounded corners */
}

.post:hover,
.archive-grid-item:hover {
    transform: translateY(-5px);
    /* Lift effect */
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
    /* Deeper shadow on hover */
}

/* Footer Styling */
.site-footer {
    background: #232323;
    /* Dark background */
    color: #bbb;
    padding: 60px 0 20px;
    margin-top: 60px;
    font-size: 14px;
}

.site-footer a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: #0073aa;
}

.footer-links {
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.footer-links a {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.site-info {
    border-top: 1px solid #444;
    padding-top: 20px;
    font-size: 12px;
    text-align: center;
}

/* Navigation */
.main-navigation {
    clear: both;
    display: block;
    float: right;
    width: 100%;
}

.main-navigation ul {
    display: none;
    list-style: none;
    margin: 0;
    padding-left: 0;
}

/* Mega Menu Styles */
.main-navigation ul ul {
    background: #fff;
    border: 1px solid #eee;
    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    /* Full width relative to container */
    z-index: 99999;
    display: none;
    /* Hidden by default */
    padding: 20px;
    box-sizing: border-box;

    /* Grid Layout for Mega Menu */
    display: none;
    /* Hidden by default */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

/* Show Mega Menu on Hover */
.main-navigation ul li:hover>ul,
.main-navigation ul li.focus>ul {
    display: grid;
    /* Switch to grid on hover */
}

.main-navigation ul ul ul {
    position: static;
    /* Reset nested positioning */
    display: block;
    box-shadow: none;
    border: none;
    padding: 0;
    width: auto;
}

.main-navigation ul ul li {
    float: none;
    /* Reset float */
    width: auto;
}

.main-navigation ul ul a {
    width: auto;
    font-weight: bold;
    /* Headers */
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
}

.main-navigation ul ul ul a {
    font-weight: normal;
    border-bottom: none;
    padding: 3px 0;
}

.main-navigation .menu-item-has-children>a:after {
    content: "\25BC";
    display: inline-block;
    padding-left: 5px;
    font-size: 10px;
}

.main-navigation li {
    float: left;
    position: static;
    /* Important for full-width mega menu */
}

.main-navigation a {
    display: block;
    text-decoration: none;
    color: #333;
    padding: 10px 15px;
}

.main-navigation a:hover,
.main-navigation a:focus {
    color: #0073aa;
}

/* Small menu */
.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid #ccc;
    padding: 10px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

/* Pagination Styles */
.page-links {
    clear: both;
    margin: 20px 0;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.page-links-title {
    font-weight: bold;
    margin-right: 10px;
    text-transform: uppercase;
    font-size: 14px;
    color: #555;
}

.page-links a,
.page-links>span {
    display: inline-block;
    padding: 8px 14px;
    margin-right: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background-color: #fff;
    transition: all 0.2s ease;
    font-size: 14px;
    min-width: 15px;
    text-align: center;
}

.page-links a:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
    color: #000;
}

.page-links>span:not(.page-links-title) {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
    font-weight: bold;
}

/* Main Query Pagination (Index/Archive) */
.pagination {
    clear: both;
    margin: 40px 0;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.pagination .nav-links {
    display: inline-block;
}

.pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background-color: #fff;
    transition: all 0.2s ease;
    font-size: 14px;
    min-width: 15px;
    text-align: center;
}

.pagination .page-numbers:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
    color: #000;
}

.pagination .page-numbers.current {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
    font-weight: bold;
}

.pagination .page-numbers.dots {
    border: none;
    background: transparent;
}

@media screen and (max-width: 768px) {
    .main-navigation {
        float: none;
    }

    .menu-toggle {
        display: block;
    }

    .main-navigation ul {
        display: none;
    }

    .main-navigation.toggled ul {
        display: block;
    }

    .main-navigation li {
        float: none;
        border-top: 1px solid #eee;
        position: relative;
        /* Reset static for mobile */
    }

    .main-navigation ul ul {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        width: auto;
        padding: 0 0 0 20px;
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }

    .main-navigation ul ul a {
        width: auto;
        padding-left: 0;
    }

    .main-navigation.toggled ul ul {
        display: block;
    }

    .main-navigation ul li:hover>ul,
    .main-navigation ul li.focus>ul {
        display: block;
        /* Block on mobile, not grid */
    }
}

@media screen and (min-width: 769px) {
    .main-navigation ul {
        display: block;
    }

    /* Ensure container is relative for mega menu positioning */
    .main-navigation {
        position: relative;
    }
}

/* Archive Grid Layout */
.archive-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
    /* Negative margin for gutter */
}

.archive-grid-item {
    width: 50%;
    /* 2 items per row */
    padding: 0 10px;
    /* Gutter */
    box-sizing: border-box;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
}

.archive-post-thumbnail {
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f0f0;
    aspect-ratio: 9 / 16;
    /* Enforce aspect ratio */
}

.archive-post-thumbnail a {
    display: block;
    height: 100%;
}

.archive-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Cover the area */
    display: block;
    transition: transform 0.3s ease;
}

.archive-post-thumbnail:hover img {
    transform: scale(1.05);
    /* Zoom effect on hover */
}

.archive-grid-item .entry-header {
    margin-top: auto;
    /* Push header to bottom if needed, or just standard flow */
}

.archive-grid-item .entry-title {
    font-size: 18px;
    margin: 0;
    line-height: 1.4;
}

.archive-grid-item .entry-title a {
    color: #333;
    text-decoration: none;
}

.archive-grid-item .entry-title a:hover {
    color: #0073aa;
}

/* Mobile Responsive for Grid */
@media screen and (max-width: 600px) {
    .archive-grid-item {
        width: 100%;
        /* 1 item per row on mobile */
    }
}

/* Index Grid Layout - 4 Columns */
.index-grid .archive-grid-item {
    width: 25%;
    /* 4 items per row */
}

@media screen and (max-width: 992px) {
    .index-grid .archive-grid-item {
        width: 50%;
        /* 2 items per row on tablet */
    }
}

@media screen and (max-width: 600px) {
    .index-grid .archive-grid-item {
        width: 100%;
        /* 1 item per row on mobile */
    }
}

/* =========================================
   Header Layout & Search Styles
   ========================================= */

/* Make Header Container Flex to align Branding and Nav */
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    /* Allow wrap on mobile only if needed */
}

.site-branding {
    margin-right: 30px;
    flex-shrink: 0;
}

/* Navigation takes remaining space and splits Menu/Search */
.main-navigation {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Pushes Menu Left, Search Right */
}

.main-navigation ul {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.header-search-wrapper {
    margin-left: auto;
    /* Ensure it sticks to the right */
    position: relative;
    z-index: 1000;
}

.search-form {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 50px;
    padding: 5px 15px;
    border: 1px solid #e1e1e1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
    white-space: nowrap;
    /* Prevent internal wrapping */
}

.search-form:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.search-form .search-field {
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    width: 200px;
    /* Fixed robust width */
    outline: none;
    color: #333;
}

.search-form .search-field::placeholder {
    color: #999;
}

.search-form .search-submit {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: 5px;
    color: #777;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

.search-form .search-submit:hover {
    color: #0073aa;
    background: #f0f8ff;
}

/* Mobile Adjustments */
@media screen and (max-width: 900px) {
    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-navigation {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 15px;
    }

    .main-navigation ul {
        margin-bottom: 15px;
        width: 100%;
    }

    .header-search-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .search-form {
        width: 100%;
        box-sizing: border-box;
    }

    .search-form .search-field {
        width: 100%;
        flex: 1;
    }

    /* Related Posts (Single Page) - Mobile Adjustments */
    @media (max-width: 768px) {
        .random-posts-section .archive-grid {
            grid-template-columns: repeat(2, 1fr);
        }

        .random-posts-section .archive-grid-item .archive-post-thumbnail {
            height: 180px;
        }
    }
}

/* =========================================
   Related Posts (Single Page) - Global Styles
   ========================================= */
.random-posts-section .archive-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    /* Force 4 items per row */
    gap: 20px !important;
    margin: 0 !important;
}

.random-posts-section .archive-grid-item {
    width: 100% !important;
    /* Override any theme width */
    margin-bottom: 0 !important;
    padding: 0 !important;
}

.random-posts-section .archive-grid-item .archive-post-thumbnail {
    aspect-ratio: 9 / 16;
    background: #f0f0f0;
    margin-bottom: 10px;
}

.random-posts-section .archive-grid-item .archive-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.random-posts-section .entry-title {
    font-size: 15px;
    text-align: center;
    font-weight: 600;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .random-posts-section .archive-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .random-posts-section .archive-grid-item .archive-post-thumbnail {
        height: 180px;
    }
}

@media screen and (max-width: 480px) {
    .random-posts-section .archive-grid {
        grid-template-columns: 1fr !important;
    }
}