/* ==============================================
   YMDigital Accessibility Widget - Frontend CSS
   v1.3.0 - Visual refresh
   - Subtle 1px borders, soft shadows for depth
   - !important on critical visuals to beat theme overrides
   - Compact spacing
   - No horizontal scroll
   ============================================== */

/* ==============================================
   1) Floating toggle button
   ============================================== */
#ymda-toggle {
    position: fixed !important;
    z-index: 999998 !important;
    background: var(--ymda-primary, #1e40af) !important;
    color: var(--ymda-icon, #ffffff) !important;
    border: 0 !important;
    cursor: pointer !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.12) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform .25s ease, box-shadow .25s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit;
    box-sizing: border-box !important;
    line-height: 1 !important;
}
#ymda-toggle:hover { transform: scale(1.08); box-shadow: 0 10px 28px rgba(0,0,0,0.25), 0 4px 8px rgba(0,0,0,0.15) !important; }
#ymda-toggle:focus-visible { outline: 3px solid #ffffff !important; outline-offset: 3px !important; box-shadow: 0 0 0 6px rgba(0,0,0,0.4) !important; }
#ymda-toggle svg { width: 60% !important; height: 60% !important; fill: var(--ymda-icon, #ffffff) !important; display: block !important; }

#ymda-toggle.ymda-pos-bottom-right { bottom: var(--ymda-offset-y, 20px) !important; right: var(--ymda-offset-x, 20px) !important; }
#ymda-toggle.ymda-pos-bottom-left  { bottom: var(--ymda-offset-y, 20px) !important; left:  var(--ymda-offset-x, 20px) !important; }
#ymda-toggle.ymda-pos-top-right    { top:    var(--ymda-offset-y, 20px) !important; right: var(--ymda-offset-x, 20px) !important; }
#ymda-toggle.ymda-pos-top-left     { top:    var(--ymda-offset-y, 20px) !important; left:  var(--ymda-offset-x, 20px) !important; }
#ymda-toggle.ymda-pos-middle-right { top: calc(50% + var(--ymda-offset-y, 0px)) !important; right: var(--ymda-offset-x, 20px) !important; transform: translateY(-50%); }
#ymda-toggle.ymda-pos-middle-left  { top: calc(50% + var(--ymda-offset-y, 0px)) !important; left:  var(--ymda-offset-x, 20px) !important; transform: translateY(-50%); }
#ymda-toggle.ymda-pos-middle-right:hover,
#ymda-toggle.ymda-pos-middle-left:hover { transform: translateY(-50%) scale(1.08) !important; }

#ymda-toggle.ymda-size-small  { width: 44px !important; height: 44px !important; }
#ymda-toggle.ymda-size-medium { width: 56px !important; height: 56px !important; }
#ymda-toggle.ymda-size-large  { width: 68px !important; height: 68px !important; }

#ymda-toggle.ymda-shape-circle  { border-radius: 50% !important; }
#ymda-toggle.ymda-shape-rounded { border-radius: 14px !important; }
#ymda-toggle.ymda-shape-square  { border-radius: 6px !important; }

/* ==============================================
   2) Panel
   ============================================== */
#ymda-panel {
    position: fixed !important;
    top: 0 !important;
    width: 340px !important;
    max-width: 100vw !important;
    height: 100vh !important;
    background: #ffffff !important;
    color: #111827 !important;
    box-shadow: -8px 0 32px rgba(0,0,0,0.18) !important;
    z-index: 999999 !important;
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.16,1,.3,1) !important;
    display: flex !important;
    flex-direction: column !important;
    direction: rtl !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    border: 0 !important;
    margin: 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}
/* Font is set via inline <style> in <head> based on admin setting.
   This is a non-!important fallback in case the inline style fails to load. */
#ymda-panel { font-family: inherit; }
#ymda-panel.ymda-side-right { right: 0 !important; transform: translateX(100%); }
#ymda-panel.ymda-side-left  { left:  0 !important; box-shadow: 8px 0 32px rgba(0,0,0,0.18) !important; transform: translateX(-100%); }
#ymda-panel.ymda-open       { transform: translateX(0) !important; }

#ymda-panel * { box-sizing: border-box; font-family: inherit; }

#ymda-panel[inert] { pointer-events: none; }

/* --- Header --- (uses inline style on element AND !important here as double safety) */
#ymda-panel .ymda-header {
    background: var(--ymda-primary, #1e40af) !important;
    color: var(--ymda-primary-text, #ffffff) !important;
    padding: 18px 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    border: 0 !important;
    margin: 0 !important;
    min-height: 64px !important;
}
#ymda-panel .ymda-header h2 {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--ymda-primary-text, #ffffff) !important;
    line-height: 1.3 !important;
    background: transparent !important;
    border: 0 !important;
    text-shadow: none !important;
}

#ymda-panel .ymda-close {
    background: rgba(255,255,255,0.18) !important;
    border: 0 !important;
    color: var(--ymda-primary-text, #ffffff) !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    font-size: 16px !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .2s !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}
#ymda-panel .ymda-close:hover { background: rgba(255,255,255,0.32) !important; }
#ymda-panel .ymda-close:focus-visible { outline: 2px solid var(--ymda-primary-text, #ffffff) !important; outline-offset: 2px !important; background: rgba(255,255,255,0.32) !important; }
#ymda-panel .ymda-close span { color: inherit !important; font-size: inherit !important; }

/* --- Body --- */
#ymda-panel .ymda-body {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px !important;
    background: #ffffff !important;
}

/* --- Sections --- */
#ymda-panel .ymda-section { margin: 0 0 18px 0 !important; padding: 0 !important; }
#ymda-panel .ymda-section h3 {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #4b5563 !important;          /* 7.6:1 on white - AAA */
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    letter-spacing: 0.3px !important;
    line-height: 1.3 !important;
    text-transform: none !important;
    background: transparent !important;
    border: 0 !important;
}

/* --- Quick row (3 cols) --- */
#ymda-panel .ymda-quick-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
}
#ymda-panel .ymda-quick {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 12px 4px !important;
    cursor: pointer !important;
    font-size: 12px !important;
    color: #111827 !important;          /* AAA */
    transition: all .15s ease !important;
    text-align: center !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
    margin: 0 !important;
    width: 100% !important;
    font-family: inherit !important;
}
#ymda-panel .ymda-quick:hover { border-color: var(--ymda-primary, #1e40af) !important; background: #f9fafb !important; transform: translateY(-1px) !important; box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important; }
#ymda-panel .ymda-quick:focus-visible { outline: 3px solid var(--ymda-primary, #1e40af) !important; outline-offset: 2px !important; }
#ymda-panel .ymda-quick.ymda-active { background: var(--ymda-primary, #1e40af) !important; color: var(--ymda-primary-text, #ffffff) !important; border-color: var(--ymda-primary, #1e40af) !important; box-shadow: 0 4px 12px rgba(30,64,175,0.25) !important; }
#ymda-panel .ymda-quick .ymda-quick-icon {
    font-size: 18px !important;
    display: block !important;
    margin: 0 auto 4px !important;
    line-height: 1 !important;
    font-weight: 700 !important;
    color: inherit !important;
}

/* --- 2-col grid --- */
#ymda-panel .ymda-grid-2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- Toggle buttons --- */
#ymda-panel .ymda-btn {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 12px 8px !important;
    cursor: pointer !important;
    font-size: 12.5px !important;
    color: #111827 !important;
    transition: all .15s ease !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
    margin: 0 !important;
    width: 100% !important;
    font-family: inherit !important;
}
#ymda-panel .ymda-btn:hover { border-color: var(--ymda-primary, #1e40af) !important; background: #f9fafb !important; transform: translateY(-1px) !important; box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important; }
#ymda-panel .ymda-btn:focus-visible { outline: 3px solid var(--ymda-primary, #1e40af) !important; outline-offset: 2px !important; }
#ymda-panel .ymda-btn.ymda-active { background: var(--ymda-primary, #1e40af) !important; color: var(--ymda-primary-text, #ffffff) !important; border-color: var(--ymda-primary, #1e40af) !important; box-shadow: 0 4px 12px rgba(30,64,175,0.25) !important; }
#ymda-panel .ymda-btn svg { width: 20px !important; height: 20px !important; fill: currentColor !important; display: block !important; }
#ymda-panel .ymda-btn span { color: inherit !important; }

/* --- Counter widgets (pill style) --- */
#ymda-panel .ymda-counter {
    display: flex !important;
    align-items: center !important;
    background: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 4px !important;
    gap: 4px !important;
    margin: 0 !important;
}
#ymda-panel .ymda-counter-btn {
    flex-shrink: 0 !important;
    width: 36px !important;
    height: 36px !important;
    border: 0 !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--ymda-primary, #1e40af) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    transition: all .15s !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06) !important;
    font-family: inherit !important;
    line-height: 1 !important;
}
#ymda-panel .ymda-counter-btn:hover { background: var(--ymda-primary, #1e40af) !important; color: var(--ymda-primary-text, #ffffff) !important; }
#ymda-panel .ymda-counter-btn:focus-visible { outline: 2px solid var(--ymda-primary, #1e40af) !important; outline-offset: 2px !important; }
#ymda-panel .ymda-counter-label {
    flex: 1 !important;
    text-align: center !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #111827 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

/* --- Reset --- */
#ymda-panel .ymda-reset-row { margin: 12px 0 16px 0 !important; padding: 0 !important; }
#ymda-panel .ymda-reset {
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #fecaca !important;
    color: #991b1b !important;
    padding: 11px !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    transition: all .15s !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
    margin: 0 !important;
    font-family: inherit !important;
    line-height: 1.3 !important;
}
#ymda-panel .ymda-reset:hover { background: #991b1b !important; color: #ffffff !important; border-color: #991b1b !important; }
#ymda-panel .ymda-reset:focus-visible { outline: 3px solid #991b1b !important; outline-offset: 2px !important; }

/* --- Footer --- */
#ymda-panel .ymda-footer {
    flex-shrink: 0 !important;
    padding: 14px 16px !important;
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
    text-align: center !important;
    font-size: 12.5px !important;
    color: #374151 !important;          /* 10.3:1 on #f9fafb - AAA */
    margin: 0 !important;
    line-height: 1.5 !important;
}
#ymda-panel .ymda-footer a {
    color: #1d4ed8 !important;          /* 6.7:1 on #f9fafb */
    text-decoration: underline !important;
    font-weight: 700 !important;
    background: transparent !important;
}
#ymda-panel .ymda-footer a:hover { color: #1e3a8a !important; }
#ymda-panel .ymda-footer a:focus-visible { outline: 2px solid #1e3a8a !important; outline-offset: 2px !important; }
#ymda-panel .ymda-statement-link { display: block !important; margin: 0 0 6px 0 !important; }
#ymda-panel .ymda-credit-line { display: block !important; color: #374151 !important; }

/* ==============================================
   3) Reading helpers
   ============================================== */
#ymda-reading-guide {
    position: fixed; left: 0; width: 100vw; height: 36px;
    background: rgba(0,0,0,0.55);
    border-top: 2px solid #ffd700;
    border-bottom: 2px solid #ffd700;
    pointer-events: none; z-index: 999997; top: 0; display: none;
}
html.ymda-reading-guide-on #ymda-reading-guide { display: block; }
#ymda-reading-mask-top, #ymda-reading-mask-bottom {
    position: fixed; left: 0; width: 100vw;
    background: rgba(0,0,0,0.7); pointer-events: none; z-index: 999997; display: none;
}
#ymda-reading-mask-top { top: 0; }
#ymda-reading-mask-bottom { bottom: 0; }
html.ymda-reading-mask-on #ymda-reading-mask-top,
html.ymda-reading-mask-on #ymda-reading-mask-bottom { display: block; }

/* ==============================================
   4) Accessibility modes
   ============================================== */

/* --- Grayscale ---
   IMPORTANT: filter must NOT be applied to <body> directly, because that
   would turn body into the containing block for our position:fixed panel,
   making it "snap" out of the viewport. Instead, we filter body's DIRECT
   CHILDREN, excluding the widget. body itself has no filter, so the panel
   stays positioned relative to the viewport. */
html.ymda-grayscale body > *:not(#ymda-panel):not(#ymda-toggle):not(#ymda-reading-guide):not(#ymda-reading-mask-top):not(#ymda-reading-mask-bottom) {
    filter: grayscale(100%) !important;
    -webkit-filter: grayscale(100%) !important;
}

html.ymda-high-contrast body :not(#ymda-panel, #ymda-panel *, #ymda-toggle, #ymda-toggle *, #ymda-reading-guide, #ymda-reading-mask-top, #ymda-reading-mask-bottom) {
    background-color: #000 !important; color: #ffff00 !important; border-color: #ffff00 !important;
}
html.ymda-high-contrast body { background: #000 !important; color: #ffff00 !important; }
html.ymda-high-contrast body a:not(#ymda-panel a):not(#ymda-toggle) { color: #00ffff !important; }
html.ymda-high-contrast body img:not(#ymda-panel img),
html.ymda-high-contrast body video:not(#ymda-panel video) { filter: brightness(.85) contrast(1.15); }

/* --- Negative contrast (invert) ---
   Same fix as grayscale: filter on direct body children, not body itself.
   This keeps our position:fixed panel anchored to the viewport. */
html.ymda-negative-contrast body > *:not(#ymda-panel):not(#ymda-toggle):not(#ymda-reading-guide):not(#ymda-reading-mask-top):not(#ymda-reading-mask-bottom) {
    filter: invert(100%) hue-rotate(180deg) !important;
    -webkit-filter: invert(100%) hue-rotate(180deg) !important;
}
/* Body bg might show through gaps - explicitly invert white→black */
html.ymda-negative-contrast body { background-color: #000 !important; }
/* Double-invert media so it looks normal (parent inverts once, this inverts again) */
html.ymda-negative-contrast body img:not(#ymda-panel img):not(#ymda-toggle img),
html.ymda-negative-contrast body video:not(#ymda-panel video):not(#ymda-toggle video),
html.ymda-negative-contrast body iframe:not(#ymda-panel iframe):not(#ymda-toggle iframe) {
    filter: invert(100%) hue-rotate(180deg);
}

html.ymda-light-bg body :not(#ymda-panel, #ymda-panel *, #ymda-toggle, #ymda-toggle *, #ymda-reading-guide, #ymda-reading-mask-top, #ymda-reading-mask-bottom) {
    background-color: #fff !important; color: #000 !important; border-color: #666 !important;
}
html.ymda-light-bg body { background: #fff !important; color: #000 !important; }
html.ymda-light-bg body a:not(#ymda-panel a):not(#ymda-toggle) { color: #0033a0 !important; }

html.ymda-dark-bg body :not(#ymda-panel, #ymda-panel *, #ymda-toggle, #ymda-toggle *, #ymda-reading-guide, #ymda-reading-mask-top, #ymda-reading-mask-bottom) {
    background-color: #1a1a1a !important; color: #f5f5f5 !important; border-color: #666 !important;
}
html.ymda-dark-bg body { background: #1a1a1a !important; color: #f5f5f5 !important; }
html.ymda-dark-bg body a:not(#ymda-panel a):not(#ymda-toggle) { color: #80b3ff !important; }

html.ymda-underline-links body a:not(#ymda-panel a):not(#ymda-toggle) { text-decoration: underline !important; }

html.ymda-highlight-links body a:not(#ymda-panel a):not(#ymda-toggle) {
    background-color: #ffff00 !important; color: #000 !important;
    outline: 2px solid #000 !important; padding: 0 3px !important;
}

html.ymda-readable-font body :not(#ymda-panel, #ymda-panel *, #ymda-toggle, #ymda-toggle *) {
    font-family: Arial, "Segoe UI", Tahoma, Verdana, sans-serif !important;
    letter-spacing: 0.5px !important;
    line-height: 1.7 !important;
    font-weight: normal !important;
}

html.ymda-big-cursor,
html.ymda-big-cursor body,
html.ymda-big-cursor body * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23000' stroke='%23fff' stroke-width='1.5' d='M5.5 3.21V20.8c0 .45.54.67.85.35l4.86-4.86a.5.5 0 0 1 .35-.15h6.87a.5.5 0 0 0 .35-.85L6.35 2.85a.5.5 0 0 0-.85.36z'/></svg>"), auto !important;
}
html.ymda-big-cursor body a,
html.ymda-big-cursor body button,
html.ymda-big-cursor body [role="button"] {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23fff' stroke='%23000' stroke-width='1.5' d='M13 2.05V5.08C16.39 5.57 19 8.47 19 12c0 .9-.18 1.75-.5 2.54l2.62 1.52A8.94 8.94 0 0 0 22 12c0-5.18-3.95-9.45-9-9.95M12 19c-3.87 0-7-3.13-7-7c0-3.53 2.61-6.43 6-6.92V2.05c-5.06.5-9 4.76-9 9.95c0 5.52 4.47 10 9.99 10c3.31 0 6.24-1.61 8.06-4.09l-2.6-1.53C16.17 17.98 14.21 19 12 19'/></svg>"), pointer !important;
}

html.ymda-stop-animations,
html.ymda-stop-animations *,
html.ymda-stop-animations *::before,
html.ymda-stop-animations *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}
html.ymda-stop-animations body img[src*=".gif"]:not(#ymda-panel img),
html.ymda-stop-animations body img[src$=".gif"]:not(#ymda-panel img) { visibility: hidden !important; }

html.ymda-focus-highlight body *:focus {
    outline: 4px solid #ffd700 !important;
    outline-offset: 2px !important;
    background-color: rgba(255, 215, 0, 0.15) !important;
}

/* ==============================================
   5) Text scaling
   ============================================== */
html.ymda-text-scaled { font-size: calc(100% * var(--ymda-text-scale, 1)) !important; }

html.ymda-line-scaled body p:not(#ymda-panel p),
html.ymda-line-scaled body li:not(#ymda-panel li),
html.ymda-line-scaled body div:not(#ymda-panel, #ymda-panel *),
html.ymda-line-scaled body span:not(#ymda-panel span),
html.ymda-line-scaled body a:not(#ymda-panel a),
html.ymda-line-scaled body td:not(#ymda-panel td),
html.ymda-line-scaled body label:not(#ymda-panel label),
html.ymda-line-scaled body blockquote:not(#ymda-panel blockquote) {
    line-height: var(--ymda-line-height, 1.5) !important;
}

html.ymda-letter-scaled body :not(#ymda-panel, #ymda-panel *, #ymda-toggle, #ymda-toggle *) {
    letter-spacing: var(--ymda-letter-spacing, normal) !important;
}

/* ==============================================
   6) Mobile
   ============================================== */
@media (max-width: 480px) {
    #ymda-panel { width: 100vw !important; max-width: 100vw !important; }
}

/* ==============================================
   7) Respect prefers-reduced-motion
   ============================================== */
@media (prefers-reduced-motion: reduce) {
    #ymda-panel, #ymda-toggle { transition: none !important; }
}
