/* =================================================================
   NSEMM CLEAN ACCESSIBILITY STYLES
================================================================= */

/* =================================================================
   SKIP LINKS - ESSENTIAL FOR KEYBOARD NAVIGATION
================================================================= */
.nsemm-skip-links {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;
    width: 100%;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--university-blue);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    transition: all 0.3s ease;
    z-index: 999999;
    font-family: 'Readex Pro', sans-serif;
}

.skip-link:focus {
    left: 0;
    clip: auto;
    width: auto;
    height: auto;
    overflow: visible;
    outline: 3px solid var(--knowledge-gold);
    outline-offset: 2px;
}

.skip-link:hover {
    background: var(--knowledge-gold);
    color: var(--foundational-brown);
}

/* =================================================================
   ENHANCED FOCUS MANAGEMENT
================================================================= */

/* Enhanced focus for keyboard users */
.nsemm-keyboard-user *:focus {
    outline: 3px solid var(--knowledge-gold) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 8px rgba(250, 205, 0, 0.3) !important;
}

/* Better focus for navigation */
.nsemm-keyboard-user .main-navigation a:focus,
.nsemm-keyboard-user .utility-link:focus {
    background: var(--coastal-green) !important;
    color: var(--university-blue) !important;
    outline: 3px solid var(--knowledge-gold) !important;
    outline-offset: 2px !important;
}

/* Form focus enhancement */
.nsemm-keyboard-user input:focus,
.nsemm-keyboard-user textarea:focus,
.nsemm-keyboard-user select:focus {
    outline: 3px solid var(--knowledge-gold) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 8px rgba(250, 205, 0, 0.3) !important;
    border-color: var(--university-blue) !important;
}

/* Button focus enhancement */
.nsemm-keyboard-user button:focus,
.nsemm-keyboard-user .btn:focus,
.nsemm-keyboard-user .header-cta-btn:focus {
    outline: 3px solid var(--knowledge-gold) !important;
    outline-offset: 3px !important;
    transform: translateY(-1px) !important;
}

/* =================================================================
   USER PREFERENCE SUPPORT
================================================================= */

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

.nsemm-reduce-motion *,
.nsemm-reduce-motion *::before,
.nsemm-reduce-motion *::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

/* High Contrast Auto Mode */
@media (prefers-contrast: high) {
    :root {
        --university-blue: #000080;
        --knowledge-gold: #FFD700;
        --midnight: #000000;
        --coastal-green: #90EE90;
    }

    .site-header,
    .utility-bar,
    .main-navigation a,
    .utility-link,
    button,
    .btn {
        border: 2px solid currentColor !important;
    }
}

.nsemm-high-contrast-auto {
    filter: contrast(150%);
}

/* =================================================================
   TARGETED DARK MODE SUPPORT
================================================================= */


/* Custom Font Size Support */
.nsemm-custom-font-size {
    font-size: calc(1rem * var(--font-scale, 1));
}

.nsemm-custom-font-size h1 { font-size: calc(3.5rem * var(--font-scale, 1)); }
.nsemm-custom-font-size h2 { font-size: calc(2.5rem * var(--font-scale, 1)); }
.nsemm-custom-font-size h3 { font-size: calc(1.8rem * var(--font-scale, 1)); }
.nsemm-custom-font-size h4 { font-size: calc(1.4rem * var(--font-scale, 1)); }
.nsemm-custom-font-size h5 { font-size: calc(1.2rem * var(--font-scale, 1)); }
.nsemm-custom-font-size h6 { font-size: calc(1rem * var(--font-scale, 1)); }

/* Enhanced Focus Mode */
.nsemm-enhanced-focus *:focus {
    outline: 4px solid #ffff00 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5) !important;
    background: rgba(255, 255, 0, 0.1) !important;
}

/* =================================================================
   IMPROVED ACCESSIBILITY FOR EXISTING ELEMENTS
================================================================= */

/* Better link accessibility - only for content links, not navigation */
.content-area a:not(.btn):not(.header-cta-btn):not(.utility-cta-btn):not(.skip-link):not(.footer-menu-list a):not(.main-navigation a):not(.utility-link):not(.custom-logo-link) {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.content-area a:not(.btn):not(.header-cta-btn):not(.utility-cta-btn):not(.skip-link):not(.footer-menu-list a):not(.main-navigation a):not(.utility-link):not(.custom-logo-link):hover {
    text-decoration-thickness: 2px;
    background: rgba(250, 205, 0, 0.1);
    padding: 1px 2px;
    border-radius: 2px;
}

a:not(.btn):not(.header-cta-btn):not(.utility-cta-btn):not(.skip-link):not(.custom-logo-link):focus {
    background: var(--coastal-green);
    color: var(--university-blue);
    padding: 2px 4px;
    border-radius: 4px;
    outline: 2px solid var(--knowledge-gold);
    outline-offset: 2px;
}

/* Current page indication - exclude logo and image links */
a[aria-current="page"]:not(.custom-logo-link):not([class*="logo"]) {
    /* background: var(--knowledge-gold); */
    /* color: var(--foundational-brown); */
    /* padding: 2px 4px; */
    /* border-radius: 4px; */
    font-weight: 600;
}

/* Better button accessibility */
button,
.btn,
.header-cta-btn,
input[type="submit"],
input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
}

/* Utility buttons are smaller by design */
.utility-cta-btn {
    min-height: auto;
    min-width: auto;
    cursor: pointer;
}

button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Form accessibility improvements */
input,
textarea,
select {
    font-size: inherit;
    line-height: 1.5;
    padding: var(--spacing-sm);
    border: 2px solid var(--serenity-slate);
    border-radius: 4px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--university-blue);
    box-shadow: 0 0 5px rgba(28, 59, 112, 0.3);
    outline: 2px solid var(--knowledge-gold);
    outline-offset: 2px;
}

input:invalid,
textarea:invalid {
    border-color: #d32f2f;
}

input:invalid:focus,
textarea:invalid:focus {
    outline-color: #d32f2f;
    box-shadow: 0 0 5px rgba(211, 47, 47, 0.3);
}

/* Label accessibility */
label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
    color: var(--midnight);
}

label[for] {
    cursor: pointer;
}

/* Required field indication */
.required::after,
[required] + label::after,
label.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
}

/* Error message styling */
.error-message,
.field-error,
[role="alert"] {
    color: #d32f2f;
    font-weight: 600;
    margin-top: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: #ffebee;
    border-left: 4px solid #d32f2f;
    border-radius: 4px;
}

/* Success message styling */
.success-message,
[role="status"] {
    color: #2e7d32;
    font-weight: 600;
    margin-top: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: #e8f5e8;
    border-left: 4px solid #2e7d32;
    border-radius: 4px;
}

/* Table accessibility */
table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--spacing-lg) 0;
}

th {
    text-align: left;
    background: var(--university-blue);
    color: white;
    padding: var(--spacing-md);
    font-weight: 600;
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--coastal-green);
}

tr:nth-child(even) {
    background: var(--coastal-green);
}

tr:hover {
    background: rgba(250, 205, 0, 0.1);
}

th[scope="col"] {
    background: var(--university-blue);
}

th[scope="row"] {
    background: var(--coastal-green);
    color: var(--midnight);
    font-weight: 600;
}

/* Better list accessibility */
ul,
ol {
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-xl);
}

li {
    margin-bottom: var(--spacing-sm);
    line-height: 1.6;
}

ul li::marker {
    color: var(--knowledge-gold);
}

ol li::marker {
    color: var(--university-blue);
    font-weight: 600;
}

/* Description list accessibility */
dl {
    margin: var(--spacing-lg) 0;
}

dt {
    font-weight: 600;
    color: var(--university-blue);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-xs);
}

dd {
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    color: var(--midnight);
}

/* Heading accessibility */
h1, h2, h3, h4, h5, h6 {
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-md);
    line-height: 1.3;
    color: var(--university-blue);
}

h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
    margin-top: 0;
}

h1:focus,
h2:focus,
h3:focus,
h4:focus,
h5:focus,
h6:focus {
    outline: 2px solid var(--knowledge-gold);
    outline-offset: 2px;
}

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

img:not([alt]) {
    border: 3px solid #d32f2f;
    filter: grayscale(100%);
}

figure {
    margin: var(--spacing-lg) 0;
}

figcaption {
    font-style: italic;
    color: var(--midnight);
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
}

/* Video accessibility */
video {
    max-width: 100%;
    height: auto;
}

/* Audio accessibility */
audio {
    width: 100%;
    margin: var(--spacing-md) 0;
}

/* =================================================================
   NAVIGATION ACCESSIBILITY ENHANCEMENTS
================================================================= */

/* Breadcrumb navigation */
.breadcrumb,
nav[aria-label*="breadcrumb"] {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm) 0;
}

.breadcrumb ol,
nav[aria-label*="breadcrumb"] ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin: 0;
    padding: 0;
}

.breadcrumb li::after,
nav[aria-label*="breadcrumb"] li::after {
    content: ">";
    margin-left: var(--spacing-sm);
    color: var(--serenity-slate);
}

.breadcrumb li:last-child::after,
nav[aria-label*="breadcrumb"] li:last-child::after {
    display: none;
}

/* Pagination navigation */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-xl) 0;
}

.pagination a,
.pagination span {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--university-blue);
    color: var(--university-blue);
    text-decoration: none;
    border-radius: 4px;
    min-width: 44px;
    text-align: center;
    transition: all 0.3s ease;
}

.pagination a:hover,
.pagination a:focus {
    background: var(--university-blue);
    color: white;
}

.pagination .current {
    background: var(--knowledge-gold);
    color: var(--foundational-brown);
    border-color: var(--knowledge-gold);
}

/* =================================================================
   CONTENT ACCESSIBILITY IMPROVEMENTS
================================================================= */

/* Blockquote accessibility */
blockquote {
    margin: var(--spacing-xl) 0;
    padding: var(--spacing-lg);
    border-left: 4px solid var(--knowledge-gold);
    background: var(--coastal-green);
    font-style: italic;
    position: relative;
}

blockquote::before {
    content: """;
    font-size: 3rem;
    color: var(--knowledge-gold);
    position: absolute;
    top: -10px;
    left: var(--spacing-md);
    font-family: 'Sora', sans-serif;
    opacity: 0.5;
}

blockquote p {
    margin-bottom: 0;
    color: var(--university-blue);
}

blockquote cite {
    display: block;
    margin-top: var(--spacing-md);
    font-style: normal;
    font-weight: 600;
    color: var(--midnight);
}

blockquote cite::before {
    content: "— ";
}

/* Code accessibility */
code {
    background: var(--coastal-green);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--university-blue);
}

pre {
    background: var(--coastal-green);
    padding: var(--spacing-md);
    border-radius: 8px;
    overflow-x: auto;
    margin: var(--spacing-lg) 0;
    border-left: 4px solid var(--knowledge-gold);
}

pre code {
    background: none;
    padding: 0;
}

/* Abbreviation accessibility */
abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
    border-bottom: 1px dotted currentColor;
}

/* Mark/highlight accessibility */
mark {
    background: var(--knowledge-gold);
    color: var(--foundational-brown);
    padding: 1px 2px;
    border-radius: 2px;
}

/* =================================================================
   RESPONSIVE ACCESSIBILITY
================================================================= */

/* Mobile touch targets */
@media (max-width: 768px) {
    button,
    .btn,
    .header-cta-btn,
    input[type="submit"],
    input[type="button"],
    a {
        min-height: 48px;
        min-width: 48px;
    }

    /* Utility buttons stay smaller on mobile */
    .utility-cta-btn {
        min-height: auto;
        min-width: auto;
    }

    .main-navigation a,
    .utility-link {
        padding: var(--spacing-md);
        display: block;
    }

    /* Larger text for better readability */
    body {
        font-size: 1.1rem;
        line-height: 1.6;
    }

    /* Better spacing for touch */
    input,
    textarea,
    select {
        padding: var(--spacing-md);
        font-size: 1rem;
    }
}

/* =================================================================
   SCREEN READER ACCESSIBILITY
================================================================= */

/* Screen reader only content */
.screen-reader-text,
.sr-only,
.visually-hidden {
    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;
}

.screen-reader-text:focus,
.sr-only:focus,
.visually-hidden:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: var(--spacing-sm) var(--spacing-md) !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background: var(--knowledge-gold) !important;
    color: var(--foundational-brown) !important;
    border: 2px solid var(--university-blue) !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    z-index: 999999 !important;
}

/* Live regions for dynamic content */
[aria-live="polite"],
[aria-live="assertive"],
[role="status"],
[role="alert"] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* When they have content, make them visible to screen readers */
[aria-live="polite"]:not(:empty),
[aria-live="assertive"]:not(:empty),
[role="status"]:not(:empty),
[role="alert"]:not(:empty) {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
}

/* =================================================================
   PRINT ACCESSIBILITY
================================================================= */

@media print {
    /* Ensure good contrast in print */
    * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    /* Show URLs for links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Show alt text for images */
    img:after {
        content: " (Alt: " attr(alt) ")";
        font-size: 0.8em;
        color: #666;
        display: block;
    }

    /* Better page breaks */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    img, table, figure {
        page-break-inside: avoid;
    }

    /* Hide non-essential elements */
    .skip-link,
    .screen-reader-text,
    nav,
    .pagination {
        display: none !important;
    }
}

/* =================================================================
   ACCESSIBILITY TESTING HELPERS (Development only)
================================================================= */

/* Uncomment these for accessibility testing */
/*
img:not([alt]) {
    border: 5px solid red !important;
}

a:not([href]) {
    background: red !important;
    color: white !important;
}

button:not([aria-label]):not([aria-labelledby]):empty {
    background: orange !important;
}

input:not([aria-label]):not([aria-labelledby]):not([id]) {
    border: 3px solid orange !important;
}

[role="button"]:not([tabindex]) {
    outline: 3px solid purple !important;
}
*/

/* =================================================================
   FORCED COLORS MODE SUPPORT (Windows High Contrast)
================================================================= */

@media (forced-colors: active) {
    .skip-link {
        forced-color-adjust: none;
        background: ButtonText;
        color: ButtonFace;
        border: 1px solid ButtonBorder;
    }

    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
        border: 1px solid ButtonBorder;
    }

    input,
    textarea,
    select {
        border: 1px solid ButtonBorder;
        background: Field;
        color: FieldText;
    }

    a {
        color: LinkText;
    }

    a:hover,
    a:focus {
        background: Highlight;
        color: HighlightText;
    }
}

/* =================================================================
   INTEGRATION WITH EXISTING NSEMM THEME
================================================================= */

/* Ensure skip links appear above floating header */
.nsemm-skip-links {
    z-index: 999999;
}

/* Adjust for existing header heights */
.skip-link:focus {
    top: 0;
    position: fixed;
}

/* Ensure accessibility features work with existing components */
.nsemm-keyboard-user .site-header a:focus,
.nsemm-keyboard-user .utility-bar a:focus {
    background: var(--coastal-green) !important;
    color: var(--university-blue) !important;
}

/* Make sure current page indicators work with existing navigation - exclude logo */
.main-navigation a[aria-current="page"]:not(.custom-logo-link),
.utility-bar a[aria-current="page"]:not(.custom-logo-link) {
    /* background: var(--knowledge-gold) !important; */
    /* color: var(--foundational-brown) !important; */
    font-weight: 600 !important;
}

/* Ensure form accessibility works with existing forms */
.entry-content input,
.entry-content textarea,
.entry-content select {
    border: 2px solid var(--serenity-slate);
    border-radius: 4px;
    padding: var(--spacing-sm);
    font-size: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.entry-content input:focus,
.entry-content textarea:focus,
.entry-content select:focus {
    border-color: var(--university-blue);
    outline: 2px solid var(--knowledge-gold);
    outline-offset: 2px;
    box-shadow: 0 0 5px rgba(28, 59, 112, 0.3);
}

/* =================================================================
   ACCESSIBILITY ANNOUNCEMENT REGION
================================================================= */

#nsemm-a11y-announcer {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* =================================================================
   BETTER SEMANTIC MARKUP SUPPORT
================================================================= */

/* Landmark roles styling */
main {
    display: block;
}

nav {
    display: block;
}

section {
    display: block;
}

article {
    display: block;
}

aside {
    display: block;
}

header {
    display: block;
}

footer {
    display: block;
}

/* Better definition for main content */
main:focus {
    outline: 2px solid var(--knowledge-gold);
    outline-offset: 2px;
}

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

[role="button"]:not([tabindex]),
[role="link"]:not([tabindex]),
[role="tab"]:not([tabindex]),
[role="menuitem"]:not([tabindex]) {
    tabindex: 0;
}

/* Style for disabled elements */
[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Style for expanded/collapsed states */
[aria-expanded="false"] {
    /* Collapsed state styling if needed */
}

[aria-expanded="true"] {
    /* Expanded state styling if needed */
}

/* Style for selected states */
[aria-selected="true"] {
    background: var(--knowledge-gold);
    color: var(--foundational-brown);
    font-weight: 600;
}

/* Style for pressed states */
[aria-pressed="true"] {
    background: var(--university-blue);
    color: white;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}