/**
 * SP Academy — WCAG 2.1 AA Accessibility Styles
 * SUS 3.0 compliance requirement
 *
 * Brand palette: warm cream (#faf7f5), burgundy (#7a2332), soft rose (#e8c4b8)
 */

/* ─── Accessibility Toolbar ─── */
#sp-a11y-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#sp-a11y-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #7a2332;
    color: #fff !important;
    border: 2px solid #e8c4b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(122, 35, 50, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

#sp-a11y-toggle svg {
    width: 24px !important;
    min-width: 24px !important;
    height: 24px !important;
    fill: #fff !important;
    flex-shrink: 0 !important;
    display: block !important;
}

#sp-a11y-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(122, 35, 50, 0.5);
}

#sp-a11y-toggle:focus-visible {
    outline: 3px solid #7a2332;
    outline-offset: 2px;
}

/* ─── Panel ─── */
.sp-a11y-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 290px;
    background: #faf7f5;
    color: #3a2a2a;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border: 1px solid #e8c4b8;
}

.sp-a11y-panel h3 {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 700;
    color: #7a2332;
    border-bottom: 2px solid #e8c4b8;
    padding-bottom: 10px;
    letter-spacing: 0.02em;
}

/* ─── Options ─── */
.sp-a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 500;
    color: #3a2a2a;
    cursor: pointer;
    border-bottom: 1px solid rgba(122, 35, 50, 0.08);
}

.sp-a11y-option:last-of-type {
    border-bottom: none;
}

.sp-a11y-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #7a2332;
    cursor: pointer;
    flex-shrink: 0;
}

/* ─── Font Size Buttons ─── */
.sp-a11y-font-btns {
    display: flex;
    gap: 6px;
}

.sp-a11y-font-btns button {
    width: 38px;
    height: 34px;
    border: 1px solid #d4b0a0;
    background: #fff;
    color: #7a2332;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s;
}

.sp-a11y-font-btns button:hover {
    background: #f3e0d8;
    border-color: #7a2332;
}

.sp-a11y-font-btns button:focus-visible {
    outline: 2px solid #7a2332;
    outline-offset: 1px;
}

/* ─── Reset Button ─── */
.sp-a11y-reset {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: #7a2332;
    color: #faf7f5 !important;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.2s, transform 0.15s;
}

.sp-a11y-reset:hover {
    background: #5e1a27;
    transform: translateY(-1px);
}

.sp-a11y-reset:focus-visible {
    outline: 2px solid #7a2332;
    outline-offset: 2px;
}

/* ─── High Contrast Mode ─── */
body.sp-high-contrast {
    filter: contrast(1.4);
}

body.sp-high-contrast .sp-course-card,
body.sp-high-contrast .sp-lesson__body,
body.sp-high-contrast .sp-dash,
body.sp-high-contrast .sp-idash {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

body.sp-high-contrast a {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

body.sp-high-contrast button,
body.sp-high-contrast .button,
body.sp-high-contrast input[type="submit"] {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #000 !important;
}

/* Protect the a11y panel from high contrast overrides */
body.sp-high-contrast #sp-a11y-toolbar {
    filter: contrast(0.714); /* 1/1.4 — cancels the parent contrast boost */
}

body.sp-high-contrast .sp-a11y-panel {
    background: #faf7f5 !important;
    color: #3a2a2a !important;
    border-color: #e8c4b8 !important;
}

body.sp-high-contrast .sp-a11y-panel h3 {
    color: #7a2332 !important;
}

body.sp-high-contrast .sp-a11y-option {
    color: #3a2a2a !important;
}

body.sp-high-contrast .sp-a11y-panel button,
body.sp-high-contrast .sp-a11y-font-btns button {
    background: #fff !important;
    color: #7a2332 !important;
    border-color: #d4b0a0 !important;
}

body.sp-high-contrast .sp-a11y-reset {
    background: #7a2332 !important;
    color: #fff !important;
    border: none !important;
}

body.sp-high-contrast #sp-a11y-toggle {
    background: #7a2332 !important;
    color: #fff !important;
    border-color: #e8c4b8 !important;
}

body.sp-high-contrast .sp-a11y-panel a {
    color: #7a2332 !important;
}

/* ─── Large Font Mode ─── */
body.sp-large-font {
    font-size: 120% !important;
}

body.sp-large-font h1 { font-size: 2.2em !important; }
body.sp-large-font h2 { font-size: 1.8em !important; }
body.sp-large-font h3 { font-size: 1.5em !important; }
body.sp-large-font p,
body.sp-large-font li,
body.sp-large-font td { font-size: 1.1em !important; }

/* ─── Dyslexia-Friendly Font ─── */
body.sp-dyslexia-font,
body.sp-dyslexia-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Trebuchet MS', sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.15em !important;
    line-height: 1.8 !important;
}

/* ─── Reduced Motion ─── */
body.sp-reduced-motion,
body.sp-reduced-motion * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* ─── Large Cursor ─── */
body.sp-large-cursor,
body.sp-large-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M4 4L4 28L12 20L20 20Z" fill="black" stroke="white" stroke-width="2"/></svg>') 4 4, auto !important;
}

body.sp-large-cursor a,
body.sp-large-cursor button,
body.sp-large-cursor [role="button"],
body.sp-large-cursor input[type="submit"] {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M8 2L8 22L14 16L24 16Z" fill="black" stroke="white" stroke-width="2"/><circle cx="20" cy="24" r="6" fill="none" stroke="black" stroke-width="2"/></svg>') 4 4, pointer !important;
}

/* ─── Focus Highlight ─── */
body.sp-focus-highlight *:focus {
    outline: 3px solid #7a2332 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(122, 35, 50, 0.25) !important;
}

body.sp-focus-highlight *:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

body.sp-focus-highlight *:focus-visible {
    outline: 3px solid #7a2332 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(122, 35, 50, 0.25) !important;
}

/* ─── Global WCAG Enhancements ─── */

/* Ensure all interactive elements have visible focus */
:focus-visible {
    outline: 2px solid #7a2332;
    outline-offset: 2px;
}

/* Minimum touch targets (44x44px per WCAG 2.1) */
.sp-dash__nav-link,
.sp-idash__nav-link,
.sp-btn,
.sp-btn--small {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
}

/* Screen reader only utility */
.sp-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Live region for dynamic content updates */
[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}
