/* =====================================================
   WD Accessibility - Toolbar CSS
   ===================================================== */

/* Skip link */
.wda-skip-link {
    position: absolute;
    top: -999px;
    left: -999px;
    z-index: 99999;
    padding: 10px 20px;
    background: #0057b8;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 6px 0;
    transition: top 0s;
}
.wda-skip-link:focus {
    top: 0;
    left: 0;
}

/* ---- Toggle Button ---- */
#wda-toggle-btn {
    position: fixed;
    z-index: 999998;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    outline: none;
}
#wda-toggle-btn:hover,
#wda-toggle-btn:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 22px rgba(0,0,0,0.35);
    outline: 3px solid #fff;
}
#wda-toggle-btn svg {
    pointer-events: none;
}

/* ---- Panel ---- */
#wda-panel {
    position: fixed;
    z-index: 999997;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 90vh;
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
#wda-panel.wda-panel-open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Panel header */
#wda-panel-header {
    background: var(--wda-color, #0057b8);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#wda-panel-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
}
#wda-panel-actions {
    display: flex;
    gap: 8px;
}
.wda-panel-action-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.wda-panel-action-btn:hover {
    background: rgba(255,255,255,0.35);
}

/* Panel body */
#wda-panel-body {
    overflow-y: auto;
    flex: 1;
    padding: 12px;
    scrollbar-width: thin;
}
#wda-panel-body::-webkit-scrollbar { width: 4px; }
#wda-panel-body::-webkit-scrollbar-thumb { background: #ccd2dc; border-radius: 4px; }

/* Section titles */
.wda-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7a99;
    margin: 14px 0 8px;
    padding-right: 4px;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
}
.wda-section-title:first-child { margin-top: 4px; }

/* Feature buttons grid */
.wda-features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.wda-feature-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    background: #f5f7fb;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 11px;
    font-weight: 600;
    color: #3a4558;
    line-height: 1.3;
    text-align: center;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
}
.wda-feature-btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.wda-feature-btn:hover {
    background: #e8edf8;
    border-color: var(--wda-color, #0057b8);
    color: var(--wda-color, #0057b8);
}
.wda-feature-btn.wda-active {
    background: var(--wda-color, #0057b8);
    border-color: var(--wda-color, #0057b8);
    color: #fff;
}
.wda-feature-btn.wda-active svg { filter: brightness(10); }

/* Font size row */
.wda-font-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f7fb;
    border-radius: 10px;
    padding: 8px 12px;
}
.wda-font-size-row .wda-fs-label {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: #3a4558;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
}
.wda-fs-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #dde3ec;
    background: #fff;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wda-color, #0057b8);
    transition: all 0.15s;
    line-height: 1;
}
.wda-fs-btn:hover {
    background: var(--wda-color, #0057b8);
    color: #fff;
    border-color: var(--wda-color, #0057b8);
}
.wda-fs-value {
    min-width: 32px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #3a4558;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
}

/* Statement link */
#wda-statement-link {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--wda-color, #0057b8);
    text-decoration: none;
    padding: 10px 0 4px;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
    transition: opacity 0.2s;
}
#wda-statement-link:hover { opacity: 0.75; text-decoration: underline; }

/* ---- Reading Guide ---- */
#wda-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 36px;
    background: rgba(255,255,0,0.35);
    border-top: 2px solid #e6b800;
    border-bottom: 2px solid #e6b800;
    pointer-events: none;
    z-index: 999996;
    display: none;
}

/* ---- Big Cursor ---- */
body.wda-big-cursor,
body.wda-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M8 4 L8 34 L16 26 L22 38 L26 36 L20 24 L32 24 Z' fill='white' stroke='black' stroke-width='2'/%3E%3C/svg%3E") 8 4, auto !important;
}

/* ---- Contrast modes ----
   backdrop-filter on ::before instead of filter on body,
   because filter on body breaks position:fixed on all children.
   The ::before overlay sits at z-index 999990, below the toolbar (999998).
---------------------------------------------------- */
body.wda-high-contrast::before,
body.wda-negative-contrast::before,
body.wda-grayscale::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999990;
}
body.wda-high-contrast::before {
    -webkit-backdrop-filter: contrast(1.6) brightness(1.05);
    backdrop-filter: contrast(1.6) brightness(1.05);
}
body.wda-negative-contrast::before {
    -webkit-backdrop-filter: invert(1) hue-rotate(180deg);
    backdrop-filter: invert(1) hue-rotate(180deg);
}
body.wda-grayscale::before {
    -webkit-backdrop-filter: grayscale(1);
    backdrop-filter: grayscale(1);
}
body.wda-light-bg {
    background: #fff !important;
    color: #000 !important;
}
body.wda-light-bg * {
    background-color: #fff !important;
    color: #000 !important;
}

/* ---- Highlight links ---- */
body.wda-highlight-links a {
    background: #ff0 !important;
    color: #000 !important;
    text-decoration: underline !important;
    outline: 2px solid #000 !important;
    border-radius: 2px;
}

/* ---- Readable fonts ---- */
body.wda-readable-fonts,
body.wda-readable-fonts * {
    font-family: Arial, Helvetica, sans-serif !important;
}

/* ---- Text spacing ---- */
body.wda-text-spacing * {
    line-height: 1.8 !important;
    letter-spacing: 0.06em !important;
    word-spacing: 0.12em !important;
}

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

/* ---- Keyboard focus ---- */
body.wda-keyboard-nav *:focus {
    outline: 3px solid var(--wda-color, #0057b8) !important;
    outline-offset: 2px !important;
}

/* RTL support */
body[dir="rtl"] #wda-panel,
html[lang="he"] #wda-panel,
html[lang="he-IL"] #wda-panel {
    direction: rtl;
    text-align: right;
}

/* Mobile & small tablets */
@media (max-width: 768px) {
    #wda-panel {
        width: calc(100vw - 20px);
        max-height: 70vh;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
        border-radius: 12px !important;
    }
}
