/* ============================================
   ML & Society Team Website - Custom Styles
   ============================================ */

/* ============================================
   Base Styles & Layout
   ============================================ */

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
}

/* Apply fonts to base elements */
body {
    font-family: 'Source Sans Pro', sans-serif;
    --header-height: 100px; /* Two-line navigation menu - desktop */
    
    /* Typography scale - consistent font sizes */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */
    
    /* Line heights for readability */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 1.75;
}

/* Ensure all major containers respect viewport width */
#main-layout, #main-content {
    max-width: 100vw;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    line-height: var(--leading-tight);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Body text readability */
p {
    line-height: var(--leading-relaxed);
}

/* Improve readability of long-form content */
.prose p {
    line-height: var(--leading-loose);
    margin-bottom: 1em;
}

/* ============================================
   Responsive Design - Mobile
   ============================================ */

/* Ensure minimum readable font size on mobile */
@media (max-width: 767px) {
    body {
        font-size: 14px; /* Minimum 14px on mobile */
    }
    
    /* Adjust heading sizes for mobile */
    h1 {
        font-size: var(--text-2xl);
    }
    
    h2 {
        font-size: var(--text-xl);
    }
    
    h3 {
        font-size: var(--text-lg);
    }
}

/* Responsive header height */
@media (max-width: 1023px) {
    body {
        --header-height: 80px; /* Tablet */
    }
}

@media (max-width: 767px) {
    body {
        --header-height: 70px; /* Mobile */
    }
}

/* Mobile menu */
@media (max-width: 1023px) {
    .mobile-menu-hidden {
        display: none;
    }
}

/* Mobile search sidebar - full screen on mobile */
@media (max-width: 767px) {
    #search-sidebar {
        width: 100vw !important;
        right: 0;
    }
    
    #search-sidebar > div {
        padding: 1rem;
    }
    
    /* Adjust search results height for mobile */
    #search-results {
        height: calc(100vh - 180px) !important;
    }
}

/* ============================================
   Navigation
   ============================================ */

/* Navigation overflow handling */
@media (min-width: 769px) {
    .nav-line-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
    }
    
    .nav-line-scroll::-webkit-scrollbar {
        height: 4px;
    }
    
    .nav-line-scroll::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    .nav-line-scroll::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 2px;
    }
}

/* Sticky Page Navigation */
.page-navigation {
    transition: all 0.3s ease;
}

#nav-container {
    transition: all 0.3s ease;
}

#nav-items {
    transition: all 0.3s ease;
}

#nav-toggle {
    transition: all 0.2s ease;
}

/* Navigation link active state transitions */
.page-navigation a {
    transition: all 0.3s ease;
    position: relative;
}

/* Subtle entrance animation for sticky nav */
@keyframes slideDown {
    from {
        opacity: 0.8;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-navigation.sticky-nav #nav-container {
    animation: slideDown 0.3s ease-out;
}

.page-navigation.sticky-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 30;
    padding: 0.5rem 0;
}

.page-navigation.sticky-nav #nav-container {
    background: rgba(240, 247, 248, 0.3);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0.75rem 1.5rem;
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.12);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Add breathing room between sticky nav and content */
.page-navigation.sticky-nav ~ section:first-of-type,
.page-navigation.sticky-nav ~ div:first-of-type {
    margin-top: 0;
}

/* Navigation collapse/expand */
#nav-items.nav-collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    width: 0;
}

/* Compact container when collapsed - just the hamburger icon */
.nav-container-collapsed {
    padding: 0.5rem !important;
    width: auto !important;
    max-width: fit-content !important;
    margin-left: auto !important;
    margin-right: 1.5rem !important;
}

/* Also make the parent section compact when collapsed */
.page-navigation.sticky-nav:has(.nav-container-collapsed) {
    padding: 0.25rem 0;
}

.page-navigation.sticky-nav .nav-container-collapsed {
    margin: 0 1.5rem 0 auto;
}

/* Mobile adjustments for sticky nav */
@media (max-width: 767px) {
    .page-navigation.sticky-nav {
        top: var(--header-height);
        padding: 0.25rem 0;
    }
    
    .page-navigation.sticky-nav #nav-container {
        padding: 0.5rem 1rem;
    }
    
    .page-navigation.sticky-nav ~ section:first-of-type,
    .page-navigation.sticky-nav ~ div:first-of-type {
        margin-top: 0.5rem;
    }
    
    /* Auto-collapse navigation on mobile when sticky for better UX */
    .page-navigation.sticky-nav #nav-items {
        font-size: 0.875rem; /* Slightly smaller text */
    }
    
    /* Ensure hamburger is more prominent on mobile */
    .page-navigation.sticky-nav #nav-toggle {
        padding: 0.5rem;
    }
}

/* ============================================
   Visual Effects
   ============================================ */

/* Frosted glass effect */
.backdrop-blur-md {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.backdrop-blur-sm {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.drop-shadow-lg {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* ============================================
   Text Utilities
   ============================================ */

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   Scrollbar Styles
   ============================================ */

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Custom scrollbar for research area card descriptions */
.overflow-y-auto::-webkit-scrollbar {
    width: 4px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Search results scrolling */
#search-results {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

#search-results::-webkit-scrollbar {
    width: 6px;
}

#search-results::-webkit-scrollbar-track {
    background: #f7fafc;
}

#search-results::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#search-results::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ============================================
   Accessibility
   ============================================ */

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ============================================
   Carousel
   ============================================ */

/* Carousel arrow styling */
.carousel-arrow {
    transition: opacity 0.2s, transform 0.2s;
}

.carousel-arrow:hover {
    transform: scale(1.1);
}

.carousel-arrow:active {
    transform: scale(0.95);
}

/* Mobile carousel improvements */
@media (max-width: 767px) {
    /* Hide carousel navigation arrows on mobile */
    .carousel-arrow {
        display: none;
    }
    
    /* Smooth touch scrolling for carousels */
    .carousel-scroll {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Add padding to carousel for better touch targets */
    .carousel-scroll > * {
        scroll-snap-align: start;
    }
}

/* ============================================
   Background Images
   ============================================ */

/* Overall background styling */
#overall-background {
    background-attachment: fixed;
}

#overall-background img {
    object-fit: cover;
    object-position: left top;
}

#page-background {
    overflow: hidden;
}

#page-background img {
    height: 100%;
    width: auto;
    min-width: 100%;
    object-fit: cover;
    object-position: left top;
}

/* Semi-transparent overlays for header and search sidebar */
header, #search-sidebar {
    background: rgba(255, 255, 255, 0.8);
}

/* Ensure content is readable over background */
header *, #search-sidebar * {
    position: relative;
    z-index: 1;
}

