/**
 * SmcAccessAbility - Self-hosted accessibility widget for Zen Cart
 * Widget UI styles + page-effect feature classes.
 *
 * Bundled font: OpenDyslexic (https://opendyslexic.org) - SIL Open Font License 1.1
 */

@font-face {
    font-family: 'SMCACC OpenDyslexic';
    src: url('fonts/OpenDyslexic-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --smcacc-accent: #132a47;
    --smcacc-on-accent: #ffffff; /* JS overrides per WCAG luminance of the accent */
    --smcacc-btn-size: 48px;
}

/* ==========================================================================
   Widget button + panel (everything scoped under #smcacc-root)
   ========================================================================== */

#smcacc-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    color: #24272b;
    text-align: left;
}
#smcacc-root *,
#smcacc-root *::before,
#smcacc-root *::after {
    box-sizing: border-box;
}

#smcacc-btn {
    position: fixed;
    z-index: 2147483645;
    width: var(--smcacc-btn-size);
    height: var(--smcacc-btn-size);
    border: 2px solid var(--smcacc-on-accent);
    border-radius: 50%;
    background: var(--smcacc-accent);
    color: var(--smcacc-on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
#smcacc-btn svg {
    width: 62%;
    height: 62%;
    fill: var(--smcacc-on-accent);
}
#smcacc-btn:hover { transform: scale(1.06); }
#smcacc-btn:focus-visible,
#smcacc-root button:focus-visible,
#smcacc-root input:focus-visible,
#smcacc-root select:focus-visible,
#smcacc-root a:focus-visible {
    /* Two-color indicator: visible on light and dark surfaces alike. */
    outline: 2px solid #000;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #fff;
}
#smcacc-root.smcacc-pos-bottom-left #smcacc-btn { left: 16px; bottom: 16px; }
#smcacc-root.smcacc-pos-bottom-right #smcacc-btn { right: 16px; bottom: 16px; }
#smcacc-root.smcacc-pos-top-left #smcacc-btn { left: 16px; top: 16px; }
#smcacc-root.smcacc-pos-top-right #smcacc-btn { right: 16px; top: 16px; }

#smcacc-panel {
    position: fixed;
    z-index: 2147483646;
    top: 0;
    bottom: 0;
    left: 0;
    width: 420px;
    max-width: 100vw;
    background: #f4f6f9;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
}
#smcacc-root.smcacc-pos-bottom-right #smcacc-panel,
#smcacc-root.smcacc-pos-top-right #smcacc-panel {
    left: auto;
    right: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}
#smcacc-root.smcacc-open #smcacc-panel { display: flex; }

@media (prefers-reduced-motion: no-preference) {
    #smcacc-root.smcacc-open #smcacc-panel { animation: smcacc-slide-in 0.22s ease-out; }
    #smcacc-root.smcacc-pos-bottom-right.smcacc-open #smcacc-panel,
    #smcacc-root.smcacc-pos-top-right.smcacc-open #smcacc-panel { animation-name: smcacc-slide-in-r; }
}
html.smcacc-stop-animations #smcacc-panel { animation: none !important; }
@keyframes smcacc-slide-in { from { transform: translateX(-40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes smcacc-slide-in-r { from { transform: translateX(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }

#smcacc-body { scrollbar-width: thin; scrollbar-color: #b6bfca #f4f6f9; }
#smcacc-body::-webkit-scrollbar { width: 8px; }
#smcacc-body::-webkit-scrollbar-track { background: #f4f6f9; }
#smcacc-body::-webkit-scrollbar-thumb { background: #b6bfca; border-radius: 4px; }

#smcacc-header {
    background: var(--smcacc-accent);
    color: var(--smcacc-on-accent);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
#smcacc-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--smcacc-on-accent);
}
#smcacc-close {
    background: transparent;
    border: 1px solid var(--smcacc-on-accent);
    border-radius: 4px;
    color: var(--smcacc-on-accent);
    font-size: 18px;
    line-height: 1;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

#smcacc-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
}

#smcacc-footer {
    flex: 0 0 auto;
    background: #fff;
    border-top: 1px solid #d9dee5;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
#smcacc-footer a,
#smcacc-footer button {
    background: none;
    border: none;
    padding: 0;
    color: #24272b;
    text-decoration: underline;
    font-size: 14px;
    cursor: pointer;
}

/* --- panel building blocks ---------------------------------------------- */

.smcacc-block {
    background: #fff;
    border: 1px solid #e2e6ec;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0 0 10px;
}

#smcacc-wiki-input,
#smcacc-translate select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #c8cfd8;
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
    color: #24272b;
}
#smcacc-wiki-result {
    margin-top: 8px;
    font-size: 14px;
    display: none;
}
#smcacc-wiki-result.smcacc-show { display: block; }
#smcacc-wiki-result h3 { margin: 0 0 4px; font-size: 15px; }

.smcacc-profile {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
}
.smcacc-profile + .smcacc-profile { border-top: 1px solid #eef1f5; }
.smcacc-profile-text b { display: block; font-weight: 600; font-size: 15px; }
.smcacc-profile-text span { display: block; font-size: 13px; color: #5a6270; }

.smcacc-switch {
    flex: 0 0 auto;
    width: 42px;
    height: 24px;
    border-radius: 12px;
    background: #cfd6df;
    border: none;
    position: relative;
    cursor: pointer;
    margin-top: 2px;
    transition: background 0.15s;
}
.smcacc-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s;
}
.smcacc-switch[aria-pressed="true"] { background: var(--smcacc-accent); }
.smcacc-switch[aria-pressed="true"]::after { left: 21px; background: var(--smcacc-on-accent); border: 1px solid #6b7280; }

.smcacc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 10px;
}
.smcacc-tile {
    background: #fff;
    border: 1px solid #e2e6ec;
    border-radius: 8px;
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    color: #24272b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.smcacc-tile svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #24272b;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.smcacc-tile:not(.smcacc-stepper):hover {
    border-color: var(--smcacc-accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.smcacc-profile:hover { background: #f7f9fc; }
.smcacc-swatch:hover { transform: scale(1.18); }
.smcacc-tile[aria-pressed="true"] {
    border-color: #6b7280;
    background: var(--smcacc-accent);
    color: var(--smcacc-on-accent);
}
.smcacc-tile[aria-pressed="true"] svg { stroke: var(--smcacc-on-accent); }

.smcacc-stepper { cursor: default; }
.smcacc-stepper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    background: #eef1f5;
    border-radius: 16px;
    padding: 3px;
}
.smcacc-stepper-row button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #6b7280;
    background: var(--smcacc-accent);
    color: var(--smcacc-on-accent);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}
.smcacc-stepper-value { font-size: 13px; }

.smcacc-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding-top: 6px;
}
.smcacc-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #d9dee5;
    cursor: pointer;
    padding: 0;
}
.smcacc-swatch[aria-pressed="true"] {
    border-color: #24272b;
    box-shadow: 0 0 0 2px #fff inset;
}
.smcacc-block-title {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
}

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

/* ==========================================================================
   JS-managed overlays (guide, mask, magnifier, keyboard, TTS outline)
   ========================================================================== */

#smcacc-guide {
    position: fixed;
    z-index: 2147483644;
    left: 0;
    width: 100%;
    height: 10px;
    background: var(--smcacc-accent);
    border-top: 2px solid #ff8c00;
    border-bottom: 2px solid #ff8c00;
    pointer-events: none;
}
#smcacc-mask-top,
#smcacc-mask-bottom {
    position: fixed;
    z-index: 2147483643;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.72);
    pointer-events: none;
}
#smcacc-magnifier {
    position: fixed;
    z-index: 2147483644;
    max-width: 60vw;
    background: #111;
    color: #fff;
    font-size: 26px;
    line-height: 1.3;
    padding: 10px 14px;
    border-radius: 6px;
    pointer-events: none;
    display: none;
}
#smcacc-keyboard {
    position: fixed;
    z-index: 2147483646;
    left: 50%;
    transform: translateX(-50%);
    bottom: 8px;
    background: #1f2430;
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 98vw;
}
.smcacc-kb-row { display: flex; justify-content: center; gap: 4px; margin: 4px 0; }
.smcacc-kb-row button {
    min-width: 32px;
    height: 38px;
    border: none;
    border-radius: 5px;
    background: #3a4152;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    padding: 0 8px;
}
.smcacc-kb-row button:active { background: var(--smcacc-accent); }

.smcacc-tts-active { outline: 3px solid #ff8c00 !important; }

#smcacc-live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ==========================================================================
   Feature classes applied to <html>
   Filters live on the ROOT element on purpose: per the CSS spec, a filter on
   the root does NOT create a containing block for fixed-position descendants,
   so sticky headers and this widget keep working.
   ========================================================================== */

/* --- fonts --------------------------------------------------------------- */
html.smcacc-readable-font body :not(#smcacc-root):not(#smcacc-root *) {
    font-family: Arial, Helvetica, sans-serif !important;
}
html.smcacc-dyslexia-friendly body :not(#smcacc-root):not(#smcacc-root *) {
    font-family: 'SMCACC OpenDyslexic', Arial, sans-serif !important;
}

/* --- highlights ---------------------------------------------------------- */
html.smcacc-highlight-titles body h1:not(#smcacc-root *),
html.smcacc-highlight-titles body h2:not(#smcacc-root *),
html.smcacc-highlight-titles body h3:not(#smcacc-root *),
html.smcacc-highlight-titles body h4:not(#smcacc-root *),
html.smcacc-highlight-titles body h5:not(#smcacc-root *),
html.smcacc-highlight-titles body h6:not(#smcacc-root *) {
    outline: 2px solid #0048ff !important;
    outline-offset: 2px;
}
html.smcacc-highlight-links body a:not(#smcacc-root *) {
    outline: 2px solid #ffb300 !important;
    outline-offset: 1px;
    text-decoration: underline !important;
}
html.smcacc-highlight-hover body :not(#smcacc-root):not(#smcacc-root *):hover {
    outline: 3px solid #ff5722 !important;
    outline-offset: 1px;
}
html.smcacc-highlight-focus body :not(#smcacc-root):not(#smcacc-root *):focus {
    outline: 4px solid #ff8c00 !important;
    outline-offset: 2px;
}

/* --- hide images --------------------------------------------------------- */
html.smcacc-hide-images body img:not(#smcacc-root *),
html.smcacc-hide-images body picture:not(#smcacc-root *),
html.smcacc-hide-images body svg:not(#smcacc-root *):not(#smcacc-root svg),
html.smcacc-hide-images body video:not(#smcacc-root *) {
    visibility: hidden !important;
}
html.smcacc-hide-images body :not(#smcacc-root):not(#smcacc-root *) {
    background-image: none !important;
}

/* --- stop animations ------------------------------------------------------ */
html.smcacc-stop-animations,
html.smcacc-stop-animations body *:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-stop-animations body *:not(#smcacc-root):not(#smcacc-root *)::before,
html.smcacc-stop-animations body *:not(#smcacc-root):not(#smcacc-root *)::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* --- big cursors ---------------------------------------------------------- */
html.smcacc-big-black-cursor,
html.smcacc-big-black-cursor body * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24'><path d='M5 2 L5 20 L10 15.5 L13 22 L15.5 21 L12.6 14.6 L19 14 Z' fill='black' stroke='white' stroke-width='1.4'/></svg>") 5 2, auto !important;
}
html.smcacc-big-white-cursor,
html.smcacc-big-white-cursor body * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24'><path d='M5 2 L5 20 L10 15.5 L13 22 L15.5 21 L12.6 14.6 L19 14 Z' fill='white' stroke='black' stroke-width='1.4'/></svg>") 5 2, auto !important;
}

/* --- line height / letter spacing / alignment ---------------------------- */
html.smcacc-lh-1 body :not(#smcacc-root):not(#smcacc-root *) { line-height: 1.5 !important; }
html.smcacc-lh-2 body :not(#smcacc-root):not(#smcacc-root *) { line-height: 1.8 !important; }
html.smcacc-lh-3 body :not(#smcacc-root):not(#smcacc-root *) { line-height: 2.1 !important; }
html.smcacc-lh-4 body :not(#smcacc-root):not(#smcacc-root *) { line-height: 2.4 !important; }

html.smcacc-ls-1 body :not(#smcacc-root):not(#smcacc-root *) { letter-spacing: 1px !important; }
html.smcacc-ls-2 body :not(#smcacc-root):not(#smcacc-root *) { letter-spacing: 2px !important; }
html.smcacc-ls-3 body :not(#smcacc-root):not(#smcacc-root *) { letter-spacing: 3px !important; }
html.smcacc-ls-4 body :not(#smcacc-root):not(#smcacc-root *) { letter-spacing: 4px !important; }

html.smcacc-align-left body :not(#smcacc-root):not(#smcacc-root *) { text-align: left !important; }
html.smcacc-align-center body :not(#smcacc-root):not(#smcacc-root *) { text-align: center !important; }
html.smcacc-align-right body :not(#smcacc-root):not(#smcacc-root *) { text-align: right !important; }

/* --- contrast & saturation ------------------------------------------------ */
html.smcacc-monochrome { filter: grayscale(100%); }
html.smcacc-high-contrast { filter: contrast(135%); }
html.smcacc-high-saturation { filter: saturate(2.2); }
html.smcacc-low-saturation { filter: saturate(0.4); }

html.smcacc-dark-contrast body,
html.smcacc-dark-contrast body :not(#smcacc-root):not(#smcacc-root *):not(img):not(picture):not(video):not(svg) {
    background-color: #0d0f12 !important;
    color: #f2f2f2 !important;
    border-color: #3a3f47 !important;
}
/* The overrides below carry TWO :not(#id) terms on purpose: the generic
   forced-color rule above has two, so anything meant to beat it needs equal
   ID weight plus more type weight. A bare border-color is useless against
   themes that set border:0 - the full border shorthand restores a box. */
html.smcacc-dark-contrast body a:not(#smcacc-root):not(#smcacc-root *) { color: #8ab4ff !important; }
html.smcacc-dark-contrast body button:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-dark-contrast body input[type="submit"]:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-dark-contrast body input[type="button"]:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-dark-contrast body .btn:not(#smcacc-root):not(#smcacc-root *) {
    background-color: #1e2733 !important;
    border: 1px solid #556070 !important;
}
html.smcacc-dark-contrast body input:not([type="submit"]):not([type="button"]):not(#smcacc-root):not(#smcacc-root *),
html.smcacc-dark-contrast body select:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-dark-contrast body textarea:not(#smcacc-root):not(#smcacc-root *) {
    background-color: #171c23 !important;
    border: 1px solid #556070 !important;
}

html.smcacc-light-contrast body,
html.smcacc-light-contrast body :not(#smcacc-root):not(#smcacc-root *):not(img):not(picture):not(video):not(svg) {
    background-color: #ffffff !important;
    color: #0d0f12 !important;
    border-color: #9aa2ad !important;
}
html.smcacc-light-contrast body a:not(#smcacc-root):not(#smcacc-root *) { color: #0038c7 !important; }
html.smcacc-light-contrast body button:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-light-contrast body input[type="submit"]:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-light-contrast body input[type="button"]:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-light-contrast body .btn:not(#smcacc-root):not(#smcacc-root *) {
    background-color: #e8ecf1 !important;
    border: 1px solid #7c8794 !important;
}
html.smcacc-light-contrast body input:not([type="submit"]):not([type="button"]):not(#smcacc-root):not(#smcacc-root *),
html.smcacc-light-contrast body select:not(#smcacc-root):not(#smcacc-root *),
html.smcacc-light-contrast body textarea:not(#smcacc-root):not(#smcacc-root *) {
    background-color: #f6f8fa !important;
    border: 1px solid #7c8794 !important;
}
