/*
 * Accessibility adjustments for The Abode of Peace (see assets/js/a11y.js).
 *
 * Page adjustments are switched on by aop-* classes on <html> and are scoped to
 * "body > :not(.aop-a11y)" so they never restyle the adjustments panel itself.
 * Text size works through --aop-text-scale, which the page's root font sizes
 * multiply by.
 */

/* ---------- Floating button and panel ---------- */

.aop-a11y,
.aop-a11y * {
    box-sizing: border-box;
    font: inherit;
    letter-spacing: normal;
    word-spacing: normal;
    margin: 0;
}

.aop-a11y {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: #1d1d1f;
}

.aop-a11y-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.aop-a11y-trigger {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 2147483001;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #1f4e79;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.aop-a11y-trigger:hover {
    background: #163a5c;
}

.aop-a11y-trigger svg {
    width: 34px;
    height: 34px;
    fill: currentColor;
}

.aop-a11y button:focus-visible,
.aop-a11y a:focus-visible {
    outline: 3px solid #1d1d1f;
    outline-offset: 3px;
}

.aop-a11y .aop-a11y-trigger:focus-visible {
    outline: 3px solid #1d1d1f;
    outline-offset: 2px;
    box-shadow: 0 0 0 7px #fff;
}

.aop-a11y-panel {
    position: fixed;
    inset: auto auto 16px 16px;
    width: min(420px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    margin: 0;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid #c9c9c9;
    border-radius: 16px;
    background: #fff;
    color: #1d1d1f;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

.aop-a11y-panel::backdrop {
    background: rgba(0, 0, 0, .2);
}

.aop-a11y-inner {
    padding: 0 20px 20px;
}

.aop-a11y-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 12px;
    background: #fff;
}

.aop-a11y .aop-a11y-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.aop-a11y-close {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ececec;
    color: #1d1d1f;
    cursor: pointer;
}

.aop-a11y-close:hover {
    background: #dcdcdc;
}

.aop-a11y-close svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.aop-a11y-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
}

.aop-a11y .aop-a11y-action {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 6px 16px;
    border: 2px solid #1d1d1f;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1f;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.aop-a11y .aop-a11y-action:hover {
    background: #f0f0f0;
    text-decoration: underline;
}

.aop-a11y-section {
    padding-top: 16px;
}

.aop-a11y .aop-a11y-subtitle {
    padding-bottom: 4px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #444;
}

.aop-a11y .aop-a11y-list {
    padding: 0;
    list-style: none;
}

.aop-a11y .aop-a11y-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid #e3e3e3;
}

.aop-a11y-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.aop-a11y .aop-a11y-label {
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.aop-a11y span.aop-a11y-label {
    cursor: default;
}

.aop-a11y .aop-a11y-hint {
    font-size: 14px;
    color: #555;
}

.aop-a11y-switch {
    display: inline-flex;
    flex: none;
    padding: 2px;
    border: 2px solid #1d1d1f;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.aop-a11y .aop-a11y-switch span {
    min-width: 40px;
    padding: 5px 8px;
    border-radius: 999px;
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
}

.aop-a11y .aop-a11y-switch[aria-checked="false"] .aop-a11y-off {
    background: #1d1d1f;
    color: #fff;
}

.aop-a11y .aop-a11y-switch[aria-checked="true"] .aop-a11y-on {
    background: #1f4e79;
    color: #fff;
}

.aop-a11y-stepper {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
}

.aop-a11y .aop-a11y-step {
    width: 44px;
    height: 36px;
    padding: 0;
    border: 2px solid #1d1d1f;
    border-radius: 8px;
    background: #fff;
    color: #1d1d1f;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.aop-a11y .aop-a11y-step-up {
    font-size: 19px;
}

.aop-a11y .aop-a11y-step:hover {
    background: #f0f0f0;
}

.aop-a11y .aop-a11y-step[aria-disabled="true"] {
    border-color: #8a8a8a;
    color: #6b6b6b;
    cursor: not-allowed;
}

.aop-a11y .aop-a11y-step-value {
    min-width: 48px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
}

.aop-a11y .aop-a11y-note {
    padding-top: 16px;
    border-top: 1px solid #e3e3e3;
    font-size: 14px;
    color: #444;
}

.aop-a11y .aop-a11y-note a {
    color: #1f4e79;
    text-decoration: underline;
}

.aop-a11y-guide {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483000;
    background: rgba(0, 0, 0, .55);
    pointer-events: none;
}

.aop-a11y-guide-top {
    top: 0;
}

.aop-a11y-guide-bottom {
    bottom: 0;
}

html.aop-guide .aop-a11y-guide {
    display: block;
}

@media screen and (max-width: 640px) {
    .aop-a11y-trigger {
        left: 12px;
        bottom: 12px;
        width: 52px;
        height: 52px;
    }

    .aop-a11y-panel {
        inset: auto 8px 8px 8px;
        width: auto;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }

    .aop-a11y-inner {
        padding: 0 16px 16px;
    }
}

@media (forced-colors: active) {
    .aop-a11y-trigger,
    .aop-a11y-switch,
    .aop-a11y-step,
    .aop-a11y-action {
        border: 2px solid ButtonText;
    }

    .aop-a11y .aop-a11y-switch[aria-checked="false"] .aop-a11y-off,
    .aop-a11y .aop-a11y-switch[aria-checked="true"] .aop-a11y-on {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
    }

    .aop-a11y-guide {
        display: none !important;
    }
}

@media print {
    .aop-a11y {
        display: none !important;
    }
}

/* ---------- Page adjustments ---------- */

/* High contrast */
html.aop-contrast body,
html.aop-contrast body > :not(.aop-a11y) :is(main, header, footer, section, article, nav, [class*="container"], [style*="background-color"], [style*="background:"]):not([aria-hidden="true"]) {
    background-color: #fff !important;
}

html.aop-contrast body > :not(.aop-a11y) [style*="linear-gradient"]:not([aria-hidden="true"]) {
    background-image: none !important;
}

html.aop-contrast body > :not(.aop-a11y),
html.aop-contrast body > :not(.aop-a11y) :is(p, li, h1, h2, h3, h4, h5, h6, span, dt, dd, label, th, td, figcaption, blockquote) {
    color: #000 !important;
    opacity: 1 !important;
}

html.aop-contrast body > :not(.aop-a11y) a,
html.aop-contrast body > :not(.aop-a11y) a * {
    color: #00008b !important;
    text-decoration: underline !important;
    text-underline-offset: .15em;
}

html.aop-contrast body > :not(.aop-a11y) :focus-visible {
    outline: 4px solid #000 !important;
    outline-offset: 3px !important;
}

/* Mute colors */
html.aop-muted body > :not(.aop-a11y) :is(img, iframe, video, svg, [style*="background-image"]) {
    filter: saturate(.25) !important;
}

html.aop-muted:not(.aop-contrast) body > :not(.aop-a11y) a[href] {
    color: #2e3a57 !important;
}

/* Readable font */
html.aop-font body > :not(.aop-a11y),
html.aop-font body > :not(.aop-a11y) * {
    font-family: "Atkinson Hyperlegible", Verdana, Tahoma, sans-serif !important;
}

/* Text spacing (the WCAG 1.4.12 values) */
html.aop-spacing body > :not(.aop-a11y) :is(p, li, h1, h2, h3, h4, h5, h6, a, span, label, dt, dd, blockquote) {
    line-height: 1.8 !important;
    letter-spacing: .12em !important;
    word-spacing: .16em !important;
}

html.aop-spacing body > :not(.aop-a11y) p {
    margin-bottom: 2em !important;
}

/* Long words and addresses wrap instead of pushing the page sideways when text is enlarged or spaced out */
html:is(.aop-text, .aop-spacing, .aop-font) body > :not(.aop-a11y) :is(p, li, h1, h2, h3, h4, h5, h6, a, span, dd, blockquote) {
    overflow-wrap: anywhere;
}

/* Highlight links */
html.aop-links body > :not(.aop-a11y) a[href] {
    /* content-box keeps the highlight on the words, not on links' layout padding */
    background-color: #ffe866 !important;
    background-clip: content-box !important;
    color: #000 !important;
    text-decoration: underline !important;
    text-decoration-thickness: 3px !important;
    text-underline-offset: .2em;
}

html.aop-links body > :not(.aop-a11y) a[href] * {
    color: #000 !important;
}

/* Stop animations */
html.aop-still *,
html.aop-still *::before,
html.aop-still *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
