/* =========================================================
   Site-wide responsive guardrails
   Loaded last so every page shares the same outer rhythm.
========================================================= */

html {
  overflow-x: clip;
}

body {
  min-width: 320px;
  overflow-x: clip;
}

.container,
.up-container {
  width: var(--iu-layout-width);
  max-width: none;
  margin-inline: auto;
}

:where(main, section, article, aside, header, footer, nav, div) {
  min-width: 0;
}

:where(img, video, canvas, svg, iframe, embed, object) {
  max-width: 100%;
}

:where(.entry-content, .single-content, .single-article, .page-content, .up-content) {
  overflow-wrap: anywhere;
}

:where(.entry-content, .single-content, .single-article, .page-content, .up-content) pre {
  max-width: 100%;
  overflow-x: auto;
}

:where(.entry-content, .single-content, .single-article, .page-content, .up-content) iframe {
  width: 100%;
}

.mobile-menu-heading {
  display: flex;
  align-items: stretch;
}

.mobile-menu-heading .mobile-menu-title {
  flex: 1 1 auto;
}

.mobile-menu-expand {
  display: grid;
  flex: 0 0 52px;
  place-items: center;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 1.35rem;
  font-weight: 500;
}

.mobile-menu-expand span {
  transition: transform 0.2s ease;
}

.mobile-menu-group.is-open .mobile-menu-expand span {
  transform: rotate(45deg);
}

.mobile-menu-children[hidden] {
  display: none !important;
}

@media (min-width: 2000px) {
  .section,
  .iu-home .section {
    padding-block: 64px;
  }

  .iu-news-grid,
  .iu-student-layout,
  .iu-achievement-grid,
  .iu-discover-grid {
    gap: 28px;
  }
}

@media (max-width: 1280px) {
  .site-topbar {
    display: none;
  }

  .header-inner {
    min-height: 76px;
  }

  .site-brand {
    min-width: 0;
  }

  .site-brand img {
    width: clamp(230px, 30vw, 300px);
  }

  .mobile-panel {
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .header-search-form {
    width: min(320px, calc(100vw - 140px));
  }
}

@media (max-width: 900px) {
  .section,
  .iu-home .section {
    padding-block: clamp(38px, 6vw, 50px);
  }

  .header-inner {
    min-height: 72px;
  }

  .site-brand img {
    width: clamp(205px, 38vw, 270px);
    max-height: 48px;
  }

  .mobile-panel {
    max-height: calc(100dvh - 72px);
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  :where(.wp-block-table, .entry-content, .single-content, .single-article, .page-content, .up-content) table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  :where(.entry-content, .single-content, .single-article, .page-content, .up-content) th,
  :where(.entry-content, .single-content, .single-article, .page-content, .up-content) td {
    min-width: 112px;
  }
}

@media (max-width: 640px) {
  .header-inner {
    min-height: 68px;
    gap: 10px;
  }

  .site-brand img {
    width: clamp(178px, 50vw, 220px);
    max-height: 44px;
  }

  .header-actions {
    gap: 8px;
  }

  .search-button,
  .menu-toggle {
    width: 40px;
    height: 40px;
  }

  .mobile-panel {
    max-height: calc(100dvh - 68px);
  }

  .mobile-mega-nav {
    gap: 9px;
  }

  .mobile-menu-group {
    border-radius: 12px;
  }

  .mobile-menu-title {
    padding: 12px 14px;
    font-size: 0.94rem;
  }

  .mobile-menu-group > ul {
    padding: 6px 14px 12px;
  }

  .iu-hero {
    --iu-hero-height: clamp(190px, 56.25vw, 280px);
  }

  .iu-hero .hero-slide.is-banner-white .hero-slide-image,
  .iu-hero .hero-slide.is-banner-only .hero-slide-image {
    width: 100vw;
    height: var(--iu-hero-height);
    object-fit: contain;
    background: #fff;
  }

  .iu-news-card,
  .iu-student-card,
  .single-article,
  .sidebar-card,
  .archive-empty {
    border-radius: 14px;
  }

  .single-article,
  .sidebar-card,
  .archive-empty {
    padding: clamp(18px, 5vw, 24px);
  }

  .iu-section-head {
    gap: 12px;
  }

  .iu-section-head h2 {
    font-size: clamp(0.98rem, 4.5vw, 1.08rem);
  }

  .iu-section-head h2::before {
    flex: 0 0 26px;
    width: 26px;
  }

  .iu-section-head a {
    font-size: 0.82rem;
  }
}

@media (max-width: 420px) {
  .site-brand img {
    width: clamp(162px, 47vw, 188px);
  }

  .search-button,
  .menu-toggle {
    width: 38px;
    height: 38px;
  }

  .header-search-form {
    width: min(230px, calc(100vw - 128px));
  }

  .iu-section-head {
    align-items: flex-start;
  }

  .iu-section-head h2 {
    line-height: 1.3;
  }
}

@media (max-width: 350px) {
  .site-brand img {
    width: 148px;
  }

  .header-actions {
    gap: 5px;
  }
}
