/* ==========================================================================
   NAVBAR — Premium Floating Glassmorphism Navigation
   Unique, warm, backend-engineer aesthetic. Not template-like.
   Features: glass blur, height shrink, golden progress bar,
   center-expanding underline, animated active dot, status indicator
   ========================================================================== */

/* ---- Scroll Progress Bar ---- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, var(--wheat), var(--amber));
    z-index: 10000;
    pointer-events: none;
    transition: width 0.08s linear;
}

/* ---- Navbar Base ---- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: transparent;
    transition:
        background 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.35s ease,
        border-color 0.35s ease;
    border-bottom: 1px solid transparent;
}

/* Scrolled State — Glass Effect */
.navbar.scrolled {
    background: rgba(250, 246, 238, 0.72);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom-color: rgba(228, 179, 99, 0.15);
    box-shadow:
        0 1px 0 rgba(228, 179, 99, 0.08),
        0 4px 24px rgba(62, 44, 35, 0.05);
}

/* Shrink on scroll */
.navbar .navbar-inner {
    height: 76px;
    transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.navbar.scrolled .navbar-inner {
    height: 64px;
}

/* ---- Inner Container ---- */
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ---- Left: Brand ---- */
.nav-brand {
    flex-shrink: 0;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    position: relative;
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    transition: color 0.3s ease;
    position: relative;
}

.logo-accent {
    color: var(--wheat);
    font-weight: 700;
}

/* Subtle underline on logo hover */
.logo-text::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: linear-gradient(90deg, var(--wheat), transparent);
    border-radius: 1px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-logo:hover .logo-text::after {
    width: 100%;
}

.nav-logo:hover .logo-text {
    color: var(--text-primary);
}

/* Status Indicator — "System Online" */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    margin-left: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    display: block;
    position: relative;
    box-shadow: 0 0 0 0 rgba(107, 143, 94, 0.4);
    animation: statusPulse 2.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(107, 143, 94, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(107, 143, 94, 0);
    }
}

/* ---- Center: Navigation Links ---- */
.nav-center {
    display: flex;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    position: relative;
    padding: 6px 0;
    transition: color 0.3s ease;
    outline-offset: 4px;
}

/* Animated underline — expands from center */
.nav-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--wheat);
    border-radius: 1px;
    transform: translateX(-50%);
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link:hover::after {
    width: 60%;
}

/* Focus visible for keyboard nav */
.nav-link:focus-visible {
    outline: 2px solid var(--wheat);
    outline-offset: 4px;
    border-radius: 2px;
}

/* ---- Active Link — Animated Dot ---- */
.nav-link.active {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-link.active::after {
    width: 5px;
    height: 5px;
    bottom: -8px;
    border-radius: 50%;
    background: var(--wheat);
    box-shadow: 0 0 6px rgba(228, 179, 99, 0.4);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* On hover of active link, expand underline instead of showing dot */
.nav-link.active:hover::after {
    width: 60%;
    height: 2px;
    bottom: -1px;
    border-radius: 1px;
    box-shadow: none;
}

/* ---- Right: CTA + Hamburger ---- */
.nav-end {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* "Let's Build" Button */
.btn-build {
    position: relative;
    padding: 0.55rem 1.5rem;
    border-radius: 40px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--wheat) 0%, var(--amber) 100%);
    border: none;
    font-family: var(--font-body);
    cursor: pointer;
    letter-spacing: 0.01em;
    overflow: hidden;
    transition:
        transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.25s ease;
    box-shadow: 0 2px 12px rgba(228, 179, 99, 0.25);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-build:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(228, 179, 99, 0.4);
}

.btn-build:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 2px 8px rgba(228, 179, 99, 0.3);
}

.btn-build:focus-visible {
    outline: 2px solid var(--wheat);
    outline-offset: 3px;
}

/* Subtle API pulse icon inside button */
.btn-build-pulse {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translateY(-50%);
    animation: apiPulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes apiPulse {
    0%, 100% { opacity: 0.3; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.8; transform: translateY(-50%) scale(1.6); }
}

/* ---- Hamburger ---- */
.hamburger {
    display: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    z-index: 1001;
    padding: 10px;
    background: none;
    border: none;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.hamburger:hover {
    background: rgba(228, 179, 99, 0.08);
}

.hamburger:focus-visible {
    outline: 2px solid var(--wheat);
    outline-offset: 2px;
}

.hamburger .bar {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    display: block;
    transition:
        transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.2s ease,
        background 0.2s ease;
    transform-origin: center;
}

/* X animation */
.hamburger.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
    background: var(--wheat);
}

.hamburger.active .bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
    background: var(--wheat);
}

/* ---- Mobile Dropdown Panel ---- */
.mobile-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(250, 246, 238, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(228, 179, 99, 0.12);
    box-shadow: 0 8px 32px rgba(62, 44, 35, 0.08);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
        max-height 0.45s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s ease;
    display: none;
}

.mobile-panel.open {
    max-height: 480px;
    opacity: 1;
}

.mobile-nav {
    padding: 1rem 32px 2rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.mobile-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-link {
    display: flex;
    align-items: center;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
    min-height: 48px;
    /* Stagger animation — set via JS */
    opacity: 0;
    transform: translateY(-8px);
}

.mobile-panel.open .mobile-link {
    animation: mobileStagger 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.mobile-panel.open .mobile-links li:nth-child(1) .mobile-link { animation-delay: 0.04s; }
.mobile-panel.open .mobile-links li:nth-child(2) .mobile-link { animation-delay: 0.08s; }
.mobile-panel.open .mobile-links li:nth-child(3) .mobile-link { animation-delay: 0.12s; }
.mobile-panel.open .mobile-links li:nth-child(4) .mobile-link { animation-delay: 0.16s; }
.mobile-panel.open .mobile-links li:nth-child(5) .mobile-link { animation-delay: 0.20s; }

@keyframes mobileStagger {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-link:hover,
.mobile-link:focus-visible {
    background: rgba(228, 179, 99, 0.08);
    color: var(--text-primary);
}

.mobile-link:active {
    transform: scale(0.98);
}

.mobile-link:focus-visible {
    outline: 2px solid var(--wheat);
    outline-offset: -2px;
}

/* Mobile CTA */
.mobile-cta {
    display: block;
    margin-top: 0.8rem;
    padding: 0.85rem 1.6rem;
    border-radius: 40px;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, var(--wheat) 0%, var(--amber) 100%);
    box-shadow: 0 2px 12px rgba(228, 179, 99, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-8px);
}

.mobile-panel.open .mobile-cta {
    animation: mobileStagger 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.26s;
}

.mobile-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(228, 179, 99, 0.4);
}

.mobile-cta:focus-visible {
    outline: 2px solid var(--wheat);
    outline-offset: 3px;
}

/* ---- Responsive ---- */

/* Tablet */
@media (max-width: 968px) {
    .nav-links {
        gap: 1.4rem;
    }

    .nav-link {
        font-size: 0.82rem;
    }

    .navbar-inner {
        padding: 0 24px;
    }
}

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

    .nav-center {
        display: none;
    }

    .btn-build {
        display: none;
    }

    .mobile-panel {
        display: block;
    }

    .navbar-inner {
        padding: 0 20px;
    }

    .navbar .navbar-inner {
        height: 64px;
    }

    .navbar.scrolled .navbar-inner {
        height: 58px;
    }
}

@media (max-width: 480px) {
    .navbar-inner {
        padding: 0 16px;
    }

    .mobile-nav {
        padding: 0.8rem 16px 1.5rem;
    }

    .logo-text {
        font-size: 1.15rem;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .navbar,
    .navbar .navbar-inner,
    .nav-link::after,
    .logo-text::after,
    .hamburger .bar,
    .mobile-panel,
    .mobile-link,
    .mobile-cta {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .status-dot {
        animation: none;
        box-shadow: 0 0 0 2px rgba(107, 143, 94, 0.2);
    }

    .btn-build-pulse {
        animation: none;
        opacity: 0;
    }

    .mobile-link,
    .mobile-cta {
        opacity: 1;
        transform: none;
    }

    .mobile-panel.open .mobile-link,
    .mobile-panel.open .mobile-cta {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
