/* Aggressive Layout Fixes for Blog Template */
body.page-template-template-blog #blog-posts-container {
    transition: opacity 0.4s ease;
    min-height: 400px;
    display: flex !important; /* Flexbox as a more robust fallback */
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    padding: 0 !important;
    max-width: 1200px !important; /* Standard container width */
    margin: 0 auto !important;
    gap: 40px !important;
}

body.page-template-template-blog #blog-posts-container.is-loading {
    opacity: 0.5;
    pointer-events: none;
    cursor: wait;
}

/* Ensure Featured Grid spans full width */
body.page-template-template-blog #blog-posts-container .featured-grid {
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-bottom: 50px !important;
}

/* Sidebar and Main Column Layout */
body.page-template-template-blog #blog-posts-container .blog-main-col {
    flex: 1 !important;
    min-width: 300px !important;
}

body.page-template-template-blog #blog-posts-container .blog-sidebar {
    width: 350px !important;
    flex: 0 0 350px !important;
}

/* Hero Section */
.blog-hero {
    position: relative;
    padding: 120px 0 80px;
    background-size: cover;
    background-position: center;
    color: #fff;
    text-align: center;
}

.blog-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0.9));
    z-index: 1;
}

.blog-hero .container {
    position: relative;
    z-index: 2;
}

.blog-hero h1 {
    font-family: var(--font-heading) !important;
    font-size: 48px;
    font-weight: 400;
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
}

.blog-hero .hero-desc {
    font-size: 18px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 30px;
    line-height: 1.6;
}

.blog-breadcrumbs {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.blog-breadcrumbs a {
    color: #fff;
    text-decoration: none;
    opacity: 0.8;
}

.blog-breadcrumbs span {
    margin: 0 10px;
    opacity: 0.5;
}

/* Filter Bar */
.blog-filter-bar {
    padding: 30px 0;
    background: #fff;
    border-bottom: 1px solid #eee;
    margin-bottom: 60px;
}

.filter-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.filter-categories {
    display: flex;
    gap: 15px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-categories li a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    padding: 10px 28px;
    border: 1px solid #eee;
    border-radius: 50px;
    background: #fff;
    display: inline-block;
}

.filter-categories li.active a {
    background: #c29941;
    color: #fff;
    border-color: #c29941;
}

.filter-categories li a:hover:not(.active a) {
    background: #f9f9f9;
    border-color: #ddd;
}

.filter-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-form-wrap {
    position: relative;
}

/* Adjusted Search Form Width to prevent mobile overflow */
body.page-template-template-blog .search-form-wrap input {
    padding: 0 20px 0 60px !important;
    height: 50px !important;
    line-height: 50px !important;
    border: none !important;
    border-radius: 12px !important;
    background: #f5f6f8 !important;
    font-size: 15px !important;
    width: 280px !important;
    max-width: 100% !important;
    transition: all 0.3s ease !important;
    color: #333 !important;
}

.search-form-wrap input::placeholder {
    color: #8c98a4;
    font-weight: 400;
    opacity: 0.8;
}

.search-form-wrap input:focus {
    width: 320px;
    max-width: 100%;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    outline: none;
}

body.page-template-template-blog .search-form-wrap i {
    position: absolute !important;
    left: 25px !important;
    right: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #6d7175 !important;
    font-size: 20px !important;
    font-weight: 300 !important;
    margin: 0 !important;
}

.sort-select select {
    padding: 12px 40px 12px 20px;
    border: 1px solid #eee;
    border-radius: 50px;
    background: #fff;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256'%3E%3Cpath fill='%23666' d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80a8,8,0,0,1,11.32-11.32L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

/* Featured Posts Grid */
.featured-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-bottom: 80px;
}

.featured-main {
    position: relative;
    height: 500px;
    border-radius: 25px !important;
    overflow: hidden;
}

.featured-side {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.featured-side-item {
    position: relative;
    height: 235px;
    border-radius: 25px !important;
    overflow: hidden;
}

.featured-card-link {
    display: block;
    height: 100%;
    width: 100%;
}

.featured-card-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1s ease;
}

.featured-card-link:hover img {
    transform: scale(1.05);
}

.featured-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #fff;
    pointer-events: none;
}

.featured-overlay .cat-tag {
    display: inline-block !important;
    background: transparent !important;
    border: 1px solid #c29941 !important;
    color: #c29941 !important;
    padding: 6px 22px !important;
    font-size: 12px !important;
    text-transform: capitalize !important;
    font-weight: 500 !important;
    border-radius: 50px !important;
    width: fit-content;
    margin-bottom: 15px;
    line-height: 1 !important;
    letter-spacing: 0.5px;
}

.featured-overlay h2, .featured-overlay h3 {
    font-family: var(--font-heading) !important;
    margin: 0 0 12px;
    line-height: 1.25;
    color: #fff;
}

.featured-main .featured-overlay h2 {
    font-size: 36px;
    font-weight: 600;
}

.featured-side-item .featured-overlay h3 {
    font-size: 22px;
    font-weight: 600;
}

.featured-overlay .post-excerpt {
    font-size: 15px;
    opacity: 0.85;
    margin-bottom: 20px;
    line-height: 1.5;
    max-width: 90%;
}

.featured-overlay .post-date {
    font-size: 13px;
    opacity: 0.7;
    font-weight: 300;
}

/* Main Archive Layout */
.blog-content-area .container {
    /* Grid handled by #blog-posts-container ID */
}

.posts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px 30px;
}

.blog-post-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.03);
    transition: all 0.4s ease;
    height: 100%;
}

.blog-post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.08);
}

.post-thumb {
    width: 100%;
    aspect-ratio: 16/11;
    overflow: hidden;
    margin-bottom: 0; /* Flush with content */
}

.post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.post-info {
    padding: 30px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.blog-post-card:hover .post-thumb img {
    transform: scale(1.08);
}

.post-info .cat-tag {
    display: inline-block !important;
    border: 1px solid #c29941 !important;
    color: #c29941 !important;
    font-size: 12px !important;
    text-transform: capitalize !important;
    font-weight: 500 !important;
    margin-bottom: 12px;
    padding: 5px 20px !important;
    border-radius: 50px !important;
    background: transparent !important;
    line-height: 1 !important;
    letter-spacing: 0.5px;
    width: fit-content !important;
    align-self: flex-start;
}

.post-info h3 {
    font-family: var(--font-heading) !important;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 15px;
    line-height: 1.4;
    color: #1a1a1a;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-post-card:hover h3 {
    color: #b18e47;
}

.post-info p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f2f2f2;
    padding-top: 20px;
    margin-top: auto;
}

.post-date {
    font-size: 13px;
    color: #fff;
}

.read-more {
    font-weight: 500;
    font-size: 14px;
    color: #b18e47;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.read-more:hover {
    opacity: 0.8;
}

/* Sidebar */
.blog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.sidebar-widget {
    background: #fff;
}

.sidebar-widget .widget-header {
    margin-bottom: 25px;
}

.sidebar-widget .widget-title {
    font-family: var(--font-heading) !important;
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 10px;
    position: relative;
}

.sidebar-widget .widget-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: #b18e47;
}

/* Latest Posts Widget */
.latest-posts-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.latest-post-item {
    display: flex;
    gap: 15px;
    text-decoration: none;
    color: inherit;
}

.lp-thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.lp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lp-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 5px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lp-content .lp-date {
    font-size: 12px;
    color: #999;
}

/* Categories List Widget */
.widget-categories ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-categories li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.widget-categories li:last-child {
    border-bottom: none;
}

.widget-categories li a {
    display: flex;
    justify-content: space-between;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    transition: color 0.3s ease;
}

.widget-categories li a:hover {
    color: #b18e47;
}

.widget-categories .cat-count {
    color: #999;
    font-size: 12px;
}

/* Sidebar CTA Banner */
.sidebar-cta {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    height: 250px;
    background-color: #b18e47;
    color: #fff;
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.sidebar-cta h3 {
    font-family: var(--font-heading) !important;
    font-size: 24px;
    margin-bottom: 15px;
}

.sidebar-cta p {
    font-size: 14px;
    margin-bottom: 20px;
    opacity: 0.9;
}

.sidebar-cta .btn-cta {
    background: #fff;
    color: #b18e47;
    padding: 10px 25px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
}

.sidebar-cta .btn-cta:hover {
    background: #f4f4f4;
    transform: translateY(-2px);
}

/* Pagination */
.blog-pagination {
    margin-top: 60px;
    display: flex;
    justify-content: center;
}

.blog-pagination .page-numbers {
    display: flex;
    gap: 10px;
    list-style: none;
    padding: 0;
}

.blog-pagination .page-numbers li a,
.blog-pagination .page-numbers li span {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
    border-radius: 4px;
    text-decoration: none;
    color: #666;
    font-weight: 600;
    transition: all 0.3s ease;
}

.blog-pagination .page-numbers li span.current,
.blog-pagination .page-numbers li a:hover {
    background: #b18e47;
    color: #fff;
    border-color: #b18e47;
}

/* Bottom Gold CTA */
.bottom-gold-cta {
    background-color: #b18e47;
    padding: 80px 0;
    text-align: center;
    color: #fff;
    margin-top: 100px;
}

.bottom-gold-cta h2 {
    font-family: var(--font-heading) !important;
    font-size: 36px;
    margin-bottom: 15px;
}

.bottom-gold-cta p {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 30px;
}

.bottom-gold-cta .btn-white {
    background: #fff;
    color: #b18e47;
    padding: 15px 40px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    display: inline-block;
    transition: all 0.3s ease;
}

.bottom-gold-cta .btn-white:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .blog-content-area .container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .featured-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 40px;
    }

    .featured-main {
        height: 400px;
    }

    .featured-side {
        flex-direction: row;
        gap: 20px;
    }

    .featured-side-item {
        flex: 1;
        height: 250px;
    }
    
    .filter-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 25px;
    }

    .filter-categories {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .blog-hero {
        padding: 80px 0 60px;
    }

    .blog-hero h1 {
        font-size: 32px !important;
    }

    .blog-hero .hero-desc {
        font-size: 15px;
        padding: 0 20px;
    }

    .blog-filter-bar {
        padding: 20px 0;
        margin-bottom: 30px;
    }

    .filter-categories {
        gap: 10px;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 5px 0 15px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .filter-categories::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Edge */
    }

    .filter-categories li a {
        padding: 8px 18px;
        font-size: 13px;
        white-space: nowrap;
    }

    .filter-actions {
        width: 100%;
        flex-direction: column;
        gap: 15px;
    }

    .search-form-wrap, 
    .search-form-wrap .search-form,
    body.page-template-template-blog .search-form-wrap input {
        width: 100% !important;
    }

    .sort-select {
        width: 100%;
    }

    .sort-select select {
        width: 100%;
        text-align: center;
        background-position: right 20px center;
    }

    .featured-main {
        height: 320px;
        border-radius: 15px !important;
    }

    .featured-side {
        flex-direction: column;
    }

    .featured-side-item {
        height: 200px;
        border-radius: 15px !important;
    }

    .featured-overlay {
        padding: 20px;
    }

    .featured-main .featured-overlay h2 {
        font-size: 24px;
    }

    .featured-side-item .featured-overlay h3 {
        font-size: 18px;
    }

    .featured-overlay .post-excerpt {
        display: none; /* Hide excerpt on mobile featured to save space */
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .post-info {
        padding: 20px;
    }

    .post-info h3 {
        font-size: 18px;
    }

    .bottom-gold-cta {
        padding: 60px 0;
        margin-top: 60px;
    }

    .bottom-gold-cta h2 {
        font-size: 26px;
    }

    .bottom-gold-cta p {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .blog-hero h1 {
        font-size: 24px;
    }

    .featured-main {
        height: 280px;
    }

    .featured-side-item {
        height: 180px;
    }
}

/* iPhone 12 and similar (390px viewport) */
@media (max-width: 430px) {
    body.page-template-template-blog #blog-posts-container {
        display: block !important;
        gap: 0 !important;
        max-width: 100% !important;
        padding: 0 14px !important;
    }

    body.page-template-template-blog #blog-posts-container .featured-grid,
    body.page-template-template-blog #blog-posts-container .blog-main-col,
    body.page-template-template-blog #blog-posts-container .blog-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        flex: 0 0 100% !important;
    }

    .blog-hero {
        padding: 72px 0 48px;
    }

    .blog-breadcrumbs {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .blog-hero h1 {
        font-size: 28px;
        line-height: 1.2;
        margin-bottom: 10px;
    }

    .blog-hero .hero-desc {
        font-size: 14px;
        line-height: 1.55;
        padding: 0 10px;
        margin-bottom: 0;
    }

    .blog-filter-bar {
        margin-bottom: 24px;
    }

    .filter-categories {
        gap: 8px;
        padding-bottom: 10px;
    }

    .filter-categories li a {
        padding: 7px 14px;
        font-size: 12px;
    }

    body.page-template-template-blog .search-form-wrap input {
        height: 46px !important;
        line-height: 46px !important;
        padding-left: 48px !important;
        font-size: 14px !important;
    }

    body.page-template-template-blog .search-form-wrap i {
        left: 18px !important;
        font-size: 18px !important;
    }

    .sort-select select {
        font-size: 13px;
        padding: 11px 36px 11px 14px;
    }

    .featured-grid {
        margin-bottom: 28px;
    }

    .featured-main {
        height: 240px;
    }

    .featured-side-item {
        height: 170px;
    }

    .featured-overlay {
        padding: 16px;
    }

    .featured-main .featured-overlay h2 {
        font-size: 20px;
    }

    .featured-side-item .featured-overlay h3 {
        font-size: 16px;
    }

    .post-info {
        padding: 16px;
    }

    .post-info h3 {
        font-size: 17px;
        margin-bottom: 10px;
    }

    .post-info p {
        font-size: 13px;
        margin-bottom: 12px;
    }

    .post-footer {
        padding-top: 14px;
    }

    .bottom-gold-cta {
        padding: 44px 0;
        margin-top: 48px;
    }

    .bottom-gold-cta h2 {
        font-size: 22px;
        line-height: 1.3;
    }

    .bottom-gold-cta p {
        font-size: 14px;
        margin-bottom: 22px;
    }

    .bottom-gold-cta .btn-white {
        width: 100%;
        max-width: 260px;
        padding: 12px 18px;
        font-size: 14px;
    }
}
