/* =========================================
   ACCESSIBILITY – Standalone Page Styles
   ========================================= */

/* Override generic .section defaults for accessibility */
.section.section-accessibility {
    margin-top: 0;
    padding: 0;
    min-height: 0;
}

/* ── Standalone Accessibility Page Layout ─────────────── */
.a11y-standalone-page {
    padding-top: 100px;
    padding-bottom: var(--space-2xl);
    max-width: 900px;
    margin: 0 auto;
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
}

.a11y-standalone-content {
    width: 100%;
}

/* ── Floating Accessibility Button (bottom-right, FAB) ──── */
.a11y-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    transition: var(--transition-base);
    box-shadow: var(--shadow-md);
}

.a11y-fab:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.a11y-fab svg {
    width: 22px;
    height: 22px;
}

/* ── Settings Page Header ─────────────────────────────── */
.settings-page-header {
    margin-bottom: var(--space-md);
}

.settings-page-header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 2px;
}

.settings-page-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.88rem;
}

/* ── Accessibility Mode Cards Grid ────────────────────── */
.settings-modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.a11y-setting-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.a11y-setting-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.3s ease;
}

.a11y-setting-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.04);
}

.a11y-setting-card.active {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.06);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.08);
}

.a11y-setting-card.active::before {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

/* Icon circle */
.a11y-setting-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-secondary);
    transition: all 0.3s ease;
}

.a11y-setting-card.active .a11y-setting-icon {
    background: rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.a11y-setting-icon svg {
    width: 18px;
    height: 18px;
}

/* Text */
.a11y-setting-info {
    flex: 1;
    min-width: 0;
}

.a11y-setting-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.a11y-setting-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 3px;
}

/* Toggle Switch (shared with settings) */
.a11y-toggle {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 26px;
}

.a11y-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.a11y-toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.25s ease;
}

.a11y-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.a11y-toggle input:checked + .a11y-toggle-slider {
    background: var(--accent-primary);
}

.a11y-toggle input:checked + .a11y-toggle-slider::after {
    transform: translateX(22px);
}

.a11y-toggle input:focus-visible + .a11y-toggle-slider {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

/* ── Reset & Actions Row ──────────────────────────────── */
.settings-actions-row {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.btn-settings-reset {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-settings-reset:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: var(--error);
}

.btn-settings-reset svg {
    width: 16px;
    height: 16px;
}

/* ── Declaration Accordion ────────────────────────────── */
.settings-declaration {
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.settings-declaration-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.settings-declaration-header:hover {
    background: rgba(59, 130, 246, 0.06);
}

.settings-declaration-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.settings-declaration-title svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.settings-declaration-chevron {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.settings-declaration.open .settings-declaration-chevron {
    transform: rotate(180deg);
}

.settings-declaration-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 20px;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.settings-declaration.open .settings-declaration-body {
    max-height: 600px;
    padding: 0 20px 20px;
}

.settings-declaration-body h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 6px;
}

.settings-declaration-body h4:first-child {
    margin-top: 0;
}

.settings-declaration-body p {
    margin: 0 0 10px;
}

.settings-declaration-body ul {
    margin: 0 0 10px;
    padding-left: 18px;
}

.settings-declaration-body li {
    margin-bottom: 4px;
}

.settings-declaration-body a {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* =========================================
   ACCESSIBILITY MODE EFFECTS
   ========================================= */

/* 1. Epilepsy-safe mode */
body.a11y-epilepsy * {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
}

body.a11y-epilepsy img,
body.a11y-epilepsy video {
    filter: saturate(0.6) !important;
}

body.a11y-epilepsy .bg-animation {
    display: none !important;
}

/* 2. Visually-impaired mode */
body.a11y-visually-impaired {
    font-size: clamp(1rem, 0.5vw + 0.85rem, 1.35rem) !important;
    letter-spacing: 0.02em;
}

body.a11y-visually-impaired * {
    line-height: 1.8 !important;
}

body.a11y-visually-impaired a,
body.a11y-visually-impaired button {
    outline-offset: 3px;
}

body.a11y-visually-impaired img {
    filter: contrast(1.15) !important;
}

/* 3. Cognitive disability mode */
body.a11y-cognitive * {
    word-spacing: 0.12em;
    letter-spacing: 0.03em;
}

body.a11y-cognitive p,
body.a11y-cognitive li,
body.a11y-cognitive span,
body.a11y-cognitive td {
    line-height: 2 !important;
}

body.a11y-cognitive .bg-animation {
    opacity: 0.3 !important;
}

/* 4. ADHD-friendly mode */
body.a11y-adhd .bg-animation {
    display: none !important;
}

body.a11y-adhd *:not(.a11y-setting-card):not(.a11y-setting-card *):not(.a11y-toggle-slider):not(.a11y-toggle-slider::after):not(.settings-sidebar):not(.settings-sidebar *) {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

body.a11y-adhd :focus:not(.settings-page *) {
    outline: 3px solid var(--accent-primary) !important;
    outline-offset: 2px !important;
}

body.a11y-adhd .bg-grid,
body.a11y-adhd .bg-gradient {
    display: none !important;
}

body.a11y-adhd img,
body.a11y-adhd video {
    filter: saturate(0.85) !important;
}

/* 5. Blindness mode – screen-reader helpers */
body.a11y-blind [aria-hidden="true"] {
    display: revert !important;
}

body.a11y-blind *:focus {
    outline: 3px dashed var(--accent-primary) !important;
    outline-offset: 4px !important;
}

body.a11y-blind img:not([alt]) {
    outline: 4px solid var(--error) !important;
}

/* 6. High Contrast mode */
body.a11y-high-contrast {
    --bg-primary: #000000 !important;
    --bg-secondary: #0a0a0a !important;
    --bg-tertiary: #111111 !important;
    --text-primary: #ffffff !important;
    --text-secondary: #f0f0f0 !important;
    --text-muted: #cccccc !important;
    --glass-border: rgba(255, 255, 255, 0.4) !important;
}

body.a11y-high-contrast * {
    border-color: rgba(255, 255, 255, 0.3) !important;
    text-shadow: none !important;
}

body.a11y-high-contrast a {
    color: #6eb5ff !important;
    text-decoration: underline !important;
}

body.a11y-high-contrast button,
body.a11y-high-contrast .btn,
body.a11y-high-contrast .btn-primary {
    border: 2px solid #ffffff !important;
}

body.a11y-high-contrast img,
body.a11y-high-contrast video {
    filter: contrast(1.4) brightness(1.1) !important;
}

body.a11y-high-contrast .glass,
body.a11y-high-contrast .product-card,
body.a11y-high-contrast .a11y-setting-card {
    background: #0a0a0a !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
}

body.a11y-high-contrast .bg-animation,
body.a11y-high-contrast .bg-grid,
body.a11y-high-contrast .bg-gradient {
    display: none !important;
}

body.a11y-high-contrast *:focus {
    outline: 3px solid #ffff00 !important;
    outline-offset: 2px !important;
}

/* 7. Virtual Keyboard – on-screen keyboard styles */
.vkb-keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    background: var(--bg-secondary, #1a1a2e);
    border-top: 2px solid var(--accent-primary, #3b82f6);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    animation: vkbSlideUp 0.25s ease;
}

/* Toggle bar with collapse arrow */
.vkb-toggle-bar {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
    cursor: pointer;
}

.vkb-collapse-btn {
    background: none;
    border: none;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    cursor: pointer;
    padding: 2px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 6px);
    transition: color 0.15s ease, background 0.15s ease;
}

.vkb-collapse-btn:hover {
    color: var(--text-primary, #fff);
    background: rgba(255, 255, 255, 0.08);
}

.vkb-collapse-btn svg {
    transition: transform 0.25s ease;
}

/* Keys wrapper – collapsible part */
.vkb-keys-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    padding: 4px 8px 14px;
    width: 100%;
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.25s ease;
    opacity: 1;
}

/* Collapsed state */
.vkb-keyboard.vkb-collapsed .vkb-keys-wrap {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.vkb-keyboard.vkb-collapsed .vkb-collapse-btn svg {
    transform: rotate(180deg);
}

@keyframes vkbSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.vkb-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.vkb-key {
    min-width: 36px;
    height: 40px;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.1));
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #fff);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    user-select: none;
}

.vkb-key:hover {
    background: rgba(59, 130, 246, 0.2);
}

.vkb-key:active {
    transform: scale(0.93);
    background: rgba(59, 130, 246, 0.35);
}

.vkb-space {
    min-width: 200px;
    flex: 1;
    max-width: 300px;
}

.vkb-backspace {
    min-width: 64px;
    color: var(--error, #ef4444);
}

.vkb-shift {
    min-width: 52px;
}

.vkb-keyboard.vkb-shifted .vkb-shift {
    background: rgba(59, 130, 246, 0.3);
    border-color: var(--accent-primary, #3b82f6);
    color: var(--accent-secondary, #60a5fa);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    .a11y-standalone-page {
        padding-top: 80px;
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }

    .settings-modes-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .a11y-fab {
        right: 3px;
        bottom: 3px;
    }
}

@media (max-width: 480px) {
    .settings-modes-grid {
        grid-template-columns: 1fr;
    }

    .a11y-setting-card {
        padding: 14px 16px;
        gap: 12px;
    }

    .a11y-setting-icon {
        width: 38px;
        height: 38px;
    }

    .vkb-key {
        min-width: 28px;
        height: 36px;
        font-size: 0.78rem;
    }

    .vkb-space {
        min-width: 120px;
    }
}
