/* Didban Ruz 2.6.2 — sitewide stability layer.
   This file intentionally loads after the historical bundle and only fixes
   cross-page regressions, overflow, typography and interactive surfaces. */

html { overflow-x: clip; }
body { min-width: 0; }
img, video, iframe, svg { max-width: 100%; }

/* The primary navigation must not clip its own dropdown menus. */
.nav-shell,
.navigation,
.main-nav,
.primary-menu { overflow: visible; }
.navigation { position: relative; }
.primary-menu { min-width: 0; }
.primary-menu > li { min-width: 0; }
.primary-menu .sub-menu {
  max-height: min(70vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Keep long Persian/Latin titles and imported source text inside cards. */
.card-title,
.timeline-list h3,
.pick h3,
.article-header h1,
.archive-header h1,
.page-article-content,
.article-content,
.widget,
.footer-grid { overflow-wrap: anywhere; }

/* Safe image behavior across imported/news content. */
.card-image img,
.article-cover img,
.page-cover-v26 img,
.wp-post-image { display: block; }
.article-content iframe,
.page-article-content iframe,
.article-content video,
.page-article-content video { width: 100%; }

/* Dialogs should remain usable on short laptop/mobile viewports. */
.site-dialog {
  max-width: min(720px, calc(100vw - 28px));
  max-height: min(84vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
}
.menu-dialog { width: min(720px, calc(100vw - 28px)); }
.search-dialog,
.saved-dialog { width: min(620px, calc(100vw - 28px)); }

/* Internal-page resilience. */
.article-layout-v26,
.page-content-shell,
.archive-layout { min-width: 0; }
.news-article-v26,
.page-article-content,
.archive-layout > div { min-width: 0; }
.article-hero-panel,
.internal-page-hero-v26,
.archive-header { max-width: 100%; }
.article-reading-frame { min-width: 0; }
.article-content-v26 > * { max-width: 100%; }
.article-content-v26 pre,
.page-article-content pre {
  max-width: 100%;
  overflow: auto;
  direction: ltr;
  text-align: left;
}
.article-content-v26 table,
.page-article-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sidebar sticky positioning must not overflow its column. */
.news-sidebar,
.sidebar-service,
.sidebar-latest { min-width: 0; }
.news-article-v26 + .news-sidebar,
.article-layout-v26 > .news-sidebar { max-height: calc(100vh - 88px); overflow: auto; scrollbar-width: thin; }

/* Footer/content safety. */
.footer-grid > * { min-width: 0; }
.footer-menu,
.footer-categories { padding-inline-start: 0; }

/* WordPress admin bar + sticky nav compatibility. */
@media (max-width: 782px) {
  .admin-bar.has-sticky-nav .nav-shell { top: 46px; }
}

@media (max-width: 900px) {
  .main-nav { display: none; }
  .mobile-menu-trigger { display: inline-flex; }
  .news-article-v26 + .news-sidebar,
  .article-layout-v26 > .news-sidebar { max-height: none; overflow: visible; }
}

@media (max-width: 720px) {
  html { scroll-padding-top: 66px; }
  .site-dialog { max-width: calc(100vw - 20px); max-height: 88vh; padding: 16px; }
  .internal-page-hero-v26,
  .article-hero-panel,
  .article-reading-frame,
  .page-article-content { overflow: hidden; }
}

/* Preserve desktop navigation behavior on laptop-class widths. The historical
   bundle suppresses dropdowns below 1050px; restore hover/focus dropdowns while
   the desktop navigation is still active. */
@media (min-width: 901px) {
  .main-nav { display: flex; }
  .mobile-menu-trigger { display: none; }
  .primary-menu li:hover > .sub-menu,
  .primary-menu li:focus-within > .sub-menu { display: block !important; }
}
