/* ========================================
   Responsive - Consolidated Media Queries
   ======================================== */

/* Large screens down to tablets */
@media (max-width: 900px) {
    .layout-with-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: calc(-1 * var(--sidebar-width) - 20px);
        width: var(--sidebar-width);
        height: 100vh;
        z-index: 200;
        padding: 50px 16px 16px 16px;
        background: var(--bg);
        overflow-y: auto;
        transition: right 0.25s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    }

    .sidebar.open {
        right: 0;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }
}

/* Mobile screens */
@media (max-width: 640px) {
    .container {
        padding: 16px;
    }

    /* Compact sort-and-create bar */
    .sort-and-create {
        gap: 6px;
        flex-wrap: nowrap;
        margin-bottom: 12px;
    }

    /* Sidebar toggle: always far right */
    .sidebar-toggle {
        order: 99;
        margin-left: auto;
        width: 32px;
        height: 28px;
    }

    .sidebar-toggle svg {
        width: 16px;
        height: 16px;
    }

    /* Smaller view mode toggle */
    .view-mode-toggle {
        padding: 2px;
        gap: 2px;
    }

    .view-btn {
        padding: 5px 6px;
        height: 28px;
    }

    .view-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Smaller sort dropdown */
    .sort-dropdown-toggle {
        padding: 5px 8px;
        font-size: 12px;
        height: 28px;
    }

    /* Smaller new post button - stays left, pushes sidebar right */
    .new-post-btn {
        width: 32px;
        height: 28px;
        margin-right: auto;
    }

    .new-post-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Reduce comment nesting indentation on mobile */
    .comment-replies {
        margin-left: 4px;
        padding-left: 8px;
    }

    /* Cap visual depth at 5 levels on mobile - stop indenting further */
    .comment-replies .comment-replies .comment-replies .comment-replies .comment-replies {
        margin-left: 0;
        padding-left: 8px;
        border-left-width: 1px;
    }

    .nav {
        height: 50px;
    }

    .logo {
        font-size: 18px;
    }

    .nav-links a, .nav-links button {
        padding: 6px 10px;
        font-size: 13px;
    }

    .post-item {
        padding: 14px 16px 14px 0;
    }

    .post-title {
        font-size: 15px;
    }

    .board-header,
    .profile-header {
        margin: -16px -16px 20px -16px;
        padding: 24px;
    }

    .board-title,
    .profile-username {
        font-size: 22px;
    }

    /* Post Grid */
    .post-grid {
        grid-template-columns: 1fr;
    }

    .post-grid-overlay {
        opacity: 1;
    }

    .post-grid-item {
        aspect-ratio: 4/3;
    }

    /* User dropdown */
    .user-dropdown-name {
        display: none;
    }

    .user-dropdown-toggle {
        padding: 8px 10px;
    }

    /* Nav icon buttons */
    .nav-icon-btn {
        width: 40px;
        height: 40px;
    }

    .nav-icon-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Report form */
    .report-header {
        margin-bottom: 24px;
        padding-bottom: 16px;
    }

    .report-header h1 {
        font-size: 22px;
    }

    .rule-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Tutorial */
    .tutorial-modal {
        max-width: calc(100vw - 24px);
    }

    .tutorial-slide {
        padding: 24px 20px 20px;
    }

    .tutorial-illustration {
        width: 100px;
        height: 100px;
    }

    .tutorial-title {
        font-size: 20px;
    }

    .tutorial-footer {
        padding: 12px 20px;
    }

    .tutorial-actions {
        gap: 8px;
    }
}

/* Small screens - profile adjustments */
@media (max-width: 600px) {
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-avatar {
        width: 64px;
        height: 64px;
    }

    .profile-stats {
        justify-content: center;
    }
}

/* Touch device adjustments */
@media (hover: none) {
    .post-grid-overlay {
        opacity: 1;
        background: linear-gradient(transparent 30%, rgba(0,0,0,0.9));
    }
}
