/* QM Accessibility Toolbar */

/* Screen reader only utility */
.qma-sr-only {
    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;
}

/* Toolbar Wrapper */
.qma-toolbar-wrap {
    position: fixed;
    z-index: 999998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}
.qma-toolbar-wrap.qma-pos-bottom-right { bottom: 20px; right: 20px; }
.qma-toolbar-wrap.qma-pos-bottom-left  { bottom: 20px; left: 20px; }
.qma-toolbar-wrap.qma-pos-top-right    { top: 20px; right: 20px; }
.qma-toolbar-wrap.qma-pos-top-left     { top: 20px; left: 20px; }

/* Toggle Button */
.qma-toolbar-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.qma-toolbar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.qma-toolbar-toggle:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}
.qma-toolbar-toggle svg {
    width: 24px;
    height: 24px;
}

/* Panel */
.qma-toolbar-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 300px;
    max-height: 80vh;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    display: none;
    flex-direction: column;
}
.qma-toolbar-panel.qma-open {
    display: flex;
}

/* Position variations */
.qma-pos-bottom-left .qma-toolbar-panel  { right: auto; left: 0; }
.qma-pos-top-right .qma-toolbar-panel    { bottom: auto; top: 64px; }
.qma-pos-top-left .qma-toolbar-panel     { bottom: auto; top: 64px; right: auto; left: 0; }

/* Header */
.qma-toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #000000;
    color: #ffffff;
}
.qma-toolbar-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.qma-toolbar-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.qma-toolbar-close:hover { opacity: 1; }
.qma-toolbar-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Body */
.qma-toolbar-body {
    padding: 16px 18px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

/* Sections */
.qma-toolbar-section {
    margin-bottom: 16px;
}
.qma-toolbar-label {
    font-size: 10px;
    font-weight: 700;
    color: #999999;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* Button rows */
.qma-toolbar-row {
    display: flex;
    gap: 6px;
}
.qma-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #e5e5e5;
    background: #f9f9f9;
    color: #333333;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    line-height: 1.3;
}
.qma-btn:hover {
    background: #f0f0f0;
    border-color: #cccccc;
}
.qma-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}
.qma-btn.qma-active {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
}

/* Reset button */
.qma-btn-reset {
    width: 100%;
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    background: #ffffff;
    border: 2px solid #000000;
    color: #000000;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.15s;
}
.qma-btn-reset:hover {
    background: #000000;
    color: #ffffff;
}

/* Footer */
.qma-toolbar-footer {
    padding: 10px 18px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
    font-size: 11px;
    color: #bbbbbb;
}
.qma-toolbar-footer a {
    color: #999999;
    text-decoration: none;
}
.qma-toolbar-footer a:hover {
    color: #000000;
}

/* Reading Guide */
.qma-reading-guide {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    height: 12px;
    background: rgba(255, 235, 59, 0.35);
    border-top: 2px solid rgba(255, 235, 59, 0.7);
    border-bottom: 2px solid rgba(255, 235, 59, 0.7);
    pointer-events: none;
    z-index: 999997;
    transition: top 0.05s linear;
}
.qma-reading-guide.qma-active {
    display: block;
}

/* === Applied accessibility overrides === */

/* High contrast */
body.qma-high-contrast,
body.qma-high-contrast * {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}
body.qma-high-contrast a {
    color: #ffff00 !important;
}
body.qma-high-contrast img {
    filter: contrast(1.5) !important;
}

/* Invert */
body.qma-invert {
    filter: invert(1) hue-rotate(180deg) !important;
}
body.qma-invert img,
body.qma-invert video {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Letter spacing */
body.qma-letter-spacing,
body.qma-letter-spacing * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

/* Line height */
body.qma-line-height,
body.qma-line-height * {
    line-height: 2 !important;
}

/* Highlight links */
body.qma-highlight-links a {
    outline: 3px solid #f59e0b !important;
    outline-offset: 2px !important;
    background: rgba(245, 158, 11, 0.1) !important;
}

/* Highlight headings */
body.qma-highlight-headings h1,
body.qma-highlight-headings h2,
body.qma-highlight-headings h3,
body.qma-highlight-headings h4,
body.qma-highlight-headings h5,
body.qma-highlight-headings h6 {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    background: rgba(59, 130, 246, 0.08) !important;
}

/* Readable font */
body.qma-readable-font,
body.qma-readable-font * {
    font-family: Verdana, Geneva, sans-serif !important;
}

/* Large cursor */
body.qma-large-cursor,
body.qma-large-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M4 4l20 8-8 4-4 8z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Grayscale */
body.qma-grayscale {
    filter: grayscale(1) !important;
}

/* Hide images */
body.qma-hide-images img {
    opacity: 0.05 !important;
}

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

/* Mobile */
@media (max-width: 480px) {
    .qma-toolbar-panel {
        width: calc(100vw - 40px);
        right: -10px;
    }
    .qma-pos-bottom-left .qma-toolbar-panel {
        left: -10px;
        right: auto;
    }
}
