/* Navigation styles */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--nav-bg, rgba(10, 10, 10, 0.8));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2.5rem;
    height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all var(--transition-normal);
}

.nav-brand:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.code-tag {
    color: #4B8BFF;
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    font-weight: 400;
    opacity: 0.95;
}

.nav-brand .name {
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 400;
    font-family: 'Fira Code', monospace;
    letter-spacing: -0.5px;
    opacity: 0.95;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 2.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    transition: all var(--transition-normal);
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Icon-only nav links */
.nav-link.icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-link.icon-only i {
    font-size: 1.1rem;
    color: var(--text);
}

.nav-link.icon-only span {
    display: none;
}

[data-theme="light"] .nav-link.icon-only {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
}

[data-theme="dark"] .nav-link.icon-only {
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--border);
}

.nav-link.icon-only:hover {
    transform: translateY(-2px);
    border-color: rgba(143, 252, 255, 0.4);
    box-shadow: 0 4px 12px rgba(143, 252, 255, 0.2);
    background: rgba(143, 252, 255, 0.1);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.search-btn:hover {
    border-color: var(--primary);
    color: var(--text);
    transform: translateY(-1px);
}

.search-btn .shortcut {
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.theme-toggle {
    display: none;
}

.theme-icon {
    width: 1.25rem;
    height: 1.25rem;
    transition: all var(--transition-normal);
    filter: invert(var(--icon-invert));
}

[data-theme="dark"] .theme-icon {
    filter: invert(1);
}

/* Icon transition between sun/moon */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

/* Floating toggle is positioned by css/style.css (fixed bottom-right).
   Do not override its positioning here; only keep overflow hidden for icon swap. */
.floating-theme-toggle {
    overflow: hidden;
}

.theme-toggle .theme-icon,
.floating-theme-toggle .theme-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 260ms ease, transform 260ms ease;
    pointer-events: none;
    display: block !important; /* ensure both are present for animation */
}

/* Light theme: show sun, hide moon */
[data-theme="light"] .theme-toggle .theme-icon.light,
[data-theme="light"] .floating-theme-toggle .theme-icon.light {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

[data-theme="light"] .theme-toggle .theme-icon.dark,
[data-theme="light"] .floating-theme-toggle .theme-icon.dark {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) rotate(-90deg);
}

/* Dark theme: show moon, hide sun */
[data-theme="dark"] .theme-toggle .theme-icon.dark,
[data-theme="dark"] .floating-theme-toggle .theme-icon.dark {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

[data-theme="dark"] .theme-toggle .theme-icon.light,
[data-theme="dark"] .floating-theme-toggle .theme-icon.light {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) rotate(90deg);
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

.mobile-menu-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    margin: 4px auto;
    transition: all 0.3s ease-in-out;
    opacity: 1;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Responsive design */
@media (max-width: 795px) {
    nav {
        padding: 0 1rem;
    }

    .nav-brand .name {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: 75%;
        max-width: 300px;
        height: 100vh;
        background: var(--background);
        margin: 0;
        padding: 5rem 1.5rem 2rem;
        flex-direction: column;
        gap: 1rem;
        transform: translateX(100%);
                transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
        will-change: transform;
        z-index: 1000;
        border-left: 1px solid var(--border);
        box-shadow: -20px 0 40px rgba(0, 0, 0, 0.28);
    }

    .nav-links .nav-link {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
        justify-content: flex-start;
        gap: 1rem;
        border: 1px solid transparent;
    }

    .nav-links .nav-link:hover {
        background: rgba(143, 252, 255, 0.05);
        border-color: rgba(143, 252, 255, 0.2);
        transform: translateX(4px);
    }

    .nav-links .nav-link.active {
        background: rgba(143, 252, 255, 0.1);
        border-color: rgba(143, 252, 255, 0.3);
    }

    /* Special styling for chat and photography links in mobile */
    .nav-links .nav-link.icon-only {
        margin-top: 0.75rem;
        padding: 0.75rem 1rem;
        width: 100%;
        height: auto;
        justify-content: flex-start;
        background: rgba(143, 252, 255, 0.03);
        border: 1px solid rgba(143, 252, 255, 0.2);
        font-size: 0.95rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .nav-links .nav-link.icon-only:hover {
        background: rgba(143, 252, 255, 0.08);
        border-color: rgba(143, 252, 255, 0.4);
        transform: translateX(4px);
        box-shadow: 0 4px 12px rgba(143, 252, 255, 0.2);
    }

    .nav-links .nav-link.icon-only span {
        display: inline;
        font-size: 0.9rem;
        opacity: 0.9;
    }

    .nav-links .nav-link.icon-only i {
        font-size: 1.1rem;
        color: #8ffcff;
    }

    .nav-links .nav-link i {
        width: 20px;
        text-align: center;
    }
    .nav-links.active { transform: translateX(0); }

    .nav-controls {
        margin-left: auto;
        margin-right: 1rem;
    }

    .search-btn {
        padding: 0.5rem;
        width: 2.5rem;
        height: 2.5rem;
        justify-content: center;
    }

    .search-btn .shortcut {
        display: none;
    }

    /* Improve touch targets */
    .nav-link,
    .search-btn,
    .theme-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-controls {
        margin-left: auto;
        margin-right: 1rem;
    }

    .mobile-menu-btn {
        order: 3;
    }

    /* Overlay when mobile menu is open */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-menu-overlay.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
}

/* Desktop styles */
@media (min-width: 796px) {
    .nav-links a[href="/"] {
        display: none;
    }

    .nav-link {
        padding: 0.625rem 1.25rem;
    }

    .nav-link.icon-only {
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .nav-link.icon-only span {
        display: none;
    }
}

@media (max-width: 1105px) and (min-width: 769px) {
    nav {
        padding: 0 1rem;
    }

    .nav-links {
        margin: 0 0.5rem;
    }

    .nav-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.95rem;
    }

    .nav-brand .name {
        font-size: 1.1rem;
    }
}

@media (max-width: 1000px) and (min-width: 769px) {
    .nav-link {
        padding: 0.5rem 0.5rem;
        font-size: 0.9rem;
    }

    .nav-links {
        margin: 0 0.5rem;
    }

    .search-btn {
        padding: 0.5rem 0.75rem;
    }

    .search-btn .shortcut {
        display: none;
    }
}

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}

/* Add smooth transition for theme changes */
@media (prefers-reduced-motion: no-preference) {
    * {
        transition-property: background-color, border-color, color, fill, stroke;
        transition-timing-function: ease-in-out;
        transition-duration: 0.2s;
    }
}

@media (min-width: 860px) {
    .theme-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 8px;
        background: var(--card-bg);
        border: 1px solid var(--border);
        cursor: pointer;
        margin-left: 0.5rem;
    }

    .floating-theme-toggle {
        display: none;
    }
}

/* Update active nav link styles for light mode */
[data-theme="light"] .nav-link {
    position: relative;
    color: var(--text-secondary);
}

/* Theme toggle animation */
@media (prefers-reduced-motion: no-preference) {
    @keyframes toggleSpin {
        from { transform: rotate(0deg) scale(0.96); }
        to   { transform: rotate(180deg) scale(1); }
    }

    .theme-toggle.spin,
    .floating-theme-toggle.spin {
        animation: toggleSpin 320ms ease;
    }
}

[data-theme="light"] .nav-link.active {
    color: var(--primary);
}

[data-theme="light"] .nav-link:hover {
    color: var(--primary);
    background: rgba(2, 132, 199, 0.08);
    border-radius: 8px;
}

[data-theme="light"] .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* Dark theme - make selectors more specific */
[data-theme="dark"] nav .nav-links .nav-link.active {
    color: #8ffcff !important;
    background: rgba(143, 252, 255, 0.1);
    box-shadow: 0 0 8px rgba(143, 252, 255, 0.5);
    position: relative;
}

/* Light theme - make selectors more specific */
[data-theme="light"] nav .nav-links .nav-link.active {
    color: var(--primary) !important;
}

/* Hover states - make selectors more specific */
[data-theme="dark"] nav .nav-links .nav-link.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(143, 252, 255, 0.7);
}

[data-theme="light"] nav .nav-links .nav-link.active:hover {
    transform: translateY(-2px);
}

/* Add back the underline for dark theme */
[data-theme="dark"] nav .nav-links .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #8ffcff;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(143, 252, 255, 0.5);
}

/* Add back the underline for light theme */
/* Indicator-driven highlight: adjust indicator for better visibility in light theme */
[data-theme="light"] .nav-active-indicator {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.22), rgba(var(--primary-rgb), 0.12));
    box-shadow:
      0 8px 24px rgba(var(--primary-rgb), 0.18),
      0 0 0 1px rgba(var(--primary-rgb), 0.50) inset,
      0 0 24px rgba(var(--primary-rgb), 0.25);
}

/* Ensure icons inside active link match primary in light theme */
[data-theme="light"] nav .nav-links .nav-link.active i {
    color: var(--primary);
}
/* ===== Navbar revamp: polish, indicator, a11y ===== */
/* Subtle depth for a more polished look */
nav {
    box-shadow: 0 4px 24px rgba(var(--primary-rgb), 0.06), 0 1px 0 rgba(0,0,0,0.04);
}

/* Gradient accent hairline at bottom for finesse */
nav::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
      rgba(var(--primary-rgb), 0) 0%,
      rgba(var(--primary-rgb), 0.45) 25%,
      rgba(var(--primary-rgb), 0.75) 50%,
      rgba(var(--primary-rgb), 0.45) 75%,
      rgba(var(--primary-rgb), 0) 100%);
    pointer-events: none;
}

@media (min-width: 796px) { .nav-links { position: relative; } }
.nav-link { position: relative; z-index: 1; }

/* Animated active-link indicator */
.nav-active-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateX(var(--nav-indicator-left, 0px)) translateY(-50%);
    width: var(--nav-indicator-width, 0px);
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.18), rgba(var(--primary-rgb), 0.10));
    box-shadow:
        0 10px 30px rgba(var(--primary-rgb), 0.12),
        0 0 0 1px rgba(var(--primary-rgb), 0.35) inset,
        0 0 24px rgba(var(--primary-rgb), 0.25);
    pointer-events: none;
    opacity: 0;
    transition: left 320ms cubic-bezier(0.22, 1, 0.36, 1),
                width 320ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 160ms ease-in-out;
}

.nav-links.indicator-visible .nav-active-indicator { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .nav-active-indicator { transition: none; }
}

/* Let the indicator be the active background; neutralize previous active bg/underline */
[data-theme="dark"] nav .nav-links .nav-link.active,
[data-theme="light"] nav .nav-links .nav-link.active {
    background: transparent !important;
    box-shadow: none !important;
}

[data-theme="dark"] nav .nav-links .nav-link.active::after,
[data-theme="light"] nav .nav-links .nav-link.active::after {
    display: none !important;
}

/* Stronger focus ring for keyboard users */
.nav-link:focus-visible,
.search-btn:focus-visible,
.theme-toggle:focus-visible,
.mobile-menu-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.6), 0 0 0 4px rgba(var(--primary-rgb), 0.65);
}

/* Hide desktop indicator in mobile drawer */
@media (max-width: 795px) {
    .nav-active-indicator { display: none; }
}
