/* =====================================================
   COMMUNITY ACCESSIBILITY - WCAG 2.1 AA Compliance
   Source: communitiesdesign/incontrol-community-li.html
   ===================================================== */

/* =====================================================
   SKIP LINK (WCAG 2.4.1)
   Copied exactly from reference: incontrol-community-li.html lines 2027-2044
   ===================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    z-index: 200;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 0.5rem 0;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.skip-link:focus {
    top: 0;
}

/* =====================================================
   SCREEN READER ONLY (WCAG 1.3.1)
   ===================================================== */

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

/* =====================================================
   FOCUS STYLES (WCAG 2.4.7)
   ===================================================== */

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

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

/* Enhanced focus for buttons */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(106, 74, 158, 0.2);
}

/* Focus within for complex components */
.post:focus-within,
.sidebar-card:focus-within {
    box-shadow: 0 0 0 3px rgba(106, 74, 158, 0.3);
}

/* =====================================================
   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;
    }

    .background-gradient {
        animation: none;
    }

    .me-notification-badge,
    .notification-bell {
        animation: none;
    }
}

/* =====================================================
   HIGH CONTRAST MODE (WCAG 1.4.11)
   ===================================================== */

@media (prefers-contrast: high) {
    :root {
        --text-secondary: var(--text-contrast-high);
        --glass-border: rgba(0, 0, 0, 0.3);
    }

    .post,
    .sidebar-card,
    .profile-card,
    .hot-topics,
    .create-post {
        border-width: 2px;
    }

    .filter-tab.active {
        border: 2px solid white;
    }
}

/* Windows High Contrast Mode */
@media (forced-colors: active) {
    *:focus-visible {
        outline-color: Highlight;
    }

    .filter-tab.active {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
    }

    .post-button,
    .follow-btn,
    .event-register-btn,
    .article-read-btn {
        forced-color-adjust: none;
        background: ButtonFace;
        color: ButtonText;
        border: 2px solid ButtonText;
    }
}

/* =====================================================
   FORM VALIDATION (WCAG 3.3.1)
   ===================================================== */

.error-message {
    color: var(--error);
    font-size: var(--font-size-xs);
    margin-top: 0.25rem;
    display: block;
    font-weight: 500;
}

.error-message:empty {
    display: none;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--error);
    border-width: 2px;
}

input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
    outline-color: var(--error);
    border-color: var(--error);
}

/* =====================================================
   TOUCH TARGETS (WCAG 2.5.5)
   Minimum 44x44px for all interactive elements
   ===================================================== */

button,
a,
[role="button"],
.nav-item,
.filter-tab,
.action-btn,
.post-option,
.mobile-nav-item {
    min-height: 44px;
    min-width: 44px;
}

/* Ensure adequate spacing between touch targets */
.post-actions {
    gap: 0.5rem;
}

/* NOTE: .nav gap is defined in header.css as 2rem per reference.
   Do NOT override it here - accessibility file should only ADD constraints,
   not replace layout properties. */

/* =====================================================
   COLOR CONTRAST HELPERS
   ===================================================== */

/* Ensure links are distinguishable */
a:not(.filter-tab):not(.nav-item):not(.mobile-nav-item):not(.topic-title) {
    text-decoration: underline;
}

a:hover {
    text-decoration: none;
}

/* Placeholder contrast */
::placeholder {
    color: var(--text-secondary);
    opacity: 1;
}

/* =====================================================
   KEYBOARD NAVIGATION
   ===================================================== */

/* Focus trap indicator for modals */
[aria-modal="true"] {
    isolation: isolate;
}

/* Tab order visual indicator */
[tabindex="-1"]:focus {
    outline: none;
}

/* =====================================================
   LIVE REGION FOR ANNOUNCEMENTS
   ===================================================== */

#sr-announcements {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =====================================================
   LINK UNDERLINES (WCAG 1.4.1)
   ===================================================== */

.post-text a,
.community-update a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.post-text a:hover,
.community-update a:hover {
    text-decoration-thickness: 2px;
}

/* =====================================================
   TEXT SPACING (WCAG 1.4.12)
   Content must remain accessible when:
   - Line height at least 1.5x font size
   - Paragraph spacing at least 2x font size
   - Letter spacing at least 0.12x font size
   - Word spacing at least 0.16x font size
   ===================================================== */

/* NOTE: .post-text and .community-update use line-height: 1.7 per reference file,
   which already exceeds WCAG 1.4.12 requirement of 1.5. Do not override here. */
.profile-title,
.member-role,
.event-details {
    line-height: 1.5;
    letter-spacing: 0.01em;
    word-spacing: 0.02em;
}

p + p {
    margin-top: 1em;
}

/* =====================================================
   RESIZE TEXT (WCAG 1.4.4)
   Content must remain readable at 200% zoom
   NOTE: Do NOT set html font-size here as it affects all rem values.
   The reference file uses browser default (16px) for consistency.
   ===================================================== */

/* =====================================================
   TARGET SIZE ENHANCEMENT
   ===================================================== */

/* Increase click area for small interactive elements */
.tag::before {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    bottom: -8px;
    left: -8px;
}

.tag {
    position: relative;
}
