/**
 * Mobile Navigation Styles for Elm City Daily
 * Bottom navigation bar with tab-based content switching
 * No scrolling - everything fits perfectly on screen
 * Expert Apple design with subtle animations and newspaper color palette
 */

/* Mobile-only styles */
@media (max-width: 768px) {
    /* Prevent body scroll on mobile */
    html,
    body {
        height: 100%;
        overflow: hidden;
        position: fixed;
        width: 100%;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Dashboard container adjustments */
    .dashboard {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        padding: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Compact header for mobile - Newspaper header design */
    .masthead {
        flex-shrink: 0;
        padding: 12px 16px 8px;
        border-bottom: 1px solid var(--line);
        display: flex;
        flex-direction: column;
        gap: 6px;
        background: rgba(255, 255, 255, 0.4);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        animation: fadeInHeader 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

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

    .masthead__title {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        width: 100%;
    }

    .masthead__title h1 {
        font-size: 20px;
        letter-spacing: 0.05em;
        margin: 0;
        font-weight: 600;
        color: var(--ink);
    }

    /* Time and temperature in header - Elegant newspaper style */
    .masthead__time-temp {
        display: flex;
        align-items: center;
        gap: 12px;
        font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        font-size: 13px;
    }

    .masthead__time {
        font-weight: 500;
        color: var(--ink);
        letter-spacing: 0.01em;
    }

    .masthead__temp {
        font-weight: 600;
        color: var(--accent);
        letter-spacing: -0.01em;
    }

    .masthead__date {
        font-size: 11px;
        margin: 0;
        color: var(--muted-ink);
        font-variant: all-small-caps;
        letter-spacing: 0.05em;
    }

    .masthead__lines {
        display: none;
    }

    /* Mobile tabs container */
    .mobile-tabs-container {
        flex: 1;
        position: relative;
        overflow: hidden;
        min-height: 0;
    }

    /* Tab content - Smooth Apple-style transitions */
    .mobile-tab-content {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        opacity: 0;
        visibility: hidden;
        transform: translateX(8px) scale(0.98);
        transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                    visibility 0.4s;
        background: var(--paper);
        will-change: transform, opacity;
    }

    .mobile-tab-content.active {
        opacity: 1;
        visibility: visible;
        transform: translateX(0) scale(1);
        z-index: 1;
    }

    /* Hide desktop content on mobile */
    main.grid,
    section.strip {
        display: none !important;
    }

    /* Bottom navigation bar - Premium newspaper aesthetic */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(245, 239, 230, 0.95); /* Newspaper paper color with transparency */
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid var(--line);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 4px 12px;
        z-index: 1000;
        box-shadow: 0 -1px 0 rgba(28, 27, 26, 0.06), 0 -4px 24px rgba(28, 27, 26, 0.04);
        /* Safe area for notched devices */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        /* Subtle entrance animation */
        animation: slideUpNav 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes slideUpNav {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Navigation items - Apple-style subtle interactions */
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        border: none;
        background: transparent;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        border-radius: 10px;
        position: relative;
        min-width: 0;
        color: var(--muted-ink);
        font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        /* Subtle hover state for larger screens */
        -webkit-tap-highlight-color: transparent;
    }

    /* Press animation - Apple-style */
    .mobile-nav-item:active {
        transform: scale(0.92);
        transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* All icons same shade - maintaining newspaper consistency */
    .mobile-nav-item.active {
        color: var(--muted-ink);
    }

    /* Active indicator - subtle newspaper accent color */
    .mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 2.5px;
        background: var(--accent); /* Coral accent from newspaper palette */
        border-radius: 0 0 2px 2px;
        animation: slideInIndicator 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes slideInIndicator {
        from {
            width: 0;
            opacity: 0;
        }
        to {
            width: 36px;
            opacity: 1;
        }
    }

    /* Navigation icons - all same shade, subtle animations */
    .mobile-nav-icon {
        font-size: 24px;
        line-height: 1;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                    opacity 0.3s ease;
        filter: grayscale(0);
        opacity: 0.75;
        display: block;
    }

    .mobile-nav-item.active .mobile-nav-icon {
        transform: scale(1.08) translateY(-1px);
        opacity: 1;
    }

    /* Subtle bounce on tap */
    .mobile-nav-item:active .mobile-nav-icon {
        transform: scale(0.9);
        transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Navigation labels - newspaper typography */
    .mobile-nav-label {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        opacity: 0.85;
    }

    .mobile-nav-item.active .mobile-nav-label {
        opacity: 1;
        transform: translateY(-0.5px);
        font-weight: 600;
    }

    /* Content padding to account for bottom nav */
    .dashboard {
        padding-bottom: 70px;
    }

    /* Tab-specific content styling - Newspaper card design */
    .mobile-tab-content .panel {
        background: rgba(255, 255, 255, 0.7);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 12px;
        border: 1px solid var(--line);
        box-shadow: 0 1px 3px rgba(28, 27, 26, 0.04);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        animation: fadeInContent 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

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

    .mobile-tab-content .panel__title {
        font-size: 16px;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--line);
        font-weight: 600;
        color: var(--ink);
        letter-spacing: 0.01em;
    }

    /* Compact stats for mobile */
    .mobile-tab-content .stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .mobile-tab-content .stat {
        padding: 8px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 8px;
        border: 1px solid var(--line);
    }

    /* List items in mobile tabs */
    .mobile-tab-content .list {
        max-height: none;
    }

    .mobile-tab-content .list__item {
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
    }

    /* Agenda in mobile */
    .mobile-tab-content .agenda--vertical {
        border: 1px solid var(--line);
        border-radius: 12px;
        overflow: hidden;
    }

    .mobile-tab-content .agenda-v__row {
        padding: 10px 12px;
    }

    /* Weather section in mobile */
    .mobile-tab-content .weather {
        padding: 12px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 12px;
        border: 1px solid var(--line);
        margin-bottom: 12px;
    }

    /* Live camera in mobile */
    .mobile-tab-content #liveCam78 {
        margin: 0;
        padding: 12px;
        border-radius: 12px;
    }

    .mobile-tab-content #cam78Canvas {
        max-width: 100%;
        border-radius: 8px;
    }

    /* Change New Haven in mobile - Premium button design */
    .mobile-tab-content .change-nh {
        background: rgba(255, 255, 255, 0.8);
        border-radius: 12px;
        padding: 16px;
        border: 1px solid var(--line);
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(28, 27, 26, 0.04);
        animation: fadeInContent 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-tab-content .change-nh__title {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--line);
        font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        color: var(--ink);
        letter-spacing: 0.01em;
    }

    .mobile-tab-content .change-nh__actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .mobile-tab-content .change-nh__btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 14px 12px;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid var(--line);
        border-radius: 10px;
        text-decoration: none;
        color: var(--ink);
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 1px 2px rgba(28, 27, 26, 0.03);
        position: relative;
        overflow: hidden;
    }

    .mobile-tab-content .change-nh__btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--accent);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-tab-content .change-nh__btn:active {
        transform: scale(0.96);
        transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-tab-content .change-nh__btn:active::before {
        opacity: 0.08;
    }

    .mobile-tab-content .change-nh__icon {
        font-size: 24px;
        position: relative;
        z-index: 1;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-tab-content .change-nh__btn:active .change-nh__icon {
        transform: scale(0.9);
    }

    .mobile-tab-content .change-nh__label {
        font-size: 12px;
        font-weight: 500;
        font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        position: relative;
        z-index: 1;
        letter-spacing: 0.01em;
    }

    /* Footer adjustments */
    .footer-mini {
        display: none;
    }

    /* Smooth scrolling */
    .mobile-tab-content {
        scroll-behavior: smooth;
    }

    /* Hide scrollbar but keep functionality */
    .mobile-tab-content::-webkit-scrollbar {
        width: 4px;
    }

    .mobile-tab-content::-webkit-scrollbar-track {
        background: transparent;
    }

    .mobile-tab-content::-webkit-scrollbar-thumb {
        background: var(--line);
        border-radius: 2px;
    }

    .mobile-tab-content::-webkit-scrollbar-thumb:hover {
        background: var(--muted-ink);
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .masthead {
        padding: 10px 12px 6px;
    }

    .masthead__title h1 {
        font-size: 18px;
    }

    .mobile-nav-icon {
        font-size: 22px;
    }

    .mobile-nav-label {
        font-size: 9px;
    }

    .mobile-tab-content {
        padding: 10px 12px;
    }

    .mobile-bottom-nav {
        padding: 6px 2px 10px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .masthead {
        padding: 8px 16px 6px;
    }

    .masthead__title h1 {
        font-size: 18px;
    }

    .mobile-bottom-nav {
        padding: 6px 4px 8px;
    }

    .mobile-nav-icon {
        font-size: 20px;
    }

    .mobile-nav-label {
        font-size: 9px;
    }
}

/* Prevent text selection on nav items for better UX */
.mobile-nav-item {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Loading state */
.mobile-tab-content:not(.active) {
    pointer-events: none;
}

/* Smooth transitions for tab switching - Apple-style */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.mobile-tab-content.active {
    animation: fadeInSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger animation for list items */
.mobile-tab-content .list__item {
    animation: fadeInItem 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.mobile-tab-content .list__item:nth-child(1) { animation-delay: 0.05s; }
.mobile-tab-content .list__item:nth-child(2) { animation-delay: 0.1s; }
.mobile-tab-content .list__item:nth-child(3) { animation-delay: 0.15s; }
.mobile-tab-content .list__item:nth-child(4) { animation-delay: 0.2s; }
.mobile-tab-content .list__item:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeInItem {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

