/* =========================================================
   Mobile Optimized Page (Adaptive UI)
   - Specialized Bottom Navigation
   - Compact Header
   - Touch-Friendly Layout
   ========================================================= */

/* Desktop-first fallback: hide mobile components by default */
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {

    /* --- Layout Adjustments --- */
    body {
        padding-bottom: 0;
        /* Reset body padding, move spacing to #app */
    }

    body.hidden-route .mobile-nav {
        display: none !important;
    }

    body.hidden-route #app {
        padding-bottom: 0 !important;
    }

    #app {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        padding-bottom: 65px;
        /* Ensure footer sits above nav */
        box-sizing: border-box;
    }

    footer {
        margin-top: auto;
        /* Push footer to bottom */
    }

    main {
        padding: 1.2rem 1rem !important;
    }

    /* --- Compact Header --- */
    header {
        position: static;
        /* Scroll with content */
        background-color: var(--header-bg);
        border-bottom: 1px solid var(--border-color);
    }

    nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.8rem 1rem !important;
    }

    /* Hide desktop links on mobile */
    .nav-links>a {
        display: none !important;
    }

    .nav-links {
        display: flex;
        align-items: center;
    }

    .logo {
        font-size: 1.1rem !important;
        line-height: 1.1;
    }

    /* --- Bottom Navigation Bar (App-like) --- */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background-color: var(--card-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--secondary-color);
        font-size: 0.7rem;
        font-weight: 500;
        gap: 4px;
        flex: 1;
        transition: color 0.2s;
    }

    .mobile-nav-item svg {
        transition: transform 0.2s;
    }

    .mobile-nav-item:active svg {
        transform: scale(0.9);
    }

    .mobile-nav-item.active,
    .mobile-nav-item:hover {
        color: var(--primary-color);
    }

    /* Dark Mode Specifics for Mobile Nav */
    [data-theme="dark"] .mobile-nav {
        background-color: #1a1a1a;
        border-top-color: #333;
        box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.3);
    }

    /* --- Post Card Optimization --- */
    .post-card {
        margin: 0 0 1.2rem 0 !important;
        border-radius: 12px !important;
        padding: 1.2rem !important;
    }

    .post-title {
        font-size: 1.4rem !important;
        margin-bottom: 0.8rem !important;
    }

    .post-excerpt {
        font-size: 0.95rem !important;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* --- Markdown Detail Mobile-Optimization --- */
    .markdown-body {
        font-size: 1.05rem !important;
        /* Slightly larger for readability */
    }

    .markdown-body pre {
        margin-left: -1rem !important;
        margin-right: -1rem !important;
        border-radius: 0 !important;
        font-size: 0.85rem !important;
    }

    .markdown-body img {
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
        max-width: none;
        border-radius: 0;
    }

    .markdown-body blockquote {
        margin: 2rem 0 !important;
        border-radius: 0 4px 4px 0 !important;
    }

    /* Back link floating style or hidden (since bottom nav exists) */
    .back-link-container {
        display: none;
    }
}

/* Very Small Devices */
@media (max-width: 380px) {
    .logo {
        font-size: 1rem !important;
    }

    .mobile-nav-item span {
        display: none;
        /* Icon-only on very small screens */
    }

    .mobile-nav {
        height: 55px;
    }

    /* Match app padding to smaller nav height */
    #app {
        padding-bottom: 55px;
    }
}

/* Footer spacing fix */
footer p {
    margin: 0;
    padding: 0;
}