/* ============================================================
   SVES — Responsive fixes (loaded LAST, see inc/enqueue.php)
   v1.2 · Fixes found in the full-theme mobile/tablet audit.
   Sections:
     1. Mobile navigation (≤900px)
     2. Tablet / small-laptop navigation (901–1280px)
     3. Global overflow safety
     4. Inner-page inline grids
     5. Homepage sections
     6. Footer
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   1. MOBILE NAVIGATION (≤ 900px)
   Bugs fixed:
   - .main-nav-inner had overflow:hidden (main.css + nav-layout.css),
     clipping the dropdown panel.
   - .nav-links had max-height:80vh but overflow:visible, so long
     sub-menus (e.g. Our Institutions, 13 items) ran off-screen and
     could never be reached.
   - Tap targets were small; no open/closed indicator on parents.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  .main-nav { z-index: 1001; }
  .main-nav .main-nav-inner { overflow: visible !important; position: relative; }

  .hamburger {
    display: flex !important;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    padding: 0; margin: 0 -6px 0 auto;
    -webkit-tap-highlight-color: transparent;
  }

  /* Panel — always rendered, shown/hidden with a slide + fade (smooth) */
  .main-nav ul#navLinks,
  .main-nav ul.nav-links {
    display: flex;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity .22s ease, transform .26s cubic-bezier(.2,.7,.3,1), visibility 0s linear .26s;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    margin: 0; padding: 4px 0 16px;
    background: var(--black, #000);
    box-shadow: 0 12px 28px rgba(0,0,0,.55);
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    z-index: 1000;
  }
  .main-nav ul#navLinks.open,
  .main-nav ul#navLinks.nav-open,
  .main-nav ul.nav-links.open,
  .main-nav ul.nav-links.nav-open {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: opacity .22s ease, transform .26s cubic-bezier(.2,.7,.3,1), visibility 0s;
  }

  /* Lock page scroll behind the open menu */
  body.nav-open { overflow: hidden; }

  /* Top-level rows */
  .nav-links > li { width: 100%; position: static; }
  .nav-links > li > a {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; min-height: 50px; height: auto;
    padding: 12px 20px; gap: 12px;
    font-size: 15px; line-height: 1.35;
    color: rgba(255,255,255,.9);
    white-space: normal;
    border-bottom: 1px solid #1f1f1f;
    -webkit-tap-highlight-color: rgba(255,255,255,.06);
  }
  .nav-links > li.open > a,
  .nav-links > li.current-menu-item > a,
  .nav-links > li.current-menu-ancestor > a { color: var(--green, #a7ce39); }

  /* Chevron indicator */
  .nav-links > li.has-dd > a .dd-arrow {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    font-size: 12px; opacity: .8;
    border: 1px solid #333; border-radius: 50%;
    transition: transform .25s ease;
  }
  .nav-links > li.has-dd.open > a .dd-arrow { transform: rotate(180deg); }

  /* Accordion panel — always block; collapsed by height (JS animates it) */
  .nav-links .mega-menu,
  .nav-links .mega-menu.mega-wide,
  .has-dd:hover > .mega-menu {
    display: block !important;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    animation: none !important;
    transition: height .3s ease, visibility 0s linear .3s;
  }
  .nav-links .has-dd.open > .mega-menu {
    height: auto;
    visibility: visible;
    transition: height .3s ease, visibility 0s;
  }
  .nav-links .mega-menu,
  .nav-links .mega-menu.mega-wide {
    position: static !important;
    min-width: 0 !important; width: auto;
    margin: 0; padding: 0;
    background: #121212;
    border: 0; border-left: 3px solid var(--purple, #a4238f);
    box-shadow: none;
    flex-direction: column;
  }
  .nav-links .mega-col { padding: 6px 20px 10px 28px; }
  .nav-links .mega-col + .mega-col { border-left: 0; border-top: 1px solid #262626; margin-top: 6px; padding-top: 8px; }
  .nav-links .mega-col-title { margin: 8px 0 4px; }
  .nav-links .mega-col a {
    display: flex !important; align-items: center;
    min-height: 44px; padding: 10px 0;
    font-size: 14px; color: #c9c9c9;
    white-space: normal; line-height: 1.35;
    border-bottom: 1px solid #1c1c1c;
  }
  .nav-links .mega-col a:last-child { border-bottom: 0; }
  .nav-links .mega-col a:active,
  .nav-links .mega-col a:hover { color: #fff; }
  .nav-links .mega-img { display: none !important; }

  /* Plain WP sub-menus (if the mega walker is ever not used) */
  .nav-links .sub-menu { position: static !important; display: none; box-shadow: none; padding: 4px 0 8px 28px; background: #121212; }
  .nav-links li.open > .sub-menu { display: block !important; }
  .nav-links .sub-menu a { display: block; padding: 10px 0; color: #c9c9c9; }

  /* Utility links + search copied in by navigation.js */
  .nav-links > li.nav-utility { padding: 14px 20px 4px; border-top: 1px solid #262626; margin-top: 6px; }
  .nav-utility-links { display: flex; flex-wrap: wrap; gap: 8px; }
  .nav-utility-links a {
    flex: 1 1 calc(50% - 8px);
    display: flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 8px 10px;
    font-size: 13px; color: rgba(255,255,255,.85);
    border: 1px solid #2c2c2c; border-radius: var(--radius, 4px);
  }
  .nav-utility-search { margin-top: 12px; }
  .nav-utility-search form { display: flex; border: 1px solid #333; border-radius: var(--radius, 4px); overflow: hidden; background: #111; }
  .nav-utility-search input[type="search"],
  .nav-utility-search .search-field { flex: 1; width: auto; min-width: 0; padding: 10px 12px; font-size: 16px; color: #fff; background: transparent; border: 0; }
  .nav-utility-search button,
  .nav-utility-search .search-submit { padding: 0 14px; color: #bbb; background: transparent; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .main-nav ul#navLinks, .main-nav ul#navLinks.open,
  .nav-links .mega-menu, .nav-links .has-dd.open > .mega-menu { transition: none !important; transform: none; }
}
@media (min-width: 901px) {
  .nav-links > li.nav-utility { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   2. TABLET / SMALL-LAPTOP NAVIGATION (901 – 1280px)
   7 top-level items with 18px side padding + nowrap overflowed the
   bar below ~1200px; right-most dropdowns spilled off-screen.
   ════════════════════════════════════════════════════════════ */
@media (min-width: 901px) and (max-width: 1280px) {
  .main-nav .container { padding-left: 24px; padding-right: 24px; }
  .nav-links > li > a { padding: 0 11px; font-size: 13.5px; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .nav-links > li > a {
    padding: 0 8px; font-size: 13px;
    white-space: normal; text-align: center; line-height: 1.2;
    max-width: 150px;
  }
  .header-inner { gap: 12px; }
  .utility-nav { gap: 12px; }
  .search-field { width: 120px; }
}
@media (min-width: 901px) {
  /* Last items: open the panel towards the left so it stays on screen */
  .nav-links > li.has-dd:nth-last-child(-n+3) > .mega-menu { left: auto; right: 0; }
  /* Keep very long panels usable on short laptop screens */
  .mega-menu { max-height: calc(100vh - 140px); overflow-y: auto; }
  .mega-menu.mega-wide { max-width: calc(100vw - 48px); }
  /* Touch laptops/tablets: .open (first tap) shows the panel */
  .has-dd.open > .mega-menu { display: flex; }
}

/* ════════════════════════════════════════════════════════════
   3. GLOBAL OVERFLOW SAFETY
   ════════════════════════════════════════════════════════════ */
iframe, video, embed, object { max-width: 100%; }
.entry-content iframe { width: 100%; }
.entry-content figure, .wp-block-image, .wp-block-embed { max-width: 100%; }
pre, code { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 768px) {
  /* Tables scroll instead of breaking the layout */
  .entry-content table,
  .wp-block-table table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .wp-block-table { overflow-x: auto; }

  /* Floated images stack */
  .alignleft, .alignright { float: none; margin: 0 auto 16px; display: block; }

  /* Long words / URLs */
  .entry-content, .sv-wrap, .site-main { overflow-wrap: anywhere; }

  /* Default page: sidebar under content, not sticky */
  .sidebar { position: static; }

  /* Buttons wrap nicely */
  .hero-btns .btn, .sec-hdr .btn { white-space: normal; text-align: center; }

  .scroll-top { right: 16px; bottom: 76px; width: 42px; height: 42px; }
}

/* iOS zooms into inputs with font-size < 16px — prevent it */
@media (max-width: 900px) {
  input[type="text"], input[type="email"], input[type="search"], input[type="tel"],
  input[type="url"], input[type="number"], select, textarea { font-size: 16px; }
}

/* ════════════════════════════════════════════════════════════
   4. INNER-PAGE INLINE GRIDS
   Several page templates use inline style="grid-template-columns:…"
   which media queries cannot reach without !important.
   (About SVES, Why Choose SVES, Campus Locations, Placements,
    Innovation Hub, Entrepreneurship, Research & Innovation Centres)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sv-wrap [style*="repeat(3,1fr)"],
  .sv-wrap [style*="repeat(3, 1fr)"],
  .sv-wrap [style*="1fr 1fr 1fr"],
  .site-main [style*="repeat(3,1fr)"],
  .site-main [style*="1fr 1fr 1fr"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .sv-wrap [style*="grid-template-columns:1fr 1fr;gap:40px"],
  .sv-wrap [style*="grid-template-columns:1fr 1fr;gap:22px"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  .sv-wrap [style*="grid-template-columns"],
  .site-main [style*="grid-template-columns"]:not(.orp-grid) { grid-template-columns: minmax(0, 1fr) !important; }

  /* Inner-page hero + stat strips */
  .sv-stat { flex: 1 1 50%; padding: 16px 10px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.14); }
  .sv-stat-n { font-size: 24px; }
  .sv-brow { gap: 24px; }
  .sv-bnum { font-size: 30px; }
  .sv-box, .sv-tbi, .sv-cols, .sv-awards { padding: 22px 18px; }
  .sv-cv, .sv-ci { padding: 24px 20px; }
  .sv-cv { min-height: 220px; }
  .sv-cong { grid-template-columns: 1fr 1fr !important; }
  .sves-hero-stat-item { flex: 1 1 50%; padding: 16px 10px; border-right: 0; }
}

/* ════════════════════════════════════════════════════════════
   5. HOMEPAGE SECTIONS
   ════════════════════════════════════════════════════════════ */

/* Why SVES / differentiators: 4 cramped columns on tablets */
@media (max-width: 768px) {
  .why-grid, .diff-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* Section header rows: stack title + arrows/buttons cleanly */
@media (max-width: 600px) {
  .sec-hdr { align-items: flex-start; }
  .sec-title { margin-bottom: 12px; }
}

/* Awards carousel: on phones only the active card is shown so the
   current award is never pushed off-screen by the centred flex row. */
@media (max-width: 768px) {
  .awards-cs-wrap { justify-content: flex-start; padding: 8px 0 24px; }
  .awards-cs-wrap .award-cs-slide { display: none; }
  .awards-cs-wrap .award-cs-slide.active {
    display: block; flex: 0 0 100%; max-width: 420px; margin: 0 auto;
    transform: none; opacity: 1;
  }
}
/* Desktop with more than 3 awards: show active ± 1 only */
@supports selector(:has(+ *)) {
  @media (min-width: 769px) {
    .awards-cs-wrap .award-cs-slide { display: none; }
    .awards-cs-wrap .award-cs-slide.active,
    .awards-cs-wrap .award-cs-slide:has(+ .active),
    .awards-cs-wrap .award-cs-slide.active + .award-cs-slide { display: block; }
    /* active is first/last → also show the card on the other side */
    .awards-cs-wrap .award-cs-slide.active:first-child + * + .award-cs-slide { display: block; }
    .awards-cs-wrap .award-cs-slide:nth-last-child(3):has(+ * + .active:last-child) { display: block; }
  }
}

/* Rankings strip */
@media (max-width: 480px) {
  .rank-strip-item { min-width: 100%; }
  .rank-big-val { font-size: 34px; }
}

/* Leadership / exec images never exceed the column */
@media (max-width: 600px) {
  .leader-layout, .lg-profile { padding-left: 0; padding-right: 0; }
  .qa-layout, .csr-wrap { gap: 24px; }
  .testi-block { padding: 24px 18px; }
  .comp-side { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* Hero slider controls clear of text on small screens */
@media (max-width: 480px) {
  .hero-controls { right: 16px; bottom: 16px; gap: 10px; }
  .hero-text h1 { font-size: 24px; }
}

/* ════════════════════════════════════════════════════════════
   6. FOOTER
   ════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .ft-logo-strip-inner { justify-content: center; gap: 14px 6px; }
}
@media (max-width: 600px) {
  .ft-logo-strip-item { flex: 0 0 calc(33.333% - 6px); padding: 0 4px; }
  .ft-logo-strip-item img { max-width: 100%; height: 28px; }
  .ft-nl-form { flex-direction: column; }
  .ft-nl-form input[type="email"], .ft-nl-form .btn { width: 100%; }
  .footer-bottom-inner { flex-direction: column; align-items: center; text-align: center; }
  .footer-legal-nav { justify-content: center; }
}
