/*
 * MOBILE RESPONSIVE SAFETY NET — Global Protected Styles
 * ========================================================
 * This file loads LAST after all other CSS.
 * It guarantees mobile responsiveness even if style.css is modified.
 * DO NOT remove or reorder this file's enqueue in functions.php.
 * Last updated: 2026-03-25
 */

/* ============================================
   BASE: Prevent horizontal overflow
   ============================================ */
html {
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
}

.wp-block-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   TABLET (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .mi-season-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mi-explore-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    /* --- Layout --- */
    .entry-content,
    .wp-block-post-content {
        padding: var(--mi-spacing-md, 1rem);
    }

    h1, .wp-block-heading:where(h1) {
        font-size: 1.6rem;
    }

    h2, .wp-block-heading:where(h2) {
        font-size: 1.2rem;
    }

    .wp-block-columns {
        flex-direction: column;
    }

    .wp-block-buttons {
        flex-direction: column;
        align-items: center;
    }

    /* --- Hero --- */
    .mi-hero-overlay {
        margin-top: -100px;
        padding: var(--mi-spacing-xl, 1rem) var(--mi-spacing-md, 1rem) var(--mi-spacing-lg, 1.5rem);
    }

    .mi-hero-section .mi-hero-img img {
        height: 300px;
    }

    .mi-hero-section .mi-hero-buttons {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .mi-hero-section .mi-hero-buttons .wp-block-button__link {
        width: 100%;
        text-align: center;
    }

    /* --- Grids to 1 column --- */
    .mi-season-grid,
    .mi-news-grid,
    .mi-character-grid {
        grid-template-columns: 1fr !important;
    }

    .mi-explore-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* --- Stats bar --- */
    .mi-stats-inner {
        padding: 1.25rem 0.5rem;
    }

    .mi-stat-number {
        font-size: 1.5rem;
    }

    .mi-stat-label {
        font-size: 0.65rem;
    }

    .mi-stat-divider {
        height: 30px;
    }

    /* --- Sections --- */
    .mi-section {
        padding: var(--mi-spacing-xl, 1rem) var(--mi-spacing-md, 1rem) !important;
    }

    .mi-section-heading {
        font-size: 1.3rem !important;
    }

    /* --- FAQ --- */
    .mi-faq-item {
        padding: 0.75rem 1rem;
    }

    .mi-faq-item h3,
    .mi-faq-item h4 {
        font-size: 0.9rem;
    }

    .mi-faq-item p {
        font-size: 0.85rem;
    }

    /* --- About --- */
    .mi-about-content {
        max-width: 100%;
    }

    .mi-about-content p {
        font-size: 0.9rem;
    }

    /* --- Streaming --- */
    .mi-streaming-option {
        font-size: 0.85rem;
        padding: 0.75rem;
    }

    .mi-btn-stream {
        display: block;
        text-align: center;
    }

    /* --- Images --- */
    .wp-block-image.size-full img,
    .hero-banner img,
    .alignfull img {
        max-height: 250px;
    }

    .mi-character-img-wrap {
        height: 160px;
    }

    .mi-season-card img {
        height: 120px;
    }

    .wiki-infobox-image {
        aspect-ratio: auto;
        max-height: none;
        object-fit: contain;
        object-position: center;
    }

    .wiki-video-thumb {
        max-height: 200px;
    }

    /* --- Breadcrumb --- */
    .mi-breadcrumb p {
        font-size: 0.75rem;
    }

    /* --- Wiki pages --- */
    .wiki-page {
        grid-template-columns: 1fr !important;
    }

    .wiki-sidebar {
        order: -1;
    }

    .wiki-infobox {
        max-width: 100% !important;
        position: static !important;
    }

    .wiki-video-grid {
        grid-template-columns: 1fr !important;
    }

    .wiki-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wiki-table th,
    .wiki-table td {
        padding: 0.5rem 0.7rem;
        font-size: 0.82rem;
    }

    .wiki-quote {
        padding: 0.9rem 1rem;
    }

    .wiki-quote p {
        font-size: 0.9rem;
        padding-left: 1rem;
    }

    .wiki-see-also,
    .wiki-season-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .wiki-see-also a,
    .wiki-season-nav a {
        width: 100%;
        justify-content: center;
    }

    .wiki-episodes {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    h1, .wp-block-heading:where(h1), .wp-block-post-title {
        font-size: 1.4rem !important;
    }

    /* --- Hero --- */
    .mi-hero-section .mi-hero-img img {
        height: 220px;
    }

    /* --- Stats --- */
    .mi-stats-inner {
        flex-wrap: wrap;
        gap: 0.75rem 0;
    }

    .mi-stat {
        flex: 0 0 40%;
    }

    .mi-stat-divider {
        display: none;
    }

    .mi-stat-number {
        font-size: 1.3rem;
    }

    .mi-stat-label {
        font-size: 0.6rem;
    }

    /* --- Explore --- */
    .mi-explore-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .mi-explore-card {
        padding: 1rem 0.5rem;
    }

    /* --- Sections --- */
    .mi-section {
        padding: var(--mi-spacing-md, 1rem) var(--mi-spacing-sm, 0.5rem) !important;
    }

    .mi-section-heading {
        font-size: 1.1rem !important;
    }

    /* --- FAQ --- */
    .mi-faq-item {
        padding: 0.6rem 0.75rem;
    }

    /* --- Images --- */
    .wp-block-image.size-full img,
    .hero-banner img,
    .alignfull img {
        max-height: 180px;
    }

    .mi-character-img-wrap {
        height: 130px;
    }

    .mi-season-card img {
        height: 100px;
    }

    .wiki-infobox-image {
        aspect-ratio: auto;
        max-height: none;
        object-fit: contain;
        object-position: center;
    }

    /* --- Tables --- */
    .wp-block-table th,
    .wp-block-table td {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }

    .wiki-table th,
    .wiki-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.78rem;
    }

    /* --- Wiki --- */
    .wiki-episodes {
        grid-template-columns: 1fr !important;
    }

    .wiki-infobox-row {
        grid-template-columns: 85px 1fr;
    }

    .wiki-infobox-label {
        font-size: 0.72rem;
    }

    .wiki-highlights {
        grid-template-columns: 1fr !important;
    }

    /* --- Breadcrumb --- */
    .mi-breadcrumb {
        margin-top: 20px !important;
    }
}
