/* =============================================================
   ACCESSIBILITY & DISABILITY OVERHAUL (WCAG 2.1 AA)
   Skip Links, High Contrast Focus Indicators, Reduced Motion,
   Screen Reader Utilities & Color Contrast Enhancements
   ============================================================= */

/* ── 1. Skip to Content Link ── */
.skip-link {
    position: fixed;
    top: -100px;
    left: 1rem;
    z-index: 999999;
    padding: 0.75rem 1.25rem;
    background: #000000;
    color: var(--color-gold, #C9A227);
    border: 2px solid var(--color-gold, #C9A227);
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9), 0 0 10px rgba(201, 162, 39, 0.4);
    transition: top 0.2s ease-in-out;
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 1rem;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px;
}

/* ── 2. Screen Reader Only Class ── */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── 3. High-Contrast Keyboard Focus Indicators ── */
:focus-visible {
    outline: 2px solid var(--color-gold, #C9A227) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.5) !important;
}

/* Fallback for browsers supporting :focus:not(:focus-visible) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-gold, #C9A227) !important;
    outline-offset: 2px !important;
}

/* ── 4. Minimum Touch & Click Targets on Interactive Elements ── */
@media (pointer: coarse) {
    /* Pill switches keep their own geometry — they get a transparent hit-area
       expansion instead, so min-height here would just distort the track. */
    button:not([role="switch"]),
    .btn,
    a.nav__link,
    input[type="button"],
    input[type="submit"] {
        min-height: 34px;
        min-width: 34px;
    }
}

/* ── 5. Color Contrast Boost for Low-Vision Players ── */
:root {
    --text-dim-accessible: #B5AFA6; /* 4.6:1 contrast ratio against #120e0a */
    --text-secondary-accessible: #D6D0C5; /* 8.2:1 contrast ratio */
}

.text-dim,
.empire-kpi-card__sub,
.fight-stat__lbl,
.precursor-shipment-source {
    color: var(--text-dim-accessible) !important;
}

/* High Contrast Override Mode (applied via data-high-contrast="true" or OS high contrast) */
@media (forced-colors: active) {
    :focus-visible {
        outline: 3px solid Highlight !important;
    }
}

body[data-high-contrast="true"] {
    --text-primary: #FFFFFF !important;
    --text-secondary: #F5F3EF !important;
    --text-tertiary: #E8E4DC !important;
    --text-dim: #DDD8CE !important;
    --text-muted: #E8E4DC !important;
    --text-brass: #DDD8CE !important;
    --dossier-brass: #E0DBD0 !important;
    --dossier-line: rgba(255, 255, 255, 0.35) !important;
    --border-color: rgba(255, 255, 255, 0.4) !important;
    --border-subtle: rgba(255, 255, 255, 0.3) !important;
}

/* Force high contrast on muted descriptions, hints, and labels */
body[data-high-contrast="true"] .dossier-row-h,
body[data-high-contrast="true"] .dossier-radio-desc,
body[data-high-contrast="true"] .dossier-nav-blurb,
body[data-high-contrast="true"] .dossier-p-blurb,
body[data-high-contrast="true"] .card-desc,
body[data-high-contrast="true"] .subtext,
body[data-high-contrast="true"] .meta-desc,
body[data-high-contrast="true"] [class*="__desc"],
body[data-high-contrast="true"] [class*="__hint"],
body[data-high-contrast="true"] [class*="__meta"] {
    color: #E2DDD3 !important;
    opacity: 1 !important;
}

/* Strengthen card and element borders for visual clarity */
body[data-high-contrast="true"] .dossier-radio-card,
body[data-high-contrast="true"] .dossier-row,
body[data-high-contrast="true"] .dossier-panel,
body[data-high-contrast="true"] .dossier-file,
body[data-high-contrast="true"] .dossier-search,
body[data-high-contrast="true"] .card,
body[data-high-contrast="true"] .panel {
    border-color: rgba(255, 255, 255, 0.35) !important;
}

body[data-high-contrast="true"] .dossier-radio-card.active {
    border-color: var(--color-gold, #c9a227) !important;
    background: rgba(201, 162, 39, 0.22) !important;
}

body[data-high-contrast="true"] .btn--outline {
    border-width: 2px !important;
    font-weight: 700 !important;
}

/* ── 6. Reduced Motion System ── */
@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;
    }

    .skeleton-shimmer,
    .fight-skeleton__header-icon,
    .fight-skeleton__round-text,
    .fight-skeleton__round-ring,
    .fight-skeleton__avatar,
    .fight-skeleton__line,
    .fight-skeleton__bar,
    .empire-warrant-banner {
        animation: none !important;
    }
}

/* =============================================================
   GLOBAL USERNAME ANIMATIONS SUITE (7 Bespoke Mafia Effects)
   ============================================================= */

/* Universal continuous looping & GPU acceleration */
[class*="pr-name-fx--"],
[class*="pr-name-fx--"] * {
    animation-iteration-count: infinite !important;
    display: inline-block;
    will-change: transform, opacity, filter;
}

/* Neutralize .m-name default gray and .vip-* color overrides */
.m-name[class*="pr-name-fx--"]:not(.pr-name-fx--classic),
.chat-msg .m-name[class*="pr-name-fx--"]:not(.pr-name-fx--classic),
.pr-name[class*="pr-name-fx--"]:not(.pr-name-fx--classic) {
    color: unset;
    text-shadow: none;
}

/* Make username borders completely invisible across all chat messages */
.chat-msg .m-name:not(.vip-premium):not(.vip-lite),
.chat-msg .m-name--titled,
.chat-msg [class*="m-name--rarity-"] {
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Remove any rogue title icon or 'H' if present */
.chat-msg__title-icon {
    display: none !important;
}

/* Chat Cartel Tag Style */
.chat-msg__cartel-tag {
    color: #eab308 !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em;
}
