/**
 * Accessibility Styles for Rivald Barber Theme
 */

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

.sr-only:focus {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: #405D86;
    color: #F8F7F3;
    border-radius: 0.25rem;
    z-index: 9999;
    text-decoration: none;
    font-weight: 600;
}

/* Focus indicators for better accessibility */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #405D86;
    outline-offset: 2px;
}

/* Ensure sufficient color contrast */
.text-secondary\/70 {
    color: rgba(64, 93, 134, 0.8);
}

.text-primary\/80 {
    color: rgba(248, 247, 243, 0.9);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .text-secondary\/70 {
        color: #405D86;
    }
    
    .text-primary\/80 {
        color: #F8F7F3;
    }
    
    .bg-secondary\/5 {
        background-color: rgba(64, 93, 134, 0.1);
    }
}

/* Reduced motion support */
@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;
    }
    
    .transition-all,
    .transition-colors,
    .transition-transform {
        transition: none !important;
    }
}

/* Focus visible for keyboard navigation */
.focus-visible:focus {
    outline: 2px solid #405D86;
    outline-offset: 2px;
}

/* Ensure interactive elements are keyboard accessible */
[role="button"],
[role="tab"],
[role="menuitem"] {
    cursor: pointer;
}

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

/* Ensure proper heading hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

/* Improve form accessibility */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea,
select {
    min-height: 44px;
    padding: 0.5rem;
    border: 1px solid #405D86;
    border-radius: 0.25rem;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    border-color: #405D86;
    box-shadow: 0 0 0 2px rgba(64, 93, 134, 0.2);
}

/* Ensure sufficient touch targets on mobile */
@media (max-width: 768px) {
    button,
    a,
    [role="button"],
    [role="tab"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Improve link underlines for better visibility */
a:not(.nav-link):not(.btn):hover {
    text-decoration: underline;
}

/* Ensure proper spacing for screen readers */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Improve modal accessibility */
[role="dialog"] {
    position: fixed;
    z-index: 1000;
}

[role="dialog"]:focus {
    outline: none;
}

/* Ensure proper list semantics */
ul, ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul[role="menubar"] {
    display: flex;
    flex-direction: row;
}

ul[role="menubar"] li {
    position: relative;
}

/* Improve button semantics */
button[type="button"],
button[type="submit"] {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

/* Ensure proper table accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #405D86;
}

th {
    font-weight: 600;
    background-color: rgba(64, 93, 134, 0.1);
}

/* Improve image accessibility */
img {
    max-width: 100%;
    height: auto;
}

img[alt=""] {
    border: 2px dashed #405D86;
}

/* Ensure full width and height for converted images */
picture {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

picture img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* Remove any unwanted borders or strokes */
img,
picture,
picture img {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Ensure proper image container sizing */
.w-full.h-full img,
.w-full.h-full picture {
    width: 100% !important;
    height: 100% !important;
}

/* Fix any line breaks or spacing issues */
picture {
    line-height: 0 !important;
    font-size: 0 !important;
}

picture img {
    vertical-align: top !important;
}

/* Additional image sizing fixes */
img[class*="w-full"],
img[class*="h-full"] {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Ensure all images in containers maintain full size */
.overflow-hidden img,
.overflow-hidden picture {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Remove any default image margins or padding */
img {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
}

/* Ensure proper image rendering */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* Fix any unwanted borders or outlines */
img,
picture,
picture img,
.w-full img,
.h-full img {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    stroke: none !important;
    stroke-width: 0 !important;
}

/* Ensure proper container sizing */
.col-span-3 img,
.col-span-2 img,
.col-span-4 img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Ensure proper landmark roles */
main[role="main"] {
    outline: none;
}

nav[role="navigation"] {
    outline: none;
}

header[role="banner"] {
    outline: none;
}

footer[role="contentinfo"] {
    outline: none;
}

/* Improve form fieldset and legend */
fieldset {
    border: 1px solid #405D86;
    border-radius: 0.25rem;
    padding: 1rem;
    margin: 1rem 0;
}

legend {
    font-weight: 600;
    padding: 0 0.5rem;
}

/* Ensure proper ARIA live regions */
[aria-live="polite"] {
    outline: none;
}

[aria-live="assertive"] {
    outline: none;
}

/* Improve progress indicators */
progress {
    width: 100%;
    height: 1rem;
    border: 1px solid #405D86;
    border-radius: 0.25rem;
}

progress::-webkit-progress-bar {
    background-color: rgba(64, 93, 134, 0.1);
    border-radius: 0.25rem;
}

progress::-webkit-progress-value {
    background-color: #405D86;
    border-radius: 0.25rem;
}

/* Ensure proper focus management for modals */
.modal-open {
    overflow: hidden;
}

/* Improve keyboard navigation for custom components */
[tabindex="-1"]:focus {
    outline: none;
}

[tabindex="0"]:focus {
    outline: 2px solid #405D86;
    outline-offset: 2px;
}
