/* ===========================================
   Olympus Commercial Accessibility Widget
   =========================================== */

/* ── Design tokens (scoped to container) ── */
#oca-container {
    /* Zero-size fixed anchor — sits above every theme element */
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 2147483647; /* INT_MAX — above WP admin bar, cookie banners, any theme z-index */

    --oca-primary:      #1565C0;
    --oca-primary-dark: #0d47a1;
    --oca-bg:           #ffffff;
    --oca-surface:      #f8fafc;
    --oca-border:       #e8eaed;
    --oca-text:         #1f2937;
    --oca-text-muted:   #6b7280;
    --oca-success:      #059669;
    --oca-danger:       #dc2626;
    --oca-r-sm:         6px;
    --oca-r-md:         10px;
    --oca-r-full:       9999px;
    --oca-shadow:       0 4px 24px rgba(0,0,0,0.14);
    --oca-panel-w:      340px;
    --oca-z:            99998;
    --oca-ease:         0.22s cubic-bezier(.4,0,.2,1);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--oca-text);
    box-sizing: border-box;
}

#oca-container *,
#oca-container *::before,
#oca-container *::after {
    box-sizing: inherit;
}

/* ── FAB Trigger Button ── */
#oca-fab {
    position: fixed;
    z-index: calc(var(--oca-z) + 2);
    width: 56px;
    height: 56px;
    border-radius: var(--oca-r-full);
    background-color: var(--oca-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 14px rgba(0,0,0,0.26), 0 1px 5px rgba(0,0,0,0.12);
    transition: transform var(--oca-ease), box-shadow var(--oca-ease), opacity var(--oca-ease), visibility var(--oca-ease);
    padding: 0;
}

#oca-fab:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#oca-fab:focus-visible {
    outline: 3px solid var(--oca-bg);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(21,101,192,0.4);
}

#oca-fab svg {
    width: 28px;
    height: 28px;
    pointer-events: none;
    flex-shrink: 0;
}

/* Hide FAB while panel is open */
#oca-container.oca-is-open #oca-fab {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Button Positions ── */
.oca-pos-middle-right #oca-fab {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}
.oca-pos-middle-right #oca-fab:hover {
    transform: translateY(-50%) scale(1.07);
}
.oca-pos-bottom-right #oca-fab {
    right: 20px;
    bottom: 24px;
}
.oca-pos-bottom-right #oca-fab:hover {
    transform: scale(1.07);
}
.oca-pos-bottom-left #oca-fab {
    left: 20px;
    bottom: 24px;
}
.oca-pos-bottom-left #oca-fab:hover {
    transform: scale(1.07);
}
.oca-pos-top-right #oca-fab {
    right: 20px;
    top: 24px;
}
.oca-pos-top-right #oca-fab:hover {
    transform: scale(1.07);
}
.oca-pos-top-left #oca-fab {
    left: 20px;
    top: 24px;
}
.oca-pos-top-left #oca-fab:hover {
    transform: scale(1.07);
}

/* ── Side Panel ── */
#oca-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--oca-panel-w);
    max-width: 100vw;
    height: 100%;
    background: var(--oca-bg);
    z-index: calc(var(--oca-z) + 1);
    box-shadow: -6px 0 40px rgba(0,0,0,0.16);
    display: flex;
    flex-direction: column;
    transform: translateX(102%);
    transition: transform var(--oca-ease), visibility var(--oca-ease);
    visibility: hidden;
    overflow: hidden;
}

/* Left-side panel */
.oca-pos-bottom-left #oca-panel,
.oca-pos-top-left    #oca-panel {
    right: auto;
    left: 0;
    transform: translateX(-102%);
    box-shadow: 6px 0 40px rgba(0,0,0,0.16);
}

#oca-panel.oca-open {
    transform: translateX(0);
    visibility: visible;
}

/* ── Panel Header ── */
.oca-panel-header {
    flex-shrink: 0;
    background-color: var(--oca-primary);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.oca-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.oca-header-title svg {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

#oca-close {
    width: 34px;
    height: 34px;
    border-radius: var(--oca-r-full);
    border: 1.5px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background var(--oca-ease);
}

#oca-close:hover {
    background: rgba(255,255,255,0.22);
}

#oca-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

#oca-close svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* ── Panel Body ── */
.oca-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 4px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.oca-panel-body::-webkit-scrollbar {
    width: 4px;
}
.oca-panel-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* ── Sections ── */
.oca-section {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f3f5;
}

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

.oca-section-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--oca-text-muted);
    margin: 0 0 14px 0;
}

.oca-section-title svg {
    color: #9ca3af;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

/* ── Font Size Step Control ── */
.oca-step-control {
    display: flex;
    gap: 8px;
}

.oca-step-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 11px 8px;
    border: 1.5px solid var(--oca-border);
    border-radius: var(--oca-r-md);
    background: var(--oca-surface);
    cursor: pointer;
    font-weight: 600;
    color: var(--oca-text);
    transition: background var(--oca-ease), border-color var(--oca-ease), color var(--oca-ease);
    line-height: 1;
}

.oca-step-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.oca-step-btn:focus-visible,
.oca-step-reset:focus-visible {
    outline: 2px solid var(--oca-primary);
    outline-offset: 2px;
}

.oca-a-small {
    font-size: 12px;
    font-weight: 800;
}
.oca-a-large {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.oca-step-reset {
    flex: 0.6;
    padding: 11px 6px;
    border: 1.5px solid var(--oca-border);
    border-radius: var(--oca-r-md);
    background: var(--oca-surface);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--oca-text-muted);
    transition: background var(--oca-ease), color var(--oca-ease);
    text-align: center;
    line-height: 1;
}

.oca-step-reset:hover {
    background: #f3f4f6;
    color: var(--oca-text);
}

/* ── Spacing Controls (+/-) ── */
.oca-spacing-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oca-spacing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.oca-spacing-label {
    font-size: 13px;
    color: var(--oca-text);
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.oca-incr-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.oca-incr-btns button {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--oca-border);
    border-radius: var(--oca-r-sm);
    background: var(--oca-surface);
    cursor: pointer;
    font-size: 17px;
    font-weight: 500;
    color: var(--oca-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--oca-ease), border-color var(--oca-ease), color var(--oca-ease);
    padding: 0;
    line-height: 1;
}

.oca-incr-btns button.oca-reset-icon {
    font-size: 14px;
}

.oca-incr-btns button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.oca-incr-btns button:focus-visible {
    outline: 2px solid var(--oca-primary);
    outline-offset: 2px;
}

/* ── Segmented Control ── */
.oca-seg-ctrl {
    display: flex;
    gap: 3px;
    background: #f3f4f6;
    padding: 3px;
    border-radius: var(--oca-r-md);
    border: 1px solid var(--oca-border);
}

.oca-seg-btn {
    flex: 1;
    padding: 7px 6px;
    border: none;
    border-radius: calc(var(--oca-r-md) - 2px);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--oca-text-muted);
    transition: background var(--oca-ease), color var(--oca-ease), box-shadow var(--oca-ease);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.2;
}

.oca-seg-btn:hover:not(.oca-active) {
    background: rgba(255,255,255,0.7);
    color: var(--oca-text);
}

.oca-seg-btn.oca-active {
    background: var(--oca-bg);
    color: var(--oca-primary);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

.oca-seg-btn:focus-visible {
    outline: 2px solid var(--oca-primary);
    outline-offset: 1px;
}

/* Inline segmented (doesn't stretch full width) */
.oca-seg-inline {
    display: inline-flex;
    width: auto;
}

/* ── Toggle Rows ── */
.oca-toggles {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.oca-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid #f9fafb;
}

.oca-toggles .oca-toggle-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.oca-toggles .oca-toggle-row:first-child {
    padding-top: 0;
}

.oca-toggle-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--oca-text);
    font-weight: 500;
}

.oca-toggle-info svg {
    color: var(--oca-text-muted);
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* ── Pill Toggle Switch ── */
.oca-switch {
    position: relative;
    display: inline-flex;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.oca-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.oca-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: var(--oca-r-full);
    transition: background var(--oca-ease);
}

.oca-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform var(--oca-ease);
}

.oca-switch input:checked + .oca-slider {
    background: var(--oca-primary);
}

.oca-switch input:checked + .oca-slider::before {
    transform: translateX(18px);
}

.oca-switch input:focus-visible + .oca-slider {
    box-shadow: 0 0 0 3px rgba(21,101,192,0.35);
}

/* ── Range Slider ── */
.oca-range-wrap {
    padding: 2px 0;
}

.oca-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 8px;
    font-weight: 500;
}

.oca-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    cursor: pointer;
}

.oca-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--oca-primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform var(--oca-ease);
    border: 2px solid #fff;
}

.oca-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.oca-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--oca-primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.oca-range:focus-visible {
    outline: none;
}

.oca-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(21,101,192,0.35);
}

/* ── Screen Reader Controls ── */
.oca-sr-controls {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.oca-sr-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    border: 1.5px solid var(--oca-border);
    border-radius: var(--oca-r-sm);
    background: var(--oca-surface);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--oca-text);
    transition: background var(--oca-ease), border-color var(--oca-ease), color var(--oca-ease);
    white-space: nowrap;
    min-width: 0;
}

.oca-sr-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.oca-sr-stop:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--oca-danger);
}

.oca-sr-btn:focus-visible {
    outline: 2px solid var(--oca-primary);
    outline-offset: 2px;
}

/* ── Panel Footer ── */
.oca-panel-footer {
    flex-shrink: 0;
    padding: 14px 20px;
    border-top: 1px solid #f1f3f5;
    background: var(--oca-surface);
}

.oca-reset-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 16px;
    border: 1.5px solid var(--oca-border);
    border-radius: var(--oca-r-md);
    background: var(--oca-bg);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--oca-text-muted);
    transition: background var(--oca-ease), border-color var(--oca-ease), color var(--oca-ease);
}

.oca-reset-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--oca-danger);
}

.oca-reset-btn:focus-visible {
    outline: 2px solid var(--oca-danger);
    outline-offset: 2px;
}

/* ── Backdrop ── */
#oca-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.38);
    z-index: var(--oca-z);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--oca-ease);
}

#oca-backdrop.oca-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ══════════════════════════════════════════
   ACCESSIBILITY EFFECT CLASSES
   (applied to <body>)
   ══════════════════════════════════════════ */

/* Keep the widget itself clean under all modes */
#oca-container,
#oca-fab,
#oca-panel,
#oca-backdrop {
    filter: none !important;
    isolation: isolate;
}

/* ── High Contrast ── */
body.oca-contrast-high {
    background-color: #000 !important;
    color: #fff !important;
}

body.oca-contrast-high *:not(#oca-container):not(#oca-container *) {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

body.oca-contrast-high a:not(#oca-container *) {
    color: #ffff00 !important;
}

/* ── Reverse Contrast ── */
body.oca-contrast-reverse::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9997;
    background: #fff;
    mix-blend-mode: difference;
}

/* ── Smart Contrast ── */
body.oca-smart-contrast::before {
    content: '';
    position: fixed;
    inset: 0;
    backdrop-filter: contrast(1.5);
    pointer-events: none;
    z-index: 9996;
}

/* ── Link Highlight ── */
body.oca-link-highlight a:not(#oca-container *) {
    outline: 2px solid #f97316 !important;
    text-decoration: underline !important;
    border-radius: 2px;
}

/* ── Hide Images ── */
body.oca-hide-images img:not(#oca-container *),
body.oca-hide-images picture:not(#oca-container *),
body.oca-hide-images video:not(#oca-container *) {
    visibility: hidden !important;
}

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

/* ── Readable Font ── */
body.oca-readable-font *:not(#oca-container *):not(i):not([class*="fa"]):not([class*="icon"]) {
    font-family: Arial, Helvetica, sans-serif !important;
}

/* ── Dyslexia Friendly ── */
body.oca-dyslexia *:not(#oca-container *):not(i):not([class*="fa"]):not([class*="icon"]) {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
    letter-spacing: 0.05em !important;
    line-height: 1.8 !important;
}

/* ── Text Alignment ── */
body.oca-align-center  *:not(#oca-container *) { text-align: center  !important; }
body.oca-align-right   *:not(#oca-container *) { text-align: right   !important; }
body.oca-align-justify *:not(#oca-container *) { text-align: justify !important; }

/* ── Saturation ── */
body.oca-saturation-grayscale::before {
    content: '';
    position: fixed;
    inset: 0;
    background: #fff;
    mix-blend-mode: color;
    pointer-events: none;
    z-index: 9995;
}

body.oca-saturation-high::before {
    content: '';
    position: fixed;
    inset: 0;
    background: #f00;
    mix-blend-mode: saturation;
    pointer-events: none;
    z-index: 9995;
    opacity: 0.6;
}

/* ── Pause Animations ── */
body.oca-no-animations *:not(#oca-container *) {
    animation-duration:       0.001ms !important;
    animation-iteration-count: 1      !important;
    transition-duration:      0.001ms !important;
    scroll-behavior: auto             !important;
}

/* ── Big Cursor ── */
body.oca-big-cursor,
body.oca-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round' d='M4 3l16 7-7 3-3 7z'/%3E%3C/svg%3E") 4 3, pointer !important;
}

/* ── Tooltips ── */
body.oca-tooltips [aria-label]:not(#oca-container *):not(input):not(select):not(textarea) {
    position: relative;
}

body.oca-tooltips [aria-label]:not(#oca-container *):not(input):not(select):not(textarea):hover::after,
body.oca-tooltips [aria-label]:not(#oca-container *):not(input):not(select):not(textarea):focus::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 99999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Page Structure ── */
body.oca-page-structure header:not(#oca-container *),
body.oca-page-structure nav:not(#oca-container *),
body.oca-page-structure main:not(#oca-container *),
body.oca-page-structure section:not(#oca-container *),
body.oca-page-structure article:not(#oca-container *),
body.oca-page-structure aside:not(#oca-container *),
body.oca-page-structure footer:not(#oca-container *) {
    outline: 2px dashed #3b82f6 !important;
    position: relative;
}

body.oca-page-structure header:not(#oca-container *)::before,
body.oca-page-structure nav:not(#oca-container *)::before,
body.oca-page-structure main:not(#oca-container *)::before,
body.oca-page-structure section:not(#oca-container *)::before,
body.oca-page-structure article:not(#oca-container *)::before,
body.oca-page-structure aside:not(#oca-container *)::before,
body.oca-page-structure footer:not(#oca-container *)::before {
    content: attr(data-oca-tag);
    position: absolute;
    top: 0;
    left: 0;
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: monospace;
    padding: 2px 6px;
    border-radius: 0 0 4px 0;
    z-index: 99997;
    line-height: 1.5;
    pointer-events: none;
}

/* ── WordPress admin bar (32px tall when logged in) ── */
body.admin-bar #oca-panel {
    top: 32px;
    height: calc(100% - 32px);
}

@media screen and (max-width: 782px) {
    /* Admin bar shrinks to 46px on small screens */
    body.admin-bar #oca-panel {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* ── Responsive ── */
/* Below the desktop breakpoint (matches theme's own cs_side_contact_tab cutoff)
   "Middle Right" must not stay vertically centered - on any narrower window
   (phone, tablet, or a resized desktop browser) it ends up floating over
   whatever paragraph/content happens to sit at mid-viewport. Anchor to the
   bottom corner instead, same as the dedicated <=480px fix below. */
@media (max-width: 991px) {
    .oca-pos-middle-right #oca-fab {
        top: auto;
        bottom: 155px;
        right: 20px;
        transform: none;
    }
    .oca-pos-middle-right #oca-fab:hover {
        transform: scale(1.07);
    }
}

@media (max-width: 480px) {
    #oca-container {
        --oca-panel-w: 100vw;
    }

    /* 56px/28px icon was sized for desktop — shrinks the stack of floating
       buttons down to match the theme's own mobile CTA/scroll-up sizing. */
    #oca-fab {
        width: 46px;
        height: 46px;
    }
    #oca-fab svg {
        width: 22px;
        height: 22px;
    }

    .oca-pos-middle-right #oca-fab,
    .oca-pos-bottom-right #oca-fab {
        right: 14px;
    }

    .oca-pos-bottom-left #oca-fab,
    .oca-pos-top-left    #oca-fab {
        left: 14px;
    }

    .oca-pos-bottom-right #oca-fab {
        bottom: 70px;
    }

    /* "Middle Right" floats over page content on short/narrow screens since it's
       vertically centered on the viewport regardless of scroll position - anchor
       it to the bottom instead, clearing the sticky mobile call/schedule bar.
       155 -> 212: the theme's chat-widget bubble now occupies 148-194px in
       this same bottom-right stack (scroll-up -> mobile CTA -> chat -> this
       FAB); 212 clears its top edge with the same ~18px gap used throughout. */
    .oca-pos-middle-right #oca-fab {
        top: auto;
        bottom: 212px;
        transform: none;
    }
    .oca-pos-middle-right #oca-fab:hover {
        transform: scale(1.07);
    }
}

@media (max-width: 768px) {
    #oca-container {
        --oca-panel-w: min(340px, 100vw);
    }
}
