/* ============================================================
   Accessibility primitives
   - Skip link (visible on focus only, for keyboard users)
   - Focus-visible ring for all interactive elements
   - ARIA utilities (aria-busy pulsing, loading states)
   Loaded by app.css (@import) so tokens are available.
   ============================================================ */

/* -----------------------------------------------------------
   Skip link: hidden off-screen until keyboard focus lands on it.
   First Tab from the address bar reveals "Перейти к содержимому".
   ----------------------------------------------------------- */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: var(--z-toast);
    padding: var(--space-2) var(--space-4);
    background: var(--accent-primary);
    color: #fff;
    border-radius: var(--radius-md);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: translateY(0);
    outline: 2px solid #fff;
    outline-offset: 2px;
    color: #fff;
}

/* -----------------------------------------------------------
   Focus-visible (already set in tokens.css for :focus-visible).
   This file adds the programmatic-focus case: the <main> gets
   tabindex=-1 so skip-link can focus it, but we DON'T want a
   permanent outline around the entire content area.
   ----------------------------------------------------------- */
main[tabindex="-1"]:focus {
    outline: none;
}

main[tabindex="-1"]:focus-visible {
    /* Soft, non-intrusive ring when focused via skip-link */
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

/* -----------------------------------------------------------
   aria-busy: containers waiting for HTMX swaps get a subtle
   pulsing opacity. Combined with skeleton blocks for long fetches.
   ----------------------------------------------------------- */
[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
    cursor: progress;
    transition: opacity var(--transition-normal);
}

[aria-busy="true"]::after {
    /* Accessibility: screen readers announce aria-busy state changes.
       For sighted users, we add a subtle busy indicator. */
    content: "";
    display: inline-block;
}

/* -----------------------------------------------------------
   Reduced-motion guardrails (already global in tokens.css).
   Here we explicitly neutralize skip-link transition.
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .skip-link {
        transition: none !important;
    }
    [aria-busy="true"] {
        transition: none !important;
    }
}

/* -----------------------------------------------------------
   Skeleton table row: overrides the base .skeleton-row from
   components/skeleton.css to match the 7-column contacts table.
   ----------------------------------------------------------- */
.skeleton-row-contacts {
    display: grid;
    grid-template-columns: 40px 1.5fr 1fr 1fr 120px 120px 100px;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    align-items: center;
}

.skeleton-row-contacts > .skeleton {
    height: 16px;
    border-radius: var(--radius-sm);
}

/* Compact skeleton for KPI-card value area (dashboard/analytics) */
.skeleton-kpi {
    height: 32px;
    width: 70%;
    margin: var(--space-2) 0;
}

/* Chart placeholder — matches bar chart container height */
.skeleton-chart {
    height: 240px;
    margin-bottom: var(--space-4);
    border-radius: var(--radius-lg);
}
