/**
 * Gravity Tables – Accessibility stylesheet (WCAG 2.1 AA)
 *
 * Loaded on every page that contains a Gravity Tables shortcode.
 * Provides: visually-hidden screen-reader text, visible focus rings,
 * high-contrast focus indicators, and aria-live region styles.
 */

/* ── Visually hidden (screen-reader only) ────────────────────────────────── */

.gt-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;
}

/* Allow the element to become visible when focused (skip-links pattern) */
.gt-sr-only-focusable:focus,
.gt-sr-only-focusable:focus-within {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ── Visible focus rings (:focus-visible) ────────────────────────────────── */

.gt-table-wrapper :focus-visible,
.gt-table :focus-visible,
.gt-pagination :focus-visible,
.gt-filter-bar :focus-visible,
.gt-toolbar :focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Sort header buttons */
.gt-table th.gt-sortable button:focus-visible,
.gt-table th.gt-sortable [role="button"]:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Pagination buttons */
.gt-pagination button:focus-visible,
.gt-pagination a:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Row action buttons */
.gt-row-actions button:focus-visible,
.gt-row-actions a:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Export toolbar icon-only buttons */
.gt-export-toolbar button:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Inline edit inputs */
.gt-inline-edit-cell input:focus-visible,
.gt-inline-edit-cell select:focus-visible,
.gt-inline-edit-cell textarea:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 1px;
}

/* Modal close button */
.gt-modal .gt-modal-close:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ── ARIA sort indicator (visual) ────────────────────────────────────────── */

.gt-table th[aria-sort="ascending"] .gt-sort-icon::after {
    content: " ↑";
}

.gt-table th[aria-sort="descending"] .gt-sort-icon::after {
    content: " ↓";
}

.gt-table th[aria-sort="none"] .gt-sort-icon::after {
    content: " ⇅";
    opacity: 0.4;
}

/* ── Live region (aria-live="polite") ────────────────────────────────────── */

.gt-live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ── Focus trap overlay (modals) ─────────────────────────────────────────── */

.gt-modal[aria-modal="true"] {
    /* Ensure modal is positioned correctly for focus containment */
    position: fixed;
    z-index: 9999;
}

/* ── Skip-link ───────────────────────────────────────────────────────────── */

.gt-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 0.5em 1em;
    background: #005fcc;
    color: #fff;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.1s;
}

.gt-skip-link:focus {
    top: 0;
}

/* ── High-contrast mode support ──────────────────────────────────────────── */

@media (forced-colors: active) {
    .gt-table th.gt-sortable button:focus-visible,
    .gt-pagination button:focus-visible,
    .gt-export-toolbar button:focus-visible {
        outline: 3px solid ButtonText;
    }
}
