/* Accessibility mode toolbar for Cedar Ridge Storage
   Smaller 24px icon toggle in the header (with a tap-friendly padding
   ring so the click target is ~40px). On tap, a panel slides down
   from the top of the viewport with toggles for common a11y modes.
   Settings persist in localStorage under 'cedar-ridge-a11y-modes'.
*/

/* Header toggle: 24px icon inside a 40px ring for an adequate tap target */
.a11y-toggle-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: var(--white, #fff);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
    align-self: center;
}
.a11y-toggle-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.6);
}
.a11y-toggle-btn:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}
.a11y-toggle-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}
.a11y-toggle-btn[aria-expanded="true"] {
    background: var(--primary-sky, #4c6066);
    border-color: var(--primary-sky, #4c6066);
    color: #fff;
}

/* Variant inside the mobile hamburger menu: inline-block, larger
   tap target, with a text label "Accessibility" next to the icon. */
.a11y-toggle-btn-mobile {
    width: 100%;
    height: 56px;
    border-radius: 8px;
    margin: 1.5rem 0 0 0;
    background: var(--primary-sky, #4c6066);
    color: #fff;
    border: none;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    gap: 0.6rem;
}
.a11y-toggle-btn-mobile:hover {
    background: var(--hover-sky, #3e5056);
}

/* Panel: slides down from the top of the page */
.a11y-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: var(--white, #ffffff);
    border-bottom: 3px solid var(--primary-sky, #4c6066);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    padding: 20px 24px 22px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-dark, #2b3133);
    max-height: 100vh;
    max-width: 100vw;          /* never wider than viewport */
    overflow-y: auto;
    overflow-x: hidden;         /* safety net: clip anything that would
                                   push content off the right edge */
    box-sizing: border-box;     /* include padding in width math */
}
.a11y-panel.open {
    display: block;
}
.a11y-panel h2 {
    margin: 0 36px 4px 0;  /* leave room for the absolute-positioned close button */
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-sky, #4c6066);
}
.a11y-panel .a11y-panel-intro {
    margin: 0 0 14px;
    font-size: 13px;
    color: #555;
}
.a11y-panel .a11y-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: transparent;
    border: 0;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    line-height: 1;
}
.a11y-panel .a11y-close:hover { color: #000; }
.a11y-panel .a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid #eee;
    gap: 1rem;
    min-width: 0;            /* allow option to shrink to fit panel */
    box-sizing: border-box;
}
.a11y-panel .a11y-option:first-of-type {
    border-top: none;
}
.a11y-panel .a11y-option label {
    flex: 1 1 auto;
    min-width: 0;            /* critical: let long descriptions wrap
                                 instead of pushing the toggle off-screen */
    font-weight: 500;
    cursor: pointer;
    word-break: break-word;
}
.a11y-panel .a11y-option label small {
    display: block;
    font-weight: 400;
    color: #666;
    font-size: 12px;
    margin-top: 2px;
}

/* Toggle switch */
.a11y-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.a11y-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.a11y-toggle-switch .slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}
.a11y-toggle-switch .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.a11y-toggle-switch input:checked + .slider {
    background: var(--primary-sky, #4c6066);
}
.a11y-toggle-switch input:checked + .slider::before {
    transform: translateX(20px);
}
.a11y-toggle-switch input:focus-visible + .slider {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}
.a11y-panel .a11y-reset {
    margin-top: 14px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1.5px solid var(--primary-sky, #4c6066);
    color: var(--primary-sky, #4c6066);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.a11y-panel .a11y-reset:hover {
    background: var(--primary-sky, #4c6066);
    color: #fff;
}

/* === Accessibility mode styles (apply to documentElement) === */

.a11y-high-contrast,
.a11y-high-contrast * {
    text-shadow: none !important;
}
.a11y-high-contrast {
    background: #ffffff !important;
    color: #000000 !important;
}
.a11y-high-contrast header,
.a11y-high-contrast footer,
.a11y-high-contrast .header-inner,
.a11y-high-contrast .admin-nav {
    background: #000000 !important;
    color: #ffffff !important;
    border-bottom: 3px solid #ffd700 !important;
}
.a11y-high-contrast footer,
.a11y-high-contrast .admin-nav {
    border-top: 3px solid #ffd700 !important;
    border-bottom: none !important;
}
.a11y-high-contrast header a,
.a11y-high-contrast .admin-nav a,
.a11y-high-contrast footer a,
.a11y-high-contrast nav a {
    color: #ffffff !important;
    text-decoration: underline !important;
    font-weight: 700 !important;
}
.a11y-high-contrast h1, .a11y-high-contrast h2,
.a11y-high-contrast h3, .a11y-high-contrast h4 {
    color: #000000 !important;
}
.a11y-high-contrast main, .a11y-high-contrast section,
.a11y-high-contrast article, .a11y-high-contrast .card {
    background: #ffffff !important;
    color: #000000 !important;
}
.a11y-high-contrast a:not(header a):not(footer a):not(nav a):not(.btn):not(.palette-card):not(.preview-btn-primary):not(.preview-btn-secondary):not(.skip-link):not(.reset-btn):not(.a11y-toggle-btn) {
    color: #0000ee !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
}

.a11y-large-text {
    font-size: 125% !important;
}
.a11y-large-text h1 { font-size: 1.4em !important; }
.a11y-large-text h2 { font-size: 1.3em !important; }
.a11y-large-text h3 { font-size: 1.2em !important; }
.a11y-large-text p, .a11y-large-text li, .a11y-large-text td,
.a11y-large-text th, .a11y-large-text label, .a11y-large-text span,
.a11y-large-text a, .a11y-large-text button, .a11y-large-text input,
.a11y-large-text select, .a11y-large-text textarea {
    font-size: 1.1em !important;
    line-height: 1.6 !important;
}

.a11y-reduced-motion, .a11y-reduced-motion *,
.a11y-reduced-motion *::before, .a11y-reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.a11y-underline-links a:not(header a):not(footer a):not(nav a):not(.btn):not(.palette-card):not(.preview-btn-primary):not(.preview-btn-secondary):not(.skip-link):not(.reset-btn):not(.a11y-toggle-btn) {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    text-decoration-thickness: 1.5px !important;
}

.a11y-strong-focus *:focus-visible {
    outline: 4px solid #ff6b00 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 7px rgba(255, 107, 0, 0.3) !important;
}

.a11y-dyslexia-font,
.a11y-dyslexia-font * {
    font-family: 'Comic Sans MS', 'Trebuchet MS', Verdana, sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.15em !important;
    line-height: 1.8 !important;
}

.a11y-highlight-links a {
    background: #ffff00 !important;
    color: #000000 !important;
    padding: 1px 3px !important;
    text-decoration: underline !important;
}

/* Skip link to accessibility panel (mirror of body's normal skip link,
   but anchored to the panel itself) */
.skip-link-a11y:focus {
    left: 8px;
    top: 56px;
}
