/* =============================================================
   Navigation — henrikkragh.dk
   Requires CSS variables defined in style.css (:root).
   ============================================================= */

.main-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(250, 250, 250, 0.95);
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

/* Logo */
.logo {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    border: none;
}

.logo:hover {
    color: var(--accent);
    border: none;
}

/* Desktop nav links */
.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links > li {
    position: relative;
}

.nav-links a,
.nav-links .dropdown-label {
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text);
    letter-spacing: 0.3px;
    border: none;
    position: relative;
    cursor: pointer;
}

.nav-links .dropdown-label {
    cursor: default;
}

/* Underline animation on top-level items */
.nav-links > li > a::after,
.nav-links > li > .dropdown-label::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.nav-links > li > a:hover::after,
.nav-links > li > a.active::after,
.nav-links > li:hover > .dropdown-label::after {
    width: 100%;
}

/* Dropdown arrow — overrides ::after on top-level triggers */
.has-dropdown > a::after,
.has-dropdown > .dropdown-label::after {
    content: ' ▾' !important;
    font-size: 0.7rem;
    opacity: 0.55;
    height: auto !important;
    width: auto !important;
    background: none !important;
    position: static !important;
    display: inline !important;
    bottom: auto !important;
    left: auto !important;
    transition: none !important;
}

/* Dropdown container — invisible bridge between trigger and panel.
   No gap means Safari won't lose hover state when moving mouse down. */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    padding-top: 10px;
    min-width: 210px;
    z-index: 100;
}

/* Visible panel inside the bridge */
.dropdown > ul {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
}

.dropdown > ul li {
    display: block;
}

.dropdown > ul a {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
}

.dropdown > ul a:hover {
    background: var(--bg);
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

/* Suppress ::after underline animation (replaced by border-bottom above) */
.dropdown > ul a::after {
    display: none !important;
}

/* Show on hover/focus */
.has-dropdown:hover > .dropdown,
.has-dropdown:focus-within > .dropdown {
    display: block;
}

/* Burger button — hidden on desktop */
.mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-toggle span {
    width: 24px;
    height: 2px;
    background: var(--primary);
    transition: all 0.3s ease;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }

    .mobile-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .mobile-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    .nav-links {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        z-index: 999;
        background: var(--bg-secondary);
        flex-direction: column;
        align-items: flex-start;
        padding: var(--spacing-md);
        gap: 0;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links > li {
        width: 100%;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border);
    }

    .nav-links > li:last-child {
        border-bottom: none;
    }

    /* Disable hover/focus-within on mobile */
    .has-dropdown:hover > .dropdown,
    .has-dropdown:focus-within > .dropdown {
        display: none;
    }

    /* JS toggles .open class */
    .has-dropdown.open > .dropdown {
        display: block;
    }

    /* Mobile dropdown panel — inline, no shadow */
    .dropdown {
        position: static;
        padding-top: 0.25rem;
        min-width: unset;
    }

    .dropdown > ul {
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: var(--bg);
        padding: 0.25rem 0;
    }

    .dropdown > ul a {
        padding: 0.4rem 0.5rem;
        margin-left: 1rem;
    }
}
