/* Accesibilidad y escalado (2.0.22) - Fase A.
   Cargar SIEMPRE al final: varias reglas sobreponen valores existentes (foco
   visible global, dvh en modales, reduced-motion). No redefine la paleta ni
   toca layouts de cartas/zonas del duelo. */

/* --- Utilidad para contenido solo-lector y live regions --- */
.sr-only,
.a11y-live-region {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* --- Enlace "Saltar al contenido principal" --- */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1000;
    transform: translateY(-160%);
    padding: 10px 16px;
    border-radius: 10px;
    background: #0b1220;
    color: #fff7ed;
    border: 2px solid #f59e0b;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.15s ease;
}

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

/* --- Foco visible global y coherente --- */
:where(a[href], button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
    outline: 3px solid #7cc0ff;
    outline-offset: 2px;
    border-radius: 6px;
}

/* Contenedores/encabezados que reciben foco programático no muestran anillo. */
[data-a11y-temp-tabindex]:focus:not(:focus-visible),
#mainContent:focus:not(:focus-visible),
.view h2:focus:not(:focus-visible),
[role="dialog"]:focus:not(:focus-visible) {
    outline: none;
}

/* Pestaña activa: refuerzo no dependiente solo del color (subrayado + peso). */
body:not(.duel-playing) .tabs .tab[aria-current="page"] {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
    font-weight: 800;
}

/* --- Escalado: evitar desbordes en hijos flex/grid --- */
.topbar,
.status-cluster,
.tabs,
.deck-current-main,
.match-history-card,
.online-room-choice-main {
    min-width: 0;
}

.status-pill,
.env-pill {
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* Textos largos que pudieran desbordar su tarjeta. */
.match-history-opponent,
.match-history-factions,
.deck-bar-label,
.online-notice-modal p {
    overflow-wrap: anywhere;
}

/* --- Modales: alto seguro en pantallas de poca altura (dvh con fallback) --- */
.choice-modal,
.social-chat-modal,
.online-notice-modal,
.online-disconnect-modal,
.online-waiting-modal,
.online-room-list-modal {
    max-height: 88vh;
    max-height: min(88vh, calc(100dvh - 24px));
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* --- Tablero de duelo: unidades dinámicas con fallback vh --- */
body.duel-playing {
    min-height: 100vh;
    min-height: 100dvh;
}

body.duel-playing main {
    height: 100vh;
    height: 100dvh;
}

/* --- Reduced motion: quitar movimiento decorativo, conservar cambios de estado.
   No usa una regla universal que anule animationend funcionales. --- */
@media (prefers-reduced-motion: reduce) {
    .skip-link {
        transition: none;
    }

    .toast {
        animation: none !important;
    }

    /* Brasas/partículas decorativas del menú: sin bucle de movimiento. */
    .menu-embers,
    .menu-embers canvas {
        animation: none !important;
    }

    /* Emblemas y realces puramente decorativos de modales. */
    .victory-emblem,
    .online-loading-spinner {
        animation: none !important;
    }
}

/* --- Controles cómodos (área clickeable) sin romper cartas ni "small" --- */
.tabs .tab {
    min-height: 40px;
}

/* --- Estados deshabilitados perceptibles más allá del color --- */
button:disabled,
.primary:disabled,
.secondary:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}
