/* OpenDyslexic font for dyslexia mode */
@import url('https://fonts.cdnfonts.com/css/opendyslexic');

.accessibility-floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulse-accessibility 2s ease-in-out infinite;
}

.accessibility-floating-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.accessibility-floating-btn:active {
    transform: scale(0.95);
}

@keyframes pulse-accessibility {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(99, 102, 241, 0.7);
    }
}

.accessibility-panel {
    position: fixed;
    top: 50%;
    right: 24px;
    transform: translateY(-50%) translateX(0);
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: 90vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 100000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.accessibility-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(400px);
}

.accessibility-header {
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accessibility-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.accessibility-content {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}

.accessibility-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.accessibility-section:last-child {
    border-bottom: none;
}

.section-header h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.control-group {
    margin-bottom: 16px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group > label:not(.toggle-switch) {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 8px;
}

.toggle-switch {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    width: 100%;
    padding: 8px 0;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a2e;
    flex: 1;
    margin-right: 16px;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: #cbd5e1;
    border-radius: 13px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    cursor: pointer;
    transition: all 0.3s;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    cursor: pointer;
    border: none;
    transition: all 0.3s;
}

.slider-value {
    font-size: 13px;
    font-weight: 600;
    color: #15264D;
    min-width: 40px;
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a2e;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

select:hover {
    border-color: #cbd5e1;
}

select:focus {
    outline: none;
    border-color: #15264D;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.button-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.btn-option {
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-option:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn-option.active {
    border-color: #15264D;
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    color: white;
}

.tts-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.btn-tts {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #1D6F42 0%, #2A8C56 100%);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-tts:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(81, 207, 102, 0.3);
}

.btn-tts:active {
    transform: translateY(0);
}

#btn-stop-reading {
    background: linear-gradient(135deg, #7F1D1D 0%, #92400E 100%);
}

#btn-stop-reading:hover {
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

#tts-controls {
    display: none;
}

.tts-selection-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    z-index: 100001;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tts-selection-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.accessibility-footer {
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.btn-reset {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-reset:hover {
    border-color: #7F1D1D;
    color: #7F1D1D;
    background: rgba(255, 107, 107, 0.05);
}

/* ========================================
   HIGH CONTRAST MODE v2
   ======================================== */

body.high-contrast-mode {
    background: #000000 !important;
    color: #ffffff !important;
}

body.high-contrast-mode * {
    text-shadow: none !important;
    border-color: #ffffff !important;
}

body.high-contrast-mode a {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

body.high-contrast-mode button,
body.high-contrast-mode .btn,
body.high-contrast-mode [role="button"] {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

body.high-contrast-mode button:hover,
body.high-contrast-mode .btn:hover,
body.high-contrast-mode [role="button"]:hover {
    background: #ffffff !important;
    color: #000000 !important;
}

body.high-contrast-mode *:focus,
body.high-contrast-mode *:focus-visible {
    outline: 3px solid #ffff00 !important;
    outline-offset: 2px !important;
}

body.high-contrast-mode img {
    filter: contrast(1.2) brightness(1.1);
}

body.high-contrast-mode input,
body.high-contrast-mode textarea,
body.high-contrast-mode select {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

body.high-contrast-mode .navbar,
body.high-contrast-mode .footer {
    background: #000000 !important;
    border-bottom: 2px solid #ffffff !important;
}

body.high-contrast-mode .nav-link,
body.high-contrast-mode .footer a {
    color: #ffffff !important;
    font-weight: 600 !important;
}

body.high-contrast-mode .nav-link:hover,
body.high-contrast-mode .footer a:hover {
    background: #ffffff !important;
    color: #000000 !important;
}

body.high-contrast-mode .accessibility-panel,
body.high-contrast-mode .accessibility-panel *,
body.high-contrast-mode .accessibility-floating-btn {
    border-color: revert !important;
}

/* ========================================
   READING RULER
   ======================================== */

.a11y-ruler-overlay {
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
    transition: none;
}

.a11y-ruler-overlay-top { top: 0; }
.a11y-ruler-overlay-bottom { bottom: 0; }

/* ========================================
   BIONIC READING
   ======================================== */

body.bionic-reading-active [data-bionic-original] b {
    font-weight: 800;
    color: inherit;
}

/* ========================================
   FOCUS MODE
   ======================================== */

body.focus-mode-active .sidebar,
body.focus-mode-active .page-header .header-actions,
body.focus-mode-active footer:not(.accessibility-footer),
body.focus-mode-active #footer-placeholder,
body.focus-mode-active .notification-badge,
body.focus-mode-active .floating-btn:not(.accessibility-floating-btn),
body.focus-mode-active .bg-animation,
body.focus-mode-active .cookie-banner,
body.focus-mode-active .chat-widget,
body.focus-mode-active .back-btn {
    display: none !important;
}

body.focus-mode-active .main-content,
body.focus-mode-active .app-content {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* ========================================
   CUSTOM SPACING
   ======================================== */

body.custom-spacing-active * {
    letter-spacing: var(--a11y-letter-spacing, normal) !important;
    word-spacing: var(--a11y-word-spacing, normal) !important;
    line-height: var(--a11y-line-height, 1.5) !important;
}

body.custom-spacing-active code,
body.custom-spacing-active pre,
body.custom-spacing-active code *,
body.custom-spacing-active pre * {
    letter-spacing: normal !important;
    word-spacing: normal !important;
}

/* ========================================
   BIG CURSOR
   ======================================== */

body.big-cursor-active,
body.big-cursor-active * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M5 2l20 14-10 2 6 12-4 2-6-12-6 8z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 5 2, auto !important;
}

/* ========================================
   HIDE IMAGES
   ======================================== */

body.hide-images-active img:not([class*="accessibility"]) {
    opacity: 0 !important;
    visibility: hidden !important;
}

body.hide-images-active svg:not(.accessibility-floating-btn svg):not(.accessibility-panel svg):not(#colorblind-filters) {
    opacity: 0.1 !important;
}

/* ========================================
   LINK HIGHLIGHTING
   ======================================== */

body.highlight-links-active a:not(.accessibility-panel a) {
    outline: 2px solid #ffff00 !important;
    outline-offset: 2px !important;
    background: rgba(255, 255, 0, 0.15) !important;
    text-decoration: underline !important;
}

body.highlight-links-active a:not(.accessibility-panel a):hover {
    background: rgba(255, 255, 0, 0.3) !important;
}

/* ========================================
   MONOCHROME MODE
   ======================================== */

body.monochrome-active {
    filter: grayscale(1) !important;
}

body.monochrome-active .accessibility-panel,
body.monochrome-active .accessibility-floating-btn {
    filter: grayscale(0) !important;
}

/* ========================================
   PANEL: SLIDER SUBGROUP STYLING
   ======================================== */

.slider-subgroup {
    padding: 12px 0 0 0;
}

.slider-subgroup label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 4px;
}

.conditional-controls {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.conditional-controls.visible {
    max-height: 200px;
    opacity: 1;
}

body.font-large {
    font-size: 18px;
}

body.font-large h1 {
    font-size: clamp(40px, 7vw, 76px);
}

body.font-large h2 {
    font-size: clamp(32px, 6vw, 60px);
}

body.font-large h3 {
    font-size: clamp(26px, 5vw, 44px);
}

body.font-extra-large {
    font-size: 22px;
}

body.font-extra-large h1 {
    font-size: clamp(48px, 8vw, 84px);
}

body.font-extra-large h2 {
    font-size: clamp(38px, 7vw, 68px);
}

body.font-extra-large h3 {
    font-size: clamp(30px, 6vw, 52px);
}

body.dyslexia-mode,
body.dyslexia-mode * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
    letter-spacing: 0.05em;
    word-spacing: 0.1em;
    line-height: 1.8;
}

body.colorblind-protanopia > *:not(.accessibility-floating-btn):not(.accessibility-panel):not(#navbar-placeholder):not(#footer-placeholder) {
    filter: url('#protanopia-filter');
}

body.colorblind-deuteranopia > *:not(.accessibility-floating-btn):not(.accessibility-panel):not(#navbar-placeholder):not(#footer-placeholder) {
    filter: url('#deuteranopia-filter');
}

body.colorblind-tritanopia > *:not(.accessibility-floating-btn):not(.accessibility-panel):not(#navbar-placeholder):not(#footer-placeholder) {
    filter: url('#tritanopia-filter');
}

svg#colorblind-filters {
    position: absolute;
    width: 0;
    height: 0;
}

body.reduce-animations,
body.reduce-animations * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

@media (max-width: 768px) {
    .accessibility-floating-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .accessibility-panel {
        right: 0;
        left: 0;
        top: auto;
        bottom: 0;
        transform: translateY(0);
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
    }

    .accessibility-panel.hidden {
        transform: translateY(100%);
    }

    .button-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .accessibility-floating-btn {
        bottom: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }

    .accessibility-header {
        padding: 16px;
    }

    .accessibility-header h3 {
        font-size: 18px;
    }

    .accessibility-content {
        padding: 16px;
    }

    .accessibility-section {
        margin-bottom: 20px;
        padding-bottom: 20px;
    }

    .section-header h4 {
        font-size: 15px;
    }

    .toggle-label {
        font-size: 13px;
    }

    .btn-option {
        padding: 8px;
        font-size: 12px;
    }

    .btn-tts {
        padding: 8px 12px;
        font-size: 12px;
    }

    .btn-reset {
        padding: 10px;
        font-size: 13px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .accessibility-floating-btn,
    .close-btn,
    .btn-option,
    .btn-tts,
    .btn-reset,
    .toggle-switch {
        min-height: 48px;
    }

    .accessibility-floating-btn:hover,
    .btn-option:hover,
    .btn-tts:hover,
    .btn-reset:hover {
        transform: none;
    }

    .accessibility-floating-btn:active,
    .btn-option:active,
    .btn-tts:active,
    .btn-reset:active {
        transform: scale(0.98);
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .accessibility-panel {
        max-height: 85vh;
    }

    .accessibility-content {
        max-height: 60vh;
    }

    .button-group {
        grid-template-columns: repeat(3, 1fr);
    }

    .tts-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}

*:focus-visible {
    outline: 2px solid #15264D;
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #15264D;
    outline-offset: 2px;
}

.accessibility-content::-webkit-scrollbar {
    width: 8px;
}

.accessibility-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.accessibility-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #0A0E1A 0%, #1E2230 100%);
    border-radius: 4px;
}

.accessibility-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #1E2230 0%, #2C3148 100%);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(400px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .accessibility-floating-btn,
    .accessibility-panel,
    .tts-selection-btn {
        display: none !important;
    }
}
