/* Enhanced Responsive Styles for Sustainability Bootcamp Website */

/* ===== MOBILE-FIRST RESPONSIVE DESIGN ===== */

/* NTU Background Image Optimizations */
@media (max-width: 768px) {
    .ntu-bg-overlay {
        background-attachment: scroll !important;
    }
    
    .hero-pattern {
        background-attachment: scroll !important;
    }
    
    .gradient-bg {
        background-attachment: scroll !important;
    }
}

/* Professional backdrop enhancement for mobile */
@media (max-width: 640px) {
    .professional-backdrop {
        backdrop-filter: blur(10px);
        background: rgba(255,255,255,0.98);
    }
}

/* Extra small devices (phones, 320px and up) */
@media (max-width: 374px) {
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.1;
    }
    
    .hero-subtitle {
        font-size: 1.125rem !important;
    }
    
    .expert-card {
        margin: 0 -1rem;
    }
    
    .floating-elements {
        display: none; /* Hide floating elements on very small screens */
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 375px) and (max-width: 575px) {
    .nav-mobile {
        width: 280px;
    }
    
    .expert-card .flex {
        flex-direction: column;
        text-align: center;
    }
    
    .expert-card .flex-shrink-0 {
        margin-bottom: 1rem;
        align-self: center;
    }
    
    .schedule-item {
        padding: 1.5rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 576px) and (max-width: 767px) {
    .hero-pattern {
        background-size: 80px 80px, 60px 60px;
    }
    
    .expert-card {
        max-width: 500px;
        margin: 0 auto;
    }
    
    .grid.lg\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 768px) {
    .nav-mobile {
        display: none !important;
    }
    
    .floating-elements {
        display: block;
    }
    
    .expert-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .hero-pattern {
        background-size: 120px 120px, 100px 100px;
    }
    
    .floating-circle {
        animation-duration: 8s;
    }
}

/* ===== LANDSCAPE ORIENTATION OPTIMIZATIONS ===== */
@media (orientation: landscape) and (max-height: 500px) {
    .min-h-screen {
        min-height: 100vh;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
    
    .hero-title {
        font-size: 3rem !important;
    }
    
    .py-16 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .fixed,
    .nav-mobile,
    .floating-elements,
    .animate-bounce-gentle {
        display: none !important;
    }
    
    .gradient-bg {
        background: #059669 !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    
    .text-white {
        color: white !important;
    }
    
    .shadow-lg,
    .shadow-xl {
        box-shadow: none !important;
    }
    
    .rounded-2xl,
    .rounded-3xl {
        border-radius: 8px !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .bg-primary\\/10 {
        background-color: rgba(5, 150, 105, 0.2) !important;
    }
    
    .bg-secondary\\/10 {
        background-color: rgba(8, 145, 178, 0.2) !important;
    }
    
    .text-primary {
        color: #047857 !important;
        font-weight: 600;
    }
    
    .text-secondary {
        color: #0e7490 !important;
        font-weight: 600;
    }
    
    .border {
        border-width: 2px !important;
    }
}

/* ===== REDUCED MOTION PREFERENCES ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .floating-elements,
    .animate-bounce-gentle,
    .animate-fade-in-up {
        animation: none !important;
    }
    
    .card-hover:hover {
        transform: none !important;
    }
}

/* ===== COMIC BOOK THEME ENHANCEMENTS ===== */
.simple-border {
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.speech-bubble {
    position: relative;
    background: #fff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

/* Removed speech bubble tails for clean look */

/* ===== ENHANCED READABILITY ===== */
.text-gray-900 {
    color: #111827 !important;
    font-weight: 700;
}

.text-gray-800 {
    color: #1f2937 !important;
    font-weight: 600;
}

.text-gray-700 {
    color: #374151 !important;
    font-weight: 500;
}

/* ===== COMIC BOOK RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .simple-border {
        border-width: 1px !important;
        box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1) !important;
    }
    
    .text-shadow {
        text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    }
    
    .speech-bubble {
        border-width: 1px !important;
        border-radius: 8px !important;
        padding: 15px !important;
        box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Fix scroll indicator positioning on mobile */
    .animate-bounce-gentle {
        bottom: 1rem !important;
        transform: translateX(-50%) scale(0.8);
    }
}

/* ===== HERO SECTION BUTTON LAYOUT FIXES ===== */
@media (max-width: 640px) {
    .flex.flex-col.sm\\:flex-row {
        gap: 1rem;
        margin-bottom: 3rem; /* Add space above scroll indicator */
    }
    
    .animate-bounce-gentle {
        bottom: 0.5rem !important;
    }
}

/* ===== SCROLL INDICATOR ADJUSTMENTS ===== */
.animate-bounce-gentle {
    z-index: 20;
}

/* Ensure proper spacing in hero section */
#home .max-w-7xl {
    padding-bottom: 4rem;
}

/* ===== SIDE-BY-SIDE LAYOUT IMPROVEMENTS ===== */
/* About & Experts side-by-side layout */
@media (min-width: 1024px) {
    #about .grid.lg\\:grid-cols-2 {
        align-items: flex-start;
        gap: 3rem;
    }
}

@media (max-width: 1023px) {
    #about .grid.lg\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Stack experts vertically on smaller screens */
    #experts .space-y-8 {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }
}

/* Ensure expert cards are properly sized in the new layout */
#experts .space-y-8 > div {
    width: 100%;
}

/* Better responsive behavior for the combined section */
@media (max-width: 768px) {
    #about h2 {
        font-size: 2.5rem;
    }
    
    #experts h2 {
        font-size: 2.5rem;
    }
    
    .speech-bubble {
        font-size: 1rem;
        padding: 1rem;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) {
    .card-hover:hover {
        transform: none;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    }
    
    .expert-card:hover {
        transform: none;
    }
    
    /* Increase touch targets */
    .nav-link,
    button,
    a {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-menu-button {
        padding: 12px;
    }
}

/* ===== FOCUS STYLES FOR ACCESSIBILITY ===== */
*:focus {
    outline: 2px solid #059669;
    outline-offset: 2px;
}

.nav-link:focus,
button:focus,
a:focus {
    outline: 2px solid #059669;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== LOADING STATES ===== */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #059669;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #059669;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #047857;
}

/* ===== UTILITY CLASSES FOR RESPONSIVE BEHAVIOR ===== */
.responsive-text-sm {
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .responsive-text-sm {
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    .responsive-text-sm {
        font-size: 1.125rem;
    }
}

.responsive-padding {
    padding: 1rem;
}

@media (min-width: 640px) {
    .responsive-padding {
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .responsive-padding {
        padding: 2rem;
    }
}

/* ===== SAFE AREA SUPPORT FOR MOBILE DEVICES ===== */
@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .fixed.top-0 {
        padding-top: max(0px, env(safe-area-inset-top));
    }
    
    .fixed.bottom-6 {
        margin-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.will-change-transform {
    will-change: transform;
}

.will-change-scroll {
    will-change: scroll-position;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ===== FLEXIBLE GRID SYSTEM ===== */
.flexible-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

@media (max-width: 640px) {
    .flexible-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* ===== IMAGE OPTIMIZATION ===== */
img {
    max-width: 100%;
    height: auto;
    loading: lazy;
}

/* Background image performance optimization */
.ntu-bg-overlay {
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

/* High resolution display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .professional-backdrop {
        backdrop-filter: blur(20px);
    }
}

.expert-image {
    object-fit: cover;
    transition: transform 0.3s ease;
}

.expert-image:hover {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .expert-image:hover {
        transform: none;
    }
}