/* ==========================================================================
   Accessibility & UX Improvements
   RentYourNest - WCAG 2.2 Compliant Styles
   ========================================================================== */

/* ==========================================================================
   1. FOCUS MANAGEMENT (WCAG 2.4.7)
   ========================================================================== */

/* High-visibility focus indicator for keyboard navigation */
:focus-visible {
    outline: 3px solid #0095c0;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Remove outline for mouse users, preserve for keyboard */
:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #0095c0;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 149, 192, 0.2);
}

/* Form elements focus enhancement */
input:focus,
select:focus,
textarea:focus {
    border-color: #0095c0;
    box-shadow: 0 0 0 3px rgba(0, 149, 192, 0.15);
}

/* ==========================================================================
   2. REDUCED MOTION (WCAG 2.3.3)
   ========================================================================== */

@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;
    }
    
    /* Disable background animations */
    .ryn-lazy-bg {
        animation: none !important;
    }
    
    /* Disable carousel animations */
    .ryn-city-carousel-track {
        scroll-behavior: auto !important;
    }
    
    /* Disable hover transforms */
    .ryn-city-slide:hover {
        transform: none !important;
    }
}

/* ==========================================================================
   3. HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
    /* Increase border visibility */
    .card,
    .btn,
    input,
    select,
    textarea {
        border-width: 2px !important;
    }
    
    /* Ensure sufficient contrast for text */
    .text-muted,
    .text-secondary {
        color: #333 !important;
    }
    
    /* Make focus indicators more prominent */
    :focus-visible {
        outline-width: 4px !important;
        outline-style: solid !important;
    }
    
    /* Enhance link visibility */
    a {
        text-decoration: underline !important;
    }
}

/* ==========================================================================
   4. COLOR CONTRAST FIXES (WCAG 1.4.3)
   ========================================================================== */

/* Ensure minimum 4.5:1 contrast ratio for normal text */
.text-muted {
    color: #5a6268 !important; /* Improved from default Bootstrap #6c757d */
}

/* Better contrast for secondary text */
.text-secondary {
    color: #495057 !important;
}

/* Placeholder text contrast */
::placeholder {
    color: #6b7280;
    opacity: 1;
}

/* ==========================================================================
   5. TOUCH TARGET SIZE (WCAG 2.5.5)
   ========================================================================== */

/* Minimum 44x44px touch targets for mobile */
@media (pointer: coarse) {
    button,
    a.btn,
    .nav-link,
    .dropdown-item,
    input[type="checkbox"],
    input[type="radio"],
    .ryn-tag-btn,
    .ryn-nav-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Increase padding for touch targets */
    .nav-link {
        padding: 12px 16px;
    }
    
    .dropdown-item {
        padding: 14px 20px;
    }
    
    /* Larger checkbox/radio hit areas */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
    }
}

/* ==========================================================================
   6. SCREEN READER ONLY UTILITIES
   ========================================================================== */

/* Enhanced visually-hidden class */
.visually-hidden,
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focusable when reached via keyboard */
.visually-hidden-focusable:focus,
.visually-hidden-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ==========================================================================
   7. SKIP LINKS (WCAG 2.4.1)
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: #0095c0;
    color: #fff;
    padding: 12px 24px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    border-radius: 0 0 8px 8px;
    transition: top 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #f4971e;
    outline-offset: 2px;
}

/* ==========================================================================
   8. LOADING & STATUS INDICATORS
   ========================================================================== */

/* Accessible loading spinner */
.spinner-border {
    border-width: 4px;
}

/* Live region styles */
[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* Status badge improvements */
.ryn-badge-featured {
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
}

/* ==========================================================================
   9. FORM ACCESSIBILITY
   ========================================================================== */

/* Error states */
.is-invalid,
input:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* Success states */
.is-valid,
input:valid:not(:placeholder-shown) {
    border-color: #198754;
}

/* Required field indicator */
label.required::after,
.form-label.required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Disabled state improvements */
:disabled,
[disabled],
.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   10. RESPONSIVE TYPOGRAPHY
   ========================================================================== */

/* Minimum text size for readability */
html {
    font-size: 100%; /* Respect user font size preferences */
}

body {
    font-size: 1rem;
    line-height: 1.6;
}

/* Scalable text that respects user preferences */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Prevent text from being too small on any device */
@media screen and (max-width: 320px) {
    body {
        font-size: 14px;
    }
}

/* ==========================================================================
   11. MODAL ACCESSIBILITY
   ========================================================================== */

/* Modal backdrop - ensure modal traps focus */
.ryn-filters-modal[aria-modal="true"] {
    /* When modal is open, ensure it's the only focusable area */
    isolation: isolate;
}

/* Modal close button accessibility */
.ryn-close-modal {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.ryn-close-modal:focus-visible {
    outline: 3px solid #0095c0;
    outline-offset: 2px;
}

/* ==========================================================================
   12. CARD COMPONENT ACCESSIBILITY
   ========================================================================== */

/* Property cards */
.ryn-listing-card {
    position: relative;
}

/* Ensure entire card is clickable via primary link */
.ryn-listing-card-link {
    display: block;
}

/* Definition list styling for property details */
.ryn-listing-card dl.info1sub {
    display: flex;
    gap: 16px;
    margin: 0;
}

.ryn-listing-card dl.info1sub dt {
    /* Visually hidden but accessible */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.ryn-listing-card dl.info1sub dd {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   13. PRINT STYLES
   ========================================================================== */

@media print {
    /* Hide non-essential elements */
    .skip-link,
    .navbar,
    footer,
    .ryn-filters-modal,
    .btn,
    video,
    audio {
        display: none !important;
    }
    
    /* Ensure good contrast */
    body {
        color: #000 !important;
        background: #fff !important;
    }
    
    /* Show link URLs */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    /* Avoid page breaks in cards */
    .ryn-listing-card {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   14. IMAGE PLACEHOLDER STYLES
   ========================================================================== */

/* Placeholder image styling when original fails to load */
.ryn-img-placeholder {
    object-fit: contain !important;
    background-color: #f8f9fa;
    padding: 1rem;
}

/* Ensure placeholder fills the container properly */
.ryn-property-gallery-img.ryn-img-placeholder,
.ryn-detail-carousel01-img.ryn-img-placeholder {
    width: 100%;
    height: 100%;
    min-height: 200px;
}

/* Compare page image container adjustments */
.ryn-compare-property-gallery-img {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ryn-compare-property-gallery-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ryn-compare-property-gallery-img img.ryn-img-placeholder {
    object-fit: contain;
    padding: 1rem;
}

/* Lightbox placeholder */
.ryn-detail-lightbox img.ryn-img-placeholder {
    max-width: 80vw;
    max-height: 80vh;
    background-color: #fff;
}

/* ==========================================================================
   15. DARK MODE SUPPORT (Future-proofing)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Placeholder for future dark mode implementation */
    /* This ensures the site respects system preferences when implemented */
}
