body {
    margin: 0;
    font-family: 'Space Mono', sans-serif;
    background-color: #1e1e1e;
    color: #f1f1f1;
    display: flex; /* Use flexbox for layout */
    flex-direction: column; /* Stack elements vertically */
    min-height: 100vh; /* Ensure body takes at least full viewport height */
}

html {
    scroll-behavior: smooth; /* Smooth scrolling */
}

.topbar {
    background-color: #0e435d;
    color: #fff;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 1rem;
    position: relative; /* Establish stacking context */
    z-index: 20;         /* Topmost: Higher z-index for topbar */
}

.logo-container {
    position: absolute;
    left: 1rem;
    display: flex;
    align-items: center;
}

.logo {
    height: 70px;
}

.head {
    font-size: 1.8rem; /* Slightly larger */
    font-weight: 700; /* Bold */
    margin: 0;
    font-family: 'Orbitron', sans-serif; /* Apply the space-themed font */
    letter-spacing: 1px; /* Add a bit of letter spacing for futuristic look */
    text-transform: uppercase; /* Optional: uppercase for more impact */
}

.navbar {
    background-color: #5b90a9;
    color: #fff;
    height: 80px; /* Or min-height if content could make it taller */
    max-height: 80px; /* Set max-height for animation */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem; /* Original padding */
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    overflow: visible; /* Allow dropdowns to overflow */
    position: relative; /* Ensure it can create a stacking context */
    z-index: 10;         /* Middle: Navbar (with dropdowns) above gallery, below topbar */

    /* Transitions for when switching TO DESKTOP (from mobile) */
    /* 1. Expand height & padding, 2. Then fade/slide in */
    transition: max-height 0.3s ease,
                padding-top 0.3s ease, /* Ensure padding animates with height */
                padding-bottom 0.3s ease,
                opacity 0.3s ease 0.3s,  /* Delay opacity animation */
                transform 0.3s ease 0.3s, /* Delay transform animation */
                visibility 0s linear; /* Becomes visible at the start of transitions */
}

.navlinks {
    display: flex;
    justify-content: space-evenly;;
    align-items: center;          /* Center items vertically */
    gap: 2rem;                    /* Space between each link */
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    position: relative;
}

.navlinks > li {
    position: relative;
    cursor: pointer;
    text-align: center;
    overflow: visible; /* Changed from hidden to visible to show dropdowns */
    height: 100%; /* Full height of navbar */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem; /* Add padding for better appearance */
}

/* Create the yellow fill effect from top to bottom */
.navlinks > li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background-color: #fcb449; /* Yellow color */
    color:#041737;
    transition: height 0.3s ease;
    z-index: 0; /* Behind the text */
}

/* Fill to full height on hover */
.navlinks > li:hover::before {
    height: 100%;
}

/* Ensure the text stays above the yellow fill */
.navlinks > li > span {
    position: relative;
    z-index: 1; /* Above the fill */
    transition: color 0.3s ease; /* Add transition for smooth color change */
    color: #fff; /* Default text color */
}

/* Change text color on hover */
.navlinks > li:hover > span {
    color: #041737; /* Change to blue when hovering */
}

/* Keep existing dropdown functionality */
.navlinks > li:hover .dropdown,
.dropdown:hover {
    display: block;
}

/* Remove the existing background color change on hover */
.navlinks > li:hover {
    background-color: transparent;
}

/* Dropdown container - basic styling */
.dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    opacity: 0;
    visibility: hidden;
    background-color: #0e435d;
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    z-index: 10;
    box-sizing: border-box;
    width: 20vw; /* Viewport-based width */
    min-width: 280px;
    max-width: 450px;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

/* Special positioning for the FIRST menu - bind to LEFT edge of screen */
.navlinks > li:first-child .dropdown {
    left: 0;
    transform: translateX(0) translateY(-10px);
}

.navlinks > li:first-child:hover .dropdown,
.navlinks > li:first-child .dropdown:hover {
    transform: translateX(0) translateY(0);
}

/* Special styling for LAST menu (Admin) - restore all special styling */
.navlinks > li:last-child .dropdown {
    left: auto;
    right: 0;
    transform: translateX(50) translateY(-10px);
    position: fixed;
    right: 0;
    /* top: 150px; */
    width: 20vw;
}

.navlinks > li:last-child:hover .dropdown,
.navlinks > li:last-child .dropdown:hover {
    transform: translateX(0) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Restore the connector for smooth animation */
.navlinks > li:last-child::after {
    content: '';
    position: fixed;
    top: 160px;
    right: 0;
    width: 30vw;
    height: 20px;
    background-color: transparent;
    z-index: 9;
    pointer-events: auto;
}

/* Animation for centered dropdowns */
.navlinks > li:not(:first-child):not(:last-child):hover .dropdown,
.navlinks > li:not(:first-child):not(:last-child) .dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Standard animation for all dropdowns */
.navlinks > li:hover .dropdown,
.dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Clean dropdown list item styling */
.dropdown li {
    width: 100%;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 1; /* Ensure proper stacking for hover effects */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Add horizontal line */
}

.dropdown li:last-child {
    border-bottom: none; /* Remove border from the last item */
}

/* Fix for hover highlight effect - use a single approach */
.dropdown li::before {
    content: '';
    position: absolute; /* Changed from fixed to absolute */
    top: 0;
    left: 0;
    width: 0; /* Start with zero width for hover effect */
    height: 100%; /* Full height of the list item */
    background-color: rgba(241, 196, 15, 0.2); /* Same yellow as mobile */
    pointer-events: none;
    z-index: -1; /* Behind the content */
    transition: width 0.3s ease; /* Add transition for smooth effect */
}

/* Ensure hover effect works on all items */
.dropdown li:hover::before {
    width: 100%;
}

/* Link styling with proper z-index and positioning */
.dropdown li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
    position: relative;
    z-index: 2; /* Above the ::before pseudoelement */
    white-space: normal;
    line-height: 1.3;
    width: 100%;
    box-sizing: border-box;
}

/* Items without links get padding for consistent alignment */
.dropdown li:not(:has(a)) {
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    position: relative;
    display: flex;
    align-items: center;
    z-index: 1;
}

/* Remove conflicting hover effects */
.dropdown li a::after {
    display: none; /* Remove underline animation that might conflict */
}

/* Ensure text color changes on hover for better visibility */
.dropdown li:hover,
.dropdown li:hover a {
    color: white; /* Brighten text on hover */
}

/* Icon styling - consistent positioning and z-index */
.dropdown li a.external-link::before,
.dropdown li a.directory-link::before,
.dropdown li a.dv-link::before, 
.dropdown li a.home-link::before {
    content: '';
    display: inline-block;
    min-width: 16px;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    position: relative;
    z-index: 3; /* Make sure icons stay visible */
}

/* Fix hover effects - ensure they work with all links */
.dropdown li:hover::before {
    width: 100%;
}

.dropdown li:hover a {
    color: white;
}

/* Icon images for items with links */
.dropdown li a.external-link::before {
    background-image: url('./icons/globe_icon.svg');
}

.dropdown li a.directory-link::before {
    background-image: url('./icons/directory.svg');
}

.dropdown li a.dv-link::before {
    background-image: url('./icons/astro-data-viewer.svg');
}

.dropdown li a.home-link::before {
    background-image: url('./icons/home.svg');
}

/* Icon images for items without links */
.dropdown li.dv-item::before,
.dropdown li.external-nolink::before,
.dropdown li.directory-nolink::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.dropdown li.dv-item::before {
    background-image: url('./icons/astro-data-viewer.svg');
}

.dropdown li.external-nolink::before {
    background-image: url('./icons/globe_icon.svg');
}

.dropdown li.directory-nolink::before {
    background-image: url('./icons/directory.svg');
}

/* Make the main content area (gallery in this case) grow to fill space */
.gallery {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin-bottom: 0; /* Remove bottom margin to align with footer */
    height: 70vh; /* Explicitly set the height to match the track */
    flex-grow: 1; /* Allow gallery to expand and push footer down */
    /* z-index will be auto/0, placing it behind navbar and topbar */
}

/* Ensure slides take up full space */
.gallery-slide {
    min-width: 100%;
    height: 100%; /* This will now be 100% of 70vh */
    position: relative;
    overflow: hidden;
    display: flex; /* Use flex to center image if needed */
    align-items: center;
    justify-content: center;
}

/* Change gallery slide images to fill the entire space */
.gallery-slide img {
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    object-fit: cover; /* Cover ensures the image fills the entire space */
    object-position: center; /* Center the image */
    display: block;
}

/* Keep gallery track full width and height */
.gallery-track {
    display: flex;
    transition: transform 0.5s ease;
    height: 100%; /* Track should take full height of container */
    width: 100%;
}

/* Position gallery dots at the bottom of the gallery container */
.gallery-nav {
    display: flex;
    justify-content: center;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 8px 0;
    background-color: transparent; /* Change to completely transparent */
}

/* Ensure gallery dots are still visible against any background */
.gallery-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7); /* Make dots more visible */
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 6px;
    border: none;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5); /* Add shadow for contrast */
}

.gallery-dot.active {
    background-color: #fcb449;
    transform: scale(1.2);
    box-shadow: 0 0 5px rgba(252, 180, 73, 0.8);
}

/* Footer fixes - ensure full width and proper attachment */
.footer {
    background-color: #0e435d;
    color: #fff;
    padding: 20px 0;
    margin: 0; /* No margin */
    width: 100%; /* Full width */
    text-align: center;
    font-family: 'Space Mono', sans-serif;
    border-top: 2px solid rgba(252, 180, 73, 0.3);
    flex-shrink: 0; /* Prevent footer from shrinking */
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-credit {
    margin-bottom: 15px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer-link {
    font-size: 1rem;
}

.footer-link a {
    color: #fcb449;
    text-decoration: none;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    position: relative;
}

.footer-link a::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: #fcb449;
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.footer-link a:hover {
    color: white;
    text-shadow: 0 0 8px rgba(252, 180, 73, 0.5);
}

.footer-link a:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Mobile Menu Styles - Add hover effects */
@media (max-width: 650px) {
    .footer {
        padding: 15px 0;
    }

    .footer-content {
        padding: 0 15px;
    }

    .footer-credit, .footer-link {
        font-size: 0.85rem;
    }

    /* Hide the desktop navbar and animate it out */
    .navbar {
        opacity: 0 !important;
        transform: translateY(-100%) !important; /* Slides up based on original 80px height */
        max-height: 0 !important; /* Collapse height */
        padding-top: 0 !important; /* Collapse padding */
        padding-bottom: 0 !important; /* Collapse padding */
        /* overflow: hidden; is inherited from base or can be re-stated */
        /* visibility will be set to hidden after animations by its transition delay */
        pointer-events: none !important;

        /* Transitions for when switching TO MOBILE (from desktop) */
        /* 1. Fade/slide out, 2. Then collapse height & padding, 3. Then set visibility:hidden */
        transition: opacity 0.3s ease,
                    transform 0.3s ease,
                    max-height 0.3s ease 0.3s, /* Delay max-height collapse */
                    padding-top 0.3s ease 0.3s,    /* Delay padding collapse */
                    padding-bottom 0.3s ease 0.3s, /* Delay padding collapse */
                    visibility 0s linear 0.6s; /* Hide after all other animations (0.3s + 0.3s) */
    }

    /* Style for hamburger lines */
    .hamburger-menu span {
        display: block !important;
        position: absolute !important;
        height: 3px !important;
        width: 100% !important;
        background-color: white !important;
        border-radius: 3px !important;
        transition: .25s ease-in-out !important;
        left: 0 !important;
        opacity: 1 !important;
    }

    /* Position hamburger lines */
    .hamburger-menu span:nth-child(1) { top: 0px !important; }
    .hamburger-menu span:nth-child(2) { top: 10px !important; }
    .hamburger-menu span:nth-child(3) { top: 20px !important; }

    /* Hamburger animation */
    .hamburger-menu.open span:nth-child(1) {
        top: 10px !important;
        transform: rotate(45deg) !important;
    }

    .hamburger-menu.open span:nth-child(2) {
        opacity: 0 !important;
        left: -60px !important;
    }

    .hamburger-menu.open span:nth-child(3) {
        top: 10px !important;
        transform: rotate(-45deg) !important;
    }

    /* Mobile menu container - its open/close is handled by JS and its own transitions */
    .mobile-menu {
        position: fixed;
        top: 80px; /* Position below the topbar */
        left: 0;
        width: 100%;
        height: calc(100vh - 80px); /* Full remaining height */
        background-color: #0e435d;
        z-index: 999; /* Ensure it's on top */
        overflow-y: auto;
        box-sizing: border-box;
        padding: 20px;

        /* Animation setup for its own open/close, not for viewport change */
        /* Starts hidden in mobile view until .open is added by JS */
        display: none;
        opacity: 0;
        transform: translateY(-20px); /* Initial state for its slide-in animation */
        transition: opacity 0.3s ease, transform 0.3s ease; /* For .open class changes */
    }

    /* Styles for when the menu is open (toggled by JS) */
    .mobile-menu.open {
        display: block; /* Make it part of the layout */
        opacity: 1;     /* Then fade in */
        transform: translateY(0); /* And slide into view */
    }

    /* Ensure no space between gallery and footer */
    .gallery {
        margin-bottom: 0;
    }

    /* Style for the dropdown arrow */
    .dropdown-arrow {
        display: inline-block;
        transition: transform 0.3s ease; /* Add transition for rotation */
        transform-origin: center; /* Ensure rotation happens around the center */
    }

    /* Rotate arrow when the parent span is active */
    .mobile-navlinks > li > span.active .dropdown-arrow {
        transform: rotate(90deg); /* Rotate down */
    }

    /* Style for icons in the mobile menu dropdown */
    .mobile-menu-icon {
        width: 16px;
        height: 16px;
        margin-right: 8px;
        flex-shrink: 0; /* Prevent icon from shrinking */
        vertical-align: middle; /* Align icon nicely with text */
        margin-left: 10px; /* Add some left margin */
    }

    /* Ensure dropdown items align correctly and have relative positioning */
    .mobile-dropdown li {
        display: flex;
        align-items: center;
        position: relative; /* Needed for ::before positioning */
        z-index: 1; /* Base stacking context */
    }

    /* Add the hover background fill effect */
    .mobile-dropdown li::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 0; /* Start with zero width */
        height: 100%;
        background-color: rgba(241, 196, 15, 0.2); /* Same yellow as desktop */
        z-index: -1; /* Behind the content */
        transition: width 0.3s ease;
    }

    /* Expand the background fill on hover */
    .mobile-dropdown li:hover::before {
        width: 100%;
    }

    /* Ensure text and icons stay above the hover effect */
    .mobile-dropdown li a,
    .mobile-dropdown li .mobile-menu-icon,
    .mobile-dropdown li > *:not(a):not(.mobile-menu-icon) { /* Target text nodes in non-link items */
        position: relative;
        z-index: 2;
    }

    /* Change text color on hover for links */
    .mobile-dropdown li:hover a {
        color: white; /* Brighten text on hover */
    }

    /* Change text color on hover for non-link items */
    .mobile-dropdown li:not(:has(a)):hover {
         color: white; /* Brighten text on hover */
    }
}