/*
 * base.css — Loaded on EVERY frontend page
 * Contains: variables, reset, navbar, footer, shared utilities
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:       #1a3d2b;
  --primary-light: #e8f5e9;
  --accent:        #e8534a;
  --text:          #1a1a2e;
  --muted:         #6b7280;
  --border:        #e5e7eb;
  --nav-h:         117px;
  --font:          'DM Sans', sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  margin: 0;
  padding: 0;
  background: #fff;
}

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
#mainNav {
  position: sticky !important;
  top: 0;
  z-index: 1040;
  overflow: visible !important;
  background: #fff;
  --bs-navbar-padding-y: 0.34rem;
}

/* Nav items gap — scales with viewport, never wraps */
@media (min-width: 1200px) {
  .nav-items-gap {
    gap: clamp(.15rem, 1.5vw, 3rem) !important;
    flex-wrap: nowrap !important;
  }
}

/* Navbar container padding */
.nav-container {
  padding-left:  clamp(1.5rem, 5vw, 6rem) !important;
  padding-right: clamp(1.5rem, 5vw, 6rem) !important;
}

@media (min-width: 1200px) {
  .nav-container {
    padding-right: clamp(1.5rem, 12vw, 10rem) !important;
  }
}

/* Logo — mobile first */
.nav-logo-svg { width: 44px; height: 44px; flex-shrink: 0; }
.nav-logo-img { height: 32px; width: auto; flex-shrink: 0; }
.navbar-brand  { padding: .35rem 0; }
.brand-text    { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name    { font-size: 1.2rem; font-weight: 700; color: var(--primary); letter-spacing: .05em; }
.brand-sub     { font-size: .6rem;  font-weight: 600; letter-spacing: .16em; color: var(--muted); }

/* Nav links — mobile */
.navbar-nav .nav-link {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  padding: .75rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active { color: var(--primary); }
.navbar-nav .nav-link-purple,
.navbar-nav .nav-link-purple:hover,
.navbar-nav .nav-link-purple:focus,
.navbar-nav .nav-link-purple:active {
  color: #612381 !important;
  text-decoration: none !important;
  background: transparent !important;
  transition: none !important;
  transform: none !important;
  --bs-nav-link-color: #612381;
  --bs-nav-link-hover-color: #612381;
}

/* Chevron dropdown arrow */
.navbar-nav .dropdown-toggle::after {
  display: inline-block;
  content: '';
  width: .462em;
  height: .462em;
  border-right: 2.2px solid currentColor;
  border-bottom: 2.2px solid currentColor;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
  margin-left: .35em;
  vertical-align: middle;
  position: relative;
  top: -.15em;
}

/* Tablet ≥768px */
@media (min-width: 768px) {
  .nav-logo-svg { width: 60px; height: 60px; }
  .nav-logo-img { height: 40px; }
  .brand-name   { font-size: 1.5rem; }
  .brand-sub    { font-size: .75rem; }
  .navbar-brand { padding: .5rem 0; }
}

/* Desktop ≥1200px — scales down with viewport to prevent wrapping */
@media (min-width: 1200px) {
  .nav-logo-svg { width: clamp(52px, 5.2vw, 82px); height: clamp(52px, 5.2vw, 82px); }
  .nav-logo-img { height: clamp(36px, 3.5vw, 50px); }
  .brand-name   { font-size: clamp(1rem, 1.35vw, 1.9rem); }
  .brand-sub    { font-size: clamp(.5rem, .6vw, .95rem); }
  .navbar-brand { padding: clamp(.2rem, .35vw, .55rem) 0; }
  .navbar-nav .nav-link {
    font-size: clamp(12px, 1.15vw, 16px);
    font-weight: 500;
    color: #374151;
    padding: .3rem clamp(.15rem, .6vw, 1.5rem);
    white-space: nowrap;
    min-height: unset;
    display: block;
  }
}

/* Regular dropdown (Campus etc.) */
.dropdown-menu {
  border: none;
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
  border-top: 2px solid var(--primary);
  min-width: 200px;
  padding: .5rem 0;
}
.dropdown-item {
  font-size: .9rem;
  padding: .7rem 1.25rem;
  color: var(--text);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }

/* ── Mega menu ───────────────────────────────────────────────────────────────── */
.mega-dropdown { position: static; }

/* Mobile: in-flow stacked list */
.mega-menu {
  position: static !important;
  width: 100%;
  height: auto;
  max-height: 65vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #f8fafc;
  margin: 0 !important;
  padding: 0 !important;
  z-index: auto;
}
.mega-inner { padding: 1rem; }

/* Desktop: fixed, positioned by JS */
@media (min-width: 1200px) {
  .mega-menu {
    position: fixed !important;
    left: 0; right: 0;
    top: var(--nav-h); /* JS overrides with exact px */
    width: 100%;
    height: auto;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border-top: none !important;
    box-shadow: none;
    z-index: 1030;
    padding: 0 !important;
    margin: 0 !important;
  }
  .mega-menu.show {
    animation: megaFadeIn .18s ease forwards;
  }
  .mega-inner { padding: 2rem 2.5rem; }
}

@keyframes megaFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mega content — mobile first */
.mega-heading {
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #612381;
  text-decoration: none;
  display: block;
  padding: .5rem 0;
}
.mega-heading:hover { color: var(--primary); text-decoration: none; }

.mega-list { list-style: none; padding: 0; margin: 0; }
.mega-list > li { margin-bottom: .55rem; }
.mega-list > li:has(> a:not(.mega-heading)) { margin-bottom: .1rem; }

.mega-list a {
  font-size: .9rem;
  font-weight: 500;
  color: #4b5563;
  text-decoration: none;
  display: block;
  padding: .25rem 0;
  transition: color .15s;
}
.mega-list a.mega-heading { color: #612381; padding: 0; }
.mega-list a:hover { color: var(--primary); }

.mega-sublist {
  list-style: none;
  padding: .1rem 0 .15rem .9rem;
  margin: .05rem 0 0;
  border-left: none;
}
.mega-sublist li { margin-bottom: .4rem; }
.mega-sublist a  { font-size: .9rem; font-weight: 400; color: #4b5563; }
.mega-sublist a:hover { color: var(--primary); }

/* Desktop text sizes */
@media (min-width: 1200px) {
  .mega-heading       { font-size: 1.15rem; padding: 0; }
  .mega-list a        { font-size: .95rem; padding: 0; }
  .mega-list a.mega-heading { font-size: 1.15rem; font-weight: 600; }
  .mega-list > li     { margin-bottom: .6rem; }
  .mega-list > li:has(> a:not(.mega-heading)) { margin-bottom: 0 !important; }
  .mega-list a:not(.mega-heading)             { padding: 0 !important; line-height: 1.34; }
  .mega-sublist a     { font-size: .95rem; }
  .mega-sublist li    { margin-bottom: .155rem !important; }
}

/* Campus mega menu needs more vertical space for 2-row category layout */
@media (min-width: 1200px) {
  .campus-mega-menu {
    height: auto;
  }
}

/* Campus 5-column grid — aligns row 2 headings under row 1 */
.campus-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 1rem;
}
@media (min-width: 768px) {
  .campus-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .campus-grid { grid-template-columns: repeat(5, 1fr); gap: 1.5rem; }
}

/* ── SDG mega menu ───────────────────────────────────────────────────────────── */
.sdg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .15rem .5rem;
}
@media (min-width: 576px) {
  .sdg-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .sdg-grid { grid-template-columns: repeat(4, 1fr); gap: .1rem .45rem; }
}

.sdg-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .4rem .5rem;
  border-radius: 0;
  text-decoration: none;
  color: #4b5563;
  transition: background .15s, color .15s;
}
.sdg-item:hover {
  background: var(--sdg-color);
  color: #fff;
}

.sdg-icon-wrap {
  position: relative;
  width: 58px;
  height: 58 px;
  flex-shrink: 0;
  background: var(--sdg-color);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sdg-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sdg-name {
  font-size: 1.076rem;
  font-weight: 500;
  line-height: 1.3;
}

.search-bar-wrapper {
  display: none;
  background: #f9fafb;
  border-top: 1px solid var(--border);
}
.search-bar-wrapper.open { display: block; }

/* ── Shared typography ───────────────────────────────────────────────────────── */
.section-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: .75rem;
}
.section-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  background: #111827;
  color: #d1d5db;
}
.footer-heading {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 1rem;
}
.footer-links {
  list-style: none;
  padding: 0; margin: 0;
}
.footer-links li + li { margin-top: .5rem; }
.footer-links a {
  color: #9ca3af;
  text-decoration: none;
  font-size: .875rem;
  transition: color .2s;
}
.footer-links a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #1f2937;
  padding: 1.5rem 0;
}
