/**
 * Accessibility improvements for Flex Content Block
 * 
 * This file contains CSS improvements to enhance accessibility
 * for screen readers and keyboard navigation.
 */

/* Screen reader only text - visible to screen readers but hidden visually */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}

/* Skip to content link for keyboard navigation */
.skip-link {
    background-color: #000;
    color: #fff;
    display: block;
    left: -9999px;
    outline: none;
    padding: 8px 16px;
    position: absolute;
    text-decoration: none;
    top: -9999px;
    z-index: 999999;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
}

/* Enhanced focus styles for better visibility */
.flex-content-button:focus,
.content-button:focus,
a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* High contrast focus for Windows High Contrast mode */
@media screen and (-ms-high-contrast: active) {
    .flex-content-button:focus,
    .content-button:focus,
    a:focus {
        outline: 2px solid ButtonText;
    }
}

/* Ensure good color contrast for text */
.wp-block-flex-content-block-flex-content .flex-content-content {
    color: #1e1e1e; /* High contrast text */
}

.wp-block-flex-content-block-flex-content.bg-light-gray .flex-content-content {
    color: #1e1e1e; /* Ensure good contrast on light gray background */
}

.wp-block-flex-content-block-flex-content.bg-green .flex-content-content {
    color: #ffffff; /* White text on green background */
}

/* Button contrast improvements */
.flex-content-button,
.content-button {
    background-color: #0073aa;
    color: #ffffff;
    border: 1px solid #0073aa;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.flex-content-button:hover,
.content-button:hover {
    background-color: #005177;
    border-color: #005177;
    color: #ffffff;
}

.flex-content-button:focus,
.content-button:focus {
    background-color: #005177;
    border-color: #005177;
    color: #ffffff;
}

/* Ensure keyboard navigation works for interactive elements */
.content-block {
    position: relative;
}

/* Make cards keyboard accessible */
.content-block:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Motion preferences - reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .flex-content-button,
    .content-button,
    .content-block {
        transition: none;
    }
    
    .content-block:hover,
    .content-block:focus-within {
        transform: none;
    }
}

/* Improved spacing for touch targets */
.flex-content-button,
.content-button {
    min-height: 44px; /* WCAG AAA minimum touch target size */
    padding: 12px 24px;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
}

/* Ensure text remains readable when zoomed to 200% */
.flex-content-headline,
.flex-content-subline,
.block-title {
    word-wrap: break-word;
    hyphens: auto;
}

/* Better spacing for content sections */
.flex-content-content > * + * {
    margin-top: 1em;
}

.block-content > * + * {
    margin-top: 0.75em;
}

/* Ensure images don't break layout when text is enlarged */
.flex-content-image img {
    max-width: 100%;
    height: auto;
}

/* Provide visual indication for image overlays */
.image-overlay[aria-hidden="true"] {
    pointer-events: none;
}

/* Improve visibility of focus indicators in high contrast mode */
@media screen and (-ms-high-contrast: active) {
    .flex-content-button,
    .content-button {
        border: 1px solid ButtonText;
    }
    
    .flex-content-button:focus,
    .content-button:focus {
        outline: 2px solid ButtonText;
        outline-offset: 2px;
    }
}

/* Ensure proper heading hierarchy styling */
.flex-content-headline {
    font-weight: 600;
    line-height: 1.2;
}

.flex-content-subline {
    font-weight: 400;
    opacity: 0.8;
    line-height: 1.3;
}

.block-title {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

/* Content block grid improvements */
.content-blocks-grid[role="list"] {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Ensure proper focus order for grid items */
.content-block[role="listitem"] {
    display: flex;
    flex-direction: column;
}

/* Icon accessibility improvements */
.block-icon[aria-hidden="true"] svg {
    pointer-events: none;
}

/* Make sure decorative elements don't interfere with screen readers */
.image-overlay[aria-hidden="true"],
.block-icon[aria-hidden="true"] {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Print styles for accessibility */
@media print {
    .screen-reader-text {
        clip: auto !important;
        clip-path: none;
        height: auto;
        margin: 0;
        overflow: visible;
        position: static !important;
        width: auto;
    }
    
    .flex-content-button,
    .content-button {
        background: none;
        color: #000;
        text-decoration: underline;
    }
    
    .flex-content-button::after,
    .content-button::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}