nav {
    width: 100%;
    background-color: var(--color-bg);
    color: var(--color-main);
    border-radius: 15px;
    padding-left: 15px;
    padding-right: 15px;
    max-width: 1280px;
    margin: auto;
    margin-top: 20px;
}

nav > ul {
    list-style-type: none;
    user-select: none;
    margin: 0 auto;
    padding: 0;
    max-width: 1280px;
    display: flex;
    justify-content: space-between; /* Distribute space between items */
    align-items: center; /* Center items vertically */
}

nav > ul > li {
    padding: 0 15px;
    height: 64px;
    transition: background-color 0.35s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative; /* Position relative for submenu positioning */
}

nav ul li a {
    color: var(--color-main);
    text-decoration: none;
}

nav ul li a:hover {
    text-decoration: none;
}

/* Stretch each link over its whole cell, not just the text */
nav li {
    position: relative;
}

nav li > a::after {
    content: "";
    position: absolute;
    inset: 0;
}

nav ul li:hover {
    background-color: var(--color-main-dark);
}

nav > ul > li:last-of-type {
    margin-left: auto; /* Push the last item to the right */
}

nav > ul ul {
    display: none;
    position: absolute;
    top: 64px; /* the height of the main nav */
    width: 150px;
    list-style-type: none;
    padding: 0;
    margin-left: -15px;
    z-index: 1000; /* Ensure the submenu is above other elements */
    background-color: var(--color-bg);
}

/* Display Dropdowns on Hover and Focus */
nav ul li:hover > ul,
nav ul li:focus-within > ul {
    display: block;
}

/* First Tier Dropdown */
nav ul ul li {
    width: auto;
    height: 40px;
    padding: 8px 16px;
    float: none;
    display: list-item;
    position: relative;
    background-color: var(--color-bg);
}

/* Second, Third and more Tiers */
nav ul ul ul {
    display: none;
    position: absolute;
    top: 0;
    left: 110%;
    width: 250px;
}

/* Display nested dropdowns on hover and focus */
nav ul ul li:hover > ul,
nav ul ul li:focus-within > ul {
    display: block;
}

footer ul {
    list-style-type: none;
    padding: 0;
    font-size: 14px;
}

.footer-menu {
    margin-left: 20px;
    margin-right: 20px;
}

#menuToggle {
    display: block;
    position: relative;
    top: 30px;
    z-index: 1;
    padding-left: 30px;
    -webkit-user-select: none;
    user-select: none;
}

#menuLogo {
    display: block;
    position: absolute;
    right: 30px;
    width: 72px;
    height: 72px;
    user-select: none;
    z-index: 1;
    background-image: url('/img/logo.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

#menuToggle input {
    display: block;
    width: 40px;
    height: 32px;
    position: absolute;
    top: -10px;
    left: 15px;
    cursor: pointer;
    opacity: 0; /* hide this */
    z-index: 2; /* and place it over the hamburger */
    -webkit-touch-callout: none;
}

/* Just a quick hamburger */
#menuToggle span {
    display: block;
    width: 33px;
    height: 4px;
    margin-bottom: 5px;
    position: relative;
    background: #cdcdcd;
    border-radius: 3px;
    z-index: 1;
    transform-origin: 4px 0px;
    transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0),
    background 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0),
    opacity 0.55s ease;
}

#menuToggle span:first-child {
    transform-origin: 0% 0%;
}

#menuToggle span:nth-last-child(2) {
    transform-origin: 0% 100%;
}

/* Transform all the slices of hamburger into a crossmark. */
#menuToggle input:checked ~ span {
    opacity: 1;
    transform: rotate(45deg) translate(-2px, -1px);
    background: var(--color-main);
}

/* But let's hide the middle one. */
#menuToggle input:checked ~ span:nth-last-child(3) {
    opacity: 0;
    transform: rotate(0deg) scale(0.2, 0.2);
}

/* Oh yeah and the last one should go the other direction */
#menuToggle input:checked ~ span:nth-last-child(2) {
    transform: rotate(-45deg) translate(0, -1px);
}

/* Make this absolute positioned at the top left of the screen */
#menu {
    position: absolute;
    width: 100vw;
    margin: -100px 0 0 -45px;
    padding-top: 100px;
    padding-left: 0;
    background: var(--color-bg);
    list-style-type: none;
    -webkit-font-smoothing: antialiased; /* to stop flickering of text in safari */
    transform-origin: 0% 0%;
    transform: translate(-100%, 0);
    border-bottom: 8px solid var(--color-main);
    transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0);
}

#menu li {
    padding: 10px 30px;
    font-size: 22px;
}

/* And let's slide it in from the left */
#menuToggle input:checked ~ ul {
    transform: none;
}

.menu-item {
    position: relative;
}

.onclick-menu-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: visibility 0s, opacity 0.5s ease, max-height 0.5s ease-out;
    padding-left: 10px;
    background: var(--color-bg);
    z-index: 3;
}

.menu-item:hover .onclick-menu-content,
.menu-item:focus-within .onclick-menu-content {
    max-height: 500px; /* Adjust based on the content height */
    opacity: 1;
    visibility: visible;
    transition: visibility 0s, opacity 0.5s ease, max-height 0.5s ease-in;
}

.onclick-menu-content li {
    list-style-type: none;
    padding: 15px 10px;
    height: auto;
}

@media only screen and (max-width: 920px) {
    .footer-menu {
        display: none;
    }
    nav {
        min-height: 72px;
    }
}
