/* ========================================
   Nutrirora — Mobile & Responsive Styles
   ======================================== */

/* ================================================
   MOBILE MENU — all rules here, loads last, wins
   ================================================ */

/* Toggle: hidden on desktop by default */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    gap: 5px;
    background: var(--bg-soft, #F8FAF9);
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 220;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.mobile-menu-toggle:hover {
    background: var(--primary-pale, #EBF7F2);
    border-color: var(--primary, #1E7A4E);
}

.mobile-menu-toggle[aria-expanded="true"] {
    background: var(--primary, #1E7A4E);
    border-color: var(--primary, #1E7A4E);
}

.hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    background-color: var(--text, #111827);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease, background-color 0.18s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line {
    background-color: #ffffff;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Full-screen menu panel — always in DOM, slid off-screen */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    /* Use 100dvh (dynamic viewport height) for mobile browsers with address bar */
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    /* Hardcoded white background — must NOT rely on CSS variable alone */
    background: #ffffff !important;
    background-color: #ffffff !important;
    z-index: 200;
    /* overflow-y scroll instead of auto — auto can collapse when height is ambiguous */
    overflow-x: hidden;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: block !important;
    visibility: visible !important;
    /* Ensure it paints above everything */
    isolation: isolate;
    will-change: transform;
}

.mobile-menu[hidden] {
    display: block !important;
    visibility: visible !important;
    transform: translateX(100%);
}

.mobile-menu.is-open {
    display: block !important;
    visibility: visible !important;
    transform: translateX(0) !important;
}

.mobile-menu-inner {
    padding: 80px 1.5rem 4rem;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
}

.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.mobile-nav-menu li {
    list-style: none;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e2e8f0;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.mobile-nav-menu li:first-child {
    border-top: 1px solid #e2e8f0;
    border-top: 1px solid var(--border, #e2e8f0);
}

.mobile-nav-menu a {
    display: block;
    padding: 1rem 0.5rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: #111827;
    color: var(--text, #111827);
    text-decoration: none;
    transition: color 0.18s ease, padding-left 0.18s ease;
}

.mobile-nav-menu a:hover,
.mobile-nav-menu .current-menu-item > a {
    color: #1E7A4E;
    color: var(--primary, #1E7A4E);
    padding-left: 0.5rem;
    text-decoration: none;
}

/* Overlay */
.mobile-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}

.mobile-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ================================================
   BREAKPOINT ≤ 1024px — tablet & mobile
   ================================================ */
@media (max-width: 1024px) {

    /* Layout grid overrides */
    .categories-grid  { grid-template-columns: 1fr; }
    .featured-grid    { grid-template-columns: 1fr; }
    .posts-grid       { grid-template-columns: repeat(2, 1fr); }
    .footer-columns   { grid-template-columns: repeat(2, 1fr); }
    .footer-brand     { grid-column: 1 / -1; }

    :root { --container-padding: 1rem; }

    /* Fixed header */
    .site-header {
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 210;
    }

    .site-main  { padding-top: 68px; }
    .header-inner { height: 56px; }

    /* HIDE desktop nav, SHOW hamburger */
    .main-navigation   { display: none !important; }
    .mobile-menu-toggle { display: flex !important; }

    /* Hero */
    .hero-section  { padding: 3rem 0 2.5rem; }
    .hero-title    { font-size: 2rem; }
    .hero-subtitle { font-size: 1.125rem; }

    .hero-search-inner {
        flex-direction: column;
        gap: 0.5rem;
        border-radius: var(--radius-lg);
        padding: 0.5rem;
    }

    .search-icon       { display: none; }
    .hero-search-input { padding: 0.625rem; text-align: center; }
    .hero-search-btn   { width: 100%; }

    /* Featured grid on tablet */
    .featured-card-large { grid-row: span 1; }

    /* Featured image */
    .featured-image { aspect-ratio: 16/9; }

    /* Article grid */
    .article-title    { font-size: 1rem; }
    .featured-title   { font-size: 1.125rem; }
    .newsletter-title { font-size: 1.25rem; }

    .newsletter-inner { flex-direction: column; text-align: center; gap: 1.5rem; }
    .newsletter-form  { width: 100%; max-width: 100%; }

    .footer-title { margin-bottom: 0.75rem; }

    .pagination a, .pagination span { min-width: 36px; height: 36px; }
}

/* ================================================
   BREAKPOINT ≤ 480px — small phones
   ================================================ */
@media (max-width: 480px) {
    .hero-title       { font-size: 1.75rem; }
    .hero-subtitle    { font-size: 1rem; }
    .hero-description { font-size: 0.875rem; }
    .section-title    { font-size: 1.25rem; }
    .featured-title   { font-size: 1.125rem; }
    .article-title    { font-size: 1rem; }
    .posts-grid       { grid-template-columns: 1fr; }
    .footer-columns   { grid-template-columns: 1fr; }

    .newsletter-form  { flex-direction: column; }
    .newsletter-btn   { width: 100%; }
}

/* ================================================
   REDUCED MOTION
   ================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================================
   DARK MODE
   ================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --text: #F9FAFB;
        --text-light: #D1D5DB;
        --text-muted: #9CA3AF;
        --bg: #111827;
        --bg-soft: #1F2937;
        --border: #374151;
    }

    .site-header { background: rgba(17, 24, 39, 0.95); }

    .article-card,
    .featured-card,
    .category-card { background: var(--bg-soft); }

    .mobile-menu { background: #111827 !important; background-color: #111827 !important; }
}

/* Search dropdown — full width on mobile */
@media (max-width: 600px) {
    .header-search {
        position: static;
    }
    .search-dropdown {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        z-index: 209;
        padding: 0.75rem 1rem;
    }
    .search-form {
        gap: 0.5rem;
    }
    .search-input {
        font-size: 1rem;
    }
}
