<?php
$tt_page_info = array(
  'Page_Info' =>   array(
    'Title' => '',
    'Description' => '',
    'Keyword' => '',
  ),
  'Social_og' => array(
    'Image' => '',
    'Type' => 'website',
    'URL' => '',
  ),
);
require_once('./header.php');
?>
<script type="application/ld+json">
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [{
        "@type": "ListItem",
        "position": 1,
        "name": "Home",
        "item": "<?php echo $site_domain ?>"
    }]
}
</script>

<style>
/* ============================================================
   TRENDING SECTION — Colorful Eye-Catching Redesign
   ============================================================ */
.trending-area { margin-bottom: 10px; }

.trending-wrapper {
    display: flex;
    align-items: stretch;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid #ececec;
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg,#ff5858,#f857a6,#a86cf0,#36d1dc,#11998e,#f7971e) 1;
    border-radius: 10px;
    overflow: hidden;
    min-height: 46px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    position: relative;
}

/* Label */
.trending-label {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 0 22px 0 16px;
    background: linear-gradient(135deg, var(--tt_primary_color, #c20000) 0%, color-mix(in srgb, var(--tt_primary_color, #c20000) 75%, #000) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.6px;
    white-space: nowrap;
    position: relative;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0,0,0,.18);
    overflow: hidden;
}
.trending-label::after {
    content: '';
    position: absolute;
    right: -13px; top: 0; bottom: 0;
    width: 26px;
    background: inherit;
    clip-path: polygon(0 0, 45% 0, 100% 50%, 45% 100%, 0 100%);
    z-index: 2;
}
.trending-label::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: -60%;
    width: 40%;
    background: linear-gradient(115deg, transparent, rgba(255,255,255,.45), transparent);
    transform: skewX(-20deg);
    animation: trendShine 3.2s ease-in-out infinite;
    z-index: 1;
}
@keyframes trendShine {
    0%   { left: -60%; }
    55%  { left: 130%; }
    100% { left: 130%; }
}
.trending-label .t-icon {
    font-size: 13px;
    position: relative;
    z-index: 2;
    animation: trendFire 1.4s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 4px rgba(255,180,0,.7));
}
.trending-label .t-text { position: relative; z-index: 2; }
@keyframes trendFire {
    from { transform: scale(1) rotate(-6deg); }
    to   { transform: scale(1.25) rotate(6deg); opacity:.85; }
}

/* Tags area */
.trending-scroll-wrap {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
}
.trending-scroll-wrap::before {
    content:'';
    position:absolute;
    left:0;top:0;bottom:0;
    width:18px;
    background:linear-gradient(to right,#fff 10%,transparent);
    pointer-events:none;
    z-index:2;
}
.trending-scroll-wrap::after {
    content:'';
    position:absolute;
    right:0;top:0;bottom:0;
    width:34px;
    background:linear-gradient(to right,transparent,#fff 90%);
    pointer-events:none;
    z-index:2;
}
.trending-scroll {
    display: flex;
    align-items: center;
    padding: 0 12px 0 22px;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 7px;
    min-height: 46px;
}
.trending-scroll::-webkit-scrollbar { display: none; }

/* Colorful gradient pills — color cycles per tag */
.trending-scroll a {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--tg-c1), var(--tg-c2));
    box-shadow: 0 2px 7px color-mix(in srgb, var(--tg-c2) 45%, transparent);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
    line-height: 1.4;
    position: relative;
}
.trending-scroll a:nth-child(6n+1) { --tg-c1:#ff5858; --tg-c2:#f857a6; }
.trending-scroll a:nth-child(6n+2) { --tg-c1:#36d1dc; --tg-c2:#5b86e5; }
.trending-scroll a:nth-child(6n+3) { --tg-c1:#11998e; --tg-c2:#38ef7d; }
.trending-scroll a:nth-child(6n+4) { --tg-c1:#f7971e; --tg-c2:#ff5858; }
.trending-scroll a:nth-child(6n+5) { --tg-c1:#8e2de2; --tg-c2:#4a6cf0; }
.trending-scroll a:nth-child(6n+6) { --tg-c1:#ee0979; --tg-c2:#ff6a00; }
.trending-scroll a:hover {
    transform: translateY(-2px) scale(1.04);
    filter: brightness(1.08);
    box-shadow: 0 5px 12px color-mix(in srgb, var(--tg-c2) 55%, transparent);
}

@media (max-width:767px) {
    .trending-wrapper { border-radius:8px; min-height:40px; }
    .trending-label { padding: 0 16px 0 12px; font-size:11.5px; }
    .trending-label::after { right:-10px; width:20px; }
    .trending-scroll { padding:0 10px 0 16px; gap:6px; min-height:40px; }
    .trending-scroll a { font-size:12px; padding:5px 12px; }
}

/* ============================================================
   NEWS TICKER — Animated Theme-Color Border
   ============================================================ */
.mfit-ticker-frame {
    position: relative;
    padding: 2px;
    border-radius: 8px;
    background: conic-gradient(
        from var(--mfit-ticker-angle, 0deg),
        var(--tt_primary_color, #c20000),
        color-mix(in srgb, var(--tt_primary_color, #c20000) 50%, #fff),
        var(--tt_primary_color, #c20000),
        color-mix(in srgb, var(--tt_primary_color, #c20000) 30%, #fff),
        var(--tt_primary_color, #c20000)
    );
    animation: mfitTickerSpin 4s linear infinite;
    overflow: hidden;
}
.mfit-ticker-frame > .mahamudfutureit-ticker-container {
    border-radius: 6px;
    background: #fff;
}
@property --mfit-ticker-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
@keyframes mfitTickerSpin {
    to { --mfit-ticker-angle: 360deg; }
}
/* Fallback for browsers without @property (animates background-position) */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .mfit-ticker-frame {
        background: linear-gradient(90deg,
            var(--tt_primary_color, #c20000),
            color-mix(in srgb, var(--tt_primary_color, #c20000) 40%, #fff),
            var(--tt_primary_color, #c20000));
        background-size: 200% 100%;
        animation: mfitTickerSlide 3s linear infinite;
    }
    @keyframes mfitTickerSlide { to { background-position: -200% 0; } }
}


/* ============================================================
   SIDEBAR SLIDER
   ============================================================ */
.home-slider-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}
.home-slider-wrapper { overflow: hidden; }
.home-slider-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
}
.home-slider-slide { flex-shrink: 0; width: 100%; position: relative; }
.home-slider-slide a { display: block; position: relative; }
.home-slider-slide img {
    width: 100%; height: 400px;
    object-fit: cover; display: block;
}
.slide-title-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--tt_primary_color, #c20000);
    padding: 12px 20px; text-align: center;
}
.slide-title-overlay h2 {
    font-size: 20px; line-height: 28px;
    color: #fff; margin: 0; font-weight: 600;
}
.slider-arrow-left,
.slider-arrow-right {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px;
    background: rgba(0,0,0,0.5);
    border: none; border-radius: 50%;
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s; z-index: 10; font-size: 16px;
}
.slider-arrow-left:hover,
.slider-arrow-right:hover { background: var(--tt_primary_color, #c20000); }
.slider-arrow-left  { left: 15px; }
.slider-arrow-right { right: 15px; }

/* Desktop: sidebar slider ছোট */
@media (min-width: 992px) {
    .sidebar-slider .home-slider-slide img { height: 200px; }
    .sidebar-slider .slide-title-overlay { padding: 7px 10px; }
    .sidebar-slider .slide-title-overlay h2 { font-size: 14px; line-height: 20px; }
    .sidebar-slider .slider-arrow-left,
    .sidebar-slider .slider-arrow-right { width: 26px; height: 26px; font-size: 11px; }
    .sidebar-slider .slider-arrow-left  { left: 8px; }
    .sidebar-slider .slider-arrow-right { right: 8px; }
}
/* Mobile */
@media (max-width: 768px) {
    .home-slider-slide img { height: 200px; }
    .slide-title-overlay { padding: 10px 14px; }
    .slide-title-overlay h2 { font-size: 18px; line-height: 26px; }
    .slider-arrow-left,
    .slider-arrow-right { width: 28px; height: 28px; font-size: 12px; }
    .slider-arrow-left  { left: 8px; }
    .slider-arrow-right { right: 8px; }
}
</style>

<section class="pt-2 pb-4">
  <div class="container">

    <?php
    /* ── News Ticker ── */
    $news_ticker = getTickerArticles();
    if (!empty($news_ticker)): ?>
    <div class="mb-2 mfit-ticker-frame">
      <div class="mahamudfutureit-ticker-container mahamudfutureit-ticker-<?php echo $advancenews['NewsTickerDesign'] ?> d-flex align-items-center">
        <div class="mahamudfutureit-ticker-title">সর্বশেষ</div>
        <div id="mahamudfutureit-ticker-box" class="mahamudfutureit-ticker">
          <ul>
            <?php foreach ($news_ticker as $the_ticker): ?>
            <li>
              <div class="ticker-item">
                <img class="ticker_img_icon" src="<?php echo $advancenews['Website_Fevicon'] ?>" alt="<?php echo $advancenews['Website_title'] ?>">
                <a class="tech-text" href="<?php echo articleLink($the_ticker['PostId']) ?>"><?php echo $the_ticker['PostTitle'] ?></a>
              </div>
            </li>
            <?php endforeach; ?>
          </ul>
        </div>
      </div>
    </div>
    <?php endif; ?>

    <?php
    /* ── Trending Topics (সুন্দর + mobile scrollable) ── */
    if ($advancenews['HomeFeaturedTopic'] == 'on'):
      $hot_topic = showHotTopic();
      if (!empty($hot_topic)): ?>
    <div class="trending-area mb-2">
      <div class="trending-wrapper">
        <div class="trending-label">
          <span class="t-icon"><i class="fas fa-fire"></i></span>
          <span class="t-text">ট্রেন্ডিং</span>
        </div>
        <div class="trending-scroll-wrap">
          <div class="trending-scroll">
            <?php foreach ($hot_topic as $the_topic): ?>
            <a href="<?php echo getTopicsUrl($the_topic) ?>"><?php echo $the_topic ?></a>
            <?php endforeach; ?>
          </div>
        </div>
      </div>
    </div>
    <?php endif; endif; ?>

    <?php
    /* ════════════════════════════════════════════════════════════
       HIGHLIGHT NEWS SECTION (Banner + Highlighted Category)
       admin: mfit-admin/option-highlight-news.php
       ════════════════════════════════════════════════════════════ */
    if (!empty($advancenews['HighlightNewsOn']) && $advancenews['HighlightNewsOn'] == 'on'
        && !empty($advancenews['HighlightNewsCategory'])):
      $hl_cat_id  = $advancenews['HighlightNewsCategory'];
      $hl_banner  = !empty($advancenews['HighlightNewsBanner']) ? $advancenews['HighlightNewsBanner'] : '';
      $hl_bgcolor = !empty($advancenews['HighlightNewsBgColor']) ? $advancenews['HighlightNewsBgColor'] : '#0b3d2e';
      $hl_title   = !empty($advancenews['HighlightNewsTitle'])
                      ? $advancenews['HighlightNewsTitle']
                      : getSingleValue('mahamudfutureit_category','CategoryID',$hl_cat_id,'CategoryName');
      if (empty($hl_title)) { $hl_title = 'হাইলাইট'; }
      $hl_link    = function_exists('categoryInfo')
                      ? categoryInfo($hl_cat_id,'url')
                      : $site_domain.'category/'.getSingleValue('mahamudfutureit_category','CategoryID',$hl_cat_id,'CategoryURL').'/';
      $hl_posts   = getArticles($hl_cat_id, 5);
      if (!empty($hl_posts)):
    ?>
    <style>
      .mfit-highlight-wrap{margin:18px 0 22px;border-radius:14px;overflow:hidden;
        box-shadow:0 10px 30px -12px rgba(0,0,0,.18);}
      .mfit-highlight-banner{display:block;line-height:0;}
      .mfit-highlight-banner img{width:100%;height:auto;display:block;}
      .mfit-highlight-body{
        background:<?php echo htmlspecialchars($hl_bgcolor) ?>;
        background-image:linear-gradient(135deg, <?php echo htmlspecialchars($hl_bgcolor) ?> 0%, rgba(0,0,0,.35) 100%);
        padding:18px 18px 22px;color:#fff;
      }
      .mfit-highlight-head{display:flex;align-items:center;justify-content:space-between;
        margin-bottom:14px;gap:10px;flex-wrap:wrap;}
      .mfit-highlight-head h2{margin:0;font-size:22px;font-weight:800;color:#fff;
        display:inline-flex;align-items:center;gap:8px;letter-spacing:.2px;}
      .mfit-highlight-head h2 .mfit-hl-dot{width:10px;height:10px;border-radius:50%;
        background:#ffd400;box-shadow:0 0 0 4px rgba(255,212,0,.25);}
      .mfit-highlight-head a.mfit-hl-all{color:#fff;font-size:13px;text-decoration:none;
        background:rgba(255,255,255,.15);padding:5px 12px;border-radius:30px;
        transition:.25s;font-weight:600;}
      .mfit-highlight-head a.mfit-hl-all:hover{background:#fff;color:<?php echo htmlspecialchars($hl_bgcolor) ?>;}
      .mfit-highlight-grid{display:grid;gap:12px;}
      .mfit-hl-card{display:block;text-decoration:none;color:inherit;
        background:rgba(255,255,255,.06);border-radius:10px;overflow:hidden;
        transition:transform .25s, background .25s;}
      .mfit-hl-card:hover{transform:translateY(-3px);background:rgba(255,255,255,.12);}
      .mfit-hl-thumb{position:relative;overflow:hidden;aspect-ratio:16/10;background:#000;}
      .mfit-hl-thumb img{width:100%;height:100%;object-fit:cover;display:block;
        transition:transform .4s;}
      .mfit-hl-card:hover .mfit-hl-thumb img{transform:scale(1.06);}
      .mfit-hl-title{padding:10px 12px 14px;color:#fff;font-weight:600;
        line-height:1.5;font-size:14px;margin:0;
        display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;}
      .mfit-hl-main .mfit-hl-thumb{aspect-ratio:16/9;}
      .mfit-hl-main .mfit-hl-title{font-size:18px;-webkit-line-clamp:2;}

      /* Mobile: 1 main + 2x2 grid */
      @media (max-width: 991.98px){
        .mfit-highlight-grid{grid-template-columns:1fr 1fr;}
        .mfit-hl-main{grid-column:1 / -1;}
      }
      /* Desktop: 5 in one row */
      @media (min-width: 992px){
        .mfit-highlight-grid{grid-template-columns:repeat(5,1fr);}
        .mfit-hl-main .mfit-hl-thumb{aspect-ratio:16/10;}
        .mfit-hl-main .mfit-hl-title{font-size:14px;-webkit-line-clamp:3;}
      }
    </style>

    <div class="mfit-highlight-wrap">
      <?php if (!empty($hl_banner)): ?>
      <a href="<?php echo $hl_link ?>" class="mfit-highlight-banner">
        <img src="<?php echo $hl_banner ?>" alt="<?php echo htmlspecialchars($hl_title) ?>">
      </a>
      <?php endif; ?>
      <div class="mfit-highlight-body">
        <div class="mfit-highlight-head">
          <h2><span class="mfit-hl-dot"></span><?php echo $hl_title ?></h2>
          <a class="mfit-hl-all" href="<?php echo $hl_link ?>">সব দেখুন <i class="bi bi-arrow-right"></i></a>
        </div>
        <div class="mfit-highlight-grid">
          <?php $hl_i = 0; foreach ($hl_posts as $hl_p): $hl_i++; ?>
            <a href="<?php echo articleLink($hl_p['PostId']) ?>"
               class="mfit-hl-card<?php echo $hl_i === 1 ? ' mfit-hl-main' : '' ?>">
              <div class="mfit-hl-thumb">
                <img src="<?php echo $advancenews['ArticlePreloader'] ?>"
                     data-src="<?php echo articleImg($hl_p['PostId']) ?>"
                     alt="<?php echo htmlspecialchars($hl_p['PostTitle']) ?>">
              </div>
              <h3 class="mfit-hl-title"><?php echo $hl_p['PostTitle'] ?></h3>
            </a>
          <?php endforeach; ?>
        </div>
      </div>
    </div>
    <?php endif; endif; ?>

    <?php
    /* ── HomeAds1 ── */
    $home_ads_1 = showAds($advancenews['HomeAds1'], $advancenews['HomeAdsCtl']);
    if ($home_ads_1 != '') echo '<div class="py-3">'.$home_ads_1.'</div>';

    $getlead_post = getLeadArticles(6);
    $slider_posts = getSliderArticles(5);   // defined here for sidebar access
    ?>

    <?php /* ── MOBILE-ONLY SLIDER (lead-এর উপরে, শুধু mobile-এ দেখাবে) ── */
    if (!empty($slider_posts)): ?>
    <div class="home-slider-container sidebar-slider mb-3 d-block d-lg-none">
      <div class="home-slider-wrapper">
        <div class="home-slider-track" id="homeSliderTrackMobile">
          <?php foreach ($slider_posts as $sp): ?>
          <div class="home-slider-slide">
            <a href="<?php echo articleLink($sp['PostId']) ?>">
              <img src="<?php echo $advancenews['ArticlePreloader'] ?>"
                   data-src="<?php echo articleImg($sp['PostId'],'featured') ?>"
                   alt="<?php echo htmlspecialchars($sp['PostTitle']) ?>">
              <div class="slide-title-overlay">
                <h2><?php echo htmlspecialchars($sp['PostTitle']) ?></h2>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <button class="slider-arrow-left"  id="ssPrevMobile"><i class="fas fa-chevron-left"></i></button>
      <button class="slider-arrow-right" id="ssNextMobile"><i class="fas fa-chevron-right"></i></button>
    </div>
    <script>
    document.addEventListener('DOMContentLoaded',function(){
      var track=document.getElementById('homeSliderTrackMobile');
      if(!track)return;
      var slides=track.querySelectorAll('.home-slider-slide');
      if(slides.length<=1)return;
      var idx=0,tmr,cnt=slides.length;
      function go(n){idx=(n+cnt)%cnt;track.style.transform='translateX(-'+(idx*100)+'%)';reset();}
      function reset(){if(tmr)clearInterval(tmr);tmr=setInterval(function(){go(idx+1);},5000);}
      document.getElementById('ssPrevMobile').addEventListener('click',function(){go(idx-1);});
      document.getElementById('ssNextMobile').addEventListener('click',function(){go(idx+1);});
      reset();
      track.querySelectorAll('img[data-src]').forEach(function(i){i.src=i.dataset.src;i.removeAttribute('data-src');});
    });
    </script>
    <?php endif; ?>

    <div class="row">

      <!-- ═══ MAIN col-lg-9 ═══ -->
      <div class="col-lg-9">
        <div class="row g-3">
          <?php
          $get_lead_1   = articlePart($getlead_post, 1, 4);
          $lead_1_count = 1;
          if (!empty($get_lead_1)):
            foreach ($get_lead_1 as $lead_1):
              if ($lead_1_count == 1): ?>
              <div class="col-12">
                <div class="lead_first">
                  <div class="row g-3 align-items-center">
                    <div class="col-lg-6 order-1 order-lg-2">
                      <img class="w-100 rounded-2"
                           src="<?php echo $advancenews['ArticlePreloader'] ?>"
                           data-src="<?php echo articleImg($lead_1['PostId']) ?>"
                           alt="<?php echo $lead_1['PostTitle'] ?>">
                    </div>
                    <div class="col-lg-6 order-2 order-lg-1">
                      <a class="tech-text" href="<?php echo articleLink($lead_1['PostId']) ?>">
                        <h1 style="font-size:34px;line-height:40px;" class="mb-0 news-title"><?php echo $lead_1['PostTitle'] ?></h1>
                      </a>
                      <div class="summery-3"><?php echo str_replace('&nbsp;','&#160;',articleContentClean(strip_tags($lead_1['PostContent']))) ?></div>
                      <div><span class="news-time"><i class="bi bi-clock"></i> <?php echo articleTime($lead_1['PostDatePublic']) ?></span></div>
                    </div>
                  </div>
                </div>
              </div>
              <?php
              else:
                if ($lead_1_count == 2) echo '<div class="col-12 d-none d-lg-block"><hr class="m-0"></div>';
              ?>
              <div class="col-lg-4 d-none d-lg-block">
                <a class="tech-text" href="<?php echo articleLink($lead_1['PostId']) ?>">
                  <h1 class="mb-0 news-title-1"><?php echo $lead_1['PostTitle'] ?></h1>
                </a>
              </div>
              <?php
              endif;
              $lead_1_count++;
            endforeach;
          else:
            echo noPost();
          endif;

          /* ── HomeAds2 ── */
          $home_ads_2 = showAds($advancenews['HomeAds2'], $advancenews['HomeAdsCtl']);
          if ($home_ads_2 != '') echo '<div class="col-12">'.$home_ads_2.'</div>';

          /* ── Spotlight ── */
          $getspot_post = getSpotLightArticles(6);
          foreach ($getspot_post as $the_spotpost): ?>
          <div class="col-lg-4">
            <a style="height:100%" href="<?php echo articleLink($the_spotpost['PostId']) ?>" class="d-block rounded-2 tt-gray prothom-songbad-post-style p-2">
              <div class="row g-1 align-items-center">
                <div class="col-5">
                  <div class="position-relative overflow-hidden">
                    <img class="w-100 ps-post-line-img rounded-2"
                         src="<?php echo $advancenews['ArticlePreloader'] ?>"
                         data-src="<?php echo articleImg($the_spotpost['PostId']) ?>"
                         alt="<?php echo $the_spotpost['PostTitle'] ?>">
                  </div>
                </div>
                <div class="col-7">
                  <h1 class="p-2 news-title-3 m-0 tt-text"><?php echo $the_spotpost['PostTitle'] ?></h1>
                </div>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div><!-- /col-lg-9 -->

      <!-- ═══ SIDEBAR col-lg-3 ═══ -->
      <div class="col-lg-3">

        <?php /* ── HomeAds3 slot → SIDEBAR SLIDER (desktop only) ── */
        if (!empty($slider_posts)): ?>
        <div class="home-slider-container sidebar-slider mb-3 d-none d-lg-block">
          <div class="home-slider-wrapper">
            <div class="home-slider-track" id="homeSliderTrackSidebar">
              <?php foreach ($slider_posts as $sp): ?>
              <div class="home-slider-slide">
                <a href="<?php echo articleLink($sp['PostId']) ?>">
                  <img src="<?php echo $advancenews['ArticlePreloader'] ?>"
                       data-src="<?php echo articleImg($sp['PostId'],'featured') ?>"
                       alt="<?php echo htmlspecialchars($sp['PostTitle']) ?>">
                  <div class="slide-title-overlay">
                    <h2><?php echo htmlspecialchars($sp['PostTitle']) ?></h2>
                  </div>
                </a>
              </div>
              <?php endforeach; ?>
            </div>
          </div>
          <button class="slider-arrow-left"  id="ssPrev"><i class="fas fa-chevron-left"></i></button>
          <button class="slider-arrow-right" id="ssNext"><i class="fas fa-chevron-right"></i></button>
        </div>
        <script>
        document.addEventListener('DOMContentLoaded',function(){
          var track=document.getElementById('homeSliderTrackSidebar');
          if(!track)return;
          var slides=track.querySelectorAll('.home-slider-slide');
          if(slides.length<=1)return;
          var idx=0,tmr,cnt=slides.length;
          function go(n){idx=(n+cnt)%cnt;track.style.transform='translateX(-'+(idx*100)+'%)';reset();}
          function reset(){if(tmr)clearInterval(tmr);tmr=setInterval(function(){go(idx+1);},5000);}
          document.getElementById('ssPrev').addEventListener('click',function(){go(idx-1);});
          document.getElementById('ssNext').addEventListener('click',function(){go(idx+1);});
          var box=document.querySelector('.sidebar-slider');
          if(box){box.addEventListener('mouseenter',function(){if(tmr)clearInterval(tmr);});box.addEventListener('mouseleave',reset);}
          reset();
          track.querySelectorAll('img[data-src]').forEach(function(i){i.src=i.dataset.src;i.removeAttribute('data-src');});
        });
        </script>
        <?php endif; ?>

        <?php
        /* ── HomeAds4 ── */
        $home_ads_4 = showAds($advancenews['HomeAds4'], $advancenews['HomeAdsCtl']);
        if ($home_ads_4 != '') echo '<div class="mb-3 mt-md-0 mt-3">'.$home_ads_4.'</div>';

        $ps_block_5 = $advancenews['PostBlock5'];
        ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_5) ?></div>
          <?php
          $ps_block_5_article = getArticles($ps_block_5, 5);
          $ps_block_5_count   = 1;
          if (!empty($ps_block_5_article)):
            foreach ($ps_block_5_article as $the_ps_5):
              if ($ps_block_5_count == 1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative">
                  <a href="<?php echo articleLink($the_ps_5['PostId']) ?>">
                    <div class="ps-clead-img">
                      <img class="w-100 rounded-2"
                           src="<?php echo $advancenews['ArticlePreloader'] ?>"
                           data-src="<?php echo articleImg($the_ps_5['PostId']) ?>"
                           alt="<?php echo $the_ps_5['PostTitle'] ?>">
                    </div>
                    <div class="ps-clead-title">
                      <h1 class="p-2 news-title-3 m-0 text-white"><?php echo $the_ps_5['PostTitle'] ?></h1>
                    </div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($the_ps_5['PostId']) ?>" class="d-block tt-white prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5">
                      <div class="position-relative overflow-hidden">
                        <img class="w-100 ps-post-line-img rounded-2"
                             src="<?php echo $advancenews['ArticlePreloader'] ?>"
                             data-src="<?php echo articleImg($the_ps_5['PostId']) ?>"
                             alt="<?php echo $the_ps_5['PostTitle'] ?>">
                      </div>
                    </div>
                    <div class="col-7">
                      <h1 class="news-title-4 m-0 tt-text"><?php echo $the_ps_5['PostTitle'] ?></h1>
                    </div>
                  </div>
                </a>
              </div>
              <?php
              endif;
              $ps_block_5_count++;
            endforeach;
          else:
            echo '<div class="col-12">'.noPost().'</div>';
          endif;
          ?>
        </div>

      </div><!-- /col-lg-3 -->
    </div><!-- /row -->
  </div>
</section>

<style media="screen">
.mahamudfutureit_video_slider .slick-next:before,
.mahamudfutureit_video_slider .slick-prev:before { color: var(--tt_primary_color); }
.mahamudfutureit_video_slider .slick-slide { margin: 0 10px; }
.mahamudfutureit_video_slider .slick-list  { margin: 0 -10px; }

/* Keep prev/next arrows inside the section so they don't drift off-screen on mobile */
.mahamudfutureit_video_slider { position: relative; }
.mahamudfutureit_video_slider .slick-prev,
.mahamudfutureit_video_slider .slick-next {
    width: 32px; height: 32px;
    z-index: 5;
}
.mahamudfutureit_video_slider .slick-prev { left: 0; }
.mahamudfutureit_video_slider .slick-next { right: 0; }
@media (max-width: 767px) {
    .mahamudfutureit_video_slider .slick-prev,
    .mahamudfutureit_video_slider .slick-next {
        width: 26px; height: 26px;
        top: 40%;
    }
    .mahamudfutureit_video_slider .slick-prev { left: 2px; }
    .mahamudfutureit_video_slider .slick-next { right: 2px; }
}
</style>

<!-- ═══════════ VIDEO ═══════════ -->
<section class="py-4 tt-gray">
  <div class="container">
    <?php echo getBlockTitle('','ভিডিও  ',$site_domain.'video/') ?>
    <div class="mahamudfutureit_video_slider">
      <?php
      $tt_recent_video = showAllttdata("mahamudfutureit_video"," ORDER BY ID DESC LIMIT 8 OFFSET 1");
      if (!empty($tt_recent_video)):
        foreach ($tt_recent_video as $the_rvideo): ?>
        <div class="m-1">
          <div class="mahamudfutureit_vwraper overflow-hidden">
            <a href="<?php echo $site_domain ?>video/<?php echo $the_rvideo['ID'] ?>/" class="position-relative">
              <i class="bi bi-play-circle"></i>
              <img class="w-100 rounded-2" src="<?php echo $the_rvideo['FeaturedImage'] ?>" alt="<?php echo $the_rvideo['VideoTitle'] ?>">
            </a>
            <h3><a href="<?php echo $site_domain ?>video/<?php echo $the_rvideo['ID'] ?>/"><?php echo $the_rvideo['VideoTitle'] ?></a></h3>
          </div>
        </div>
        <?php
        endforeach;
      else:
        echo '<div class="text-center p-2 bg-light rounded-t">কোন ভিডিও নেই !</div>';
      endif;
      ?>
    </div>
  </div>
</section>
<script>
$('.mahamudfutureit_video_slider').slick({
  slidesToShow:4,slidesToScroll:1,autoplay:true,autoplaySpeed:2000,arrows:true,
  responsive:[{breakpoint:768,settings:{slidesToShow:2,slidesToScroll:1}}]
});
</script>

<?php
/* ════════════════════════════════════════════════════════════
   QUICK CATEGORY SECTION (12 clickable icons)
   admin: mfit-admin/option-quick-category.php
   Mobile: 3 per row × 4 rows  |  Desktop: 6 per row × 2 rows
   ════════════════════════════════════════════════════════════ */
if (!empty($advancenews['QuickCatOn']) && $advancenews['QuickCatOn'] == 'on'):
    $qc_bg     = !empty($advancenews['QuickCatBgColor']) ? $advancenews['QuickCatBgColor'] : '#ffffff';
    $qc_title  = !empty($advancenews['QuickCatTitle'])   ? $advancenews['QuickCatTitle']   : '';
    // Default icons (fallback if admin has not uploaded yet)
    $qc_defaults = array(
      1 => 'https://onenewsexpress.com/uploads/100070112%20(2).jpeg',
      2 => 'https://onenewsexpress.com/uploads/100070112%20(1).jpeg',
      3 => 'https://onenewsexpress.com/uploads/100070112.jpeg',
      4 => 'https://onenewsexpress.com/uploads/100070113.jpeg',
      5 => 'https://onenewsexpress.com/uploads/z5r9zoajfjsinqvahn3o.png',
      6 => 'https://onenewsexpress.com/uploads/gecqqvv2kth8hsbwuq8g.png',
      7 => 'https://onenewsexpress.com/uploads/ftopo6wtzuu3gide5hj8.png',
      8 => 'https://onenewsexpress.com/uploads/ztnvxv4e6sjctpqdjaoh.png',
      9 => 'https://onenewsexpress.com/uploads/biwnzsjmga5epsb56ptt.png',
     10 => 'https://onenewsexpress.com/uploads/jv2vaksmhrzkczfe8gna.png',
     11 => 'https://onenewsexpress.com/uploads/akq7ddxjcg97zr5rxscm.png',
     12 => 'https://onenewsexpress.com/uploads/y4d6nvhxgybmio2ceoxg.png',
    );
?>
<style>
.quick-cat-section { padding: 18px 0; }
.quick-cat-title {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 14px;
    color: #1a1a1a;
}
.quick-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.quick-cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    color: #222;
    text-align: center;
    transition: transform .2s ease;
}
.quick-cat-item:hover { transform: translateY(-3px); }
.quick-cat-item img {
    width: 68px; height: 68px;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,.10);
    background: #fff;
    border: 2px solid rgba(0,0,0,.05);
}
.quick-cat-item .qc-label {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    color: #333;
}
@media (min-width: 992px) {
    .quick-cat-grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
    .quick-cat-item img { width: 78px; height: 78px; }
    .quick-cat-item .qc-label { font-size: 14px; }
}
@media (max-width: 380px) {
    .quick-cat-item img { width: 58px; height: 58px; }
    .quick-cat-item .qc-label { font-size: 12px; }
}
</style>

<section class="quick-cat-section" style="background-color: <?php echo htmlspecialchars($qc_bg); ?>;">
  <div class="container">
    <?php if ($qc_title != ''): ?>
      <div class="quick-cat-title"><?php echo $qc_title; ?></div>
    <?php endif; ?>
    <div class="quick-cat-grid">
      <?php for ($i = 1; $i <= 12; $i++):
        $icon  = !empty($advancenews['QuickCat'.$i.'Icon'])  ? $advancenews['QuickCat'.$i.'Icon']  : $qc_defaults[$i];
        $link  = !empty($advancenews['QuickCat'.$i.'Link'])  ? $advancenews['QuickCat'.$i.'Link']  : '#';
        $label = !empty($advancenews['QuickCat'.$i.'Label']) ? $advancenews['QuickCat'.$i.'Label'] : '';
      ?>
        <a href="<?php echo htmlspecialchars($link); ?>" class="quick-cat-item">
          <img src="<?php echo htmlspecialchars($icon); ?>" alt="<?php echo htmlspecialchars($label ?: 'icon '.$i); ?>" loading="lazy">
          <?php if ($label != ''): ?><span class="qc-label"><?php echo htmlspecialchars($label); ?></span><?php endif; ?>
        </a>
      <?php endfor; ?>
    </div>
  </div>
</section>
<?php endif; ?>


<?php
/* ════════════════════════════════════════════════════════════
   HOMEPAGE TV SECTION (Live TV embedded on homepage)
   admin: mfit-admin/option-homepage-tv.php
   Toggle: HomeTVOn   |  Title: HomeTVTitle   |  BG: HomeTVBgColor
   Reuses LiveTV_Source / LiveTV_URL / LiveTV_Status from Live TV settings
   ════════════════════════════════════════════════════════════ */
if (!empty($advancenews['HomeTVOn']) && $advancenews['HomeTVOn'] == 'on'):
    $htv_bg     = !empty($advancenews['HomeTVBgColor']) ? $advancenews['HomeTVBgColor'] : '#0b0b0b';
    $htv_title  = !empty($advancenews['HomeTVTitle'])   ? $advancenews['HomeTVTitle']   : 'লাইভ টিভি';
    $htv_status = isset($advancenews['LiveTV_Status']) ? $advancenews['LiveTV_Status'] : 'deactive';
    $htv_source = isset($advancenews['LiveTV_Source']) ? $advancenews['LiveTV_Source'] : 'auto';
    $htv_url    = isset($advancenews['LiveTV_URL'])    ? trim($advancenews['LiveTV_URL']) : '';

    if ($htv_source === 'auto' && $htv_url !== '') {
        if (preg_match('~youtube\.com|youtu\.be~i', $htv_url))      { $htv_source = 'youtube'; }
        elseif (preg_match('~facebook\.com|fb\.watch~i', $htv_url)) { $htv_source = 'facebook'; }
        elseif (preg_match('~\.m3u8(\?|$)~i', $htv_url))            { $htv_source = 'hls'; }
        else                                                         { $htv_source = 'iframe'; }
    }
    $htv_embed = '';
    if ($htv_source === 'youtube') {
        $vid = '';
        if (preg_match('~(?:v=|youtu\.be/|embed/|live/)([A-Za-z0-9_\-]{6,})~', $htv_url, $m)) { $vid = $m[1]; }
        if ($vid !== '') {
            // No autoplay; user clicks play → sound on by default
            $htv_embed = 'https://www.youtube.com/embed/' . $vid
                       . '?autoplay=0&mute=0&controls=1&rel=0&modestbranding=1&playsinline=1';
        }
    } elseif ($htv_source === 'facebook') {
        $htv_embed = 'https://www.facebook.com/plugins/video.php?href=' . urlencode($htv_url)
                   . '&show_text=false&autoplay=false&mute=false&controls=true';
    } elseif ($htv_source === 'iframe') {
        $htv_embed = $htv_url;
    }
?>
<style>
.home-tv-section { padding: 22px 0; }
.home-tv-title {
    text-align: center;
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 14px;
    color: #fff;
    letter-spacing: .3px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.home-tv-title .live-dot{
    width:10px;height:10px;border-radius:50%;background:#e30613;
    box-shadow:0 0 0 0 rgba(227,6,19,.6);
    animation:liveDotPulse 1.4s infinite;
}
@keyframes liveDotPulse{
  0%{box-shadow:0 0 0 0 rgba(227,6,19,.6)}
  70%{box-shadow:0 0 0 10px rgba(227,6,19,0)}
  100%{box-shadow:0 0 0 0 rgba(227,6,19,0)}
}
.home-tv-frame {
    max-width: 720px;
    margin: 0 auto;
    padding: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.home-tv-box {
    position: relative; width: 100%;
    background:#000; overflow:hidden; line-height:0; font-size:0;
    border-radius: 10px;
}
.home-tv-box iframe, .home-tv-box video {
    display:block; width:100%; height:auto; aspect-ratio:16/9; border:0; background:#000;
}
.home-tv-off {
    width:100%; aspect-ratio:16/9;
    display:flex; align-items:center; justify-content:center;
    color:#bbb; font-size:18px; letter-spacing:1px; background:#000;
}
@media (max-width:600px){
    .home-tv-section { padding: 14px 0; }
    .home-tv-title { font-size: 17px; }
    .home-tv-frame { padding: 6px; border-radius: 10px; }
}
</style>
<section class="home-tv-section" style="background-color: <?php echo htmlspecialchars($htv_bg); ?>;">
  <div class="container">
    <div class="home-tv-title">
      <span class="live-dot"></span>
      <span><?php echo htmlspecialchars($htv_title); ?></span>
    </div>
    <div class="home-tv-frame">
      <div class="home-tv-box">
        <?php if ($htv_status !== 'active' || $htv_url === ''): ?>
          <div class="home-tv-off">● Off Air</div>
        <?php elseif ($htv_source === 'hls'): ?>
          <video id="home-tv-hls" playsinline controls preload="metadata"></video>
          <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
          <script>
          (function(){
            var v=document.getElementById('home-tv-hls');
            var u=<?php echo json_encode($htv_url); ?>;
            if(window.Hls && Hls.isSupported()){
              var h=new Hls(); h.loadSource(u); h.attachMedia(v);
              h.on(Hls.Events.MANIFEST_PARSED,function(){v.play().catch(function(){});});
            } else if (v.canPlayType('application/vnd.apple.mpegurl')){
              v.src=u; v.addEventListener('loadedmetadata',function(){v.play().catch(function(){});});
            } else { v.src=u; }
          })();
          </script>
        <?php elseif ($htv_embed !== ''): ?>
          <iframe src="<?php echo htmlspecialchars($htv_embed, ENT_QUOTES); ?>"
                  allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
                  allowfullscreen></iframe>
        <?php else: ?>
          <div class="home-tv-off">● Stream Unavailable</div>
        <?php endif; ?>
      </div>
    </div>
  </div>
</section>
<?php endif; ?>



<?php $ps_block_3 = $advancenews['PostBlock3']; ?>

<!-- ═══════════ POSTBLOCK4 + MOST-RECENT ═══════════ -->
<section class="py-5" style="background-color:#fff8f0;">
  <div class="container">
    <div class="row g-3">
      <div class="col-lg-9">
        <?php $ps_block_4 = $advancenews['PostBlock4']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_4) ?></div>
          <?php
          $ps_block_4_article = getArticles($ps_block_4, 6);
          $ps_block_4_count   = 1;
          if (!empty($ps_block_4_article)):
            foreach ($ps_block_4_article as $the_ps_4): ?>
            <div class="col-6 col-lg-<?php echo ($ps_block_4_count >= 3) ? '3' : '6' ?>">
              <a href="<?php echo articleLink($the_ps_4['PostId']) ?>" class="d-block tt-white prothom-songbad-post-style">
                <div class="align-items-center">
                  <div class="position-relative overflow-hidden">
                    <img class="w-100 rounded-2 ps-post-line-img"
                         src="<?php echo $advancenews['ArticlePreloader'] ?>"
                         data-src="<?php echo articleImg($the_ps_4['PostId']) ?>"
                         alt="<?php echo $the_ps_4['PostTitle'] ?>">
                  </div>
                  <h1 class="p-2 news-title-<?php echo ($ps_block_4_count >= 3) ? '3' : '2' ?> m-0 tt-text"><?php echo $the_ps_4['PostTitle'] ?></h1>
                </div>
              </a>
            </div>
            <?php
            $ps_block_4_count++;
            endforeach;
          else:
            echo '<div class="col-12">'.noPost().'</div>';
          endif;
          ?>
        </div>
      </div>

      <?php
      /* ── HomeAds5 (col-12 d-block d-lg-none) ── */
      $home_ads_5 = showAds($advancenews['HomeAds5'], $advancenews['HomeAdsCtl']);
      if ($home_ads_5 != '') echo '<div class="col-12 d-block d-lg-none">'.$home_ads_5.'</div>';
      ?>

      <div class="col-lg-3">
        <?php require_once('template-part/most-recent-2.php'); ?>

      </div>

      <?php
      /* ── HomeAds6 (col-lg-12 mt-3) ── */
      $home_ads_6 = showAds($advancenews['HomeAds6'], $advancenews['HomeAdsCtl']);
      if ($home_ads_6 != '') echo '<div class="col-lg-12 mt-3">'.$home_ads_6.'</div>';
      ?>
    </div>
  </div>
</section>

<!-- ═══════════ WEB STORY ═══════════ -->
<section class="py-5">
  <div class="container">
    <div class="mb-3">
      <?php echo getBlockTitle('','ওয়েব স্টোরি',$site_domain.'photo-stories/','bi bi-files-alt') ?>
    </div>
    <div class="swiper">
      <div class="swiper-wrapper">
        <?php
        $all_storys = showAllttdata('mahamudfutureit_photostories',"WHERE story_status='Published' AND story_date<='$the_time' ORDER BY story_date DESC LIMIT 12");
        foreach ($all_storys as $the_story):
          $story_items = json_decode($the_story['story_items'],true); ?>
          <div class="swiper-slide">
            <a href="<?php echo $site_domain.'photo-stories/'.$the_story['story_url'] ?>/" class="story-single-block" style="background-image:url(<?php echo $story_items[1]['storyimage'] ?>)">
              <h3 class="news-title-4"><?php echo $the_story['story_title'] ?></h3>
              <span class="photo-stories-icon"><i class="bi bi-files-alt"></i></span>
            </a>
          </div>
        <?php endforeach; ?>
      </div>
      <div class="swiper-button-prev"></div>
      <div class="swiper-button-next"></div>
    </div>
    <script>
    const swiper = new Swiper('.swiper',{
      direction:'horizontal',loop:false,spaceBetween:10,speed:500,
      navigation:{nextEl:'.swiper-button-next',prevEl:'.swiper-button-prev'},
      breakpoints:{100:{slidesPerView:2},576:{slidesPerView:2},768:{slidesPerView:4},1024:{slidesPerView:6}}
    });
    </script>
    <?php
    /* ── HomeAds7 ── */
    $home_ads_7 = showAds($advancenews['HomeAds7'], $advancenews['HomeAdsCtl']);
    if ($home_ads_7 != '') echo '<div class="col-lg-12 mt-3">'.$home_ads_7.'</div>';
    ?>
  </div>
</section>

<!-- ═══════════ POSTBLOCK 6 / 7 / 8 ═══════════ -->
<section class="py-5" style="background-color:#f3f9f4;">
  <div class="container">
    <div class="row g-3 mt-3">

      <!-- Block 6 -->
      <div class="col-lg-4">
        <?php $ps_block_6 = $advancenews['PostBlock6']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_6) ?></div>
          <?php
          $ps_block_6_article = getArticles($ps_block_6,5);
          $ps_block_6_count   = 1;
          if (!empty($ps_block_6_article)):
            foreach ($ps_block_6_article as $the_ps_6):
              if ($ps_block_6_count == 1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($the_ps_6['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_6['PostId']) ?>" alt="<?php echo $the_ps_6['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $the_ps_6['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($the_ps_6['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_6['PostId']) ?>" alt="<?php echo $the_ps_6['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $the_ps_6['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php
              endif;
              $ps_block_6_count++;
            endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds8 (d-block d-md-none, between block6 and block7) ── */
      $home_ads_8 = showAds($advancenews['HomeAds8'], $advancenews['HomeAdsCtl']);
      if ($home_ads_8 != '') echo '<div class="col-lg-12 d-block d-md-none">'.$home_ads_8.'</div>';
      ?>

      <!-- Block 7 -->
      <div class="col-lg-4">
        <?php $ps_block_7 = $advancenews['PostBlock7']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_7) ?></div>
          <?php
          $ps_block_7_article = getArticles($ps_block_7,5);
          $ps_block_7_count   = 1;
          if (!empty($ps_block_7_article)):
            foreach ($ps_block_7_article as $the_ps_7):
              if ($ps_block_7_count == 1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($the_ps_7['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_7['PostId']) ?>" alt="<?php echo $the_ps_7['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $the_ps_7['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($the_ps_7['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_7['PostId']) ?>" alt="<?php echo $the_ps_7['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $the_ps_7['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php
              endif;
              $ps_block_7_count++;
            endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds9 (d-block d-md-none, between block7 and block8) ── */
      $home_ads_9 = showAds($advancenews['HomeAds9'], $advancenews['HomeAdsCtl']);
      if ($home_ads_9 != '') echo '<div class="col-lg-12 d-block d-md-none">'.$home_ads_9.'</div>';
      ?>

      <!-- Block 8 -->
      <div class="col-lg-4">
        <?php $ps_block_8 = $advancenews['PostBlock8']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_8) ?></div>
          <?php
          $ps_block_8_article = getArticles($ps_block_8,5);
          $ps_block_8_count   = 1;
          if (!empty($ps_block_8_article)):
            foreach ($ps_block_8_article as $the_ps_8):
              if ($ps_block_8_count == 1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($the_ps_8['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_8['PostId']) ?>" alt="<?php echo $the_ps_8['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $the_ps_8['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($the_ps_8['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden"><img class="w-100 rounded-2 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_8['PostId']) ?>" alt="<?php echo $the_ps_8['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $the_ps_8['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php
              endif;
              $ps_block_8_count++;
            endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds10 (col-lg-12, after block6/7/8) ── */
      $home_ads_10 = showAds($advancenews['HomeAds10'], $advancenews['HomeAdsCtl']);
      if ($home_ads_10 != '') echo '<div class="col-lg-12">'.$home_ads_10.'</div>';
      ?>
    </div>
  </div>
</section>

<!-- ═══════════ POSTBLOCK9 + LOCAL-NEWS ═══════════ -->
<section class="py-5" style="background-color:#f5f7fc;">
  <div class="container">
    <div class="row">
      <div class="col-lg-9">
        <?php $ps_block_9 = $advancenews['PostBlock9']; ?>
        <div class="row g-3">
          <div class="col-12">
            <?php
            echo getBlockTitle($ps_block_9);
            $ps_block_9_article   = getArticles($ps_block_9,9);
            $ps_block_9_article_1 = articlePart($ps_block_9_article,1,3);
            $ps_block_9_article_2 = articlePart($ps_block_9_article,4,9);
            ?>
          </div>
          <div class="col-lg-7">
            <div class="row g-3">
              <?php
              if (!empty($ps_block_9_article_1)):
                $ps9c = 1;
                foreach ($ps_block_9_article_1 as $the_ps_9_1):
                  if ($ps9c == 1): ?>
                  <div class="col-lg-12">
                    <a href="<?php echo articleLink($the_ps_9_1['PostId']) ?>" class="d-block prothom-songbad-post-style">
                      <div class="align-items-center">
                        <div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_9_1['PostId']) ?>" alt="<?php echo $the_ps_9_1['PostTitle'] ?>"></div>
                        <h1 class="p-2 news-title-3 m-0 tt-text"><?php echo $the_ps_9_1['PostTitle'] ?></h1>
                      </div>
                    </a>
                  </div>
                  <?php else: ?>
                  <div class="col-6">
                    <a href="<?php echo articleLink($the_ps_9_1['PostId']) ?>" class="d-block prothom-songbad-post-style">
                      <div class="align-items-center">
                        <div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_9_1['PostId']) ?>" alt="<?php echo $the_ps_9_1['PostTitle'] ?>"></div>
                        <h1 class="p-2 news-title-3 m-0 tt-text"><?php echo $the_ps_9_1['PostTitle'] ?></h1>
                      </div>
                    </a>
                  </div>
                  <?php
                  endif;
                  $ps9c++;
                endforeach;
              else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
            </div>
          </div>
          <div class="col-lg-5">
            <div class="row g-3">
              <?php
              if (!empty($ps_block_9_article_2)):
                foreach ($ps_block_9_article_2 as $the_ps_9_2): ?>
                <div class="col-12">
                  <a href="<?php echo articleLink($the_ps_9_2['PostId']) ?>" class="d-block prothom-songbad-post-style">
                    <div class="row g-2 align-items-center">
                      <div class="col-4"><div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_9_2['PostId']) ?>" alt="<?php echo $the_ps_9_2['PostTitle'] ?>"></div></div>
                      <div class="col-8"><h1 class="news-title-3 m-0 tt-text"><?php echo $the_ps_9_2['PostTitle'] ?></h1></div>
                    </div>
                  </a>
                </div>
                <?php endforeach;
              else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
            </div>
          </div>
        </div>
      </div>

      <?php
      /* ── HomeAds11 (col-lg-12 d-block d-md-none) ── */
      $home_ads_11 = showAds($advancenews['HomeAds11'], $advancenews['HomeAdsCtl']);
      if ($home_ads_11 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_11.'</div>';
      ?>

      <div class="col-lg-3">
        <?php require_once('template-part/local-news-1.php'); ?>
      </div>

      <?php
      /* ── HomeAds12 (col-lg-12 my-3) ── */
      $home_ads_12 = showAds($advancenews['HomeAds12'], $advancenews['HomeAdsCtl']);
      if ($home_ads_12 != '') echo '<div class="col-lg-12 my-3">'.$home_ads_12.'</div>';
      ?>
    </div>
  </div>
</section>

<!-- ═══════════ POSTBLOCK10 + POLL ═══════════ -->
<section class="py-5" style="background-color:#fdf6ef;">
  <div class="container">
    <div class="row g-3">
      <div class="col-lg-9">
        <div class="row g-3">
          <div class="col-12">
            <?php
            $ps_block_10 = $advancenews['PostBlock10'];
            echo getBlockTitle($ps_block_10);
            ?>
          </div>
          <?php
          $ps_block_10_article = getArticles($ps_block_10,6);
          $ps_block_10_count   = 1;
          if (!empty($ps_block_10_article)):
            foreach ($ps_block_10_article as $the_ps_10):
              if ($ps_block_10_count == 1): ?>
              <div class="col-lg-9">
                <div class="tt-white">
                  <a href="<?php echo articleLink($the_ps_10['PostId']) ?>" class="d-block tt-white prothom-songbad-post-style">
                    <div class="row g-2">
                      <div class="col-lg-5 order-2 order-md-1 col-12 mt-0 p-3">
                        <h1 class="news-title m-0 tt-text"><?php echo $the_ps_10['PostTitle'] ?></h1>
                        <p class="summery-4"><?php echo strip_tags($the_ps_10['PostContent']) ?></p>
                      </div>
                      <div class="col-lg-7 order-1 order-md-2 col-12 mt-0">
                        <div class="position-relative overflow-hidden">
                          <img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_10['PostId']) ?>" alt="<?php echo $the_ps_10['PostTitle'] ?>">
                        </div>
                      </div>
                    </div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-lg-3 col-6">
                <a href="<?php echo articleLink($the_ps_10['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="align-items-center">
                    <div class="position-relative overflow-hidden">
                      <img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($the_ps_10['PostId']) ?>" alt="<?php echo $the_ps_10['PostTitle'] ?>">
                    </div>
                    <div class="p-2"><h1 class="news-title-2 m-0 tt-text"><?php echo $the_ps_10['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php
              endif;
              $ps_block_10_count++;
            endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <!-- POLL (main code থেকে সম্পূর্ণ) -->
      <div class="col-lg-3">
        <?php
        echo getBlockTitle('','অনলাইন জরিপ',$site_domain.'opinion-poll/');
        $all_poll = getPoll(1, 0);
        foreach ($all_poll as $the_poll):
          $total_votes = $the_poll['PollOptionOneView']+$the_poll['PollOptionTwoView']+$the_poll['PollOptionThreeView'];
          if ($total_votes > 0) {
            $p1 = floor(($the_poll['PollOptionOneView']/$total_votes)*100);
            $p2 = floor(($the_poll['PollOptionTwoView']/$total_votes)*100);
            $p3 = floor(($the_poll['PollOptionThreeView']/$total_votes)*100);
          } else { $p1=$p2=$p3=0; }
          $poll_link  = pollLink($the_poll['PollID']);
          $poll_title = htmlentities($the_poll['PollTitle'],ENT_QUOTES,'utf-8');
          ?>
          <div class="border rounded-2 bg-white p-3 mahamudfutureit_poll" style="height:auto">
            <div class="row">
              <div class="col-10"><span class="mahamudfutureit_poll_date"><?php echo dateTimeShow($the_poll['PollDate']) ?></span></div>
              <div class="col-2 text-end">
                <span class="mahamudfutureit_poll_download"
                      id="poll_download_<?php echo $the_poll['PollID'] ?>"
                      data-poll-date="<?php echo dateTimeShow($the_poll['PollDate']) ?>"
                      data-poll-image="<?php echo getPollImage($the_poll['PollID']) ?>"
                      data-poll-title="<?php echo $poll_title ?>"
                      data-poll-option1="<?php echo htmlentities($the_poll['PollOptionOne'],ENT_QUOTES,'utf-8') ?>"
                      data-poll-option2="<?php echo htmlentities($the_poll['PollOptionTwo'],ENT_QUOTES,'utf-8') ?>"
                      data-poll-option3="<?php echo htmlentities($the_poll['PollOptionThree'],ENT_QUOTES,'utf-8') ?>"
                      data-poll-option1-vote="<?php echo bnNumber($p1) ?> %"
                      data-poll-option2-vote="<?php echo bnNumber($p2) ?> %"
                      data-poll-option3-vote="<?php echo bnNumber($p3) ?> %"
                      data-poll-option1-vote-per="<?php echo $p1 ?>%"
                      data-poll-option2-vote-per="<?php echo $p2 ?>%"
                      data-poll-option3-vote-per="<?php echo $p3 ?>%"
                      data-poll-download="ডাউনলোডঃ <?php echo dateTimeShow(date('Y-m-d H:i:s')) ?>"
                      data-poll-total-votes="মোট ভোটদাতাঃ <?php echo bnNumber($total_votes) ?> জন">
                  <i class="bi bi-download"></i>
                </span>
              </div>
            </div>
            <div class="mahamudfutureit_poll_image mt-2">
              <img class="rounded-2 w-100" src="<?php echo $advancenews['Poll_DF_Img'] ?>" data-src="<?php echo getPollImage($the_poll['PollID']) ?>" alt="<?php echo $poll_title ?>">
            </div>
            <div class="mahamudfutureit_poll_title mt-2"><h2 class="news-title-2"><?php echo $poll_title ?></h2></div>
            <div class="mahamudfutureit_poll_options">
              <?php for ($pi=1;$pi<=3;$pi++):
                $opt_key = 'PollOption'.['','One','Two','Three'][$pi];
                $opt_text = htmlentities($the_poll[$opt_key],ENT_QUOTES,'utf-8');
              ?>
              <div class="mahamudfutureit_poll_options_item rounded-2 collect_vote collect_vote_<?php echo $the_poll['PollID'] ?>" data-poll-id="<?php echo $the_poll['PollID'] ?>" data-poll-option="<?php echo $pi ?>">
                <div class="mahamudfutureit_poll_item_info fw-bold">
                  <i class="bi bi-circle tt_poll_selector_<?php echo $the_poll['PollID'] ?>" id="ttpoll_icon_<?php echo $the_poll['PollID'] ?>_<?php echo $pi ?>"></i>&nbsp;&nbsp;<?php echo $opt_text ?>
                  <span id="ttpoll_perc_<?php echo $the_poll['PollID'] ?>_<?php echo $pi ?>" style="display:none" class="float-end fw-bold">৯৭%</span>
                </div>
                <div class="mahamudfutureit_poll_item_bar" id="ttpoll_opt_<?php echo $the_poll['PollID'] ?>_<?php echo $pi ?>" style="width:0%;display:none"></div>
              </div>
              <?php endfor; ?>
            </div>
            <div class="mahamudfutureit_poll_total_voter text-center my-3 fw-bold">
              মোট ভোটদাতাঃ <span id="ttpoll_total_<?php echo $the_poll['PollID'] ?>"><?php echo bnNumber($total_votes) ?></span> জন
            </div>
            <div class="text-center mb-2">
              <div class="mahamudfutureit_social_menu bordered round color">
                <a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $poll_link ?>" target="_blank" class="facebook"><i class="fa-brands fa-facebook-f"></i></a>
                <a href="https://api.whatsapp.com/send?text=<?php echo $poll_title.' '.$poll_link ?>" target="_blank" class="whatsapp"><i class="fa-brands fa-whatsapp"></i></a>
                <a href="https://www.messenger.com/t/?link=<?php echo $poll_link ?>" target="_blank" class="messenger"><i class="bi bi-messenger"></i></a>
                <a href="https://twitter.com/intent/tweet?url=<?php echo $poll_link ?>&text=<?php echo $poll_title ?>" target="_blank" class="twitter"><i class="fa-brands fa-x-twitter"></i></a>
                <a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $poll_link ?>&title=<?php echo $poll_title ?>" target="_blank" class="linkedin"><i class="fa-brands fa-linkedin-in"></i></a>
              </div>
            </div>
          </div>
        <?php endforeach; ?>
      </div>
    </div>

    <?php
    /* ── HomeAds13 (col-lg-12 my-3, after poll section) ── */
    $home_ads_13 = showAds($advancenews['HomeAds13'], $advancenews['HomeAdsCtl']);
    if ($home_ads_13 != '') echo '<div class="col-lg-12 my-3">'.$home_ads_13.'</div>';
    ?>
  </div>
</section>

<!-- ═══════════ POSTBLOCK11 ═══════════ -->
<section class="py-5" style="background-color:#f8f5fb;">
  <div class="container">
    <div class="row g-3">
      <div class="col-12">
        <?php
        $ps_block_11 = $advancenews['PostBlock11'];
        $ps_block_11_article   = getArticles($ps_block_11,9);
        $ps_block_11_article_1 = articlePart($ps_block_11_article,1,1);
        $ps_block_11_article_2 = articlePart($ps_block_11_article,2,4);
        $ps_block_11_article_3 = articlePart($ps_block_11_article,5,4);
        echo getBlockTitle($ps_block_11);
        ?>
      </div>
      <?php if (!empty($ps_block_11_article)): ?>
      <div class="col-lg-6">
        <?php foreach ($ps_block_11_article_1 as $a): ?>
        <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
          <div class="align-items-center">
            <div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
            <h1 class="p-2 news-title-2 m-0"><?php echo $a['PostTitle'] ?></h1>
          </div>
        </a>
        <?php endforeach; ?>
      </div>
      <div class="col-lg-3">
        <div class="row g-3">
          <?php foreach ($ps_block_11_article_2 as $a): ?>
          <div class="col-12">
            <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
              <div class="row g-2 align-items-center">
                <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                <div class="col-7"><h1 class="news-title-3 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <?php
      /* ── HomeAds18 (d-block d-md-none) ── */
      $home_ads_18 = showAds($advancenews['HomeAds18'], $advancenews['HomeAdsCtl']);
      if ($home_ads_18 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_18.'</div>';
      ?>
      <div class="col-lg-3">
        <div class="row g-3">
          <?php foreach ($ps_block_11_article_3 as $a): ?>
          <div class="col-12">
            <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
              <div class="row g-2 align-items-center">
                <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                <div class="col-7"><h1 class="news-title-3 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <?php
      /* ── HomeAds19 (col-lg-12 my-3) ── */
      $home_ads_19 = showAds($advancenews['HomeAds19'], $advancenews['HomeAdsCtl']);
      if ($home_ads_19 != '') echo '<div class="col-lg-12 my-3">'.$home_ads_19.'</div>';
      ?>
      <?php else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
    </div>
  </div>
</section>

<!-- ═══════════ POSTBLOCK 12 / 13 / 14 ═══════════ -->
<section class="py-5" style="background-color:#f3f8fa;">
  <div class="container">
    <div class="row g-3 mt-3">

      <!-- Block 12 -->
      <div class="col-lg-4">
        <?php $ps_block_12 = $advancenews['PostBlock12']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_12) ?></div>
          <?php
          $ps_block_12_article = getArticles($ps_block_12,5); $c12=1;
          if (!empty($ps_block_12_article)):
            foreach ($ps_block_12_article as $a):
              if ($c12==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100 rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="news-title-2 m-0"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c12++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds15 (d-block d-md-none, between block12 and block13) ── */
      $home_ads_15 = showAds($advancenews['HomeAds15'], $advancenews['HomeAdsCtl']);
      if ($home_ads_15 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_15.'</div>';
      ?>

      <!-- Block 13 -->
      <div class="col-lg-4">
        <?php $ps_block_13 = $advancenews['PostBlock13']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_13) ?></div>
          <?php
          $ps_block_13_article = getArticles($ps_block_13,5); $c13=1;
          if (!empty($ps_block_13_article)):
            foreach ($ps_block_13_article as $a):
              if ($c13==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c13++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds16 (d-block d-md-none, between block13 and block14) ── */
      $home_ads_16 = showAds($advancenews['HomeAds16'], $advancenews['HomeAdsCtl']);
      if ($home_ads_16 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_16.'</div>';
      ?>

      <!-- Block 14 -->
      <div class="col-lg-4">
        <?php $ps_block_14 = $advancenews['PostBlock14']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_14) ?></div>
          <?php
          $ps_block_14_article = getArticles($ps_block_14,5); $c14=1;
          if (!empty($ps_block_14_article)):
            foreach ($ps_block_14_article as $a):
              if ($c14==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden"><img class="w-100 ps-post-line-img rounded-2" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c14++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds17 (col-lg-12 my-3, after block12/13/14) ── */
      $home_ads_17 = showAds($advancenews['HomeAds17'], $advancenews['HomeAdsCtl']);
      if ($home_ads_17 != '') echo '<div class="col-lg-12 my-3">'.$home_ads_17.'</div>';
      ?>
    </div>
  </div>
</section>

<!-- ═══════════ PHOTO GALLERY ═══════════ -->
<section class="py-5">
  <div class="container">
    <div class="row g-3 mt-3">
      <div class="col-12">
        <?php echo getBlockTitle('','ফটো গ্যালারি ',$site_domain.'photos/') ?>
      </div>
      <div class="col-lg-6">
        <?php
        $first_gallery = getGallery(1, 0);
        if (!empty($first_gallery)): ?>
        <div id="MahamudFutureITPhoto" class="carousel slide">
          <div class="carousel-inner rounded-2 overflow-hidden">
            <?php
            $gallery_f_items = json_decode($first_gallery[0]['gallery_items'], TRUE);
            $count_gall = 1;
            foreach ($gallery_f_items as $the_f_galllery):
              if ($the_f_galllery['storyimage'] != ''): ?>
              <div class="carousel-item <?php echo ($count_gall==1)?'active':'' ?>">
                <a href="<?php echo $site_domain ?>photos/<?php echo $first_gallery[0]['gallery_url'] ?>/">
                  <div class="featured-image-photo">
                    <img src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo $the_f_galllery['storyimage'] ?>" class="d-block gallery-img-cover-1" alt="">
                    <i class="bi bi-image"></i>
                  </div>
                </a>
              </div>
              <?php $count_gall++; endif; endforeach; ?>
          </div>
          <button class="carousel-control-prev" type="button" data-bs-target="#MahamudFutureITPhoto" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Previous</span>
          </button>
          <button class="carousel-control-next" type="button" data-bs-target="#MahamudFutureITPhoto" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Next</span>
          </button>
        </div>
        <a href="<?php echo $site_domain ?>photos/<?php echo $first_gallery[0]['gallery_url'] ?>/">
          <h1 class="py-2 news-title mt-1"><?php echo $first_gallery[0]['gallery_title'] ?></h1>
        </a>
        <?php else: echo '<div class="text-center p-2 bg-light rounded-t">কোন ছবি নেই !</div>'; endif; ?>
      </div>
      <div class="col-lg-6">
        <div class="row">
          <?php
          $all_gallery = getGallery(4, 1);
          if (!empty($all_gallery)):
            foreach ($all_gallery as $the_galllery):
              $gallery_items = json_decode($the_galllery['gallery_items'], TRUE); ?>
              <div class="col-6">
                <a href="<?php echo $site_domain ?>photos/<?php echo $the_galllery['gallery_url'] ?>/" class="d-block prothom-songbad-post-style">
                  <div class="align-items-center">
                    <div class="position-relative featured-image-photo overflow-hidden rounded-2">
                      <img class="gallery-img-1 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo $gallery_items[1]['storyimage'] ?>" alt="<?php echo htmlentities($the_galllery['gallery_title'],ENT_QUOTES,'utf-8') ?>">
                      <i class="bi bi-image"></i>
                    </div>
                    <h1 class="py-2 news-title-2 m-0"><?php echo htmlentities($the_galllery['gallery_title'],ENT_QUOTES,'utf-8') ?></h1>
                  </div>
                </a>
              </div>
            <?php endforeach;
          else: echo '<div class="text-center p-2 bg-light rounded-t">কোন ছবি নেই !</div>'; endif; ?>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ═══════════ POSTBLOCK15 ═══════════ -->
<section class="py-5" style="background-color:#fbf6f8;">
  <div class="container">
    <div class="row g-3">
      <div class="col-12">
        <?php
        $ps_block_15 = $advancenews['PostBlock15'];
        $ps_block_15_article   = getArticles($ps_block_15,9);
        $ps_block_15_article_1 = articlePart($ps_block_15_article,1,1);
        $ps_block_15_article_2 = articlePart($ps_block_15_article,2,4);
        $ps_block_15_article_3 = articlePart($ps_block_15_article,5,4);
        echo getBlockTitle($ps_block_15);
        ?>
      </div>
      <?php if (!empty($ps_block_15_article)): ?>
      <div class="col-lg-6">
        <?php foreach ($ps_block_15_article_1 as $a): ?>
        <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
          <div class="align-items-center">
            <div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
            <h1 class="p-2 news-title-2 m-0"><?php echo $a['PostTitle'] ?></h1>
          </div>
        </a>
        <?php endforeach; ?>
      </div>
      <div class="col-lg-3">
        <div class="row g-3">
          <?php foreach ($ps_block_15_article_2 as $a): ?>
          <div class="col-12">
            <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
              <div class="row g-2 align-items-center">
                <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                <div class="col-7"><h1 class="news-title-3 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <?php
      /* ── HomeAds18 reuse (d-block d-md-none) ── */
      $home_ads_18b = showAds($advancenews['HomeAds18'], $advancenews['HomeAdsCtl']);
      if ($home_ads_18b != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_18b.'</div>';
      ?>
      <div class="col-lg-3">
        <div class="row g-3">
          <?php foreach ($ps_block_15_article_3 as $a): ?>
          <div class="col-12">
            <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
              <div class="row g-2 align-items-center">
                <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                <div class="col-7"><h1 class="news-title-3 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
              </div>
            </a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <?php
      /* ── HomeAds19 reuse (col-lg-12 my-3) ── */
      $home_ads_19b = showAds($advancenews['HomeAds19'], $advancenews['HomeAdsCtl']);
      if ($home_ads_19b != '') echo '<div class="col-lg-12 my-3">'.$home_ads_19b.'</div>';
      ?>
      <?php else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
    </div>
  </div>
</section>

<!-- ═══════════ POSTBLOCK 16 / 17 / 18 ═══════════ -->
<section class="py-5" style="background-color:#f5f9f3;">
  <div class="container">
    <div class="row g-3 mt-3">

      <!-- Block 16 -->
      <div class="col-lg-4">
        <?php $ps_block_16 = $advancenews['PostBlock16']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_16) ?></div>
          <?php
          $ps_block_16_article = getArticles($ps_block_16,5); $c16=1;
          if (!empty($ps_block_16_article)):
            foreach ($ps_block_16_article as $a):
              if ($c16==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c16++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds20 (d-block d-md-none, between block16 and block17) ── */
      $home_ads_20 = showAds($advancenews['HomeAds20'], $advancenews['HomeAdsCtl']);
      if ($home_ads_20 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_20.'</div>';
      ?>

      <!-- Block 17 -->
      <div class="col-lg-4">
        <?php $ps_block_17 = $advancenews['PostBlock17']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_17) ?></div>
          <?php
          $ps_block_17_article = getArticles($ps_block_17,5); $c17=1;
          if (!empty($ps_block_17_article)):
            foreach ($ps_block_17_article as $a):
              if ($c17==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block tt-white prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c17++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds21 (d-block d-md-none, between block17 and block18) ── */
      $home_ads_21 = showAds($advancenews['HomeAds21'], $advancenews['HomeAdsCtl']);
      if ($home_ads_21 != '') echo '<div class="col-lg-12 d-block d-md-none my-3">'.$home_ads_21.'</div>';
      ?>

      <!-- Block 18 -->
      <div class="col-lg-4">
        <?php $ps_block_18 = $advancenews['PostBlock18']; ?>
        <div class="row g-3">
          <div class="col-12"><?php echo getBlockTitle($ps_block_18) ?></div>
          <?php
          $ps_block_18_article = getArticles($ps_block_18,5); $c18=1;
          if (!empty($ps_block_18_article)):
            foreach ($ps_block_18_article as $a):
              if ($c18==1): ?>
              <div class="col-12">
                <div class="ps-category-lead-news position-relative rounded-2">
                  <a href="<?php echo articleLink($a['PostId']) ?>">
                    <div class="ps-clead-img"><img class="w-100" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div>
                    <div class="ps-clead-title"><h1 class="p-2 news-title-2 m-0 text-white"><?php echo $a['PostTitle'] ?></h1></div>
                  </a>
                </div>
              </div>
              <?php else: ?>
              <div class="col-12">
                <a href="<?php echo articleLink($a['PostId']) ?>" class="d-block tt-white prothom-songbad-post-style">
                  <div class="row g-2 align-items-center">
                    <div class="col-5"><div class="position-relative overflow-hidden rounded-2"><img class="w-100 ps-post-line-img" src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo articleImg($a['PostId']) ?>" alt="<?php echo $a['PostTitle'] ?>"></div></div>
                    <div class="col-7"><h1 class="news-title-2 m-0 tt-text"><?php echo $a['PostTitle'] ?></h1></div>
                  </div>
                </a>
              </div>
              <?php endif; $c18++; endforeach;
          else: echo '<div class="col-12">'.noPost().'</div>'; endif; ?>
        </div>
      </div>

      <?php
      /* ── HomeAds22 (col-lg-12 my-3, after block16/17/18) ── */
      $home_ads_22 = showAds($advancenews['HomeAds22'], $advancenews['HomeAdsCtl']);
      if ($home_ads_22 != '') echo '<div class="col-lg-12 my-3">'.$home_ads_22.'</div>';
      ?>
    </div>
  </div>
</section>

<!-- ═══════════ POLL VOTE JS ═══════════ -->
<script>
document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('click', function(e) {
        var target = e.target.closest('.collect_vote');
        if (target) {
            var pollId     = target.getAttribute('data-poll-id');
            var pollOption = target.getAttribute('data-poll-option');
            fetch('<?php echo $site_domain ?>ajax_master/collect-vote/', {
                method: 'POST',
                headers: {'Content-Type':'application/x-www-form-urlencoded'},
                body: 'poll_id='+encodeURIComponent(pollId)+'&poll_option='+encodeURIComponent(pollOption)
            })
            .then(function(res){return res.text();})
            .then(function(data){
                var resultDiv = document.getElementById('XtcC23ts23a');
                if (resultDiv) {
                    resultDiv.innerHTML = data;
                    resultDiv.querySelectorAll('script').forEach(function(s){
                        var ns = document.createElement('script');
                        if (s.src) { ns.src=s.src; ns.async=false; document.head.appendChild(ns); }
                        else       { ns.textContent=s.textContent; document.body.appendChild(ns); }
                    });
                }
            });
        }
    });
});
</script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<div id="XtcC23ts23a"></div>

<!-- Poll Download Preview Box -->
<div class="dPoll bg-white p-2" id="downloadPoll" style="display:none;">
  <div class="p-3 rounded-2 border">
    <div class="row align-items-center">
      <div class="col-7">
        <h4 class="mb-1">অনলাইন জরিপ</h4>
        <h5 class="fw-normal m-0 poll-date"></h5>
      </div>
      <div class="col-5">
        <img class="w-100" src="<?php echo $advancenews['Website_Logo'] ?>" alt="Poll Image">
      </div>
    </div>
    <div class="py-2 mt-2"><img class="w-100 rounded-2 poll-image" src="" alt="Poll Image"></div>
    <div class="mt-2"><h5 class="poll-title"></h5></div>
    <div class="mahamudfutureit_poll_options">
      <div class="mahamudfutureit_poll_options_item rounded-2">
        <div class="mahamudfutureit_poll_item_info fw-bold"><span class="poll-option1-text"></span><span class="float-end fw-bold poll-option1-vote"></span></div>
        <div class="mahamudfutureit_poll_item_bar poll-option1-bar"></div>
      </div>
      <div class="mahamudfutureit_poll_options_item rounded-2">
        <div class="mahamudfutureit_poll_item_info fw-bold"><span class="poll-option2-text"></span><span class="float-end fw-bold poll-option2-vote"></span></div>
        <div class="mahamudfutureit_poll_item_bar poll-option2-bar"></div>
      </div>
      <div class="mahamudfutureit_poll_options_item rounded-2">
        <div class="mahamudfutureit_poll_item_info fw-bold"><span class="poll-option3-text"></span><span class="float-end fw-bold poll-option3-vote"></span></div>
        <div class="mahamudfutureit_poll_item_bar poll-option3-bar"></div>
      </div>
    </div>
    <div class="text-center mt-3">
      <h4 class="poll-total-votes"></h4>
      <h6 class="poll-download-date"></h6>
    </div>
  </div>
</div>

<?php require_once('./footer.php'); ?>
