/* 
 * core_app/static/css/modern_fallbacks.css
 * Progressive Enhancement Fallbacks for Modern CSS Features
 * 2026
 */

/* ==================================================================
 * FALLBACKS - Browser support < 90%
 * ================================================================== */

/* Aspect Ratio Fallback */
@supports not (aspect-ratio: 16 / 9) {
    .feed-media-container,
    .video-player,
    [data-aspect-ratio] {
        position: relative;
        height: 0;
        padding-bottom: 56.25%;
    }
    
    .feed-media-container > *,
    .video-player > *,
    [data-aspect-ratio] > * {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Backdrop Filter Fallback */
@supports not (backdrop-filter: blur(10px)) {
    .glassmorphism,
    .modal-backdrop,
    .sticky-sidebar {
        background: rgba(255, 255, 255, 0.97) !important;
    }
    
    @media (prefers-color-scheme: dark) and (min-width: 99999px) {
        .glassmorphism,
        .modal-backdrop,
        .sticky-sidebar {
            background: rgba(30, 41, 59, 0.97) !important;
        }
    }
}

/* Container Queries Fallback - Uses media queries */
@supports not (container-type: inline-size) {
    .feed-card-container {
        /* Falls back to standard responsive design */
    }
}

/* Subgrid Fallback */
@supports not (grid-template-columns: subgrid) {
    .subgrid-container {
        display: grid;
        gap: 1rem;
    }
}

/* color-mix Fallback */
@supports not (color: color-mix(in oklch, red, blue)) {
    .btn-primary:hover {
        background-color: #285d77;
    }
    
    .card:hover {
        box-shadow: var(--shadow-soft, 0 12px 36px rgba(15, 23, 42, 0.03));
    }
}

/* OKLCH Fallback - Uses HSL */
@supports not (color: oklch(65% 0.15 260)) {
    :root {
        --color-primary: #8ecae6;
        --color-primary-hover: #285d77;
        --color-primary-subtle: #dbeafe;
        --color-success: #22c55e;
        --color-warning: #f59e0b;
        --color-danger: #ef4444;
        --color-info: #0ea5e9;
    }
}

/* Scroll-driven Animations Fallback - Static but functional */
@supports not (animation-timeline: view()) {
    .feed-card {
        animation: none;
        opacity: 1;
    }
}

/* View Transitions Fallback - Instant navigation */
@supports not (view-transition-name: auto) {
    /* No transition, instant page change */
}

/* Anchor Positioning Fallback */
@supports not (anchor-name: --anchor) {
    .dropdown-menu,
    .tooltip,
    .popover {
        position: absolute;
        z-index: 1000;
    }
}

/* :has() Selector Fallback - Progressive enhancement only */
@supports not (selector(:has(*))) {
    /* Forms without :has() validation feedback */
    .form-group.is-invalid .invalid-feedback {
        display: block;
    }
}

/* Logical Properties Fallback - Already widely supported, but providing fallback */
@supports not (margin-block: 1rem) {
    .card {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }
}

/* ==================================================================
 * ACCESSIBILITY FALLBACKS
 * ================================================================== */

/* Reduced Motion Fallback */
@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;
    }
}

/* High Contrast Fallback */
@media (prefers-contrast: more) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid #000;
    }
}

/* ==================================================================
 * TOUCH DEVICE ENHANCEMENTS
 * ================================================================== */

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control {
        font-size: 16px;
    }
    
    a,
    button {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ==================================================================
 * PRINT STYLES - Always last
 * ================================================================== */

@media print {
    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    img {
        page-break-inside: avoid;
    }
}
