/*
 * Layout primitives for pages that omit bootstrap.min.css ($iitd_exclude_bootstrap_css).
 * Covers class names still used by shared header/footer + mega menu grid.
 * Load before custom.css so site rules can override.
 */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
}

/* --- Display & flex (utilities used in markup) --- */
.d-none { display: none !important; }
.d-flex { display: flex !important; }

@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
}

.flex-column { flex-direction: column !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.ms-auto { margin-left: auto !important; }
.position-static { position: static !important; }

@media (min-width: 992px) {
  .align-items-lg-center { align-items: center !important; }
}

/* --- Spacing utilities (flattened on new-design shell pages) --- */
.py-2 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-3 { padding-top: 0 !important; padding-bottom: 0 !important; }
.px-3 { padding-left: 0 !important; padding-right: 0 !important; }
.p-0 { padding: 0 !important; }

.shadow {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* --- Container (new-design shell = full bleed; no horizontal inset) --- */
.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: 0;
  padding-left: 0;
}

/* Figma shell pages set gutters in header.php / iitd-chrome-figma — never Bootstrap column widths */
body.iitd-design-v2 .container {
  max-width: 100% !important;
}

@media (min-width: 576px) {
  .container { max-width: 540px; }
  body.iitd-design-v2 .container { max-width: 100% !important; }
}
@media (min-width: 768px) {
  .container { max-width: 720px; }
  body.iitd-design-v2 .container { max-width: 100% !important; }
}
@media (min-width: 992px) {
  .container { max-width: 960px; }
  body.iitd-design-v2 .container { max-width: 100% !important; }
}
@media (min-width: 1200px) {
  .container { max-width: 1140px; }
  body.iitd-design-v2 .container { max-width: 100% !important; }
}
@media (min-width: 1400px) {
  .container { max-width: 1320px; }
  body.iitd-design-v2 .container { max-width: 100% !important; }
}

/* --- Navbar structure --- */
.navbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.navbar-nav {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

.nav-item {
  list-style: none;
}

.nav-link {
  display: block;
  padding: 0;
  text-decoration: none;
}

.navbar-collapse {
  flex-basis: 100%;
  flex-grow: 1;
  align-items: center;
}

.navbar-toggler {
  padding: 0.25rem 0.75rem;
  font-size: 1.25rem;
  line-height: 1;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 0.375rem;
}

/* --- Collapse (mobile drawer + Bootstrap JS) --- */
.collapse:not(.show) {
  display: none;
}

.collapsing {
  height: 0;
  overflow: hidden;
  transition: height 0.35s ease;
}

@media (max-width: 991.98px) {
  .navbar-collapse.show {
    display: flex !important;
    flex-direction: column;
  }
}

@media (min-width: 992px) {
  .navbar-expand-lg .navbar-nav {
    flex-direction: row;
  }

  .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
    flex-grow: 1;
    align-items: center;
    justify-content: flex-end;
  }

  .navbar-expand-lg .navbar-toggler {
    display: none;
  }
}

/* --- Dropdown menus (mega menus rely on .show from Bootstrap JS) --- */
.dropdown-menu {
  position: absolute;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  margin: 0;
  list-style: none;
  background-clip: padding-box;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  width: 100%;
  clear: both;
  text-align: inherit;
  background-color: transparent;
}

/* --- Buttons (dropdown triggers use .btn .btn-link) --- */
.btn {
  display: inline-block;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}

.btn-link {
  text-decoration: underline;
}

/* --- Grid rows inside mega menus (.g-4 restores gutters where custom.css zeros .row) --- */
.row {
  display: flex;
  flex-wrap: wrap;
}

.row.g-4 {
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
  margin-top: 0;
  margin-right: 0;
  margin-left: 0;
}

.row.g-4 > * {
  flex-shrink: 0;
  padding-right: 0;
  padding-left: 0;
  margin-top: 0;
}

.col-12 {
  flex: 0 0 auto;
  width: 100%;
}

@media (min-width: 992px) {
  .col-lg-6 {
    flex: 0 0 auto;
    width: 50%;
  }
}

/* --- Rare footer-loader utilities --- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.text-primary {
  color: #0d6efd !important;
}

.spinner-border {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 0.25em solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: iitd-shell-spin 0.75s linear infinite;
}

@keyframes iitd-shell-spin {
  to { transform: rotate(360deg); }
}
