/* ============================================================
   KOJI ACCESSIBILITY TOOLBAR — a11y.css
   ============================================================ */

/* Toolbar wrapper — fixed bottom-right */
#koji-a11y-toolbar {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9000;
    font-family: 'Nunito', sans-serif;
}

/* Toggle button */
#koji-a11y-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #3D7A8A;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(26,74,88,0.25);
    transition: background 0.2s, transform 0.2s;
    min-height: 48px;
}
#koji-a11y-toggle:hover {
    background: #2E6676;
    transform: translateY(-1px);
}
#koji-a11y-toggle:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* Panel */
#koji-a11y-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 300px;
    background: #fff;
    border: 1px solid #D4CFC8;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(26,74,88,0.15);
    overflow: hidden;
}
#koji-a11y-panel[hidden] {
    display: none;
}

.a11y-panel-inner {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.a11y-panel-title {
    font-size: 1rem;
    font-weight: 800;
    color: #1A4A58;
    margin: 0 0 4px;
}

/* Rows */
.a11y-row {
    display: flex;
    gap: 8px;
}
.a11y-row--spread {
    justify-content: space-between;
    align-items: center;
}
.a11y-row--col {
    flex-direction: column;
    gap: 6px;
}
.a11y-row-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1A4A58;
}

/* Toggle buttons */
.a11y-btn {
    flex: 1;
    padding: 0.625rem 0.5rem;
    background: #F5F2EE;
    border: 1.5px solid #D4CFC8;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    color: #2C2C2A;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-height: 44px;
    text-align: center;
}
.a11y-btn:hover {
    border-color: #3D7A8A;
    background: #eaf3f6;
}
.a11y-btn[aria-pressed="true"] {
    background: #3D7A8A;
    border-color: #3D7A8A;
    color: #fff;
}
.a11y-btn--full {
    flex: none;
    width: 100%;
}
.a11y-btn--reset {
    background: #F5F2EE;
    border-color: #c0392b;
    color: #c0392b;
    font-size: 0.8rem;
}
.a11y-btn--reset:hover {
    background: #c0392b;
    color: #fff;
}
.a11y-btn:focus-visible {
    outline: 3px solid #3D7A8A;
    outline-offset: 2px;
}

/* Text size controls */
.a11y-size-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.a11y-size-btn {
    width: 36px;
    height: 36px;
    border: 1.5px solid #D4CFC8;
    border-radius: 8px;
    background: #F5F2EE;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 800;
    color: #1A4A58;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.a11y-size-btn:hover {
    background: #3D7A8A;
    color: #fff;
    border-color: #3D7A8A;
}
.a11y-size-btn:focus-visible {
    outline: 3px solid #3D7A8A;
    outline-offset: 2px;
}
#a11y-size-display {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1A4A58;
    min-width: 40px;
    text-align: center;
}

/* Font select */
.a11y-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid #D4CFC8;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    color: #2C2C2A;
    background: #F5F2EE;
    cursor: pointer;
    min-height: 44px;
}
.a11y-select:focus-visible {
    outline: 3px solid #3D7A8A;
    outline-offset: 2px;
    border-color: #3D7A8A;
}

/* Colour inputs */
.a11y-colour-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.a11y-colour-row label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #5A5A58;
}
.a11y-colour-row input[type="color"] {
    width: 36px;
    height: 36px;
    border: 1.5px solid #D4CFC8;
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: none;
}
.a11y-reset-colours {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    color: #5A5A58;
    border: 1px solid #D4CFC8;
    border-radius: 6px;
    background: #F5F2EE;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    min-height: 36px;
}
.a11y-reset-colours:hover {
    background: #D4CFC8;
}

/* Reading guide line */
#koji-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 36px;
    background: rgba(123,170,184,0.35);
    pointer-events: none;
    z-index: 8999;
    border-top: 2px solid rgba(61,122,138,0.4);
    border-bottom: 2px solid rgba(61,122,138,0.4);
}
#koji-reading-guide[hidden] {
    display: none;
}

/* ============================================================
   GLOBAL STATE CLASSES — applied to <body> by JS
   ============================================================ */

/* Dark mode */
body.a11y-dark {
    background-color: #111 !important;
    color: #e8e8e8 !important;
}
body.a11y-dark h1, body.a11y-dark h2,
body.a11y-dark h3, body.a11y-dark h4 {
    color: #f0f0f0 !important;
}
body.a11y-dark .site-header,
body.a11y-dark .card,
body.a11y-dark .section--alt {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
}
body.a11y-dark p, body.a11y-dark li {
    color: #d0d0d0 !important;
}

/* High contrast */
body.a11y-contrast {
    filter: contrast(1.5) brightness(1.05);
}

/* Dyslexia font */
body.a11y-dyslexia,
body.a11y-dyslexia p,
body.a11y-dyslexia li,
body.a11y-dyslexia h1, body.a11y-dyslexia h2,
body.a11y-dyslexia h3, body.a11y-dyslexia h4 {
    font-family: 'OpenDyslexic', cursive !important;
    letter-spacing: 0.05em;
    word-spacing: 0.1em;
    line-height: 1.9;
}

/* Highlight links */
body.a11y-links a {
    background-color: #fff176 !important;
    color: #111 !important;
    padding: 1px 4px;
    border-radius: 3px;
    text-decoration: underline !important;
}

/* On smaller screens, panel opens upward from button */
@media (max-width: 400px) {
    #koji-a11y-panel {
        width: calc(100vw - 2rem);
        right: 0;
    }
    .koji-a11y-label {
        display: none;
    }
}
