/*
 * TheVerificat News Theme — responsive homepage layout hardening.
 * Loaded after the theme's existing editorial styles. This file narrows
 * overrides to the public homepage; admin and plugin styles are untouched.
 */
.kt-main.kt-home,
.kt-main.kt-home *,
.kt-main.kt-home *::before,
.kt-main.kt-home *::after {
  box-sizing: border-box;
}

.kt-main.kt-home {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.kt-main.kt-home > .kt-container {
  width: 100%;
  min-width: 0;
  max-width: var(--kt-container, 1240px);
}

.kt-main.kt-home :where(
  .kt-home-content,
  .kt-home-editorial-wrapper,
  .kt-home-builder-row,
  .kt-home-builder-cell,
  .kt-home-full-section,
  .kt-home-persistent-layout,
  .kt-home-persistent-main,
  .kt-home-persistent-sidebar,
  .kt-grid-layout,
  .kt-hero,
  .kt-hero-main,
  .kt-hero-side,
  .kt-card,
  .kt-card-body,
  .kt-card-media,
  .bt-local-cat,
  .bt-local-cat-stories,
  .bt-cat-story,
  .bt-cat-caption,
  .bt-news-with-urgent,
  .bt-news-with-urgent__main,
  .bt-news-with-urgent__aside,
  .kt-portal-editorial,
  .kt-portal-primary,
  .kt-portal-secondary,
  .kt-weather-card,
  .kt-bt-prayer
) {
  min-width: 0;
  max-width: 100%;
}

/* Arabic headlines must wrap at word boundaries, not between glyphs. */
.kt-main.kt-home :is(
  .kt-card h2,
  .kt-card h3,
  .kt-card h3 a,
  .bt-cat-caption h3,
  .bt-cat-caption h3 a,
  .bt-local-cat-head h2,
  .kt-section-title h2,
  .kt-hero-copy h2,
  .kt-portal-primary h2,
  .kt-portal-secondary h3,
  .kt-newsroom-row h3,
  .kt-category-tab-copy h3,
  .kt-latest-list h3
) {
  min-width: 0 !important;
  max-width: 100%;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  hyphens: none !important;
  letter-spacing: normal !important;
  line-break: auto;
  text-wrap: pretty;
}

/* Higher-specificity RTL headline contract for the existing BeirutTime archetypes. */
.kt-main.kt-home .bt-local-cat .bt-cat-caption h3,
.kt-main.kt-home .bt-local-cat .bt-cat-caption h3 a,
.kt-main.kt-home .kt-section-head .kt-section-title h2,
.kt-main.kt-home .kt-card .kt-card-body h3,
.kt-main.kt-home .kt-card .kt-card-body h3 a {
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  hyphens: none !important;
  letter-spacing: normal !important;
}

/* Preserve editorial image ratios and prevent intrinsic image widths. */
.kt-main.kt-home .kt-card:not(.kt-card-overlay) .kt-card-media {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.kt-main.kt-home .kt-card-media img,
.kt-main.kt-home .bt-cat-media img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.kt-main.kt-home .bt-cat-media {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* Tablet: 768–1024 CSS px. Avoid the three-column squeeze at iPad widths. */
@media (min-width: 768px) and (max-width: 1024px) {
  .kt-main.kt-home .kt-grid-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px;
  }

  .kt-main.kt-home .kt-hero {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 14px;
  }

  .kt-main.kt-home .kt-hero-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .kt-main.kt-home .bt-local-cat-stories {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .kt-main.kt-home .bt-local-cat .bt-cat-story {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .kt-main.kt-home :is(
    .bt-local-cat--spotlight,
    .bt-local-cat--frontline,
    .bt-local-cat--market,
    .bt-local-cat--opinion,
    .bt-local-cat--video,
    .bt-local-cat--defense
  ) .bt-cat-story:first-child {
    grid-column: 1 / -1 !important;
  }

  .kt-main.kt-home .bt-local-cat--breaking .bt-local-cat-stories {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Mobile: 360–767 CSS px. Keep the two-card editorial rhythm without overflow. */
@media (max-width: 767px) {
  .kt-main.kt-home .kt-grid-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .kt-main.kt-home .kt-hero {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
  }

  .kt-main.kt-home .kt-hero-main {
    width: 100%;
    min-width: 0;
    min-height: 260px;
  }

  .kt-main.kt-home .kt-hero-side {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: auto;
    min-width: 0;
  }

  .kt-main.kt-home .kt-card-body {
    min-width: 0;
    padding: 9px 10px;
  }

  .kt-main.kt-home .kt-card h3,
  .kt-main.kt-home .bt-cat-caption h3 {
    font-size: clamp(13px, 3.7vw, 16px);
    line-height: 1.55;
  }

  .kt-main.kt-home .bt-local-cat-stories {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .kt-main.kt-home .bt-local-cat .bt-cat-story {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .kt-main.kt-home :is(
    .bt-local-cat--spotlight,
    .bt-local-cat--frontline,
    .bt-local-cat--market,
    .bt-local-cat--opinion,
    .bt-local-cat--video,
    .bt-local-cat--defense,
    .bt-local-cat--pressdesk,
    .bt-local-cat--culture
  ) .bt-cat-story:first-child {
    grid-column: 1 / -1 !important;
  }

  .kt-main.kt-home .bt-local-cat--breaking .bt-local-cat-stories,
  .kt-main.kt-home .bt-local-cat--regional .bt-local-cat-stories,
  .kt-main.kt-home .bt-local-cat--market .bt-local-cat-stories {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .kt-main.kt-home .kt-portal-editorial.has-secondary {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .kt-main.kt-home .kt-portal-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    min-width: 0;
  }

  .kt-main.kt-home ~ .kt-nav,
  body.home .kt-nav {
    max-width: 100vw;
    overflow-x: hidden;
  }

  body.home .kt-primary-menu,
  body.home .kt-primary-menu > li,
  body.home .kt-primary-menu > li > a {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
  }
}

/* The base theme switches navigation at 760px; cover the 761–767px gap. */
@media (min-width: 761px) and (max-width: 767px) {
  body:not(.kt-beirut-time-header) .kt-mobile-toggle { display: block !important; }
  body:not(.kt-beirut-time-header) .kt-nav {
    display: none;
    position: fixed;
    inset: 72px 0 0;
    z-index: 100;
    overflow: auto;
    background: var(--kt-surface, #fff);
  }
  body:not(.kt-beirut-time-header) .kt-nav.is-open { display: block; }
  body:not(.kt-beirut-time-header) .kt-primary-menu { display: block; margin: 0; padding: 12px 0; }
  body:not(.kt-beirut-time-header) .kt-primary-menu > li { border-bottom: 1px solid var(--kt-line, #e5e7eb); }
  body:not(.kt-beirut-time-header) .kt-primary-menu > li > a { display: block; padding: 12px 6px; }
}
