/*---------------------------------
  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; }

  /* Inkuru Zigezweho: smaller type while it shares the row with the slider */
  .imv-top-lead { padding-right: var(--space-4); }
  .imv-top-side { padding-left: var(--space-4); }
  .imv-top-lead h2 { font-size: 23px; }
  .imv-top-excerpt { font-size: 14px; }
  .imv-top-more ul { gap: var(--space-4); }
  .imv-top-more li { padding-left: 17px; }
  .imv-top-more li:before { width: 9px; height: 9px; }
  .imv-top-more li a { font-size: 13.5px; overflow-wrap: break-word; }
}

/* ===== Tablet: 768-991px ===== */
@media (max-width: 991px) {
  /* top row: slider full width, Inkuru Zigezweho full width below */
  .container-fluid > .row > .imv-slider-col { flex: 0 0 100%; max-width: 100%; width: auto; }
  .container-fluid > .row > .col-lg-6.col-md-6.col-6:is(:has(.imv-highligh), .imv-top-col) { flex: 0 0 100%; max-width: 100%; width: auto; margin-top: var(--space-5); }
  .imv-highligh ~ .news-card-three { flex-direction: row; }
  /* Inkuru Zigezweho is full width here: back to full-size type */
  .imv-top-lead h2 { font-size: 30px; }
  .imv-top-excerpt { font-size: 16px; }
  .imv-top-more li a { font-size: 15px; }
  .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) {
  /* 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) ===== */
/* Above the WordPress admin bar (z-index 99999), which otherwise hides the header and close button */
.imv-drawer.offcanvas { z-index: 100001; width: min(360px, 90vw); border: 0; background: #fff; display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(20, 32, 28, .18); }
.offcanvas-backdrop { z-index: 100000; }
.offcanvas-backdrop.show { opacity: .55; }
.imv-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 14px var(--space-4); background: var(--green-700); }
.imv-drawer-head img { height: 30px; width: auto; filter: brightness(0) invert(1); }
.imv-drawer-close { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 22px; line-height: 1; transition: background-color .2s; }
.imv-drawer-close:hover, .imv-drawer-close:focus-visible { background: rgba(255, 255, 255, .28); color: #fff; }
.imv-drawer-search { position: relative; margin: var(--space-4) var(--space-4) var(--space-2); }
.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: 1px solid var(--line); border-radius: 999px; background: #F4F7F5;
  font-family: var(--secondaryFont); font-size: 15px; color: var(--ink); outline: 0;
}
.imv-drawer-search input:focus { border-color: var(--green-600); background: #fff; box-shadow: 0 0 0 3px var(--green-50); }
.imv-drawer-nav { flex: 1 1 auto; overflow-y: auto; padding: var(--space-2) var(--space-3) var(--space-4); }
.imv-drawer-menu, .imv-drawer-menu ul { margin: 0; padding: 0; list-style: none; }
.imv-drawer-menu { display: flex; flex-wrap: wrap; gap: 2px 8px; }
.imv-drawer-menu > li { flex: 0 0 100%; }
.imv-drawer-menu li { float: none !important; }
.imv-drawer-menu a {
  position: relative; display: block; padding: 11px 12px; border-radius: 8px;
  font-family: var(--secondaryFont); font-size: 14px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink); transition: background-color .15s, color .15s;
}
.imv-drawer-menu a:hover { background: #F4F7F5; color: var(--green-800); }
.imv-drawer-menu .imv-active > a { background: var(--green-50); color: var(--green-800); }
.imv-drawer-menu .imv-active > a:before { content: ""; position: absolute; left: 0; 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: 16px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  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: -1px; }
/* IZINDI sub-sections open as a wrap of chips */
.imv-drawer-menu .dropdown-menu {
  position: static !important; display: none; float: none; width: auto; margin: 4px 0 var(--space-2); padding: 0 4px;
  border: 0; 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: flex; flex-wrap: wrap; gap: 6px; }
.imv-drawer-menu .dropdown-menu a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--text); }
.imv-drawer-menu .dropdown-menu a:hover { border-color: var(--green-600); background: var(--green-50); }
.imv-drawer-menu .dropdown-menu .imv-active > a { border-color: var(--green-600); }
.imv-drawer-menu .dropdown-menu .imv-active > a:before { content: none; }
/* E-PAPER and FRANCAIS close the list as two buttons side by side */
.imv-drawer-menu > .imv-nav-epaper, .imv-drawer-menu > .imv-drawer-fr { flex: 1 1 0; margin-top: var(--space-3); }
.imv-drawer-menu > .imv-nav-epaper > a, .imv-drawer-menu > .imv-drawer-fr > a { padding: 12px 8px; text-align: center; font-size: 13px; color: #fff; }
.imv-drawer-menu > .imv-nav-epaper > a { background: var(--green-700); }
.imv-drawer-menu > .imv-nav-epaper > a:hover, .imv-drawer-menu > .imv-nav-epaper.imv-active > a { background: var(--green-800); color: #fff; }
.imv-drawer-menu > .imv-nav-epaper.imv-active > a:before { content: none; }
.imv-drawer-menu > .imv-drawer-fr > a { background: var(--lnr-blue); }
.imv-drawer-menu > .imv-drawer-fr > a:hover { background: var(--lnr-blue); color: #fff; filter: brightness(.9); }
.imv-drawer-menu a[href*="e-paper"]:before { content: none; }
.imv-drawer-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; padding: 14px var(--space-4); border-top: 1px solid var(--line); background: #F7FAF8; font-size: 13px; color: var(--muted); }
.imv-drawer-foot a { color: var(--green-800); font-weight: 600; }
