/* Mobile Navigation Drawer */
.mobile-nav {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-nav {
        display: block;
    }
}

.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.mobile-nav.open .mobile-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.mobile-nav-drawer {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 18rem;
    background-color: var(--color-surface);
    overflow-y: auto;
    z-index: 101;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-nav.open .mobile-nav-drawer {
    transform: translateX(0);
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.mobile-nav-close {
    padding: var(--space-sm);
    color: var(--color-text-secondary);
    transition: color 0.2s;
}

.mobile-nav-close:hover {
    color: var(--color-text-primary);
}

.mobile-nav-body {
    padding: var(--space-md);
}

/* Mobile Search */
.mobile-search {
    display: block;
    padding: 0 var(--space-md) var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

@media (min-width: 768px) {
    .mobile-search {
        display: none;
    }
}

.mobile-search input {
    width: 100%;
    padding: var(--space-sm) var(--space-sm) var(--space-sm) 2.5rem;
    background-color: var(--color-surface-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    outline: none;
}

.mobile-search-wrapper {
    position: relative;
}

.mobile-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--color-text-muted);
}

/* Global overflow guard: one wide element must never widen the page */
html, body {
    overflow-x: clip;
    max-width: 100%;
}
.post-body, .post-title, .report-summary, .report-title,
.detail-content, .fw-comment-body, .deep-result-excerpt,
.review-content-box, .trending-tag {
    overflow-wrap: anywhere;
    word-break: break-word;
}
iframe, video {
    max-width: 100%;
}

/* Landing hero: tagline is the widest element on small phones */
@media (max-width: 480px) {
    .hero-content {
        padding: var(--space-lg) var(--space-md);
    }
    .hero-title {
        font-size: 2rem;
    }
    .hero-tagline {
        font-size: 0.72rem;
        letter-spacing: 0.02em;
        line-height: 1.7;
        max-width: 100%;
    }
    .hero-description {
        font-size: 0.95rem;
    }
    .hero-features {
        grid-template-columns: 1fr 1fr;
    }
}

/* Report modal 3-column rows stack on phones (rule lives in style.css —
   it loads after this file). */

/* Admin tables scroll inside their card instead of widening the page
   (rules live in style.css — it loads after this file). */
@media (max-width: 640px) {
    .admin-panel-page {
        padding: var(--space-sm);
    }
    .panel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Dynamic container: the shared home container (banner + feeds + lists)
   must shrink with the viewport — grid/flex children default to
   min-width:auto and can force it wider on phones. Mobile only. */
@media (max-width: 767px) {
    .page-layout, .main-content, .content-panel,
    .hero, .hero-content, .reports-feed, .pub-feed, .pub-preview-feed,
    .freedom-wall-posts, .kilosph-tv-videos, .trending-list,
    .platform-impact-grid {
        min-width: 0;
        max-width: 100%;
    }
    .hero-features {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .hero-feature {
        min-width: 0;
    }
    .hero-feature-text {
        overflow-wrap: anywhere;
        font-size: 0.8rem;
    }
    .report-card, .post-card, .video-card, .sidebar-card,
    .pub-preview-header, .report-meta, .post-meta {
        min-width: 0;
        max-width: 100%;
    }
    .report-meta, .post-meta, .pub-preview-header, .fw-actions,
    .deep-result-meta {
        flex-wrap: wrap;
    }
    .trending-item, .trending-hashtag {
        min-width: 0;
    }
    .trending-tag, .trending-count {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

/* Tight header on very small phones */
@media (max-width: 380px) {
    .header-actions {
        gap: 4px;
    }
    .header-btn-login, .header-btn-signup {
        padding: 6px 10px;
        font-size: 12px;
    }
    .header-logo-text {
        font-size: 1rem;
    }
}

/* Mobile Search Results */
@media (max-width: 767px) {
    .search-results {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: 0 8px 24px rgba(0,0,0,0.15);
        z-index: 1000;
        max-height: 50vh;
        overflow-y: auto;
        margin-top: 4px;
    }
    
    .search-result {
        padding: 10px 12px;
    }
    
    .search-result-title {
        font-size: 13px;
    }
    
    .search-deep-link {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Mobile Auth Buttons */
.mobile-auth {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-top: 1px solid var(--color-border);
}

/* Mobile Notification Dropdown */
@media (max-width: 480px) {
    .notification-dropdown {
        width: calc(100vw - 2rem);
        right: -0.5rem;
    }
    .notification-dropdown-header {
        padding: var(--space-xs) var(--space-sm);
    }
    .notification-item {
        padding: var(--space-xs) var(--space-sm);
    }
}

.mobile-auth-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    text-align: center;
}

.mobile-auth-login {
    background-color: var(--color-surface-secondary);
    color: var(--color-text-primary);
}

.mobile-auth-signup {
    background-color: var(--color-brand);
    color: white;
}

/* Mobile Modal */
@media (max-width: 640px) {
    .modal {
        max-width: 95%;
        margin: var(--space-sm);
        max-height: 90vh;
    }
    
    .modal-large {
        max-width: 95%;
        width: 95%;
    }
    
    .modal-header {
        padding: var(--space-sm) var(--space-md);
    }
    
    .modal-body {
        padding: var(--space-sm) var(--space-md);
    }
    
    .modal-footer {
        padding: var(--space-sm) var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .form-row .form-group {
        min-width: 100%;
    }
    
    .deep-search-results {
        max-height: 40vh;
    }
}

/* Mobile Header */
@media (max-width: 640px) {
    .header-inner {
        padding: var(--space-xs) var(--space-sm);
    }
    
    .header-logo-text {
        font-size: 1rem;
    }
    
    .header-tagline {
        display: none;
    }
}

/* Mobile Nav Bar */
@media (max-width: 768px) {
    .nav-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-bar-inner {
        padding: 0 var(--space-sm);
        min-width: max-content;
    }
    
    .nav-link {
        padding: var(--space-sm) var(--space-xs);
        font-size: 12px;
        white-space: nowrap;
    }
}

/* Mobile Panels */
@media (max-width: 768px) {
    .page-layout {
        flex-direction: column;
    }
    
    .sidebar-left,
    .sidebar-right {
        display: none;
    }
    
    .main-content {
        padding: var(--space-sm);
    }
    
    .panel-header {
        padding: var(--space-sm);
    }
    
    .panel-header h1 {
        font-size: 1.25rem;
    }
    
    .freedom-wall-sort,
    .kilosph-tv-filters,
    .pub-filters,
    .reports-category-filter {
        flex-wrap: wrap;
        gap: var(--space-xs);
    }
    
    .sort-btn,
    .filter-btn,
    .pub-filter-btn,
    .reports-cat-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 12px;
    }
    
    .post-card {
        flex-direction: row;
    }

    /* Slim side vote rail lives in style.css (it loads after this file). */
    
    .video-card {
        margin-bottom: var(--space-sm);
    }
    
    .kilosph-tv-videos {
        grid-template-columns: 1fr;
    }
    
    .deep-result-meta {
        flex-direction: column;
        gap: var(--space-xs);
    }
}
