/* a11y.css — shared accessibility primitives, loaded on every page.
 *
 * Kept separate from tailwind.css (which is a generated build artifact —
 * see css:build in package.json) so these rules survive a Tailwind rebuild
 * and are trivially auditable in one place. Load AFTER tailwind.css so
 * focus-visible etc. aren't overridden by a utility class.
 */

/* ── Skip link ──
 * Hidden off-screen until keyboard-focused, then jumps above everything.
 * Pair with <a href="#main-content" class="skip-link">Skip to main content</a>
 * as the first element inside <body>, and id="main-content" on the page's
 * main landmark. */
.skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 10000;
    background: #166534;
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 8px 8px;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid #bbf7d0;
    outline-offset: 2px;
}

/* ── Visible focus ring everywhere ──
 * Several pages set `outline: none` on inputs/buttons and replace it with a
 * box-shadow only on inputs — interactive elements with no custom focus
 * style (nav buttons, icon buttons, links) were left with no visible focus
 * indicator at all when tabbed to. :focus-visible only fires for keyboard/
 * programmatic focus, not mouse clicks, so this doesn't add a ring around
 * every mouse click. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* ── Screen-reader-only text ──
 * For labeling icon-only controls without changing their visual layout.
 * Usage: <button aria-label="..."> is preferred when there's no visible
 * label at all; use .sr-only when you want an extra text node read by
 * assistive tech but never shown (e.g. a table header only sighted users
 * infer from column position). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Respect reduced-motion preference ──
 * Cuts all CSS animation/transition duration to near-zero for anyone who
 * has requested reduced motion at the OS level (vestibular disorders,
 * motion sensitivity). Covers e.g. .plot-found-pulse in plot-editor.html. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
