/* =============================================
   mobile.css — Shared mobile styles for Amanah.az
   Loaded by: index.html, post.html, search.html
   ============================================= */

/* ── Global overflow fix ── */
html {
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

body {
    overflow-x: hidden;
    overscroll-behavior-x: none;
    position: relative;
    width: 100%;
    max-width: 100vw;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ── Mobile Navigation Sidebar (off-canvas) ── */
.mobile-nav-sidebar,
.internal-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem 2rem;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-nav-sidebar.open,
.internal-sidebar.mobile-open {
    transform: translateX(0);
}

/* Close button inside sidebar */
.sidebar-toggle {
    position: absolute;
    right: 0.75rem;
    top: 0.75rem;
    z-index: 201;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: none;
    width: 2rem;
    /* 32px */
    height: 2rem;
    /* 32px */
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar brand */
.sidebar-brand {
    margin-bottom: 0.5rem;
    /* 8px */
}

.sidebar-brand a {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    /* 28px */
    color: white;
    text-decoration: none;
    border-bottom: none;
}

.sidebar-tagline {
    font-size: 0.875rem;
    /* 14px */
    opacity: 0.7;
    margin-bottom: 2rem;
    /* 32px */
    line-height: 1.4;
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* 12px */
    padding: 0.5rem 1rem;
    /* 8px 16px */
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9375rem;
    /* 15px */
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-icon {
    width: 1.125rem;
    /* 18px */
    height: 1.125rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Sidebar copyright */
.sidebar-copyright {
    font-size: 0.75rem;
    /* 12px */
    opacity: 0.5;
    line-height: 1.6;
    padding-top: 1rem;
    /* 16px */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── Overlay backdrop ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Mobile header bar ── */
.mobile-header {
    display: none;
    /* shown via media query */
}

/* ── Floating open button (desktop, when sidebar collapsed) ── */
.sidebar-open-btn {
    position: fixed;
    left: 0;
    top: 1rem;
    z-index: 201;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    width: 2rem;
    /* 32px */
    height: 2rem;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.sidebar-open-btn:hover {
    opacity: 1;
}

.sidebar-open-btn.visible {
    display: flex;
}


/* ==============================================
   MOBILE BREAKPOINT — max-width: 768px
   ============================================== */
@media (max-width: 768px) {

    /* ── Mobile header bar ── */
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 50;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        /* 12px 16px → 48px total height */
        background: var(--sidebar-bg);
        color: white;
    }

    .mobile-header .mobile-hamburger {
        background: none;
        border: none;
        color: white;
        font-size: 1.25rem;
        /* 20px */
        cursor: pointer;
        padding: 0.25rem;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-header .mobile-brand {
        font-family: var(--font-heading);
        font-size: 1.25rem;
        /* 20px */
        color: white;
        text-decoration: none;
    }

    /* ── Mobile hero banner (index only) ── */
    .mobile-hero {
        display: block;
        background: var(--sidebar-bg);
        color: white;
        text-align: center;
        padding: 2rem 1rem 1.5rem;
        /* 32px 16px 24px */
    }

    .mobile-hero .mobile-hero-title {
        font-family: var(--font-heading);
        font-size: 2rem;
        /* 32px */
        color: white;
        margin-bottom: 0.5rem;
        /* 8px */
    }

    .mobile-hero .mobile-hero-tagline {
        font-size: 0.875rem;
        /* 14px */
        opacity: 0.75;
        margin: 0;
    }

    /* ── Hide desktop elements ── */
    .hero-sidebar {
        display: none !important;
    }

    .sidebar-open-btn {
        display: none !important;
    }

    /* ── Layout reset ── */
    .layout-container {
        flex-direction: column !important;
    }

    /* ── Main content — full width ── */
    .main-content,
    .internal-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 1rem !important;
        /* 16px all sides */
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .internal-main.expanded {
        margin-left: 0 !important;
    }

    /* ── Post card feed ── */
    .posts-grid {
        gap: 0.5rem !important;
        /* 8px */
        width: 100% !important;
        max-width: 100% !important;
    }

    .post-card {
        padding: 1rem !important;
        /* 16px */
        border-radius: 0.5rem;
        /* 8px */
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .post-card h2 {
        font-size: 1.125rem;
        /* 18px */
        max-width: 100% !important;
        line-height: 1.3;
    }

    .post-meta {
        font-size: 0.8125rem;
        /* 13px */
    }

    .post-excerpt {
        font-size: 0.875rem;
        /* 14px */
        max-width: 100% !important;
        line-height: 1.5;
    }

    .pagination {
        margin-top: 1.5rem;
        /* 24px */
    }

    /* ── Blog post article content ── */
    .internal-main .blog-post {
        max-width: 100% !important;
        width: 100% !important;
    }

    .internal-main .entry-content {
        max-width: 100% !important;
        width: 100% !important;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .internal-main .entry-content p,
    .internal-main .entry-content h2,
    .internal-main .entry-content h3,
    .internal-main .entry-content h4,
    .internal-main .entry-content h5,
    .internal-main .entry-content h6 {
        max-width: 100% !important;
    }

    /* Article typography scale */
    .internal-main h1 {
        font-size: 1.5rem;
        /* 24px */
        line-height: 1.3;
    }

    .internal-main .entry-content {
        font-size: 1rem;
        /* 16px */
        line-height: 1.7;
    }

    .internal-main .entry-content h2 {
        font-size: 1.25rem;
        /* 20px */
    }

    .internal-main .entry-content h3 {
        font-size: 1.125rem;
        /* 18px */
    }

    /* Tables — horizontal scroll */
    .internal-main .entry-content table,
    .entry-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    .internal-main .entry-content th,
    .internal-main .entry-content td,
    .entry-content th,
    .entry-content td {
        padding: 0.5rem 0.75rem;
        min-width: 80px;
        white-space: normal;
    }

    .internal-main .entry-content th,
    .entry-content th {
        white-space: nowrap;
    }

    /* Related posts — single column */
    .related-posts-grid {
        grid-template-columns: 1fr;
    }

    /* Share buttons — wrap */
    .share-buttons-container {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        /* 8px */
    }

    .share-buttons-container a {
        font-size: 0.875rem;
        /* 14px */
    }

    /* Post tags — wrap */
    .post-tags {
        line-height: 2;
    }

    /* Search input */
    .search-bar-container {
        margin-bottom: 1.5rem;
        /* 24px */
    }

    #main-search-input {
        font-size: 1rem;
        /* 16px — prevents iOS zoom */
        padding: 0.75rem 1rem;
        /* 12px 16px */
    }

    /* Internal sidebar — mobile override */
    .internal-sidebar {
        z-index: 200;
    }
}


/* ── Desktop: hide mobile-only elements ── */
@media (min-width: 769px) {
    .mobile-nav-sidebar {
        display: none !important;
    }

    .mobile-hero {
        display: none !important;
    }

    /* Keep sidebar-overlay hidden on desktop for index page */
    body.home .sidebar-overlay {
        display: none !important;
    }

    /* Post/search pages: overlay also hidden on desktop */
    .internal-page .sidebar-overlay {
        display: none;
    }

    .internal-page .mobile-header {
        display: none;
    }
}