/* WS WCAG Tools CSS */

/* Skip Link */
.ws-wcag-skip-link {
    position: absolute;
    top: -9999px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 10px 20px;
    z-index: 999999;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #fff;
}
.ws-wcag-skip-link:focus {
    top: 0;
}

/* Toggle Button */
#ws-wcag-container {
    position: fixed;
    z-index: 99999;
}
#ws-wcag-container.ws-wcag-right {
    right: 0;
}
#ws-wcag-container.ws-wcag-left {
    left: 0;
}

#ws-wcag-toggle {
    background-color: var(--ws-wcag-color, #0055aa);
    color: #fff;
    border: none;
    border-radius: 4px 0 0 4px;
    padding: 10px;
    cursor: pointer;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.2);
    transition: opacity 0.3s, visibility 0.3s, right 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* Ensure it can be positioned if needed, though we use opacity now */
}
#ws-wcag-container.ws-wcag-left #ws-wcag-toggle {
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

#ws-wcag-toggle:hover, #ws-wcag-toggle:focus {
    filter: brightness(0.9);
    outline: 2px solid #ffcc00;
}

/* Panel */
#ws-wcag-panel {
    position: fixed;
    right: 0;
    width: 300px !important;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 4px 0 0 4px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
}

#ws-wcag-panel.ws-hidden {
    display: none !important;
}

#ws-wcag-panel * {
    box-sizing: border-box;
}

#ws-wcag-container.ws-wcag-left #ws-wcag-panel {
    right: auto;
    left: 0;
    border-radius: 0 4px 4px 0;
    transform: translateX(-100%);
}

#ws-wcag-container.ws-wcag-left #ws-wcag-panel.ws-visible {
    transform: translateX(0);
}

#ws-wcag-panel.ws-visible {
    transform: translateX(0);
}

.ws-hidden {
    display: none; /* Fallback */
}

/* Header */
.ws-wcag-header {
    background-color: var(--ws-wcag-color, #0055aa);
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ws-wcag-header h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
    font-weight: bold;
}

#ws-wcag-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
}

/* Grid */
.ws-wcag-grid {
    padding: 15px;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Buttons */
.ws-wcag-btn {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 80px !important; /* Ensure visibility */
    box-sizing: border-box !important;
}

.ws-wcag-btn:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: #eef4ff;
    border-color: var(--ws-wcag-color, #0055aa);
    color: var(--ws-wcag-color, #0055aa);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.ws-wcag-btn:active:not(:disabled):not([aria-disabled="true"]) {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12);
}

.ws-wcag-btn.active {
    background-color: var(--ws-wcag-color, #0055aa);
    border-color: var(--ws-wcag-color, #0055aa);
    color: #fff;
}

.ws-wcag-btn.active .ws-icon,
.ws-wcag-btn.active .ws-label {
    color: inherit;
}

.ws-wcag-btn:focus {
    outline: 3px solid #ffcc00;
    outline-offset: 2px;
}

.ws-wcag-btn:disabled,
.ws-wcag-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ... existing hover styles ... */

.ws-wcag-btn.wcag-full-width,
.ws-wcag-btn[data-action="reset"] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    background-color: #fff !important;
    border: 2px solid var(--ws-wcag-color, #0055aa) !important;
    color: var(--ws-wcag-color, #0055aa) !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    min-height: 50px !important;
    margin-top: 10px !important;
}

.ws-wcag-btn.wcag-full-width:hover,
.ws-wcag-btn[data-action="reset"]:hover {
    background-color: var(--ws-wcag-color, #0055aa) !important;
    color: #fff !important;
}
.ws-wcag-btn.wcag-full-width:hover {
    background-color: var(--ws-wcag-color, #0055aa);
    color: #fff;
}

.ws-icon {
    font-size: 24px;
    margin-bottom: 5px;
    display: block;
    height: 24px;
    width: 24px;
}
.ws-icon svg {
    width: 100%;
    height: 100%;
}

.ws-label {
    font-size: 12px;
}

.ws-wcag-footer {
    padding: 10px 15px;
    text-align: center;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 10px;
    color: #6c757d;
}

.ws-declaration-link {
    color: var(--ws-wcag-color, #0055aa);
    text-decoration: underline;
    font-weight: bold;
    font-size: 11px;
}

/* Accessibility Modes */

/* Grayscale */
body.wcag-grayscale {
    filter: grayscale(100%) !important;
}

/* High Contrast */
body.wcag-contrast {
    background-color: #000 !important;
    color: #fff !important;
}
body.wcag-contrast main,
body.wcag-contrast section,
body.wcag-contrast article,
body.wcag-contrast aside,
body.wcag-contrast header,
body.wcag-contrast footer,
body.wcag-contrast nav,
body.wcag-contrast div,
body.wcag-contrast p,
body.wcag-contrast span,
body.wcag-contrast strong,
body.wcag-contrast em,
body.wcag-contrast small,
body.wcag-contrast li,
body.wcag-contrast ul,
body.wcag-contrast ol,
body.wcag-contrast dl,
body.wcag-contrast dt,
body.wcag-contrast dd,
body.wcag-contrast h1,
body.wcag-contrast h2,
body.wcag-contrast h3,
body.wcag-contrast h4,
body.wcag-contrast h5,
body.wcag-contrast h6,
body.wcag-contrast label,
body.wcag-contrast button,
body.wcag-contrast input,
body.wcag-contrast textarea,
body.wcag-contrast select,
body.wcag-contrast table,
body.wcag-contrast thead,
body.wcag-contrast tbody,
body.wcag-contrast tr,
body.wcag-contrast th,
body.wcag-contrast td,
body.wcag-contrast form {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}
body.wcag-contrast a,
body.wcag-contrast a:hover,
body.wcag-contrast button,
body.wcag-contrast input {
    color: #ffff00 !important;
    text-decoration: underline !important;
}
body.wcag-contrast img {
    filter: grayscale(100%) contrast(120%);
}
body.wcag-contrast .ws-wcag-btn {
    border: 2px solid #fff;
}
body.wcag-contrast .ws-wcag-btn.active {
    background-color: #ffff00 !important;
    color: #000 !important;
    border-color: #fff !important;
}

/* Links Underline */
body.wcag-links a {
    text-decoration: underline !important;
}

/* Stop Animations */
body.wcag-stop-animations *,
body.wcag-stop-animations *:before,
body.wcag-stop-animations *:after {
    transition: none !important;
    animation: none !important;
}

html.wcag-stop-animations,
body.wcag-stop-animations {
    scroll-behavior: auto !important;
}

/* Readable Font */
/* Note: Exclusions are handled via dynamic CSS in PHP */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('../fonts/OpenDyslexic-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Readable Font handled in PHP to support exclusions */
/*
body.wcag-readable-font * {
    font-family: 'OpenDyslexic', Arial, Helvetica, sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
}
*/

/* Big Cursor */
body.wcag-big-cursor,
body.wcag-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' stroke='%23ffffff' stroke-width='2' d='M7 2l12 11.2-5.8.5 3.3 7.3-2.2.9-3.2-7.4-4.4 4.6z'/%3E%3C/svg%3E") 0 0, auto !important;
}
body.wcag-big-cursor a,
body.wcag-big-cursor button,
body.wcag-big-cursor input,
body.wcag-big-cursor [role="button"] {
     cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffcc00' stroke='%23000000' stroke-width='2' d='M9 20l-1.3-3H6.2L12 4l5.8 13h-1.5l-1.3 3H9z'/%3E%3C/svg%3E") 12 12, pointer !important;
}

/* Enhanced Focus Ring */
body.wcag-focus-ring *:focus {
    outline: 4px solid #ffcc00 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px #000 !important;
}

/* Reading Guide */
#ws-wcag-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 0, 0.7);
    z-index: 2147483647;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    display: none;
}
#ws-wcag-reading-guide.ws-visible {
    display: block;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #ws-wcag-panel {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        top: 0 !important; /* Force top 0 on mobile */
        border-radius: 0;
    }

    #ws-wcag-toggle {
        width: 40px;
        height: 40px;
        top: 50% !important; /* Center vertically on mobile initially */
    }

    .ws-wcag-grid {
        grid-template-columns: 1fr 1fr;
        padding-bottom: 50px; /* Space for scroll */
    }
}
