/**
 * TREJKA Accessibility - Widget (Compact Tabs)
 * Based on TrackStack design
 */

.tra-a11y {
    position: fixed;
    z-index: 999990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.tra-a11y * { box-sizing: border-box; }

/* Positions */
.tra-a11y--bottom-right { bottom: 20px; right: 20px; }
.tra-a11y--bottom-left { bottom: 20px; left: 20px; }
.tra-a11y--top-right { top: 20px; right: 20px; }
.tra-a11y--top-left { top: 20px; left: 20px; }

/* Button */
.tra-a11y__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    color: #fff;
}

.tra-a11y__btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.tra-a11y__btn:focus { outline: 3px solid rgba(255,255,255,0.5); outline-offset: 2px; }

.tra-a11y--small .tra-a11y__btn { width: 44px; height: 44px; }
.tra-a11y--small .tra-a11y__btn svg { width: 24px; height: 24px; }
.tra-a11y--medium .tra-a11y__btn { width: 54px; height: 54px; }
.tra-a11y--medium .tra-a11y__btn svg { width: 28px; height: 28px; }
.tra-a11y--large .tra-a11y__btn { width: 64px; height: 64px; }
.tra-a11y--large .tra-a11y__btn svg { width: 32px; height: 32px; }

/* Panel */
.tra-a11y__panel {
    position: absolute;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    display: none;
}

.tra-a11y__panel.is-open { display: block; animation: tra-a11y-slide 0.2s ease-out; }

@keyframes tra-a11y-slide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tra-a11y--bottom-right .tra-a11y__panel { bottom: 70px; right: 0; }
.tra-a11y--bottom-left .tra-a11y__panel { bottom: 70px; left: 0; }
.tra-a11y--top-right .tra-a11y__panel { top: 70px; right: 0; }
.tra-a11y--top-left .tra-a11y__panel { top: 70px; left: 0; }

/* Header */
.tra-a11y__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--tra-a11y-color, #bc0000);
    color: #fff;
}

.tra-a11y__title { margin: 0; font-size: 14px; font-weight: 600; }

.tra-a11y__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #fff;
    transition: all 0.15s;
}

.tra-a11y__close:hover { background: rgba(255,255,255,0.3); }

/* Tabs */
.tra-a11y__tabs {
    display: flex;
    background: #F3F4F6;
    border-bottom: 1px solid #E5E7EB;
}

.tra-a11y__tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 500;
    color: #6B7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.tra-a11y__tab:hover { color: #374151; background: #fff; }
.tra-a11y__tab.is-active { color: var(--tra-a11y-color, #bc0000); background: #fff; border-bottom-color: var(--tra-a11y-color, #bc0000); }
.tra-a11y__tab svg { width: 18px; height: 18px; }

/* Tab Content */
.tra-a11y__content { display: none; padding: 10px 14px; max-height: 300px; overflow-y: auto; }
.tra-a11y__content.is-active { display: block; }

/* Features */
.tra-a11y__feature {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #F3F4F6;
}

.tra-a11y__feature:last-child { border-bottom: none; }
.tra-a11y__feature-label { font-size: 13px; color: #374151; }

/* Toggle */
.tra-a11y__toggle { position: relative; width: 38px; height: 20px; flex-shrink: 0; }
.tra-a11y__toggle input { opacity: 0; width: 0; height: 0; }

.tra-a11y__toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #D1D5DB;
    border-radius: 20px;
    transition: 0.2s;
}

.tra-a11y__toggle-slider:before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.tra-a11y__toggle input:checked + .tra-a11y__toggle-slider { background: var(--tra-a11y-color, #bc0000); }
.tra-a11y__toggle input:checked + .tra-a11y__toggle-slider:before { transform: translateX(18px); }

/* Stepper */
.tra-a11y__stepper { display: flex; align-items: center; gap: 4px; }

.tra-a11y__stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: #F3F4F6;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    transition: all 0.15s;
}

.tra-a11y__stepper-btn:hover { background: #E5E7EB; }
.tra-a11y__stepper-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tra-a11y__stepper-value { min-width: 24px; text-align: center; font-size: 13px; font-weight: 600; color: #374151; }

/* Footer */
.tra-a11y__footer { padding: 10px 14px; border-top: 1px solid #E5E7EB; background: #F9FAFB; }

.tra-a11y__reset {
    width: 100%;
    padding: 7px 10px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.tra-a11y__reset:hover { background: #F3F4F6; }

.tra-a11y__powered { margin-top: 8px; text-align: center; font-size: 10px; color: #9CA3AF; }
.tra-a11y__powered a { color: inherit; text-decoration: none; font-weight: 600; }
.tra-a11y__powered a:hover { text-decoration: underline; }

/* Skip Links (WCAG 2.4.1) */
.tra-skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--tra-a11y-color, #bc0000);
    color: #fff;
    padding: 12px 20px;
    z-index: 999999;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    transition: top 0.2s;
}

.tra-skip-link:focus {
    top: 0;
    outline: 3px solid #ffcc00;
    outline-offset: 2px;
}

/* ============================================
   Accessibility Effects
   ============================================ */

body.tra-font-size-1 { font-size: 110% !important; }
body.tra-font-size-2 { font-size: 120% !important; }
body.tra-font-size-3 { font-size: 130% !important; }
body.tra-font-size-4 { font-size: 140% !important; }
body.tra-font-size-5 { font-size: 150% !important; }

body.tra-line-height-1 * { line-height: 1.6 !important; }
body.tra-line-height-2 * { line-height: 1.8 !important; }
body.tra-line-height-3 * { line-height: 2.0 !important; }
body.tra-line-height-4 * { line-height: 2.2 !important; }
body.tra-line-height-5 * { line-height: 2.5 !important; }

body.tra-letter-spacing-1 * { letter-spacing: 1px !important; }
body.tra-letter-spacing-2 * { letter-spacing: 2px !important; }
body.tra-letter-spacing-3 * { letter-spacing: 3px !important; }
body.tra-letter-spacing-4 * { letter-spacing: 4px !important; }
body.tra-letter-spacing-5 * { letter-spacing: 5px !important; }

body.tra-readable-font, body.tra-readable-font * { font-family: "OpenDyslexic", "Comic Sans MS", Arial, sans-serif !important; }

body.tra-highlight-titles h1, body.tra-highlight-titles h2, body.tra-highlight-titles h3,
body.tra-highlight-titles h4, body.tra-highlight-titles h5, body.tra-highlight-titles h6 {
    background: linear-gradient(90deg, #FEF3C7, #FDE68A) !important;
    padding: 4px 8px !important;
    display: inline-block !important;
    border-radius: 4px !important;
}

body.tra-highlight-links a { background: #DBEAFE !important; color: #1E40AF !important; text-decoration: underline !important; padding: 2px 4px !important; border-radius: 2px !important; }

body.tra-high-contrast, body.tra-high-contrast * { background-color: #000 !important; color: #fff !important; border-color: #fff !important; }
body.tra-high-contrast a { color: #ff0 !important; }

body.tra-negative-contrast { filter: invert(1) hue-rotate(180deg) !important; }
body.tra-negative-contrast img, body.tra-negative-contrast video { filter: invert(1) hue-rotate(180deg) !important; }

body.tra-light-background, body.tra-light-background * { background-color: #fff !important; color: #000 !important; }
body.tra-light-background a { color: #0000EE !important; }

body.tra-dark-background, body.tra-dark-background * { background-color: #1a1a2e !important; color: #eaeaea !important; border-color: #333 !important; }
body.tra-dark-background a { color: #82b1ff !important; }

body.tra-grayscale { filter: grayscale(100%) !important; }
body.tra-high-saturation { filter: saturate(2) !important; }
body.tra-low-saturation { filter: saturate(0.5) !important; }

/* Color Blindness Filters */
body.tra-protanopia { filter: url('#tra-protanopia-filter') !important; }
body.tra-deuteranopia { filter: url('#tra-deuteranopia-filter') !important; }
body.tra-tritanopia { filter: url('#tra-tritanopia-filter') !important; }
body.tra-achromatopsia { filter: grayscale(100%) !important; }

body.tra-big-cursor, body.tra-big-cursor * {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="%23000" stroke="%23fff" stroke-width="1" d="M5.5 3.21V20.8l4.71-4.71h6.71L5.5 3.21z"/></svg>') 4 4, auto !important;
}

body.tra-stop-animations, body.tra-stop-animations * { animation: none !important; transition: none !important; }
body.tra-seizure-safe, body.tra-seizure-safe * { animation: none !important; transition: none !important; }
body.tra-seizure-safe img[src*=".gif"] { visibility: hidden !important; }

body.tra-hide-images img, body.tra-hide-images svg:not(.tra-a11y svg), body.tra-hide-images [style*="background-image"] { visibility: hidden !important; }

/* Focus Highlight (WCAG 2.4.7) */
body.tra-focus-highlight *:focus {
    outline: 3px solid #ff0 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(255,255,0,0.3) !important;
}

/* ADHD Friendly */
body.tra-adhd-friendly main, body.tra-adhd-friendly article, body.tra-adhd-friendly .content {
    max-width: 800px !important;
    margin: 0 auto !important;
}

/* Cognitive Mode */
body.tra-cognitive-mode { font-size: 18px !important; }
body.tra-cognitive-mode * { line-height: 1.8 !important; letter-spacing: 0.03em !important; }

/* Reading Guide */
.tra-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 32px;
    background: rgba(255, 235, 59, 0.25);
    border-top: 2px solid #FFC107;
    border-bottom: 2px solid #FFC107;
    pointer-events: none;
    z-index: 999989;
}

/* Reading Mask */
.tra-reading-mask { position: fixed; inset: 0; pointer-events: none; z-index: 999989; }
.tra-reading-mask__top, .tra-reading-mask__bottom { position: absolute; left: 0; right: 0; background: rgba(0, 0, 0, 0.75); }
.tra-reading-mask__top { top: 0; }
.tra-reading-mask__bottom { bottom: 0; }

/* SVG Filters */
.tra-svg-filters { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Exclude widget from effects */
.tra-a11y, .tra-a11y *, .tra-reading-guide, .tra-reading-mask, .tra-reading-mask * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    line-height: 1.5 !important;
    letter-spacing: normal !important;
    filter: none !important;
}

.tra-a11y__panel { background-color: #fff !important; }
.tra-a11y__header, .tra-a11y__header * { color: #fff !important; }
.tra-a11y__tabs { background-color: #F3F4F6 !important; }
.tra-a11y__tab.is-active { background-color: #fff !important; }
.tra-a11y__footer { background-color: #F9FAFB !important; }
.tra-a11y__feature-label { color: #374151 !important; }

/* Mobile */
@media (max-width: 480px) {
    .tra-a11y__panel { width: calc(100vw - 40px); }
}
