/*---------------------------------
  Phase 4: tablets and narrow windows
  Phones (screen <= 768px) are redirected to m.imvahonshya.co.rw; these
  rules cover tablets (769-1199px) and narrow desktop windows.
  Loaded last. Uses the same four breakpoints as tokens.css.
-----------------------------------*/

/* ===== Laptop / large tablet: 992-1199px ===== */
@media (max-width: 1199px) {
  /* feed | main sections; the ad rail moves to a full-width row below */
  .news-col-wrap .news-col-one { width: calc(40% - 12px); }
  .news-col-wrap .news-col-two { width: calc(60% - 12px); }
  .news-col-wrap .news-col-three {
    width: 100%;
    margin-top: var(--space-6);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: var(--space-4);
  }
  .news-col-wrap .news-col-three .promo-img { margin: 0; width: 240px; max-width: 100%; }
  .news-col-wrap .news-col-three br { display: none; }

  /* Inkuru Zigezweho small cards: thumbnail above text instead of beside */
  .imv-highligh ~ .news-card-three { flex-direction: column; }
  .imv-highligh ~ .news-card-three .imv-news-card-img { width: 100%; }
  .imv-highligh ~ .news-card-three .imv-news-card-img img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; }
  .imv-highligh ~ .news-card-three .imv-news-card-info { width: 100%; margin: var(--space-2) 0 0; }

  /* story sections: list thumbnails a bit smaller */
  .news-col-two .imv-tab-sect-sc .news-card-three .imv-all-card-img img { width: 76px; height: 52px; }
}

/* ===== Tablet: 768-991px ===== */
@media (max-width: 991px) {
  /* top row: slider + its slim ad side by side, Inkuru Zigezweho full width below */
  .container-fluid > .row > .col-lg-5.col-md-5.col-5 { flex: 0 0 calc(100% - 124px); max-width: calc(100% - 124px); width: auto; }
  .container-fluid > .row > .col-lg-1.col-md-1.col-1 { flex: 0 0 124px; max-width: 124px; width: auto; padding-left: var(--space-4) !important; }
  .container-fluid > .row > .col-lg-6.col-md-6.col-6:has(.imv-highligh) { flex: 0 0 100%; max-width: 100%; width: auto; margin-top: var(--space-5); }
  .imv-highligh ~ .news-card-three { flex-direction: row; }
  .imv-highligh ~ .news-card-three .imv-news-card-img { width: 110px; flex: none; }
  .imv-highligh ~ .news-card-three .imv-news-card-img img { height: 72px; }
  .imv-highligh ~ .news-card-three .imv-news-card-info { margin: 0 0 0 var(--space-3); }

  /* main sections first, then the feed as a two-column grid, then ads */
  .news-col-wrap { display: flex; flex-direction: column; }
  .news-col-wrap .news-col-one,
  .news-col-wrap .news-col-two,
  .news-col-wrap .news-col-three { width: 100%; }
  .news-col-wrap .news-col-two { order: 1; display: block; }
  .news-col-wrap .news-col-one {
    order: 2;
    margin-top: var(--space-6);
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-5);
    align-content: start;
  }
  .news-col-wrap .news-col-one > * { min-width: 0; }
  .news-col-wrap .news-col-one > .imv-header-nav,
  .news-col-wrap .news-col-one > nav,
  .news-col-wrap .news-col-one > .imv-all-cat { grid-column: 1 / -1; }
  .news-col-wrap .news-col-one .imv-all-cat .news-card-two .news-card-img img { height: 260px; }
  .news-col-wrap .news-col-three { order: 3; }
  /* nothing to balance once the columns stack */
  .imv-fill { display: none !important; }

  /* story sections: overlay cards in a row, list below them */
  .news-col-two .section .row > .col-md-7,
  .news-col-two .section .row > .col-md-5 { flex: 0 0 100%; max-width: 100%; }
  .news-col-two .col-md-7.imv-bord-news { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .news-col-two .col-md-7.imv-bord-news .news-card-four.imv-section { margin: 0; }
  .news-col-two .imv-tab-sect-sc {
    height: auto;
    max-height: none;
    overflow: visible;
    margin-top: var(--space-4);
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-5);
    -webkit-mask-image: none;
            mask-image: none;
  }
  .news-col-two .imv-tab-sect-sc .news-card-three:last-child { margin-bottom: var(--space-3); }

  /* article page: sidebar ads below the story */
  .imv-article-page .col-lg-9,
  .imv-article-page .col-lg-3 { flex: 0 0 100%; max-width: 100%; }
  .imv-article-page .col-lg-3 .sidebar { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-4); margin-top: var(--space-6); }
  .imv-article-page .col-lg-3 .promo-img { width: 240px; margin: 0; }
  .imv-article-page .col-lg-3 br { display: none; }

  /* search page the same */
  .imv-search-page .col-lg-9,
  .imv-search-page .col-lg-3 { flex: 0 0 100%; max-width: 100%; }
  .imv-search-page .col-lg-3 .sidebar { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-4); margin-top: var(--space-6); }
  .imv-search-page .col-lg-3 .promo-img { width: 240px; margin: 0; }
  .imv-search-page .col-lg-3 br { display: none; }

  /* e-paper hero */
  .imv-ep-hero { grid-template-columns: 220px 1fr; gap: var(--space-6); padding: var(--space-5); }
}

/* ===== Narrow windows: < 768px ===== */
@media (max-width: 767px) {
  .container-fluid > .row > .col-lg-5.col-md-5.col-5 { flex: 0 0 100%; max-width: 100%; }
  .container-fluid > .row > .col-lg-1.col-md-1.col-1 { flex: 0 0 100%; max-width: 100%; display: flex; justify-content: center; margin-top: var(--space-3); padding-left: 0 !important; }
  .container-fluid > .row > .col-lg-1.col-md-1.col-1 .promo-img { width: 108px; }   /* the slim ad keeps its own size */
  /* Inkuru Zigezweho: one card per row */
  .container-fluid > .row > .col-lg-6.col-md-6.col-6:has(.imv-highligh) > .row > .col-lg-6 { flex: 0 0 100%; max-width: 100%; }
  /* slider headline stays visible (Bootstrap hides captions below 768px) */
  #carouselExampleDark .carousel-caption.d-none { display: flex !important; flex-direction: column-reverse; align-items: flex-start; gap: 6px; padding: var(--space-5) var(--space-3) var(--space-3); }
  #carouselExampleDark .carousel-caption .imv-sl-news-categ { position: static; }
  #carouselExampleDark .carousel-caption h1 { min-height: 0; margin: 0; font-size: 16px; }
  .imv-article-body > p:first-of-type { font-size: 18px; }
  .imv-article-body, .imv-article-body p { font-size: 17px; line-height: 1.7; }
  #carouselExampleDark .carousel-item { height: 260px; }
  #carouselExampleDark .carousel-indicators [data-bs-target] { height: 40px; }

  .imv-highligh ~ .news-card-three .imv-news-card-img { width: 96px; }
  .imv-highligh ~ .news-card-three .imv-news-card-img img { height: 64px; }

  .news-col-wrap .news-col-one { grid-template-columns: 1fr; }
  .news-col-wrap .news-col-one .imv-all-cat .news-card-two .news-card-img img { height: 200px; }
  .news-col-two .col-md-7.imv-bord-news,
  .news-col-two .imv-tab-sect-sc { grid-template-columns: 1fr; }
  .news-card-four.imv-section img { height: 220px; }
  /* responsive.css stacks compact cards below 768px; keep thumbnail beside the headline with a gap */
  .news-card-three { flex-wrap: nowrap !important; }
  .news-card-three .news-card-info,
  .news-card-three .imv-news-card-info,
  .news-col-one .news-card-three .news-card-info { width: auto !important; flex: 1 1 auto; min-width: 0; margin: 0 0 0 var(--space-3) !important; }
  .news-card-three .news-card-img,
  .news-col-one .news-card-three .news-card-img { width: auto !important; flex: none; }
  .page-nav li, nav.pagination li { margin: 0 2px; }
  .page-nav li a, .page-nav li span.page-numbers { width: 30px; height: 30px; font-size: 12px; }

  .imv-tab-content .row > .col-md-6 { flex: 0 0 100%; max-width: 100%; }
  .imv-tab-sc { height: auto; max-height: 360px; }

  .imv-related-grid { grid-template-columns: 1fr !important; }
  .imv-article-card { padding: var(--space-4) var(--space-3); }
  .imv-byline { flex-wrap: wrap; }
  .imv-latest-list { grid-template-columns: 1fr; }

  .imv-cat-head-inner { padding-left: var(--space-3); }
  .imv-ep-hero { grid-template-columns: 1fr; text-align: center; }
  .imv-ep-hero-cover { max-width: 200px; margin: 0 auto; }
  .imv-ep-actions, .imv-ep-kicker { justify-content: center; }
  .imv-404-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 575px) {
  .imv-404-grid { grid-template-columns: 1fr !important; }
  .imv-ep-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Drawer menu (tablets and narrow windows) ===== */
.imv-drawer.offcanvas { width: min(340px, 88vw); border: 0; background: #fff; display: flex; flex-direction: column; }
.imv-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-4) var(--space-3); border-bottom: 3px solid var(--green-600); }
.imv-drawer-head img { height: 36px; width: auto; }
.imv-drawer-close { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #F1F4F2; color: var(--ink); font-size: 20px; }
.imv-drawer-close:hover { background: var(--green-50); color: var(--green-800); }
.imv-drawer-search { position: relative; margin: var(--space-4); }
.imv-drawer-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--green-700); line-height: 1; }
.imv-drawer-search input {
  width: 100%; height: 44px; padding: 0 14px 0 40px;
  border: 2px solid var(--line); border-radius: 10px; background: #F7FAF8;
  font-family: var(--secondaryFont); font-size: 15px; color: var(--ink); outline: 0;
}
.imv-drawer-search input:focus { border-color: var(--green-600); background: #fff; }
.imv-drawer-nav { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--space-4); }
.imv-drawer-menu, .imv-drawer-menu ul { margin: 0; padding: 0; list-style: none; }
.imv-drawer-menu > li { border-bottom: 1px solid var(--line); }
.imv-drawer-menu li { float: none !important; }
.imv-drawer-menu a {
  position: relative; display: block; padding: 13px 4px;
  font-family: var(--secondaryFont); font-size: 14px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink);
}
.imv-drawer-menu a:hover, .imv-drawer-menu .imv-active > a { color: var(--green-700); }
.imv-drawer-menu .imv-active > a:before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--green-600); }
.imv-drawer-menu .menu-item-has-children > a:after {
  content: ""; position: absolute; right: 8px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s;
}
.imv-drawer-menu .menu-item-has-children.is-open > a:after { transform: rotate(225deg); margin-top: -2px; }
.imv-drawer-menu .dropdown-menu {
  position: static !important; display: none; float: none; width: auto; margin: 0 0 var(--space-2); padding: 0 0 0 var(--space-3);
  border: 0; border-left: 2px solid var(--green-100); border-radius: 0; box-shadow: none; background: none;
  opacity: 1 !important; visibility: visible !important; transform: none !important;
}
.imv-drawer-menu .is-open > .dropdown-menu { display: block; }
.imv-drawer-menu .dropdown-menu a { padding: 9px 4px; font-size: 13px; font-weight: 500; color: var(--text); }
.imv-drawer-menu .imv-drawer-fr a { color: var(--red-600); }
.imv-drawer-menu a[href*="e-paper"]:before { content: none; }
.imv-drawer-foot { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); background: #F7FAF8; font-size: 13px; color: var(--muted); }
.imv-drawer-foot a { color: var(--green-800); font-weight: 600; }
