/* ============================================================================
   Navigation — extracted from nav.html inline <style>
   ========================================================================= */

/* ---- Navbar ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: rgba(250, 250, 247, 0.88);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border-bottom: 1px solid var(--color-border-subtle);
    transition: box-shadow var(--duration-base) var(--ease-out);
}

.navbar.scrolled {
    box-shadow: 0 1px 8px rgba(28, 25, 23, 0.06);
}

[data-theme="dark"] .navbar {
    background: rgba(15, 14, 19, 0.92);
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .navbar.scrolled {
    box-shadow: 0 1px 16px rgba(0, 0, 0, 0.4);
}

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

/* Brand */
.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-base);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-brand-text {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Hamburger toggle */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    color: var(--color-text);
    border-radius: var(--radius-md);
    min-width: 44px;
    min-height: 44px;
    transition: background var(--duration-fast) var(--ease-out);
}

.nav-toggle:hover {
    background: var(--color-surface);
}

.nav-toggle svg line {
    transition: all var(--duration-slow) var(--ease-out);
    transform-origin: center;
}

/* Menu */
.nav-menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-decoration: none;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease-out);
}

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

.nav-link.is-active {
    color: var(--color-primary);
    background: var(--color-primary-ghost);
    font-weight: var(--weight-semibold);
}

.nav-link-strava {
    color: var(--color-accent);
}

.nav-link-strava:hover {
    color: var(--color-accent-dark);
    background: var(--color-accent-subtle);
}

/* User section */
.nav-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-left: var(--space-3);
    margin-left: var(--space-2);
    border-left: 1px solid var(--color-border);
}

.nav-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}

.nav-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
}

.nav-user-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-signout {
    font-size: var(--text-xs) !important;
    padding: 4px 10px !important;
    min-height: 32px !important;
}

.nav-auth {
    display: flex;
    align-items: center;
    padding-left: var(--space-3);
    margin-left: var(--space-2);
    border-left: 1px solid var(--color-border);
    min-height: 40px;
}

.nav-gsi-button {
    width: 200px;
    flex-shrink: 0;
}

.nav-signin-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}

.nav-signin-btn:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
}

/* ---- Mobile nav ---- */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 var(--space-4);
    }

    .nav-toggle {
        display: flex;
        z-index: calc(var(--z-sticky) + 1);
    }

    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        background: var(--color-bg);
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-6) var(--space-4);
        gap: var(--space-4);
        overflow-x: hidden;
        overflow-y: auto;
        z-index: var(--z-sticky);
        /* Hidden by default */
        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px);
        transition: opacity var(--duration-base) var(--ease-out),
                    transform var(--duration-base) var(--ease-out);
        display: flex;
    }

    .nav-menu.active {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .nav-links {
        flex-direction: column;
        gap: var(--space-1);
        width: 100%;
    }

    .nav-link {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-md);
        border-radius: var(--radius-lg);
        white-space: normal;
        justify-content: flex-start;
        width: 100%;
    }

    .nav-theme-toggle {
        align-self: flex-start;
    }

    .nav-user {
        flex-direction: column;
        align-items: stretch;
        padding-left: 0;
        margin-left: 0;
        border-left: none;
        padding-top: var(--space-4);
        border-top: 1px solid var(--color-border);
        gap: var(--space-3);
    }

    .nav-user-name {
        max-width: none;
    }

    .nav-signout {
        width: 100%;
    }

    .nav-auth {
        padding-left: 0;
        margin-left: 0;
        border-left: none;
        padding-top: var(--space-4);
        border-top: 1px solid var(--color-border);
        justify-content: center;
        overflow: hidden;
        flex-direction: column;
        align-items: stretch;
    }

    /* Hide the GSI iframe button on mobile, show our custom button instead */
    .nav-gsi-button {
        display: none !important;
    }

    #nav-signin-fallback {
        display: inline-flex !important;
    }
}

/* ---- Theme toggle ---- */
.nav-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
}

.nav-theme-toggle:hover {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

/* Show sun in dark mode, moon in light mode */
.nav-theme-toggle .icon-sun  { display: none; }
.nav-theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .nav-theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .nav-theme-toggle .icon-moon { display: none; }

/* Dark mode adjustments for mobile nav */
[data-theme="dark"] .nav-menu {
    background: var(--color-bg);
}

/* ---- Strava dropdown ---- */
.nav-item-strava {
    position: relative;
}

.strava-trigger {
    /* inherits .nav-link and .nav-link-strava */
    background: none;
    border: none;
    cursor: pointer;
    gap: 6px;
}

.strava-icon {
    flex-shrink: 0;
}

.strava-chevron {
    flex-shrink: 0;
    transition: transform var(--duration-fast) var(--ease-out);
}

.strava-trigger[aria-expanded="true"] .strava-chevron {
    transform: rotate(180deg);
}

/* Panel */
.strava-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(28, 25, 23, 0.10), 0 1px 4px rgba(28, 25, 23, 0.06);
    padding: 14px;
    z-index: 200;
    flex-direction: column;
    gap: 12px;
}

.strava-panel.is-open {
    display: flex;
}

[data-theme="dark"] .strava-panel {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Status row */
.strava-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: var(--weight-medium);
}

.strava-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-success);
    flex-shrink: 0;
}

.strava-status-text {
    color: var(--color-success);
    font-weight: var(--weight-semibold);
}

.strava-sep {
    color: var(--color-text-muted);
}

.strava-last-synced {
    color: var(--color-text-secondary);
}

/* Primary sync button */
.strava-primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    font-family: var(--font-body);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                opacity var(--duration-fast) var(--ease-out);
}

.strava-primary-btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.strava-primary-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Divider with label */
.strava-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: var(--weight-medium);
}

.strava-divider::before,
.strava-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.strava-divider-label {
    white-space: nowrap;
}

/* Chips row */
.strava-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.strava-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    font-family: var(--font-body);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

.strava-chip:hover:not(:disabled) {
    background: var(--color-surface);
    color: var(--color-text);
}

.strava-chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback area */
.strava-feedback {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    line-height: 1.4;
}

.strava-feedback.is-success {
    background: var(--color-success-subtle);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.strava-feedback.is-error {
    background: var(--color-error-subtle);
    color: var(--color-error);
    border: 1px solid var(--color-error-border);
}

/* Spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.strava-spinner {
    animation: spin 0.8s linear infinite;
}

/* Mobile: panel is inline, no absolute positioning */
@media (max-width: 768px) {
    .nav-item-strava {
        position: static;
        width: 100%;
    }

    .strava-trigger {
        width: 100%;
        justify-content: flex-start;
    }

    .strava-panel {
        position: static;
        top: auto;
        right: auto;
        box-shadow: none;
        border-radius: var(--radius-md);
        background: var(--color-surface);
        border-color: var(--color-border);
        margin-top: 4px;
    }

    .strava-chips {
        width: 100%;
    }
}
