/* Enhanced Responsive Styles for Full Mobile Support */

/* Base responsive adjustments */
@media (max-width: 640px) {
    /* Mobile typography */
    h1 {
        font-size: 1.875rem !important; /* 30px */
        line-height: 2.25rem;
    }
    
    h2 {
        font-size: 1.5rem !important; /* 24px */
        line-height: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem !important; /* 20px */
        line-height: 1.5rem;
    }

    /* Navigation improvements */
    nav .text-xl {
        font-size: 1rem;
    }

    /* Logo spacing */
    nav .space-x-2 > * + * {
        margin-left: 0.25rem;
    }

    /* Hero section */
    .bg-gradient-to-r {
        padding: 1.5rem !important;
    }

    .bg-gradient-to-r h1 {
        font-size: 1.75rem !important;
    }

    .bg-gradient-to-r p {
        font-size: 1rem !important;
    }

    /* Cards spacing */
    .grid.gap-6 {
        gap: 1rem;
    }

    /* Tables responsive */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem;
    }

    /* Code blocks */
    pre {
        font-size: 0.75rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Interactive features mobile adjustments */
    #reading-progress {
        width: 50px !important;
        height: 50px !important;
        bottom: 15px !important;
        right: 15px !important;
    }

    #reading-progress span {
        font-size: 10px !important;
    }

    /* Share buttons mobile */
    .share-buttons {
        left: 10px !important;
        gap: 8px !important;
    }

    .share-buttons a {
        width: 45px !important;
        height: 45px !important;
        font-size: 0.875rem !important;
    }

    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }

    /* Buttons */
    button,
    .btn {
        min-height: 44px; /* Touch target size */
        min-width: 44px;
    }

    /* Padding adjustments */
    .p-8 {
        padding: 1.5rem !important;
    }

    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-8 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    /* Margin adjustments */
    .mb-8 {
        margin-bottom: 1.5rem !important;
    }

    .mt-8 {
        margin-top: 1.5rem !important;
    }

    /* Grid columns */
    .grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }

    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }

    /* Text alignment */
    .text-center {
        text-align: center !important;
    }
}

/* Tablet adjustments (640px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    h1 {
        font-size: 2.25rem;
    }

    h2 {
        font-size: 1.875rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    a,
    button {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .hover\:shadow-lg:hover {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }

    /* Better spacing for touch */
    nav a {
        padding: 0.75rem 1rem;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 896px) and (orientation: landscape) {
    nav {
        height: auto;
        min-height: 56px;
    }

    nav .h-16 {
        height: auto;
        padding: 0.5rem 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Can add dark mode styles here if needed */
}

/* Print styles */
@media print {
    nav,
    .share-buttons,
    #reading-progress,
    #scroll-progress,
    #live-notification,
    button,
    .no-print {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }
}

/* Container max-width fixes */
@media (max-width: 640px) {
    .max-w-4xl,
    .max-w-7xl {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Mobile menu improvements */
@media (max-width: 768px) {
    #mobile-menu {
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-dropdown-content {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Search bar mobile */
@media (max-width: 640px) {
    #search-bar {
        padding: 1rem 0.5rem !important;
    }

    #search-input {
        font-size: 16px !important; /* Prevents zoom */
        padding: 0.75rem 0.5rem 0.75rem 2.5rem !important;
    }
}

/* Footer mobile */
@media (max-width: 768px) {
    footer .grid {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
        gap: 1.5rem;
    }
}

/* Article content mobile */
@media (max-width: 640px) {
    article {
        padding: 1rem !important;
    }

    article section {
        margin-bottom: 2rem !important;
    }

    /* Lists spacing */
    ul.list-disc,
    ol.list-decimal {
        padding-left: 1.25rem;
    }

    /* Blockquotes */
    blockquote {
        margin: 1rem 0;
        padding: 1rem;
        font-size: 0.875rem;
    }
}

/* Ensure images are responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive tables wrapper */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem -1rem;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .table-wrapper {
        margin: 0;
        padding: 0;
    }
}

/* Responsive code blocks */
pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-wrap: break-word;
    white-space: pre-wrap;
}

@media (max-width: 640px) {
    pre {
        font-size: 0.75rem;
        padding: 0.75rem;
    }
    
    pre code {
        font-size: 0.75rem;
    }
}

/* Card responsive improvements */
@media (max-width: 640px) {
    .bg-white.rounded-lg.shadow-md {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 0;
    }
    
    .bg-white.rounded-lg.shadow-md:first-child {
        border-radius: 0.5rem 0.5rem 0 0;
    }
    
    .bg-white.rounded-lg.shadow-md:last-child {
        border-radius: 0 0 0.5rem 0.5rem;
    }
}

/* Video responsive */
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Fix for iOS Safari viewport */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }

    html {
        height: -webkit-fill-available;
    }
}

/* Better scrolling on mobile */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Interactive elements mobile optimization */
@media (max-width: 768px) {
    /* Hide some elements on very small screens */
    #live-visitors {
        display: none !important;
    }

    /* Adjust notification position */
    #live-notification {
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        transform: translateX(0) !important;
        width: calc(100% - 20px);
        max-width: none;
        font-size: 0.875rem;
        padding: 10px 16px;
    }
}

/* Active states for touch devices */
@media (hover: none) and (pointer: coarse) {
    a:active,
    button:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    .mobile-dropdown-btn:active {
        background-color: #f3f4f6;
    }
}

/* Better scrollbar for mobile */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    nav {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

