/* ================================================================
   ECRN Accessibility — Styles
   ================================================================ */

:root {
    --ecrn-a11y-accent: #0D47A1;
    --ecrn-a11y-accent-hover: #002F52;
    --ecrn-a11y-panel-bg: #f5f5f7;
    --ecrn-a11y-card-bg: #ffffff;
    --ecrn-a11y-card-active-bg: #e8eaf6;
    --ecrn-a11y-card-active-border: var(--ecrn-a11y-accent);
    --ecrn-a11y-text: #1a1a2e;
    --ecrn-a11y-text-light: #555;
    --ecrn-a11y-radius: 12px;
}

/* ── Default Trigger Button ──────────────────────────────────────── */

#ecrn-a11y-trigger-default {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999998;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--ecrn-a11y-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    transition: transform .2s ease, box-shadow .2s ease;
    padding: 0;
    line-height: 1;
}

/* Hide default trigger in Elementor editor (widget provides its own) */
body.elementor-editor-active #ecrn-a11y-trigger-default {
    display: none !important;
}

#ecrn-a11y-trigger-default:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}

#ecrn-a11y-trigger-default svg {
    fill: none;
    stroke: currentColor;
}

/* ── Elementor Widget — Fixed Positioning ────────────────────────── */

.ecrn-a11y-pos-fixed-tl,
.ecrn-a11y-pos-fixed-tr,
.ecrn-a11y-pos-fixed-bl,
.ecrn-a11y-pos-fixed-br {
    position: fixed !important;
    z-index: 999998 !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ecrn-a11y-pos-fixed-tl {
    top: var(--ecrn-a11y-offset-y, 24px) !important;
    left: var(--ecrn-a11y-offset-x, 24px) !important;
    right: auto !important;
    bottom: auto !important;
}

.ecrn-a11y-pos-fixed-tr {
    top: var(--ecrn-a11y-offset-y, 24px) !important;
    right: var(--ecrn-a11y-offset-x, 24px) !important;
    left: auto !important;
    bottom: auto !important;
}

.ecrn-a11y-pos-fixed-bl {
    bottom: var(--ecrn-a11y-offset-y, 24px) !important;
    left: var(--ecrn-a11y-offset-x, 24px) !important;
    right: auto !important;
    top: auto !important;
}

.ecrn-a11y-pos-fixed-br {
    bottom: var(--ecrn-a11y-offset-y, 24px) !important;
    right: var(--ecrn-a11y-offset-x, 24px) !important;
    left: auto !important;
    top: auto !important;
}

/* Widget trigger base */
.ecrn-a11y-trigger[data-widget] {
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.ecrn-a11y-trigger[data-widget]:hover {
    transform: scale(1.06);
}

/* ── Panel ───────────────────────────────────────────────────────── */

#ecrn-a11y-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--ecrn-a11y-panel-bg);
    z-index: 999999;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ecrn-a11y-text);
}

#ecrn-a11y-panel.ecrn-a11y-open {
    transform: translateX(0);
}

/* Panel from right */
#ecrn-a11y-panel.ecrn-a11y-panel--right {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: -4px 0 24px rgba(0, 0, 0, .15);
}

#ecrn-a11y-panel.ecrn-a11y-panel--right.ecrn-a11y-open {
    transform: translateX(0);
}

/* Header */
.ecrn-a11y-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    flex-shrink: 0;
}

.ecrn-a11y-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--ecrn-a11y-text);
    line-height: 1.3;
}

.ecrn-a11y-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--ecrn-a11y-text-light);
    padding: 0;
    transition: background .15s;
}

.ecrn-a11y-close:hover {
    background: rgba(0, 0, 0, .06);
}

/* Body */
.ecrn-a11y-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 20px 24px;
    -webkit-overflow-scrolling: touch;
}

/* Sections */
.ecrn-a11y-section {
    background: var(--ecrn-a11y-card-bg);
    border-radius: var(--ecrn-a11y-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.ecrn-a11y-section h3 {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--ecrn-a11y-text);
    line-height: 1.3;
}

/* Grid */
.ecrn-a11y-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

/* ── Cards ───────────────────────────────────────────────────────── */

.ecrn-a11y-card {
    background: var(--ecrn-a11y-panel-bg);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 14px 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    transition: border-color .15s, background-color .15s;
    grid-column: span 2;
    min-height: 80px;
    font-family: inherit;
    color: var(--ecrn-a11y-text);
}

.ecrn-a11y-card:hover {
    border-color: rgba(0, 0, 0, .1);
}

.ecrn-a11y-card.ecrn-a11y-active {
    border-color: var(--ecrn-a11y-card-active-border);
    background: var(--ecrn-a11y-card-active-bg);
}

/* Stepper cards span wider */
.ecrn-a11y-card--stepper {
    grid-column: span 4;
    cursor: default;
}

.ecrn-a11y-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.ecrn-a11y-card-icon svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.ecrn-a11y-card-label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ecrn-a11y-text);
}

/* ── Stepper ─────────────────────────────────────────────────────── */

.ecrn-a11y-stepper {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.ecrn-a11y-step-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--ecrn-a11y-accent);
    transition: opacity .15s;
}

.ecrn-a11y-step-btn:hover {
    opacity: .7;
}

.ecrn-a11y-step-btn svg {
    width: 22px;
    height: 22px;
}

.ecrn-a11y-step-val {
    font-size: 13px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
    color: var(--ecrn-a11y-text);
}

/* ── Reset Button ────────────────────────────────────────────────── */

#ecrn-a11y-reset {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 4px;
    border: none;
    border-radius: var(--ecrn-a11y-radius);
    background: var(--ecrn-a11y-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background-color .15s;
}

#ecrn-a11y-reset:hover {
    background: var(--ecrn-a11y-accent-hover);
}

/* ── Overlay: Reading Line ───────────────────────────────────────── */

#ecrn-a11y-reading-line {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--ecrn-a11y-accent, #0D47A1);
    z-index: 999997;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(13, 71, 161, .4);
}

/* ── Overlay: Reading Mask ───────────────────────────────────────── */

.ecrn-a11y-mask {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, .6);
    z-index: 999997;
    pointer-events: none;
}

#ecrn-a11y-mask-top {
    top: 0;
}

#ecrn-a11y-mask-bottom {
    bottom: 0;
}

/* ── Overlay: Color Filter ──────────────────────────────────────── */

#ecrn-a11y-filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999990;
    pointer-events: none;
}

#ecrn-a11y-filter-overlay.ecrn-a11y-filter-active {
    display: block;
}

/* ── Overlay: Text Magnifier ─────────────────────────────────────── */

#ecrn-a11y-magnifier {
    display: none;
    position: fixed;
    z-index: 999997;
    pointer-events: none;
    background: #fff;
    color: #111;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 24px;
    line-height: 1.4;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    word-break: break-word;
    font-family: inherit;
}

/* ================================================================
   ACCESSIBILITY MODIFICATIONS
   ================================================================ */

/* ── Highlight Links ─────────────────────────────────────────────── */

body.ecrn-a11y-highlight-links a:not(#ecrn-a11y-panel a):not(.ecrn-a11y-trigger) {
    outline: 2px solid currentColor !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
}

/* ── Readable Font ───────────────────────────────────────────────── */

body.ecrn-a11y-readable-font *:not(#ecrn-a11y-panel *):not(.ecrn-a11y-trigger *):not(#ecrn-a11y-trigger-default *) {
    font-family: Arial, Helvetica, "Segoe UI", sans-serif !important;
}

/* ── Dyslexic Font ───────────────────────────────────────────────── */

@font-face {
    font-family: "OpenDyslexic";
    src: url("https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff") format("woff");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body.ecrn-a11y-dyslexic-font *:not(#ecrn-a11y-panel *):not(.ecrn-a11y-trigger *):not(#ecrn-a11y-trigger-default *) {
    font-family: "OpenDyslexic", sans-serif !important;
}

/* ── Font Weight ─────────────────────────────────────────────────── */

body.ecrn-a11y-font-weight *:not(#ecrn-a11y-panel *):not(.ecrn-a11y-trigger *):not(#ecrn-a11y-trigger-default *) {
    font-weight: bold !important;
}

/* ── Big Cursor ──────────────────────────────────────────────────── */

body.ecrn-a11y-big-cursor,
body.ecrn-a11y-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M6 2l28 22-11 3 7 14-6 3-7-14-8 8z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 6 2, auto !important;
}

/* ── Text Alignment ──────────────────────────────────────────────── */

body.ecrn-a11y-align-left *:not(#ecrn-a11y-panel *) {
    text-align: left !important;
}

body.ecrn-a11y-align-center *:not(#ecrn-a11y-panel *) {
    text-align: center !important;
}

body.ecrn-a11y-align-right *:not(#ecrn-a11y-panel *) {
    text-align: right !important;
}

/* ── Letter Spacing ──────────────────────────────────────────────── */

body.ecrn-a11y-letter-spacing-1 *:not(#ecrn-a11y-panel *) {
    letter-spacing: 0.06em !important;
}

body.ecrn-a11y-letter-spacing-2 *:not(#ecrn-a11y-panel *) {
    letter-spacing: 0.14em !important;
}

/* ── Dark Contrast — re-invert media ─────────────────────────────── */

body.ecrn-a11y-dark-contrast img:not(#ecrn-a11y-panel img),
body.ecrn-a11y-dark-contrast video:not(#ecrn-a11y-panel video),
body.ecrn-a11y-dark-contrast picture:not(#ecrn-a11y-panel picture) {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* ── Keyboard Navigation ─────────────────────────────────────────── */

body.ecrn-a11y-keyboard-nav *:focus {
    outline: 3px solid var(--ecrn-a11y-accent, #0D47A1) !important;
    outline-offset: 3px !important;
}

body.ecrn-a11y-keyboard-nav a:focus,
body.ecrn-a11y-keyboard-nav button:focus,
body.ecrn-a11y-keyboard-nav input:focus,
body.ecrn-a11y-keyboard-nav select:focus,
body.ecrn-a11y-keyboard-nav textarea:focus {
    box-shadow: 0 0 0 3px rgba(13, 71, 161, .35) !important;
}

/* ── Hide Images ─────────────────────────────────────────────────── */

body.ecrn-a11y-hide-images img:not(#ecrn-a11y-panel img):not(.ecrn-a11y-trigger img),
body.ecrn-a11y-hide-images picture:not(#ecrn-a11y-panel picture),
body.ecrn-a11y-hide-images svg:not(#ecrn-a11y-panel svg):not(.ecrn-a11y-trigger svg):not(#ecrn-a11y-trigger-default svg):not(.ecrn-a11y-card-icon svg):not(.ecrn-a11y-step-btn svg) {
    opacity: 0 !important;
}

body.ecrn-a11y-hide-images [style*="background-image"]:not(#ecrn-a11y-panel *):not(.ecrn-a11y-trigger) {
    background-image: none !important;
}

/* ── Highlight Titles ────────────────────────────────────────────── */

body.ecrn-a11y-highlight-titles :is(h1, h2, h3, h4, h5, h6):not(#ecrn-a11y-panel *) {
    outline: 2px dashed var(--ecrn-a11y-accent, #0D47A1) !important;
    outline-offset: 4px !important;
    background: rgba(13, 71, 161, .07) !important;
}

/* ── Highlight Content ───────────────────────────────────────────── */

body.ecrn-a11y-highlight-content :is(p, li, td, th, blockquote, figcaption, dd):not(#ecrn-a11y-panel *) {
    outline: 2px dashed #f0b400 !important;
    outline-offset: 2px !important;
    background: rgba(240, 180, 0, .06) !important;
}

/* ── Stop Animations ─────────────────────────────────────────────── */

body.ecrn-a11y-stop-animations *,
body.ecrn-a11y-stop-animations *::before,
body.ecrn-a11y-stop-animations *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* ── Panel backdrop ──────────────────────────────────────────────── */

#ecrn-a11y-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 999998;
}

#ecrn-a11y-backdrop.ecrn-a11y-open {
    display: block;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #ecrn-a11y-panel {
        width: 100vw;
    }

    .ecrn-a11y-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
