/**
 * Navigation — Newtype v2 HUD dropdown nav
 * Four categorical dropdowns (Cards / Decks / Collection / Hub) + Admin (hidden until auth).
 * CSS-hover reveal with JS .is-open fallback for touch devices.
 */

/* ── Header grid layout ── */
.header-content {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

.header-left {
    display: contents;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Main navigation ── */
.main-navigation {
    display: flex;
    align-items: stretch;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    align-items: stretch;
}

/* Each top-level nav item wraps trigger + dropdown */
.nav-menu li,
.dropdown {
    position: relative;
    display: flex;
    align-items: stretch;
}

/* Trigger button */
.nav-link,
.dropdown-toggle {
    font-family: var(--font-family-display);
    letter-spacing: 0.08em;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 14px 14px;
    position: relative;
    text-transform: uppercase;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}

/* Drop-arrow via pseudo */
.dropdown-toggle::after {
    content: '▾';
    font-size: 9px;
    opacity: 0.4;
    transition: opacity 0.15s, transform 0.15s;
}

/* Active / hover trigger state */
.dropdown:hover .dropdown-toggle,
.dropdown:focus-within .dropdown-toggle,
.dropdown.is-open .dropdown-toggle,
.dropdown.active .dropdown-toggle,
.nav-link:hover,
.nav-link.active {
    color: var(--neon);
    background: rgba(46, 255, 126, 0.03);
    transform: none; /* override any translateY from old styles */
}

.dropdown:hover .dropdown-toggle::after,
.dropdown:focus-within .dropdown-toggle::after,
.dropdown.is-open .dropdown-toggle::after,
.dropdown.active .dropdown-toggle::after {
    opacity: 1;
    transform: translateY(1px);
}

/* Neon underline bar on active trigger */
.dropdown:hover .dropdown-toggle::before,
.dropdown:focus-within .dropdown-toggle::before,
.dropdown.is-open .dropdown-toggle::before,
.dropdown.active .dropdown-toggle::before {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--neon);
    box-shadow: 0 0 6px var(--neon);
}

/* Coming soon / new badges */
.coming-soon-badge {
    display: inline-block;
    padding: 1px 5px;
    margin-left: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--amber);
    color: var(--bg-body);
    letter-spacing: 0.1em;
    font-family: var(--font-family-mono);
    vertical-align: middle;
    border-radius: 0;
}

.new-badge {
    display: inline-block;
    padding: 1px 5px;
    margin-left: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--neon);
    color: var(--bg-body);
    letter-spacing: 0.1em;
    font-family: var(--font-family-mono);
    vertical-align: middle;
    border-radius: 0;
}

/* ── Dropdown panel ── */
.dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    /* Bridge gap so hover doesn't drop when moving cursor to panel */
    padding-top: 6px;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 400px;
    z-index: 200;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s, visibility 0s 0.18s, transform 0.18s;
}

/* Last item (Hub / Admin) anchors right to avoid off-screen overflow */
.nav-menu li:nth-last-child(-n+2) .dropdown-menu,
.dropdown:last-child .dropdown-menu {
    left: auto;
    right: 0;
}

/* Reveal: CSS hover + JS .is-open + .active fallback */
.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu,
.dropdown.is-open .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.18s, visibility 0s, transform 0.18s;
}

/* Panel inner box */
.dropdown-menu-inner {
    position: relative;
    background: var(--bg-container);
    border: 1px solid var(--border-strong);
    clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
    padding: 6px 0 8px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

/* Corner accent marks */
.dropdown-menu-inner::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 16px;
    height: 16px;
    border-top: 2px solid var(--neon);
    border-left: 2px solid var(--neon);
    box-shadow: -1px -1px 0 var(--neon-glow);
}

.dropdown-menu-inner::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 14px;
    height: 14px;
    border-bottom: 2px solid var(--neon);
    border-right: 2px solid var(--neon);
}

/* Panel header row */
.dropdown-menu-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px 8px;
    font-family: var(--font-family-mono);
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.dropdown-menu-head .head-code {
    color: var(--neon);
    font-weight: 600;
}

/* ── Menu items ── */
.dropdown-menu li {
    position: relative;
    display: block;
}

.dropdown-menu a {
    position: relative;
    display: grid;
    grid-template-columns: 14px 1fr auto;
    gap: 12px;
    padding: 9px 18px 9px 22px;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.12s;
    /* Remove any border-radius from legacy styles */
    border-radius: 0;
}

/* Left neon bar on hover */
.dropdown-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 24px;
    background: var(--neon);
    box-shadow: 0 0 6px var(--neon);
    transition: width 0.12s;
}

.dropdown-menu a:hover {
    background: rgba(46, 255, 126, 0.03);
    border-radius: 0;
}

.dropdown-menu a:hover::before {
    width: 3px;
}

/* Icon glyph (◢ / ◇) */
.menu-icon {
    color: var(--text-tertiary);
    font-size: 10px;
    transition: color 0.12s;
    line-height: 1;
}

.dropdown-menu a:hover .menu-icon {
    color: var(--neon);
}

/* Label + descriptor block */
.menu-label-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.menu-label {
    font-family: var(--font-family-display);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    text-transform: uppercase;
    transition: color 0.12s;
    white-space: nowrap;
}

.dropdown-menu a:hover .menu-label {
    color: var(--neon);
}

.menu-descriptor {
    font-family: var(--font-family-mono);
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--text-tertiary);
    text-transform: none;
    font-weight: 400;
    white-space: nowrap;
}

/* Badge inside menu item */
.menu-item-badge {
    font-family: var(--font-family-mono);
    font-size: 8px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 2px 6px;
    color: var(--amber);
    border: 1px solid var(--amber);
    align-self: start;
    margin-top: 1px;
    flex: 0 0 auto;
    line-height: 1.4;
}

/* ── Mobile nav overlay (slide-in drawer) ── */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-navigation {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: var(--bg-container);
    border-left: 1px solid var(--border-strong);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-nav-overlay.active .mobile-navigation {
    transform: translateX(0);
}

.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 64px 0 20px;
}

.mobile-nav-link {
    display: block;
    padding: 14px 24px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s, color 0.15s;
}

.mobile-nav-link:hover {
    background: rgba(46, 255, 126, 0.05);
    color: var(--neon);
}

/* Mobile dropdown */
.mobile-dropdown {
    border-bottom: 1px solid var(--border-color);
}

.mobile-dropdown-toggle {
    width: 100%;
    padding: 14px 24px;
    background: none;
    border: none;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mobile-dropdown-toggle:hover {
    background: rgba(46, 255, 126, 0.05);
    color: var(--neon);
}

.mobile-dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(46, 255, 126, 0.02);
    border-top: 1px solid var(--border-color);
    display: none;
}

.mobile-dropdown.active .mobile-dropdown-menu {
    display: block;
}

.mobile-dropdown-menu a {
    display: block;
    padding: 11px 24px 11px 42px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-family: var(--font-family-display);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: background 0.15s, color 0.15s;
}

.mobile-dropdown-menu a:hover {
    background: rgba(46, 255, 126, 0.05);
    color: var(--neon);
}

.mobile-nav-close {
    position: absolute;
    top: 15px;
    right: 18px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    transition: color 0.15s;
}

.mobile-nav-close:hover {
    color: var(--neon);
}

/* ── Responsive breakpoints ── */
@media (max-width: 1024px) {
    .nav-link,
    .dropdown-toggle {
        font-size: 12px;
        padding: 14px 10px;
    }
}

@media (max-width: 768px) {
    .main-navigation {
        display: none;
    }

    .mobile-nav-overlay {
        display: block;
    }

    .mobile-navigation {
        width: 100%;
    }
}

/* ── Touch device fallback (no :hover) ── */
@media (hover: none) {
    .dropdown-menu {
        /* Rely purely on .is-open class toggled by JS */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-4px);
        transition: opacity 0.18s, visibility 0s 0.18s, transform 0.18s;
    }

    .dropdown.is-open .dropdown-menu,
    .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition: opacity 0.18s, visibility 0s, transform 0.18s;
    }
}

/* ── Focus states (accessibility) ── */
.nav-link:focus,
.dropdown-toggle:focus,
.mobile-nav-link:focus,
.mobile-dropdown-toggle:focus {
    outline: 2px solid var(--neon);
    outline-offset: -2px;
}

.dropdown-menu a:focus {
    outline: 2px solid var(--neon);
    outline-offset: -2px;
}
