/* header.css */

header {
    background-color: var(--clr-header-background);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    -webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-left {
    display: flex;
    align-items: center;
    /* Removed font styles from here, they will be applied to .home-link */
}

.header-left .home-link { /* New rule for the clickable logo/text */
    display: flex; /* Make the link a flex container to align image and text */
    align-items: center;
    text-decoration: none; /* Remove underline from the link */
    color: var(--clr-main-text); /* Apply text color */
    font-size: 1.8rem; /* Apply font size */
    font-weight: 700; /* Apply font weight */
    transition: color 0.3s ease; /* Optional: Add transition for hover effect */
}

.header-left .home-link:hover {
    color: var(--clr-primary-accent); /* Optional: Change color on hover */
}


.header-left img {
    height: 40px;
    margin-right: 10px;
    border-radius: 0.25rem;
}

header nav {
    display: flex;
    gap: 1.2rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

header nav a {
    color: var(--clr-main-text);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.8rem;
    border-radius: 0.4rem;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

header nav a:hover {
    background-color: var(--clr-highlight-background);
    color: var(--clr-muted-greys);
    transform: translateY(-2px);
}

header nav a:active {
    background-color: var(--clr-secondary-accent);
    color: var(--clr-background);
    transform: translateY(0);
}

header nav span {
    color: var(--clr-main-text);
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

header nav span a {
    color: var(--clr-primary-accent);
    padding: 0;
    background: none;
    text-decoration: underline;
}

header nav span a:hover {
    color: var(--clr-secondary-accent);
    background: none;
    text-decoration: none;
    transform: none;
}

header nav form button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: var(--clr-primary-accent);
    text-decoration: underline;
    box-shadow: none;
}

header nav form button:hover {
    color: var(--clr-secondary-accent);
    text-decoration: none;
    transform: none;
    box-shadow: none;
}

header hr {
    display: none;
}

/* Hamburger menu styles */
.hamburger-menu {
    display: none; /* Hidden by default, shown on small screens */
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001; /* Ensure it's above the nav when collapsed */
}

.hamburger-menu .bar {
    width: 100%;
    height: 3px;
    background-color: var(--clr-main-text);
    border-radius: 5px;
    transition: all 0.3s ease-in-out;
}

/* Styles for when the menu is active/open */
.nav-links.active {
    display: flex; /* Show the menu */
    flex-direction: column;
    width: auto; /* Allow width to be determined by content */
    min-width: 180px; /* Optional: Set a minimum width for readability */
    max-width: calc(100% - 20px); /* Optional: Prevent it from exceeding viewport width, with some margin */
    position: absolute;
    top: 100%; /* Position right below the header */
    right: 0; /* Align to the right edge of the header */
    background-color: var(--clr-background) !important; /* Match header background */
    border: 1px solid var(--clr-border); /* Add a border for definition */
    border-radius: 0.5rem; /* Add some rounded corners */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0; /* Add top/bottom padding for the dropdown itself */
    animation: slideIn 0.3s forwards;
    height: auto; /* Allow content to dictate height */
    overflow-y: auto; /* Scroll if content overflows */
    z-index: 999;
}

/* Animation for sliding in */
@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Hamburger icon animation when active */
.hamburger-menu.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger-menu.active .bar:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}


@media (max-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0.8rem 1rem;
        position: relative; /* Crucial for absolute positioning of nav */
    }

    .header-left .home-link { /* Target the link directly in media query */
        font-size: 1.5rem; /* Adjust font size for smaller screens */
    }
    .header-left .home-link img { /* Target the image directly in media query */
        height: 35px; /* Adjust image size for smaller screens */
    }

    .hamburger-menu {
        display: flex;
    }

    header nav.nav-links {
        display: none; /* Hide navigation by default */
        position: absolute;
        top: 100%; /* Position right below the header */
        right: 0; /* Align to the right edge of the header */
        width: auto; /* Allow width to be determined by content */
        min-width: 180px; /* Optional: Set a minimum width for readability */
        max-width: calc(100% - 20px); /* Optional: Prevent it from exceeding viewport width, with some margin */
        background-color: var(--clr-background);
        border: 1px solid var(--clr-border); /* Add a border for definition */
        border-radius: 0.5rem; /* Add some rounded corners */
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        flex-direction: column;
        align-items: flex-start; /* Align items to the left within the dropdown */
        gap: 0; /* Remove gap between items to let padding handle spacing */
        padding: 0.5rem 0; /* Add top/bottom padding for the dropdown itself */
        z-index: 999;
    }

    header nav.nav-links a,
    header nav.nav-links span {
        width: 100%; /* Make links take full width of the dropdown */
        text-align: left; /* Align text to the left */
        padding: 0.7rem 1.2rem; /* Add horizontal padding for dropdown items */
        border-bottom: 1px solid var(--clr-border); /* Separator for menu items */
    }

    header nav.nav-links a:last-child,
    header nav.nav-links span:last-child {
        border-bottom: none;
    }

    header nav.nav-links span {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    header nav.nav-links span form button {
        padding-left: 1.2rem; /* Match padding of other menu items */
        text-align: left;
        width: 100%;
    }

    header nav.nav-links hr {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-left .home-link {
        font-size: 1.3rem;
    }
    .header-left .home-link img {
        height: 35px;
    }
}