/* ============================================================================
   responsive.css — the responsive layer for the NUSRL revamp
   Loaded LAST, after style.css, so it wins the cascade at equal specificity.

   Kept as its own file on purpose: style.css has grown as an append-log of
   patches (the .mega-intro rule alone is set three separate times, and one
   ~2.4KB block is duplicated), so editing in place risks re-opening old
   conflicts. Everything responsive now lives in one reviewable place, and
   every block below records WHY, not just what.
   ========================================================================= */


/* -- 1. Layout tokens ------------------------------------------------------
   --header-h is re-measured from the live DOM by js/main.js on load and on
   resize, so the fixed drawer always starts exactly at the bottom edge of the
   header even if the brand lockup rewraps. The value here is only a fallback
   for the first paint (and for JS-off).                                     */
:root{--header-h:72px;--gutter:clamp(20px,5vw,32px)}

/* -- 2. Stacking order -----------------------------------------------------
   The header becomes sticky below, so it needs a layer. The two overlays must
   still sit above it, which they would not have at their old z-indexes.     */
.site-header{z-index:40}
.lightbox{z-index:60}
.inner-modal{z-index:70}

/* -- 3. Sticky header ------------------------------------------------------
   This site is a directory: the mega menu is the primary way to reach ~250
   pages. Losing the nav the moment you scroll makes every deep page a dead
   end that costs a scroll-to-top. The thin utility bar is allowed to scroll
   away - only the nav row is pinned.                                        */
.site-header{position:sticky;top:0}

/* Two consequences of pinning the header, both easy to miss:
   1. In-page anchors (#about, #academics, #apply, and the "Skip to content"
      link) would land with the target's first lines hidden underneath it.
      scroll-margin-top offsets the landing by the live header height.
   2. The skip link is painted before the header in source order, so it needs a
      layer above it or it appears *behind* the header when focused - which
      makes the one control keyboard users rely on invisible. */
:target,#main,main>section[id],main{scroll-margin-top:calc(var(--header-h) + 12px)}
.skip-link{z-index:80}

/* Long unbreakable strings (the email address, "Organisational") must never
   push a horizontal scrollbar on a 320px phone. */
.footer-cols a,.footer-meta a,.brand span,.notice-list span{overflow-wrap:anywhere}

/* The drawer's rescued utility links exist in the DOM at every width; they are
   only ever shown inside the drawer (see §4g). */
.drawer-utility{display:none}


/* ==========================================================================
   4. THE BREAKPOINT: 1024px
   --------------------------------------------------------------------------
   Measured, not guessed. At the design's own type scale the horizontal nav
   needs 909px of viewport before it wraps (brand 255 + nav items 566 + 40px
   separation + 48px gutter). The old breakpoint was 800px, which left a
   109px-wide band - 801-909, i.e. exactly the small-laptop / split-screen
   range - where the desktop nav was shown but could not fit, so it broke into
   two ragged rows with "Apply" split across lines.

   1024 is chosen over ~950 for two reasons: it leaves 115px of slack so the
   row still breathes rather than merely fitting, and it is the iPad-landscape
   width, so the tablet a reviewer is most likely to hold gets the full
   desktop nav while everything narrower gets a drawer built for touch.
   ======================================================================== */
@media (max-width:1023px){

  /* 4a. Utility bar: 10px uppercase text is unreadable on a phone and costs
         35px of a ~780px viewport. It is hidden here, but its three links are
         NOT lost - js/main.js clones them into the bottom of the drawer, so
         Gallery keeps an entry point on mobile. Previously hiding the bar was
         the only handling, and Gallery appeared nowhere in the drawer. */
  .utility{display:none}

  /* 4b. Header row */
  .nav-wrap{min-height:var(--header-h)}
  .brand img{width:44px;max-height:52px}
  .brand span{font-size:9px}
  .brand strong{font-size:11px}

  /* 4c. Hamburger - a square 44x44 target that morphs into an X, so the
         open/closed state is readable at a glance.
         Icon only: the three-bar glyph is the most recognised control on the
         web and the "MENU" caption beside it only competed with the brand
         lockup for the narrow strip of header width a phone has. The label
         moves to aria-label, so screen readers still announce it. */
  .menu-button{
    display:flex;align-items:center;justify-content:center;
    width:44px;height:44px;margin-right:-10px;padding:0;
    border:0;background:none;color:var(--teal);cursor:pointer;
  }
  .menu-button i{display:none}
  .menu-button .bars{display:grid;gap:5px;width:22px}
  .menu-button .bars span{display:block;height:2px;width:22px;background:var(--teal);transition:transform .22s ease,opacity .18s ease}
  .menu-button[aria-expanded="true"] .bars span:nth-child(1){transform:translateY(7px) rotate(45deg)}
  .menu-button[aria-expanded="true"] .bars span:nth-child(2){opacity:0}
  .menu-button[aria-expanded="true"] .bars span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}
  .menu-button i{font-style:normal}

  /* 4d. THE DRAWER
         Was: position:absolute, no height cap, no scroll container. With
         Explore open it measured 1664px inside a 780px viewport - it stretched
         the document, scrolled the page behind it, and once you were 800px
         down the list the header and its close control were gone.

         Now: a fixed sheet that owns its own scroll. dvh (with a vh fallback)
         so iOS/Android URL-bar collapse does not clip the last row.
         overscroll-behavior:contain stops scroll chaining to the page.
         Animated via visibility+opacity rather than display, so open/close
         reads as a transition and the drawer stays untabbable when closed.  */
  .main-nav{
    display:flex;flex-direction:column;align-items:stretch;gap:0;
    position:fixed;top:var(--header-h);left:0;right:0;
    height:calc(100vh - var(--header-h));
    height:calc(100dvh - var(--header-h));
    margin:0;padding:0 0 40px;
    background:var(--paper);
    border-top:1px solid var(--line);
    box-shadow:0 24px 44px rgba(5,30,38,.16);
    overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    opacity:0;transform:translateY(-6px);visibility:hidden;
    transition:opacity .22s ease,transform .22s ease,visibility 0s linear .22s;
  }
  .main-nav.open{opacity:1;transform:none;visibility:visible;transition-delay:0s}

  /* 4e. Row rhythm. Every top-level row is >=52px, comfortably past the 44px
         Apple / 48px Material guidance and the 24px WCAG 2.5.8 floor; the old
         rows measured 17-20px, which is not a thumb target at all.
         Hairline separators give the list structure without extra chrome.   */
  .main-nav>a:not(.nav-cta),
  .main-nav .nav-dropdown-toggle,
  .main-nav .explore-toggle{
    display:flex;align-items:center;justify-content:space-between;gap:14px;
    width:100%;min-height:52px;padding:0 var(--gutter);
    border-bottom:1px solid var(--line);
    font:700 14px var(--sans);letter-spacing:.01em;text-transform:none;
    color:var(--ink);text-align:left;
  }
  /* The gold underline sweep is a hover affordance; there is no hover on a
     phone and it renders as a stray 1px line, so it is switched off. */
  .main-nav>a:not(.nav-cta):after{display:none}
  .main-nav .nav-dropdown-item{width:100%;position:static}
  .main-nav .nav-dropdown-toggle .lucide,
  .main-nav .explore-toggle .lucide{width:18px;height:18px;margin:0;flex:0 0 auto}

  /* 4f. Source order vs. reading order.
         In the markup the CTA sits between the Explore toggle and the panel it
         opens, so a stacked drawer would show the directory *below* "Apply".
         Flex `order` puts the panel back under its own trigger and parks the
         CTA at the bottom of the sheet - which is also the easiest place to
         reach with a thumb.                                                 */
  .main-nav>.mega-menu{order:1}
  .main-nav>.nav-cta{order:2}
  .main-nav>.drawer-utility{order:3}

  .main-nav .nav-cta{
    display:flex;align-items:center;justify-content:center;gap:8px;
    margin:22px var(--gutter) 0;min-height:52px;padding:0 20px;
    background:var(--teal);color:#fff;font:700 13px var(--sans);
    letter-spacing:.08em;text-transform:uppercase;
  }

  /* 4g. The Notices / Gallery / Contact links rescued from the utility bar. */
  .drawer-utility{display:flex;flex-direction:column;margin:26px var(--gutter) 0;padding-top:18px;border-top:1px solid var(--line)}
  .drawer-utility a{display:flex;align-items:center;min-height:44px;color:var(--muted);font:600 12px var(--sans);letter-spacing:.06em;text-transform:uppercase}

  /* 4h. PANELS INSIDE THE DRAWER
         The desktop panels are centred overlays (position:absolute, translated
         to the viewport centre, capped at 76vh with their own scrollbar). None
         of that applies in a stacked sheet - an overlay inside an overlay
         gives you two nested scroll areas. They become plain in-flow blocks
         and the drawer is the single scroll container.                      */
  .main-nav .nav-dropdown,
  .main-nav .nav-dropdown-wide,
  .main-nav .mega-menu{
    position:static;transform:none;inset:auto;
    width:100%;max-height:none;overflow:visible;
    display:block;margin:0;padding:0;
    background:#f4f1ea;border-top:0;box-shadow:none;
  }
  .main-nav .nav-dropdown[hidden],
  .main-nav .mega-menu[hidden]{display:none}

  /* 4i. The decorative intro panel is DESKTOP-ONLY.
         It is a teal poster - headline, paragraph and photo - whose job is to
         give the wide overlay visual weight and balance the link grid.
         Stacked on a phone it measured 404px, so a tap on "Explore NUSRL"
         showed a picture and zero links until you scrolled most of a screen.
         style.css originally hid it below 800px; three later patches turned it
         back on. Navigation on a phone is a list, not a poster.             */
  .main-nav .mega-intro{display:none}

  .main-nav .menu-about-container,
  .main-nav .menu-academics-container,
  .main-nav .menu-explore-container{
    max-height:none;overflow:visible;padding:0;width:100%;
    display:block;grid-template-columns:none;
  }
  /* Desktop deals the directory into 2-3 balanced columns; one column here. */
  .main-nav .menu,
  .main-nav .menu-about,
  .main-nav .menu-academics,
  .main-nav .menu-explore{display:block;grid-template-columns:none;column-count:1;gap:0}
  /* Every section gets a separator. The rule cannot key off :last-child alone:
     the Explore directory is dealt into three balanced <ul>s for the desktop
     grid, so stacking them would drop the separator at the foot of each list
     and leave the rhythm looking arbitrary. Only the final list's final row
     goes without. */
  .main-nav .menu>li,
  .main-nav .menu-explore>li{padding:0;margin:0;border-bottom:1px solid #e6e2d8}
  .main-nav .menu-explore-container>.menu-explore:last-child>li:last-child,
  .main-nav .menu-about-container>.menu:last-child>li:last-child,
  .main-nav .menu-academics-container>.menu:last-child>li:last-child{border-bottom:0}

  /* Section headings become 48px accordion rows. */
  .main-nav .menu>li>.menu-link,
  .main-nav .menu-explore>li>.menu-link{
    display:flex;align-items:center;justify-content:space-between;gap:12px;
    min-height:48px;padding:0 var(--gutter);
    color:var(--teal);font:700 11px var(--sans);letter-spacing:.1em;text-transform:uppercase;
  }

  /* Leaf links: 44px rows, indented one step so depth stays legible. Nowrap is
     released here - desktop keeps labels on one line inside fixed-width
     columns, but on a narrow sheet a long label must wrap, not overflow.

     SPECIFICITY, deliberately: style.css sets these links with four-class
     selectors (.nav-dropdown .menu .sub-menu .menu-link and
     .mega-content .menu-explore .sub-menu .menu-link, both 0-4-0). Being later
     in the cascade does not help a three-class selector against those — it
     simply loses, which left every leaf link at padding:5px 0, flush against
     the edge of the screen while its own section heading sat at the gutter.
     Matching the panel and list classes takes these to 0-5-0 so they win on
     specificity rather than on file order, which also survives style.css
     growing another patch. */
  .main-nav .nav-dropdown .menu .sub-menu .menu-link,
  .main-nav .mega-content .menu-explore .sub-menu .menu-link{
    display:flex;align-items:center;min-height:44px;
    padding:6px var(--gutter) 6px calc(var(--gutter) + 14px);
    color:var(--ink);font:600 13px/1.45 var(--sans);letter-spacing:0;text-transform:none;
    white-space:normal;
  }
  .main-nav .nav-dropdown .menu .sub-menu .sub-menu .menu-link,
  .main-nav .mega-content .menu-explore .sub-menu .sub-menu .menu-link{
    padding-left:calc(var(--gutter) + 30px);font-size:12.5px;color:var(--muted);
  }
  .main-nav .nav-dropdown .menu .sub-menu .is-collapsible>.menu-link,
  .main-nav .mega-content .menu-explore .sub-menu .is-collapsible>.menu-link{
    justify-content:space-between;gap:12px;color:var(--teal);font-weight:700;
  }
  .main-nav .submenu-arrow .lucide{width:16px;height:16px}
  .main-nav .sub-menu[hidden]{display:none}

  /* 4j. Rows turned into accordions by js/main.js on small screens. */
  .main-nav li.is-m-collapsible>.menu-link{cursor:pointer}
  .main-nav li.is-m-collapsible.is-open>.menu-link .submenu-arrow .lucide{transform:rotate(180deg)}

  /* 4k. Simple header (gallery.html) - "back to home" is the only control, so
         it needs to be a real target, and it must not wrap: at 390px the
         two-line "<- BACK TO / HOME" collided with the brand lockup. Keeping
         it on one line and letting the (secondary) brand text shrink keeps a
         single clean row. */
  .simple-header .nav-wrap{gap:12px}
  .simple-header .back-home{display:inline-flex;align-items:center;flex:0 0 auto;min-height:44px;white-space:nowrap}
  .simple-header .brand{min-width:0}
}


/* ==========================================================================
   5. FOOTER — now owned entirely by css/sections.css
   --------------------------------------------------------------------------
   The footer this section used to fix (.footer-main / .footer-links, a brand
   block beside two short link columns) no longer exists: it was replaced by
   the full four-band footer restored from nusrlranchi.ac.in. Its rules lived
   here and are deleted rather than left behind, because a stylesheet full of
   selectors that match nothing is exactly the problem documented at the top of
   this file. The new footer's layout and its responsive behaviour sit together
   in sections.css, so there is one place to look.
   ======================================================================== */
@media (max-width:560px){
  .footer-bottom{gap:6px;padding:16px 0;text-align:left}
}

/* Touch laptops and hybrids can be wider than 1024 yet still be finger-driven.
   Sizing by input modality rather than width alone catches them. */
@media (hover:none) and (pointer:coarse){
  .main-nav .nav-cta{min-height:48px}
}


/* ==========================================================================
   6. Page-level fixes adjacent to the header/footer work
   ======================================================================== */

/* Desktop nav rows were 17-20px tall. That passes WCAG 2.5.8 only via the
   spacing exception, and it is a fussy target for a trackpad either way.
   Vertical padding grows the hit area to ~44px with no visual change: the
   header row is 91px tall and the items are centred inside it, so nothing
   moves. The gold hover rule is re-anchored to sit where it always sat. */
@media (min-width:1024px){
  .main-nav>a:not(.nav-cta),
  .main-nav .nav-dropdown-toggle,
  .main-nav .explore-toggle{padding-top:12px;padding-bottom:12px}
  .main-nav>a:not(.nav-cta):after{bottom:6px}
}

/* Legacy WordPress content ships fixed-width tables (the CLAT admission page
   carries width="423"), which pushed a horizontal scrollbar onto the whole
   document at 320-360px. js/main.js wraps each one so the table - and only
   the table - scrolls. */
.table-scroll{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.table-scroll>table{margin-bottom:0}

/* The compact footer used on gallery.html has a single "Home" link that was
   still a 17px target. */
@media (max-width:1023px){
  .footer-bottom a{display:inline-flex;align-items:center;min-height:44px}
}

/* Desktop footer links sat at 20.4px — the last targets anywhere on the site
   under the WCAG 2.5.8 floor of 24x24. A min-height clears it; at 12px type in
   an 8px-gap column the change is ~4px a row and reads as slightly calmer
   spacing rather than as a different design. */
@media (min-width:1024px){
  .footer-bottom a{display:inline-flex;align-items:center;min-height:24px}
  .simple-header .back-home{display:inline-flex;align-items:center;min-height:24px}
}

/* The hero sits directly under the header and was the first thing to break:
   at 390px the CTA and the text link were forced side by side, so
   "EXPLORE PROGRAMMES" wrapped to two lines inside its own button. */
@media (max-width:600px){
  .hero-actions{flex-wrap:wrap;gap:18px}
  .hero-actions .button{width:100%;justify-content:space-between}
}

/* At 320px the brand lockup wrapped to three lines and crowded the
   hamburger. */
@media (max-width:359px){
  :root{--gutter:16px}
  .brand{gap:9px}
  .brand img{width:38px}
  .brand span{font-size:8px}
  .brand strong{font-size:10px}
}


/* ==========================================================================
   7. INNER-PAGE SECTION SIDEBAR
   --------------------------------------------------------------------------
   Inner pages carry a navy "section" sidebar - the sibling pages of whichever
   branch you are in. On desktop it is a 260px column beside the article, which
   is exactly right. Below 800px the legacy layout stacks it, and because it
   holds 24-27 links it measured 1,049px tall on a 390x760 phone: the reader
   met a screen and a half of dark link list before the first word of the page
   they actually opened.

   It collapses to a single icon toggle instead. The nav is still there, one
   tap away and in the same place, but the page now opens on its own content.
   Collapsed by default because the reader arrived wanting THIS page - section
   navigation is a next step, not an entry requirement.

   Note this breakpoint is 800px, not the 1024px used for the header. They
   answer different questions: 1024 is where the horizontal nav stops fitting,
   800 is where this page's two-column reading layout collapses. Tying the
   sidebar to the layout that actually contains it keeps both honest.
   ======================================================================== */
.sidenav-toggle{display:none}

@media (max-width:800px){
  .original-inner-page .col-md-3{margin-bottom:22px;padding:0;background:transparent}

  /* Icon-only control: 44x44, labelled for assistive tech via aria-label. */
  .original-inner-page .sidenav-toggle{
    display:inline-flex;align-items:center;justify-content:center;
    width:44px;height:44px;padding:0;border:0;
    background:var(--navy);color:#dbe5e1;cursor:pointer;
    transition:background .2s ease,color .2s ease;
  }
  .original-inner-page .sidenav-toggle .lucide{width:21px;height:21px;stroke-width:1.9}
  .original-inner-page .col-md-3.is-open .sidenav-toggle{background:var(--teal);color:#fff}

  /* Expanded, the list still runs ~1,200px. Capping it at 60vh with its own
     scroll means the icon that closes it never leaves the screen - the same
     reasoning as the main drawer, applied at section scale. */
  .original-inner-page .sidenav-panel{
    margin-top:8px;padding:14px 20px 6px;
    background:var(--navy);color:#dbe5e1;
    max-height:60vh;overflow-y:auto;overscroll-behavior:contain;
  }
  .original-inner-page .sidenav-panel[hidden]{display:none}

  /* The sidebar repeats the university crest, which the sticky header already
     shows 60px above it. Redundant, and it cost ~90px of the panel. */
  .original-inner-page .col-md-3 .widget_media_image{display:none}

  /* Same thumb-target rule as the rest of the mobile nav. */
  .original-inner-page .col-md-3 a{display:flex;align-items:center;min-height:44px;padding:4px 0;font-size:13px}
}

/* The drawer transition and the hero zoom are decorative. Honour the OS
   setting rather than animating regardless. */
@media (prefers-reduced-motion:reduce){
  *,*:before,*:after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
}
