/* FIX MOBILE BLOG LAYOUT */

/* Force box-sizing to prevent padding from increasing width */
*,
*:before,
*:after {
    box-sizing: border-box !important;
}

/* Base resets */
html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Wrapper to contain everything */
#page-wrapper {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* Ensure images don't overflow */
img,
video,
canvas,
iframe {
    max-width: 100% !important;
    height: auto;
}

/* Containers */
.container,
section,
header,
footer,
.max-w-6xl,
.max-w-4xl {
    width: 100%;
    max-width: 100vw;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: auto;
    margin-right: auto;
}

/* Grid Override - Force 1 column on mobile */
#blog-posts-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    /* minmax(0, 1fr) prevents grid blowout */
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    #blog-posts-container {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 2rem;
    }
}

/* Card Styles */
.blog-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    /* Critical for flex/grid children */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Fix for specific sections */
.theme-switch-wrapper,
.flex {
    max-width: 100%;
}

/* Hide overflow explicitly on header nav to be safe */
header nav {
    max-width: 100%;
}

/* Fix Language Flags overflow */
.flex.items-center.gap-0\.5 {
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* CRITICAL: Fix blog card images on mobile */
.blog-card img {
    width: 100% !important;
    max-width: 100% !important;
    height: 200px !important;
    object-fit: cover !important;
}

/* Force all direct children of grid to respect bounds */
#blog-posts-container>* {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Aggressive mobile overrides */
@media (max-width: 767px) {

    .max-w-6xl,
    .max-w-4xl,
    .max-w-3xl {
        max-width: calc(100vw - 2rem) !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    #blog-posts-container {
        max-width: calc(100vw - 2rem) !important;
    }

    .blog-card {
        max-width: calc(100vw - 2rem) !important;
    }

    .blog-card img {
        max-width: calc(100vw - 2rem) !important;
    }
}

/* MOBILE HEADER FIX: Prevent status bar overlap */
@media (max-width: 768px) {
    header.sticky {
        padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    }
}