/* ==================== MOBILE RESPONSIVENESS & OPTIMIZATION ==================== */

/* Research Section Mobile Responsiveness */
@media (max-width: 1024px) {
    .research-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 25px;
    }
}

@media (max-width: 768px) {
    /* Research Section */
    .research-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .research-card {
        padding: 25px;
    }
    
    .research-title {
        font-size: 1.3rem;
    }
    
    .research-card-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .research-btn {
        width: 100%;
    }
    
    /* Research Modal */
    .research-modal-content {
        margin: 10px;
        max-height: 90vh;
        border-radius: 16px;
    }
    
    .research-modal-header,
    .research-modal-body {
        padding: 20px;
    }
    
    .research-modal-header h2 {
        font-size: 1.4rem;
    }
    
    .research-modal-footer {
        padding: 15px 20px 20px;
    }
    
    /* Wave Dividers - Reduce height on mobile */
    .wave-divider svg {
        height: 50px;
    }
    
    /* Reduce section padding */
    .research {
        padding: 60px 0;
    }
    
    /* Glassmorphic effects - lighter on mobile */
    .research-card,
    .project-card,
    .course-card,
    .certification-card {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

@media (max-width: 480px) {
    .research-card {
        padding: 20px;
    }
    
    .research-title {
        font-size: 1.2rem;
    }
    
    .research-field-badge {
        font-size: 0.7rem;
        padding: 5px 12px;
    }
    
    .research-description {
        font-size: 0.9rem;
    }
    
    .research-topic-tag {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    
    .research-modal-header h2 {
        font-size: 1.2rem;
        padding-right: 40px;
    }
    
    .research-modal-close {
        width: 36px;
        height: 36px;
        top: 15px;
        right: 15px;
    }
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */

/* Reduce animations on low-end devices */
@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;
    }
    
    .research-card:hover,
    .project-card:hover,
    .course-card:hover {
        transform: none !important;
    }
}

/* Optimize for touch devices */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .research-card:hover,
    .project-card:hover,
    .course-card:hover,
    .certification-card:hover {
        transform: none;
        box-shadow: var(--glass-shadow);
    }
    
    /* Larger touch targets */
    .research-btn,
    .btn {
        min-height: 44px;
        padding: 12px 24px;
    }
    
    .nav-link {
        padding: 12px 20px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .research-card,
    .project-card,
    .course-card,
    .certification-card {
        border: 2px solid var(--border-color);
    }
    
    .research-field-badge {
        border: 2px solid currentColor;
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
    }
}

/* Print styles */
@media print {
    .navbar,
    .preloader,
    .wave-divider,
    .hero-blobs,
    .ambient-particles,
    .scroll-progress {
        display: none !important;
    }
    
    .research-card,
    .project-card,
    .course-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ==================== ACCESSIBILITY ENHANCEMENTS ==================== */

/* Focus visible styles */
.research-btn:focus-visible,
.research-card:focus-visible,
.nav-link:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

/* Skip to content link */
.skip-to-content:focus {
    top: 0;
    z-index: 10001;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Ensure sufficient color contrast */
.research-topic-tag,
.research-skill-badge {
    font-weight: 500;
}

/* Keyboard navigation indicators */
.research-modal-overlay:focus-within .research-modal-content {
    box-shadow: 0 0 0 3px var(--primary-color);
}

/* ==================== LOADING STATES ==================== */

/* Skeleton loading optimization */
.skeleton-card {
    contain: layout style paint;
}

/* Lazy loading images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ==================== BROWSER COMPATIBILITY ==================== */

/* 
 * Fallback for browsers that don't support backdrop-filter.
 * Uses @supports to detect feature availability and applies
 * a solid background as fallback when blur is not supported.
 */

/* Apply backdrop-filter when supported (modern browsers) */
@supports (backdrop-filter: blur(10px)) {
    .research-card,
    .project-card,
    .course-card,
    .certification-card {
        backdrop-filter: blur(var(--glass-blur));
        -webkit-backdrop-filter: blur(var(--glass-blur));
    }
}

/* Fallback for browsers without backdrop-filter support (e.g., older Firefox) */
@supports not (backdrop-filter: blur(10px)) {
    .research-card,
    .project-card,
    .course-card,
    .certification-card {
        background: rgba(30, 41, 59, 0.95);
    }
    
    [data-theme="light"] .research-card,
    [data-theme="light"] .project-card,
    [data-theme="light"] .course-card,
    [data-theme="light"] .certification-card {
        background: rgba(255, 255, 255, 0.95);
    }
}
