/* Home Builder Grid System - STRICT AND CLEAN */
.noskhabar-dynamic-homepage {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 30px;
}

/* Global Card Styles */
.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    height: 100%;
    width: 100%;
}
.card-thumb {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    width: 100%;
}
.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card-content {
    padding: 12px 0 0 0;
}
.card-title {
    font-size: 1rem;
    margin: 0;
    line-height: 1.4;
    transition: color 0.2s ease;
    font-weight: 700;
    text-align: right;
    color: #222;
}
.card-link:hover .card-title {
    color: #d62828;
}

/* 1. Featured Grid (2 | 1 Slider | 2) */
.featured-grid {
    max-width: 1400px;
    margin: 0 auto;
    height: 560px;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
}
.featured-col {
    min-height: 0;
    overflow: hidden;
}

/* Side Columns */
.side-column {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
    min-height: 0;
}
.side-column .side-card {
    min-height: 0;
    overflow: hidden;
    position: relative;
    border-radius: 4px;
}
.side-column .card-thumb {
    height: 100%;
    width: 100%;
}
.side-column .card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.side-column .card-content {
    padding: 10px 0 0 0;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.9) 70%, transparent 100%);
    padding: 30px 10px 10px;
    text-align: right;
}

/* Center Column (Swiper) */
.center-column {
    min-height: 0;
    overflow: hidden;
    border-radius: 4px;
}
.center-column .swiper {
    width: 100%;
    height: 100%;
}
.center-column .large-card {
    height: 100%;
    position: relative;
}
.center-column .card-thumb {
    height: 100%;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
}
.center-column .card-cat {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.85rem;
    padding: 4px 12px;
    z-index: 10;
    font-weight: bold;
    border-radius: 2px;
}
.center-column .overlay-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    color: #fff;
    padding: 40px 30px 30px;
    z-index: 5;
    text-align: center;
}
.center-column .card-title {
    color: #fff;
    font-size: 1.4rem;
    line-height: 1.4;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.center-column .card-link:hover .card-title {
    color: #fff; /* Keep white on hover for overlay */
}

/* Swiper Customizations */
.swiper-pagination-bullet {
    background: rgba(255, 255, 255, 0.5);
    opacity: 1;
}
.swiper-pagination-bullet-active {
    background: #d62828;
}
.swiper-button-next, .swiper-button-prev {
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* 2. Dynamic 2 Columns */
.dynamic-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.dynamic-two-col .card-thumb {
    aspect-ratio: 16 / 9;
}

/* 3. Dynamic 3 Columns */
.dynamic-three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.dynamic-three-col .card-thumb {
    aspect-ratio: 16 / 9;
}

/* 4. List with Sidebar */
.dynamic-list-sidebar {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}
.nos-list-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.nos-list-view .list-card .card-link {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}
.nos-list-view .list-card:last-child .card-link {
    border-bottom: none;
    padding-bottom: 0;
}
.nos-list-view .list-card .card-thumb {
    aspect-ratio: 16 / 10;
}
.nos-sidebar-view {
    background: #f9f9f9;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 1199px) {
    .featured-grid {
        height: 500px;
    }
}

@media (max-width: 991px) {
    .featured-grid {
        height: auto;
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
    .center-column {
        order: -1;
    }
    .center-column .swiper {
        min-height: 350px;
    }
    .dynamic-two-col, .dynamic-three-col, .dynamic-list-sidebar {
        grid-template-columns: 1fr;
    }
    .nos-list-view .list-card .card-link {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Layout A (1 Large + 4 Small)
   ========================================================================== */

.layout-a-title-bar {
    background-color: #eaf0f6;
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    margin-bottom: 25px;
    min-height: 40px;
    position: relative;
}

.title-ribbon {
    color: #fff;
    padding: 8px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    position: relative;
    display: flex;
    align-items: center;
}
.title-ribbon a {
    color: #fff;
    text-decoration: none;
}

/* RTL Ribbon Fold */
[dir="rtl"] .layout-a-title-bar {
    justify-content: flex-end; /* Push to right side */
}
[dir="rtl"] .title-ribbon::before {
    content: '';
    position: absolute;
    top: 0;
    left: -15px; /* Stick out to the left */
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-right: 15px solid var(--ribbon-color, #6a99c9);
}

/* LTR Ribbon Fold */
[dir="ltr"] .title-ribbon::after {
    content: '';
    position: absolute;
    top: 0;
    right: -15px;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-left: 15px solid var(--ribbon-color, #6a99c9);
}

.layout-a-grid {
    display: grid;
    grid-template-columns: 6fr 4fr; /* exactly 60% / 40% */
    gap: 20px;
    align-items: stretch;
    height: 480px; /* fixed height to match original design and prevent stretching */
}

.layout-a-grid.flipped {
    grid-template-columns: 4fr 6fr;
}
.layout-a-grid.flipped .side-large {
    order: 2;
}
.layout-a-grid.flipped .side-grid {
    order: 1;
}

/* 4 small posts in a 2x2 grid */
.layout-a-grid .side-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    height: 100%;
}

.layout-a-grid .side-large {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* All cards: flex column to fill space */
.layout-a-grid .featured-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    height: 100%;
}

.layout-a-grid .featured-card .card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Large card image fills most of the card */
.layout-a-grid .large-card .card-thumb {
    flex: 1 1 auto;
    position: relative;
    min-height: 200px;
    background-color: transparent;
}

.layout-a-grid .large-card .card-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Large card text */
.layout-a-grid .large-card .card-content {
    flex-shrink: 0;
    padding: 12px 0 4px;
}

.layout-a-grid .large-card .card-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 8px;
    color: #111;
}

.layout-a-grid .large-card .post-meta {
    color: #888;
    font-size: 0.82rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layout-a-grid .large-card .post-excerpt {
    color: #555;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Small cards: image takes most space, small title below */
.layout-a-grid .small-card {
    border-bottom: none;
}

.layout-a-grid .small-card .card-thumb {
    flex: 1 1 auto;
    position: relative;
    min-height: 100px;
}

.layout-a-grid .small-card .card-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.layout-a-grid .small-card .card-content {
    flex-shrink: 0;
    padding: 6px 0 2px;
}

.layout-a-grid .small-card .card-title {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
    color: #111;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}



/* Category Badge */
.card-cat {
    position: absolute;
    top: 0;
    right: 0;
    color: #fff;
    padding: 3px 8px;
    font-size: 0.75rem;
    z-index: 2;
    pointer-events: none;
}
[dir="ltr"] .card-cat {
    right: auto;
    left: 0;
}

/* Responsive Layout A */
@media (max-width: 991px) {
    .layout-a-grid {
        grid-template-columns: 1fr;
    }
    .layout-a-grid .large-card .card-thumb {
        padding-top: 60%; /* On mobile, fallback to padding ratio */
        min-height: 0;
    }
}
@media (max-width: 575px) {
    .layout-a-grid .side-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
}

/* Layout B (4 Vertical Columns) */
.layout-b-title {
    position: relative;
    margin-bottom: 20px;
    text-align: right;
}
.layout-b-title .title-badge {
    display: inline-block;
    color: #fff;
    padding: 5px 15px;
    font-weight: bold;
    font-size: 16px;
    border-radius: 3px;
}
.layout-b-title .title-badge a {
    color: #fff;
    text-decoration: none;
}
.layout-b-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.layout-b-card {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    aspect-ratio: 3/4;
}
.layout-b-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.layout-b-cat {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: bold;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
    z-index: 2;
}
.layout-b-card .card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 15px 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0));
    color: #fff;
    z-index: 1;
    text-align: center;
}
.layout-b-card .card-title {
    color: #fff;
    font-size: 16px;
    line-height: 1.4;
    margin: 0 0 10px;
}
.layout-b-card .post-meta {
    color: #ddd;
    font-size: 13px;
}

/* ==========================================================================
   Layout C (Half Width Block)
   ========================================================================== */

.layout-c-block {
    width: 100%;
    margin-bottom: 50px;
}
.layout-c-grid {
    display: block;
}
.layout-c-card {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
}
.layout-c-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.layout-c-card .card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 20px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
    color: #fff;
    z-index: 1;
}
.layout-c-card .card-title {
    color: #fff;
    font-size: 20px;
    margin-bottom: 10px;
}
.layout-c-card .post-meta {
    color: #ddd;
    font-size: 14px;
}

/* Clearfix for the container holding Layout C blocks */
.noskhabar-dynamic-homepage::after {
    content: '';
    display: table;
    clear: both;
}

/* Mobile Adjustments for B & C */
@media (max-width: 991px) {
    .layout-b-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .layout-c-block {
        width: 100%;
        float: none;
        margin-left: 0;
    }
}
@media (max-width: 575px) {
    .layout-b-grid {
        grid-template-columns: 1fr;
    }
}

.layout-b-card .card-cat {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: fit-content;
}

/* Force all category badges to be centered globally */
.card-cat {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: fit-content !important;
    top: 0;
}

.center-column .card-thumb {
    background-color: transparent;
}
.center-column .card-thumb img {
    object-fit: cover !important;
    object-position: top center !important;
}
@media (max-width: 991px) {
  /* Fix Mobile Hamburger Menu */
  .menu-toggle { display: flex !important; }
  .primary-menu-container {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: #fff; z-index: 999;
    padding: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  }
  .primary-menu-container.is-active { display: block !important; }
  .header-nav-area { position: relative; }
  .primary-menu-container ul { list-style: none; padding: 0; margin: 0; }
  .primary-menu-container ul li { margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
  
  /* Reset fixed heights that cause overlapping on mobile */
  .layout-a-grid { height: auto !important; }
  .layout-a-grid .side-grid { height: auto !important; display: flex !important; flex-direction: column !important; }
  .layout-a-grid .featured-card { min-height: 250px; }
  
  /* Layout C spacing */
  .layout-c-block { margin-bottom: 25px !important; }
  
  /* Reset slider explicit height to ensure image wrapper has height */
  .center-column, .noskhabar-hero-swiper { min-height: 300px !important; }
  .noskhabar-hero-swiper .swiper-slide { height: auto !important; }
  .noskhabar-hero-swiper .large-card { height: 100% !important; }
  .noskhabar-hero-swiper .card-link { display: flex !important; flex-direction: column !important; height: 100% !important; }
  .noskhabar-hero-swiper .card-thumb {
    position: relative !important;
    flex: 1 1 auto !important;
    min-height: 250px !important;
    height: 300px !important;
  }
  
  .featured-col { height: auto !important; }
  
  /* Removed bad image height constraints that broke layout overlays */
  
  /* Fix category badges on mobile */
  .card-cat { z-index: 10; }
}
@media (max-width: 991px) {
  .layout-a-grid, .layout-a-grid.flipped {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 991px) {
  .layout-c-card img,
  .layout-a-card img,
  .layout-b-card img,
  .featured-card img,
  .card-thumb img {
    height: 100% !important;
    width: 100% !important;
    object-fit: cover !important;
  }
  
  /* Make sure container height adapts if we don't want fixed 250px */
  /* Actually, since card-thumb has inline style height: 250px, forcing img to height 100% is the only way to fill it */
}
@media (max-width: 991px) {
  .menu-toggle {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: transparent !important;
    border: none !important;
    padding: 5px !important;
    margin: 0 !important;
    order: -1 !important; /* First item (Right in RTL) */
    box-shadow: none !important;
    outline: none !important;
    color: #000;
  }
  .header-nav-area {
    border-top: none !important;
    border-bottom: none !important;
  }
  .main-navigation {
    border-top: none !important;
  }
  .header-nav-area .nav-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
  }
  .header-search { order: 1 !important; margin: 0 !important; }
}
@media (max-width: 991px) { .menu-item-has-children > .sub-menu { display: none; padding-right: 15px; border-right: 2px solid #000; margin-top: 10px; background: #fdfdfd; } .menu-item-has-children.is-active > .sub-menu { display: block !important; } .menu-item-has-children > a::after { content: '\25BC'; font-size: 10px; float: left; margin-top: 6px; transition: transform 0.3s; } .menu-item-has-children.is-active > a::after { transform: rotate(180deg); } }

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: #f4c425; /* Logo yellow */
  color: #111;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background-color 0.3s;
  z-index: 9999;
}
.back-to-top:hover {
  background-color: #55bfd3; /* Logo cyan */
  transform: translateY(-3px);
  color: #fff;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
}
.list-thumb img, .card-thumb img { width: 100% !important; height: 100% !important; object-fit: cover !important; }
