.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px; /* Fixed height to prevent layout shift */
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-brand {
    font-family: 'Pacifico', 'Comic Sans MS', cursive;
    font-size: 28px;
    font-weight: 400;
    color: #333;
    text-decoration: none;
    line-height: 1.2;
    display: inline-block;
    min-height: 34px;
    opacity: 0; /* Hide until font loads */
    transition: opacity 0.2s ease-in;
}

/* Show brand when fonts are loaded */
.fonts-loaded .nav-brand {
    opacity: 1;
}

.nav-toggle {
    display: none; /* Hidden by default */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 24px;
    height: 3px; /* Slightly thicker */
    background-color: #333;
    position: relative;
    border-radius: 2px; /* Rounded edges */
    transition: background-color 0.3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px; /* Slightly thicker */
    background-color: #333;
    border-radius: 2px; /* Rounded edges */
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Smoother animation */
}

.hamburger::before {
    top: -8px;
}

.hamburger::after {
    bottom: -8px;
}

.nav-link {
    position: relative; /* Needed for the pseudo-element */
    padding: 12px 18px; /* Fine-tune padding */
    text-decoration: none;
    color: #555;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: color 0.3s ease;
    background-color: transparent; /* Ensure no background by default */
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background-color: #0066ff;
    transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #0066ff;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    .main-nav {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: #fff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
    }

    .main-nav.is-active {
        max-height: 500px; /* Adjust as needed */
    }

    .nav-link {
        padding: 15px 20px;
        text-align: center;
        border-bottom: 1px solid #e0e0e0;
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .nav-link::after {
        display: none; /* Hide the underline on mobile */
    }

    .nav-toggle.is-active .hamburger {
        background-color: transparent;
    }

    .nav-toggle.is-active .hamburger::before {
        transform: rotate(45deg) translate(5px, 6px);
    }

    .nav-toggle.is-active .hamburger::after {
        transform: rotate(-45deg) translate(5px, -6px);
    }
}

body {
    padding-top: 48px; /* Match fixed header height */
}
