/* Spectre - Accessibility options. Toggled via html.a11y-* classes set from localStorage. */

/* Always-on: visible keyboard focus ring (keyboard navigation only) */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible,
summary:focus-visible, [contenteditable]:focus-visible {
    outline: 3px solid var(--pp-lt,#ffcc66) !important;
    outline-offset: 2px !important;
    border-radius: 2px;
}

/* A link inside a line of text is told apart by more than its colour (WCAG 1.4.1): underlined. Only plain links
   (no class: a styled button or menu link is never one) in running text of the page, and the footer credit line. */
#sp-main p a:not([class]), #sp-main li a:not([class]), #sp-main small a:not([class]), #sp-main dd a:not([class]), .sp-footer__credit a {
    text-decoration: underline !important; text-underline-offset: 0.15em;
}

/* A field's edge is at least 3:1 against what it sits on (WCAG 1.4.11): the theme's own edge colour, pulled a little
   toward its text colour, so it holds in every look (a theme's line token is often a faint rule colour). Error and
   hover/focus edges keep the theme's own. */
:is(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file], [type=submit], [type=button], [type=reset], [type=hidden], [type=image]), select, textarea, .form-control):not(:hover, :focus, .is-invalid, [aria-invalid=true]) {
    border-color: color-mix(in srgb, var(--sp-line-strong, #3b6482), var(--sp-text-hi, #e8f0ff) 24%);
}

/* Screen-reader-only text (names for icon buttons, empty table headers, live regions).
   top/left 0: with no positioned box around it, a hidden name in the last column of a wide table (e.g. "Actions" on
   the Admin dashboard's tables) otherwise sits out at the table's right end and widens the whole page on a phone. */
.sr-only {
    position: absolute !important; top: 0; left: 0; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The device's "reduce motion" setting is honoured even when the site option is off */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Text / page size */
html.a11y-text-large  { zoom: 1.12; }
html.a11y-text-xlarge { zoom: 1.25; }

/* Reduce motion */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* Underline all links */
html.a11y-underline a { text-decoration: underline !important; }

/* Boost contrast: brighter text and stronger rules everywhere, plus the main reading surfaces */
html.a11y-contrast {
    --sp-text: #fbf5ec;
    --sp-text-dim: #d6cdbf;
    --sp-line: rgba(255,220,180,0.28);
    --sp-line-strong: rgba(255,220,180,0.45);
}
html.a11y-contrast .post-content-wrap,
html.a11y-contrast .bio-section,
html.a11y-contrast .sp-main p,
html.a11y-contrast .sp-main li,
html.a11y-contrast .sp-main td {
    color: #fffaf2 !important;
}
html.a11y-contrast a { text-decoration: underline; }

/* Readable (dyslexia-friendly) font everywhere */
html.a11y-readable-font,
html.a11y-readable-font :where(*) {
    font-family: 'Atkinson Hyperlegible', Verdana, Tahoma, 'Segoe UI', Arial, sans-serif !important;
    letter-spacing: 0.01em;
}

/* ---- Accessibility settings page UI ---- */
.a11y-panel { max-width: 700px; margin: 18px 0; }
.a11y-row {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 16px; background: var(--sp-surface, #111114);
    border: 1px solid var(--sp-line, rgba(255,204,153,0.12)); border-radius: var(--sp-radius, 8px);
}
.a11y-row + .a11y-row { margin-top: 8px; }
.a11y-label { font-family: var(--sp-font-display, sans-serif); font-weight: 600; color: var(--sp-text-hi, #fbf5ec); font-size: 0.95rem; }
.a11y-desc  { color: var(--sp-text-dim, #a69e92); font-size: 0.82rem; margin-top: 3px; line-height: 1.5; }
.a11y-control { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; }
.a11y-control label { display: inline-flex; align-items: center; gap: 5px; margin-left: 12px; color: var(--sp-text, #e4ddd2); font-size: 0.85rem; cursor: pointer; }
.a11y-control input[type=radio] { accent-color: var(--pp,#ff9900); cursor: pointer; }
.a11y-switch input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pp,#ff9900); cursor: pointer; }
@media (max-width: 560px) {
    .a11y-row { flex-direction: column; }
    .a11y-control { margin-left: 0; }
    .a11y-control label:first-child { margin-left: 0; }
}
