/**
 * Mobile Critical Fixes - Inline CSS
 * Must load AFTER Tailwind CDN to override
 * Version: 1.0
 */

/* ============================================
   FORCE MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 640px) {
    /* CRITICAL: Override Tailwind font sizes */
    html {
        font-size: 14px !important;
    }

    body {
        font-size: 0.875rem !important; /* 12.25px */
        line-height: 1.5 !important;
    }

    /* Headings - Much smaller */
    h1, .text-4xl, .text-5xl, .text-6xl, .text-7xl, .text-8xl {
        font-size: 1.5rem !important; /* 21px */
        line-height: 1.2 !important;
        margin-bottom: 0.75rem !important;
    }

    h2, .text-3xl {
        font-size: 1.25rem !important; /* 17.5px */
        line-height: 1.25 !important;
        margin-bottom: 0.625rem !important;
    }

    h3, .text-2xl {
        font-size: 1.125rem !important; /* 15.75px */
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }

    h4, .text-xl {
        font-size: 1rem !important; /* 14px */
        line-height: 1.35 !important;
    }

    h5, h6, .text-lg {
        font-size: 0.875rem !important; /* 12.25px */
        line-height: 1.4 !important;
    }

    .text-sm {
        font-size: 0.75rem !important; /* 10.5px */
    }

    .text-xs {
        font-size: 0.625rem !important; /* 8.75px */
    }

    /* ============================================
       SPACING - AGGRESSIVE REDUCTION
       ============================================ */

    /* Padding classes */
    .p-8, .p-10, .p-12 {
        padding: 0.75rem !important; /* 12px */
    }

    .p-6 {
        padding: 0.625rem !important; /* 10px */
    }

    .p-4 {
        padding: 0.5rem !important; /* 8px */
    }

    .px-8, .px-10, .px-12 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .px-6 {
        padding-left: 0.625rem !important;
        padding-right: 0.625rem !important;
    }

    .px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .py-8, .py-10, .py-12, .py-16 {
        padding-top: 1.5rem !important; /* 24px */
        padding-bottom: 1.5rem !important;
    }

    .py-6 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .py-4 {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }

    /* Margin classes */
    .mb-12, .mb-16, .mb-20 {
        margin-bottom: 1.25rem !important; /* 20px */
    }

    .mb-8, .mb-10 {
        margin-bottom: 1rem !important; /* 16px */
    }

    .mb-6 {
        margin-bottom: 0.75rem !important; /* 12px */
    }

    .mb-4 {
        margin-bottom: 0.5rem !important; /* 8px */
    }

    .mt-12, .mt-16, .mt-20 {
        margin-top: 1.25rem !important;
    }

    .mt-8, .mt-10 {
        margin-top: 1rem !important;
    }

    /* Gap classes */
    .gap-12, .gap-16, .gap-20 {
        gap: 0.75rem !important; /* 12px */
    }

    .gap-8, .gap-10 {
        gap: 0.625rem !important; /* 10px */
    }

    .gap-6 {
        gap: 0.5rem !important; /* 8px */
    }

    .gap-4 {
        gap: 0.375rem !important; /* 6px */
    }

    /* ============================================
       HEADER FIXES
       ============================================ */

    /* Top bar */
    #masthead .bg-slate-50 {
        padding: 0.25rem 0 !important;
        font-size: 8px !important;
    }

    /* Main header */
    #masthead > div.relative {
        height: 56px !important; /* Even smaller */
    }

    /* Logo */
    #masthead .w-10, #masthead .h-10 {
        width: 1.75rem !important; /* 28px */
        height: 1.75rem !important;
    }

    #masthead .text-2xl {
        font-size: 1rem !important; /* 14px */
    }

    #masthead .text-\[8px\] {
        font-size: 6px !important;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        padding: 0.375rem !important;
    }

    /* ============================================
       DISABLE ANIMATIONS ON MOBILE
       ============================================ */

    * {
        animation: none !important;
        transition-duration: 0.15s !important;
    }

    /* Disable hover animations that cause flickering */
    *:hover {
        transform: none !important;
        scale: 1 !important;
    }

    .hover\:scale-105:hover,
    .hover\:scale-110:hover,
    .group-hover\:scale-105,
    .group-hover\:scale-110 {
        transform: scale(1) !important;
    }

    /* Disable image zoom animations */
    img {
        transform: none !important;
        transition: none !important;
    }

    .group:hover img,
    .group-hover img {
        transform: none !important;
        scale: 1 !important;
    }

    /* ============================================
       MOBILE MENU SIDEBAR FIX
       ============================================ */

    #mobile-menu {
        position: fixed !important;
        inset: 0 !important;
        z-index: 9999 !important;
        display: none !important;
    }

    #mobile-menu.flex {
        display: flex !important;
    }

    #mobile-menu.hidden {
        display: none !important;
    }

    /* Menu sidebar */
    #mobile-menu > div:last-child {
        width: 260px !important;
        padding: 0.75rem !important;
    }

    #mobile-menu .p-6 {
        padding: 0.625rem !important;
    }

    #mobile-menu .px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    #mobile-menu .py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    #mobile-menu .text-lg {
        font-size: 0.875rem !important; /* 14px */
    }

    #mobile-menu .text-sm {
        font-size: 0.75rem !important; /* 12px */
    }

    #mobile-menu .gap-3 {
        gap: 0.5rem !important;
    }

    /* ============================================
       CONTAINER & SECTION FIXES
       ============================================ */

    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    section {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    /* ============================================
       GRID FIXES
       ============================================ */

    .grid {
        gap: 0.75rem !important;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(1, 1fr) !important;
    }

    /* ============================================
       CARD FIXES
       ============================================ */

    [class*="rounded"] {
        border-radius: 0.5rem !important;
    }

    [class*="shadow"] {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }

    /* ============================================
       BUTTON FIXES
       ============================================ */

    button, .button, a.button {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
        min-height: 40px !important;
    }

    /* ============================================
       FOOTER FIXES
       ============================================ */

    #colophon {
        padding: 1.5rem 0 1rem !important;
    }

    #colophon h3 {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }

    #colophon p,
    #colophon li,
    #colophon a {
        font-size: 0.7rem !important;
        line-height: 1.4 !important;
    }

    /* ============================================
       LINE CLAMP FOR CONTENT DENSITY
       ============================================ */

    .line-clamp-2 {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    .line-clamp-3 {
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
}

/* ============================================
   TABLET (641px - 1023px)
   ============================================ */

@media (min-width: 641px) and (max-width: 1023px) {
    html {
        font-size: 14px !important;
    }

    body {
        font-size: 0.875rem !important;
    }

    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    #masthead .bg-slate-50 {
        display: none !important;
    }

    #masthead > div.relative {
        height: 48px !important;
    }

    section {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}
