/**
 * Navbar component - Dark Glass Automotive
 * Uses design tokens from assets/css/style.css (:root)
 */

.bd-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: rgba(15, 23, 42, 0.92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Racing accent line: red -> electric blue */
.bd-nav::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 18%, var(--tech-ev) 60%, transparent 100%);
    opacity: 0.9;
}

.bd-nav.is-scrolled {
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
}

.bd-nav__inner {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: padding 0.3s ease;
}

.bd-nav.is-scrolled .bd-nav__inner {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* ---------- Brand ---------- */
.bd-nav__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 44px;
    text-decoration: none;
}

.bd-nav__logo {
    height: 2.25rem;
    width: auto;
    transition: transform 0.3s ease;
}

.bd-nav__brand:hover .bd-nav__logo {
    transform: scale(1.06);
}

.bd-nav__brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.bd-nav__brand-name {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.925rem;
    letter-spacing: 0.03em;
    color: #fff;
    white-space: nowrap;
}

.bd-nav__brand-tag {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #38bdf8;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---------- Hamburger ---------- */
.bd-nav__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.bd-nav__toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bd-nav__bars {
    position: relative;
    width: 20px;
    height: 14px;
}

.bd-nav__bars span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.3s ease, opacity 0.2s ease, top 0.3s ease;
}

.bd-nav__bars span:nth-child(1) { top: 0; }
.bd-nav__bars span:nth-child(2) { top: 6px; }
.bd-nav__bars span:nth-child(3) { top: 12px; }

.bd-nav__toggle[aria-expanded='true'] .bd-nav__bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.bd-nav__toggle[aria-expanded='true'] .bd-nav__bars span:nth-child(2) { opacity: 0; }
.bd-nav__toggle[aria-expanded='true'] .bd-nav__bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* ---------- Menu (mobile first: slide-down panel) ---------- */
.bd-nav__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease, visibility 0.35s;
}

.bd-nav__menu.is-open {
    max-height: calc(100vh - 3.5rem);
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
}

.bd-nav__list {
    list-style: none;
    margin: 0;
    padding: 0.75rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bd-nav__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 48px;
    padding: 0.5rem 0.875rem;
    border: 0;
    border-radius: 0.75rem;
    background: transparent;
    color: #cbd5e1;
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.bd-nav__link i.bd-nav__icon {
    width: 1.25rem;
    text-align: center;
    color: #64748b;
    transition: color 0.2s ease;
}

.bd-nav__link:hover,
.bd-nav__link:focus-visible {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    outline: none;
}

.bd-nav__link:hover i.bd-nav__icon { color: #f87171; }

.bd-nav__link.is-active {
    background: rgba(220, 38, 38, 0.14);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.bd-nav__link.is-active i.bd-nav__icon { color: #f87171; }

.bd-nav__chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.bd-nav__item--dropdown.is-open .bd-nav__chevron { transform: rotate(180deg); }

/* Dropdown (mobile = accordion) */
.bd-nav__dropdown {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.bd-nav__item--dropdown.is-open .bd-nav__dropdown {
    max-height: 30rem;
    padding-top: 0.25rem;
}

.bd-nav__sublink {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 44px;
    padding: 0.5rem 0.875rem;
    border-radius: 0.625rem;
    color: #94a3b8;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.bd-nav__sublink:hover,
.bd-nav__sublink:focus-visible,
.bd-nav__sublink.is-active {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    outline: none;
}

/* Actions (CTA + login) */
.bd-nav__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.bd-nav__cta,
.bd-nav__login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.bd-nav__cta {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    box-shadow: 0 6px 18px -6px var(--accent-glow);
}

.bd-nav__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -6px rgba(220, 38, 38, 0.55);
}

.bd-nav__login {
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

.bd-nav__login:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* ---------- Desktop ---------- */
@media (min-width: 768px) {
    .bd-nav__inner { padding: 0.5rem 1.5rem; }
    .bd-nav__logo { height: 2.5rem; }
    .bd-nav__brand-name { font-size: 1.05rem; }

    .bd-nav__toggle { display: none; }

    .bd-nav__menu {
        position: static;
        display: flex;
        align-items: center;
        gap: 1rem;
        max-height: none;
        overflow: visible;
        opacity: 1;
        visibility: visible;
        background: transparent;
        border: 0;
    }

    .bd-nav__list {
        flex-direction: row;
        align-items: center;
        gap: 0.25rem;
        padding: 0;
    }

    .bd-nav__link {
        position: relative;
        width: auto;
        min-height: 44px;
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }

    .bd-nav__link i.bd-nav__icon { display: none; }

    /* Animated underline */
    .bd-nav__link::after {
        content: '';
        position: absolute;
        left: 0.875rem;
        right: 0.875rem;
        bottom: 0.3rem;
        height: 2px;
        border-radius: 2px;
        background: var(--accent);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.3s ease;
    }

    .bd-nav__link:hover::after,
    .bd-nav__link:focus-visible::after,
    .bd-nav__link.is-active::after { transform: scaleX(1); }

    .bd-nav__link:hover,
    .bd-nav__link.is-active {
        background: transparent;
        box-shadow: none;
    }

    .bd-nav__item--dropdown { position: relative; }
    .bd-nav__chevron { margin-left: 0.25rem; }

    /* Mega dropdown */
    .bd-nav__dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 17rem;
        max-height: none;
        padding: 0.5rem;
        margin-top: 0.5rem;
        background: rgba(15, 23, 42, 0.98);
        border: 1px solid rgba(148, 163, 184, 0.2);
        border-radius: 1rem;
        box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
        opacity: 0;
        visibility: hidden;
        transform: translateY(8px);
        overflow: visible;
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    }

    /* Invisible bridge so hover is not lost between trigger and panel */
    .bd-nav__dropdown::before {
        content: '';
        position: absolute;
        top: -0.6rem;
        left: 0;
        right: 0;
        height: 0.6rem;
    }

    .bd-nav__item--dropdown:hover .bd-nav__dropdown,
    .bd-nav__item--dropdown:focus-within .bd-nav__dropdown,
    .bd-nav__item--dropdown.is-open .bd-nav__dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        max-height: none;
        padding-top: 0.5rem;
    }

    .bd-nav__item--dropdown:hover .bd-nav__chevron,
    .bd-nav__item--dropdown:focus-within .bd-nav__chevron { transform: rotate(180deg); }

    .bd-nav__actions {
        flex-direction: row;
        align-items: center;
        margin: 0 0 0 0.5rem;
        padding: 0;
        border: 0;
    }
}
