/* =============================================================================
   AOSAWY.ORG — Apple Liquid Glass Design System
   Shared stylesheet linked from all 14 pages.
   Pipeline A (4 HTML pages) + Pipeline B (10 Vite/React pages).
   !important overrides counter Pipeline B's inline style injection.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. GOOGLE FONTS
----------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700&display=swap');


/* -----------------------------------------------------------------------------
   2. CSS CUSTOM PROPERTIES
----------------------------------------------------------------------------- */
:root {
  /* -- Colors -- */
  --color-bg:            #f5f5f7;
  --color-text:          #1d1d1f;
  --color-secondary:     #6e6e73;
  --color-tertiary:      #86868b;
  --color-accent:        #0071e3;
  --color-accent-light:  rgba(0, 113, 227, 0.06);
  --color-accent-border: rgba(0, 113, 227, 0.15);
  --color-border:        rgba(0, 0, 0, 0.06);

  /* -- Glass surfaces -- */
  --card-bg:        rgba(255, 255, 255, 0.65);
  --card-blur:      saturate(180%) blur(20px);
  --card-border:    0.5px solid rgba(0, 0, 0, 0.06);
  --card-radius:    16px;
  --card-shadow:    0 1px 4px rgba(0, 0, 0, 0.03);
  --nav-bg:         rgba(255, 255, 255, 0.72);
  --surface-bg:     rgba(255, 255, 255, 0.45);
  --surface-blur:   saturate(120%) blur(12px);

  /* -- Typography -- */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-math:    'Cambria Math', 'Latin Modern Math', 'STIX Two Math', Georgia, 'Times New Roman', serif;

  /* -- Font sizes -- */
  --fs-h1:     clamp(2.4rem, 5.5vw, 3.8rem);
  --fs-h2:     2rem;
  --fs-h3:     1.1rem;
  --fs-body:   0.95rem;
  --fs-label:  0.73rem;
  --fs-pill:   0.73rem;
  --fs-button: 0.85rem;
  --fs-nav:    0.82rem;

  /* -- Spacing -- */
  --section-padding:  80px 24px;
  --card-padding:     24px;
  --container-max:    1200px;

  /* -- Transitions -- */
  --transition-fast:   all 0.2s ease;
  --transition-normal: all 0.3s ease;

  /* -- Button radii -- */
  --button-radius: 12px;
  --pill-radius:   100px;
}


/* -----------------------------------------------------------------------------
   3. BODY FONT OVERRIDE
   !important forces the design-system font stack over Pipeline B's useEffect
   which injects system fonts as inline styles on <body>.
----------------------------------------------------------------------------- */
body {
  font-family: var(--font-body) !important;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* -----------------------------------------------------------------------------
   4. @KEYFRAMES
----------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 113, 227, 0.25);
  }
  50% {
    box-shadow: 0 0 40px rgba(0, 113, 227, 0.55);
  }
}

@keyframes heroFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes heroButtonGlow {
  0%, 100% {
    box-shadow: 0 0 6px rgba(255,255,255,0.15), 0 0 12px rgba(255,255,255,0.05);
  }
  50% {
    box-shadow: 0 0 12px rgba(255,255,255,0.35), 0 0 24px rgba(255,255,255,0.12);
  }
}


/* -----------------------------------------------------------------------------
   5. SCROLL-REVEAL UTILITY
----------------------------------------------------------------------------- */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}


/* -----------------------------------------------------------------------------
   6. FLOATING BACK-NAVIGATION COMPONENT
   Glass-style fixed button — shared across all showcase pages.
----------------------------------------------------------------------------- */
/* Hidden — persistent site header now provides navigation on all pages */
.site-back-nav {
  display: none !important;
}

.site-back-nav a,
.site-back-nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--card-bg);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: var(--card-border);
  border-radius: 50px;
  box-shadow: var(--card-shadow);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-nav);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.site-back-nav a:hover,
.site-back-nav button:hover {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  transform: translateY(-1px);
}

.site-back-nav a:active,
.site-back-nav button:active {
  transform: translateY(0);
}


/* -----------------------------------------------------------------------------
   7. CUSTOM SCROLLBAR
----------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.30);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}


/* -----------------------------------------------------------------------------
   8. RESPONSIVE DEFAULTS  (desktop-first: hidden by default)
----------------------------------------------------------------------------- */
.ds-hamburger {
  display: none;
}

.ds-mobile-drawer {
  display: none;
}


/* -----------------------------------------------------------------------------
   8.1 ANIMATED HAMBURGER ICON (Apple-style)
----------------------------------------------------------------------------- */
.ds-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
}
.ds-hamburger-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}
.ds-hamburger-lines span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--color-text);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}
/* Open state: X animation */
.ds-hamburger.open .ds-hamburger-lines span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.ds-hamburger.open .ds-hamburger-lines span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.ds-hamburger.open .ds-hamburger-lines span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* -----------------------------------------------------------------------------
   8.2 UNIFIED SITE HEADER (injected on showcase/research/teaching pages)
----------------------------------------------------------------------------- */
.ds-site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--color-border);
  height: 56px;
}
.ds-header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.ds-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
  vertical-align: middle;
}
.ds-header-logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}
.ds-site-header .ds-nav-links {
  display: flex;
  gap: 24px;
}
.ds-site-header .ds-nav-links a {
  font-family: var(--font-body);
  font-size: var(--fs-nav);
  color: var(--color-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}
.ds-site-header .ds-nav-links a:hover {
  color: var(--color-accent);
}
/* Drawer close button */
.ds-drawer-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--color-text);
  cursor: pointer;
}
/* Scroll-lock when mobile drawer is open */
body.drawer-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
}
/* Pages with injected site header need top padding */
body:has(.ds-site-header) #root {
  padding-top: 56px;
}
/* Sticky elements below the fixed header */
body:has(.ds-site-header) [style*="position: sticky"] {
  top: 56px !important;
}


/* -----------------------------------------------------------------------------
   8.3 SCROLL INDICATOR (mouse icon with bouncing dot)
----------------------------------------------------------------------------- */
.ds-scroll-indicator {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  z-index: 5;
}
.ds-scroll-indicator:hover { opacity: 1; }

.ds-scroll-mouse {
  width: 24px;
  height: 38px;
  border: 2px solid currentColor;
  border-radius: 12px;
  position: relative;
}
.ds-scroll-mouse::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 8px;
  background: currentColor;
  border-radius: 3px;
  animation: scrollBounce 1.5s ease-in-out infinite;
}
.ds-scroll-indicator span {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: currentColor;
}

@keyframes scrollBounce {
  0%, 100% { opacity: 1; transform: translateX(-50%) translateY(0); }
  50% { opacity: 0.3; transform: translateX(-50%) translateY(10px); }
}

/* Color variants for different hero backgrounds */
.ds-scroll-indicator--light { color: rgba(255,255,255,0.7); }
.ds-scroll-indicator--dark { color: rgba(29,29,31,0.5); }


/* =============================================================================
   9. RESPONSIVE BREAKPOINTS
   ============================================================================= */

/* -----------------------------------------------------------------------------
   8a. TABLET  (640px – 1024px)
----------------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 1024px) {
  :root {
    --fs-h1:            clamp(2rem, 4vw, 3rem);
    --fs-h2:            1.75rem;
    --section-padding:  64px 24px;
  }

  /* 3- and 4-column grids collapse to 2 columns */
  .ds-grid-3,
  .ds-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Hamburger visible on tablet too */
  .ds-hamburger {
    display: flex !important;
  }

  .ds-nav-links {
    display: none !important;
  }

  /* -- Mobile navigation drawer (tablet) -- */
  .ds-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(245, 245, 247, 0.92);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .ds-mobile-drawer.open {
    opacity: 1;
    pointer-events: all;
  }

  .ds-mobile-drawer a {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color 0.15s ease;
  }

  .ds-mobile-drawer a:hover {
    color: var(--color-accent);
  }
}


/* -----------------------------------------------------------------------------
   8b. MOBILE  (< 640px)
----------------------------------------------------------------------------- */
@media (max-width: 639px) {
  :root {
    --fs-h1:            clamp(1.6rem, 6vw, 2.4rem);
    --fs-h2:            1.5rem;
    --section-padding:  48px 16px;
    --card-padding:     16px;
  }

  /* -- Layout grids → single column -- */
  .ds-grid-2,
  .ds-grid-3,
  .ds-grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* -- Stats grid → 2 columns -- */
  .ds-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* -- Hero flex stacking -- */
  .ds-hero-flex {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .ds-hero-photo {
    width: 140px !important;
    height: 140px !important;
    margin: 0 auto 20px !important;
  }

  .ds-hero-buttons {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .ds-hero-buttons > * {
    width: 100% !important;
    text-align: center !important;
  }

  /* -- Navigation: hamburger visible, links hidden -- */
  .ds-hamburger {
    display: flex !important;
  }

  .ds-nav-links {
    display: none !important;
  }

  /* -- Mobile navigation drawer --
     Full-screen glass overlay with centered Playfair links */
  .ds-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(245, 245, 247, 0.92);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .ds-mobile-drawer.open {
    opacity: 1;
    pointer-events: all;
  }

  .ds-mobile-drawer a {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color 0.15s ease;
  }

  .ds-mobile-drawer a:hover {
    color: var(--color-accent);
  }

  /* -- Back-nav smaller on mobile -- */
  .site-back-nav a,
  .site-back-nav button {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  /* -------------------------------------------------------------------------
     Pipeline B inline-style overrides (attribute selectors + !important)
     These target Vite-bundled React components that set styles via inline
     style attributes. Attribute selectors are more specific than class
     selectors but less specific than id or !important.
  ------------------------------------------------------------------------- */

  /* Prevent horizontal overflow on root */
  #root {
    overflow-x: hidden;
  }

  /* Prevent media overflow */
  img, video, canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Grid columns → single column */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Large paddings → reduced */
  [style*="padding: 3rem"],
  [style*="padding:3rem"],
  [style*="padding: 4rem"],
  [style*="padding:4rem"],
  [style*="padding: 100px"],
  [style*="padding:100px"] {
    padding: 24px 16px !important;
  }

  [style*="padding: 80px"],
  [style*="padding:80px"] {
    padding: 48px 16px !important;
  }

  [style*="padding: 64px"],
  [style*="padding:64px"] {
    padding: 40px 16px !important;
  }

  [style*="padding: 60px"],
  [style*="padding:60px"] {
    padding: 36px 16px !important;
  }

  [style*="padding: 48px"],
  [style*="padding:48px"] {
    padding: 32px 16px !important;
  }

  /* 100vh sections → auto height on mobile, with breathing room */
  [style*="height: 100vh"],
  [style*="height:100vh"],
  [style*="min-height: 100vh"],
  [style*="min-height:100vh"] {
    height: auto !important;
    min-height: auto !important;
    padding-top: 60px !important;
    padding-bottom: 40px !important;
  }

  /* Large inline font-sizes → clamped */
  [style*="font-size: 3"],
  [style*="font-size:3"] {
    font-size: clamp(1.5rem, 6vw, 2.2rem) !important;
  }

  [style*="font-size: 2"],
  [style*="font-size:2"] {
    font-size: clamp(1.2rem, 5vw, 1.75rem) !important;
  }

  /* Wide-gap flex rows → column stack */
  [style*="display: flex"][style*="gap: 4"],
  [style*="display:flex"][style*="gap:4"],
  [style*="display: flex"][style*="gap: 3"],
  [style*="display:flex"][style*="gap:3"] {
    flex-direction: column !important;
  }

  /* =========================================================
     MOBILE OPTIMIZATION — Reference: iPhone 17 Pro Max (440x956)
     ========================================================= */

  /* -- Images, videos, logos -- */
  img, video, canvas, svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Ensure no horizontal overflow — use clip on #root to preserve sticky */
  #root {
    overflow-x: clip;
  }
  main, section, article, .scroll-reveal {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
  }

  /* -- Hero section mobile: stack content + scroll indicator vertically -- */
  #hero {
    flex-direction: column !important;
  }

  /* -- Research showcase hero: stack on mobile -- */
  #research-hero {
    height: auto !important;
    min-height: 100vh;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    padding: 56px 20px 24px !important;
    margin-top: -56px !important;
    overflow: visible !important;
  }

  #research-hero video,
  #research-hero > div:first-of-type,
  #research-hero > div:nth-of-type(2) {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  .research-hero-stats {
    position: static !important;
    order: 1;
    display: flex !important;
    justify-content: center !important;
    gap: 8px !important;
    margin-bottom: 16px;
    z-index: 5;
  }

  .research-hero-stats > div {
    padding: 8px 12px !important;
    flex: 1;
    max-width: 110px;
  }

  .research-hero-stats > div > div:first-child {
    font-size: 1rem !important;
  }

  .research-hero-stats > div > div:last-child {
    font-size: 0.55rem !important;
  }

  .research-hero-content {
    position: static !important;
    order: 2;
    z-index: 5;
    max-width: 100% !important;
    text-align: center !important;
  }

  .research-hero-content > div:first-child {
    padding: 1.25rem !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Logo links row — move to bottom of card */
  .research-hero-content > div:first-child > div:first-child {
    order: 10 !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-bottom: 0 !important;
    margin-top: 1rem !important;
  }

  /* Logo buttons — darker background + glow animation */
  .research-hero-content > div:first-child > div:first-child a {
    padding: 6px 12px 6px 8px !important;
    border-radius: 12px !important;
    background: rgba(0,0,0,0.55) !important;
    border: 0.5px solid rgba(255,255,255,0.2) !important;
    animation: heroButtonGlow 3s ease-in-out infinite !important;
  }

  .research-hero-content > div:first-child > div:first-child img {
    height: 26px !important;
    width: auto !important;
    filter: brightness(1.3) !important;
  }

  .research-hero-content h1 {
    font-size: 1.5rem !important;
    text-align: center !important;
  }

  .research-hero-content p {
    text-align: center !important;
    font-size: 0.85rem !important;
  }

  /* Author/metadata row: center and wrap */
  .research-hero-content > div:first-child > div:nth-child(4) {
    justify-content: center !important;
  }

  /* Institution line */
  .research-hero-content > div:first-child > div:last-child {
    text-align: center !important;
  }

  /* Cap RIA logo in overview tab on mobile */
  img[alt*="RIA - Renewables"] {
    max-width: 160px !important;
    width: auto !important;
  }

  /* Scroll indicator in research hero */
  #research-hero .ds-scroll-indicator {
    position: static !important;
    order: 3;
    margin: 16px auto 0 !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    width: fit-content !important;
  }

  /* =============================================
     RESEARCH SHOWCASE — COMPREHENSIVE MOBILE FIXES
     ============================================= */

  /* Issue 1: Move hero logo buttons to bottom of card — side by side, centered
     MUST use #root prefix to outweigh #root [style*="..."] broad rule (specificity 0,1,3,0 > 0,1,2,0) */
  #root .research-hero-content > div:first-child > div:first-child {
    order: 10 !important;
    margin-bottom: 0 !important;
    margin-top: 0.75rem !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Issue 2: Stat/config cards — 2 per row on mobile */
  /* Target grids with small minmax (stat chips, config cards, cost structure) */
  #root [style*="display: grid"][style*="minmax(160px"],
  #root [style*="display: grid"][style*="minmax(180px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Grids with medium minmax (250px) — also 2 per row */
  #root [style*="display: grid"][style*="minmax(250px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Grids with large minmax (280px+, 320px+, 340px+) — keep single column */
  /* These contain long-text cards (research thrusts, datasets) */
  #root [style*="display: grid"][style*="minmax(280px"],
  #root [style*="display: grid"][style*="minmax(320px"],
  #root [style*="display: grid"][style*="minmax(340px"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Compact stat card text */
  #root [style*="display: grid"][style*="minmax(180px"] > div,
  #root [style*="display: grid"][style*="minmax(250px"] > div {
    padding: 0.75rem !important;
  }

  /* Issue 3: Research-specific footer — separate from dark footer */
  .ds-site-footer {
    margin-top: 0 !important;
  }

  /* Issue 4: Tab bar — wrap buttons, not scrollable */
  [style*="position: sticky"][style*="top: 56px"] > div {
    white-space: normal !important;
    overflow-x: visible !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    justify-content: center !important;
  }

  [style*="position: sticky"][style*="top: 56px"] > div > button {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.7rem !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    white-space: nowrap !important;
  }

  /* Multi-column fixed grids → 2 per row on mobile */
  #root [style*="display: grid"][style*="repeat(5"],
  #root [style*="display: grid"][style*="repeat(6"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Issue 5: Sponsor/funding logos — much smaller, side by side */
  [style*="Supported By"] + div img,
  [style*="gap: 2.5rem"] > a img {
    height: 28px !important;
    width: auto !important;
  }

  [style*="gap: 2.5rem"] {
    gap: 1rem !important;
  }

  /* Issue 7: Dataset Engineering cards — fix layout on mobile */

  /* Title row (title + pills): stack vertically on mobile */
  #root [style*="justify-content: space-between"][style*="align-items: flex-start"],
  #root [style*="justify-content: space-between"][style*="align-items: center"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  /* Monospace filenames: allow wrapping + truncate */
  #root h4[style*="Courier"] {
    word-break: break-all !important;
    font-size: 0.78rem !important;
    line-height: 1.4 !important;
  }

  /* 3-column detail grids inside cards: vertical single column on mobile */
  #root [style*="display: grid"][style*="1fr 1fr 1fr"]:not([style*="repeat"]) {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  /* Overflow containers — enable horizontal scroll */
  #root [style*="overflow-x: auto"],
  #root [style*="overflowX"] {
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables inside scrollable containers — readable min-width */
  #root [style*="overflow"] table {
    min-width: 600px !important;
    font-size: 0.78rem !important;
  }

  #root [style*="overflow"] table th,
  #root [style*="overflow"] table td {
    padding: 0.6rem 0.75rem !important;
    white-space: nowrap !important;
  }

  /* All tables and code blocks inside cards — scroll */
  #root table, #root pre, #root code {
    font-size: 0.7rem !important;
    word-break: break-all;
  }

  /* Issue 8: Figures/flowcharts — make scrollable when too wide */
  #root [style*="display: grid"][style*="1fr 1fr 1fr"],
  #root [style*="display: grid"][style*="repeat(3"],
  #root [style*="display: grid"][style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* SVG and canvas figures — full width + scrollable container */
  #root svg[viewBox] {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Image figures (flowcharts, diagrams) — scrollable */
  #root img[alt*="framework"],
  #root img[alt*="Framework"],
  #root img[alt*="POSYDON"],
  #root img[alt*="pipeline"],
  #root img[alt*="Pipeline"] {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
  }

  /* Generic: any figure container inside research cards */
  #root [style*="overflow: hidden"] {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* =============================================
     END RESEARCH SHOWCASE MOBILE FIXES
     ============================================= */

  [style*="background-image"] {
    background-size: cover !important;
    background-position: center !important;
  }

  /* Scroll indicator: static flow on mobile, centered */
  .ds-scroll-indicator {
    position: static !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    width: fit-content !important;
    margin: 24px auto 16px !important;
  }

  /* Hero CTA buttons: smaller on mobile */
  .ds-hero-buttons {
    gap: 10px !important;
  }
  .ds-hero-buttons a,
  .ds-hero-buttons button {
    padding: 10px 20px !important;
    font-size: 0.8rem !important;
  }

  /* -- Journey image grid: full aspect ratio on mobile -- */
  .ds-journey-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .ds-journey-grid > div {
    min-height: auto !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }
  .ds-journey-grid img {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    border-radius: 16px !important;
  }

  /* Commencement photo: full width on mobile */
  img[alt*="Commencement"], img[alt*="commencement"], img[alt*="graduation"], img[alt*="Graduation"], img[alt*="Class of 2024"] {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    border-radius: 12px !important;
  }

  /* -- University logos in degree cards -- */
  [alt*="AUC School"], [alt*="Rutgers ISE"] {
    max-height: 60px !important;
    margin-top: 12px !important;
  }

  /* -- Commencement people info: stack on mobile -- */
  .ds-people-row {
    flex-direction: column !important;
    gap: 16px !important;
  }

  /* -- RIA logo button: prevent overflow -- */
  [alt="RIA Lab"] {
    max-height: 24px !important;
  }

  /* -- Teaching stats: stack properly on mobile -- */
  .ds-teaching-stats {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: stretch !important;
  }
  .ds-teaching-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* -- Teaching stats grid: ensure proper stacking -- */
  [style*="gridTemplateColumns: 'repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* -- Contact cards: single column -- */
  [style*="gridTemplateColumns: 'repeat(4, 1fr)'"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* -- Buttons: full width on mobile -- */
  [style*="borderRadius: '980px'"],
  [style*="border-radius: 980px"] {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* -- Resume/CV card: tone down glow -- */
  [style*="boxShadow"][style*="rgba(0,113,227"] {
    box-shadow: 0 2px 12px rgba(0,113,227,0.15) !important;
  }

  /* -- Section padding tighter on mobile -- */
  section > div[style*="maxWidth"],
  [style*="max-width: 1200px"],
  [style*="maxWidth: '1200px'"] {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* -- Footer on mobile -- */
  .ds-site-footer {
    padding: 40px 16px 16px !important;
  }

  /* -- Prevent text overflow anywhere -- */
  h1, h2, h3, h4, h5, h6, p, span, a, li {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* -- Tab nav: horizontal scroll with momentum -- */
  [style*="position: sticky"] {
    padding: 8px 12px !important;
  }
  [style*="position: sticky"] button,
  [style*="position: sticky"] a {
    font-size: 0.75rem !important;
    padding: 6px 12px !important;
    white-space: nowrap;
  }

  /* -- 3D model viewers & canvas -- */
  canvas {
    max-width: 100% !important;
    max-height: 60vh !important;
  }
  model-viewer {
    max-width: 100% !important;
    max-height: 300px !important;
  }
}


/* -----------------------------------------------------------------------------
   10. SITE FOOTER
----------------------------------------------------------------------------- */
.ds-site-footer {
  background: #1d1d1f;
  color: rgba(255,255,255,0.7);
  padding: 64px 24px 24px;
  font-family: var(--font-body);
}
.ds-footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 48px;
}
.ds-footer-heading {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 16px;
}
.ds-footer-text {
  font-size: 0.85rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.6);
}
.ds-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ds-footer-links li {
  margin-bottom: 10px;
}
.ds-footer-links a {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}
.ds-footer-links a:hover {
  color: #0071e3;
}
.ds-footer-bar {
  max-width: var(--container-max);
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 0.5px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}
.ds-footer-bar a {
  color: rgba(255,255,255,0.4);
  text-decoration: none;
}
.ds-footer-bar a:hover {
  color: #0071e3;
}

@media (max-width: 639px) {
  .ds-footer-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .ds-footer-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}
