/* =========================================================
   Primera Infancia — Accesibilidad UX desacoplada
   WCAG 2.2 AA básico · sin cambios en backend ni lógica
========================================================= */
:root {
    --pi-a11y-font-scale: 1;
    --pi-a11y-primary: #38bdf8;
    --pi-a11y-primary-strong: #0ea5e9;
    --pi-a11y-warning: #fbbf24;
    --pi-a11y-bg: #020617;
    --pi-a11y-panel: #0f172a;
    --pi-a11y-panel-soft: #111827;
    --pi-a11y-text: #f8fafc;
    --pi-a11y-muted: #cbd5e1;
    --pi-a11y-border: rgba(148, 163, 184, .35);
    --pi-a11y-shadow: 0 24px 80px rgba(2, 6, 23, .42);
}

.pi-a11y-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;
}

.pi-a11y-skip-link {
    position: fixed;
    top: .85rem;
    left: .85rem;
    z-index: 10050;
    transform: translateY(-160%);
    border-radius: 999px;
    background: #fbbf24;
    color: #0f172a;
    padding: .75rem 1rem;
    font-weight: 900;
    box-shadow: var(--pi-a11y-shadow);
    transition: transform .18s ease;
}
.pi-a11y-skip-link:focus { transform: translateY(0); outline: 3px solid #fff; outline-offset: 3px; }

.pi-a11y-widget {
    position: fixed;
    right: 6rem;
    bottom: 1.35rem;
    z-index: 10040;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .65rem;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pi-a11y-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.625rem;
    height: 3.625rem;
    flex: 0 0 3.625rem;
    border: 1px solid rgba(56, 189, 248, .42);
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(37, 99, 235, .97), rgba(14, 165, 233, .95));
    color: white;
    padding: 0;
    box-shadow: 0 16px 44px rgba(14, 165, 233, .28);
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
}
.pi-a11y-toggle:hover { transform: translateY(-1px); box-shadow: 0 20px 52px rgba(14, 165, 233, .38); }
.pi-a11y-toggle-icon {
    display: grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    background: #fbbf24;
    color: #0f172a;
    font-weight: 950;
    letter-spacing: -.05em;
}
.pi-a11y-toggle-text { display: none; }

.pi-a11y-panel {
    width: min(360px, calc(100vw - 1.5rem));
    max-height: min(78vh, 720px);
    overflow-y: auto;
    border: 1px solid var(--pi-a11y-border);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(15, 23, 42, .98), rgba(17, 24, 39, .98));
    color: var(--pi-a11y-text);
    box-shadow: var(--pi-a11y-shadow);
    padding: 1rem;
    backdrop-filter: blur(14px);
}
.pi-a11y-panel[hidden] { display: none !important; }

.pi-a11y-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, .22);
    padding-bottom: .75rem;
    margin-bottom: .85rem;
}
.pi-a11y-panel-head strong { display: block; font-size: 1.02rem; }
.pi-a11y-panel-head small { display: block; color: var(--pi-a11y-muted); font-size: .72rem; margin-top: .15rem; }

.pi-a11y-icon-btn {
    display: grid;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: .8rem;
    background: rgba(15, 23, 42, .64);
    color: var(--pi-a11y-text);
    font-size: 1.35rem;
    cursor: pointer;
}

.pi-a11y-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 .9rem;
}
.pi-a11y-fieldset legend,
.pi-a11y-control label {
    display: block;
    margin-bottom: .45rem;
    color: #e2e8f0;
    font-size: .74rem;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.pi-a11y-segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .35rem;
    padding: .25rem;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 1rem;
    background: rgba(2, 6, 23, .45);
}
.pi-a11y-segmented button,
.pi-a11y-font-row button,
.pi-a11y-read-actions button,
.pi-a11y-reset {
    border: 1px solid rgba(148, 163, 184, .24);
    border-radius: .8rem;
    background: rgba(15, 23, 42, .78);
    color: var(--pi-a11y-text);
    padding: .58rem .65rem;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 800;
}
.pi-a11y-segmented button.is-active {
    border-color: rgba(56, 189, 248, .75);
    background: linear-gradient(135deg, rgba(37, 99, 235, .95), rgba(14, 165, 233, .86));
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .14);
}

.pi-a11y-control { margin: .85rem 0; }
.pi-a11y-font-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: .45rem;
}
.pi-a11y-font-row input[type="range"] { width: 100%; accent-color: var(--pi-a11y-primary); }
.pi-a11y-font-row output { min-width: 3.25rem; text-align: right; color: var(--pi-a11y-muted); font-size: .78rem; font-weight: 850; }

.pi-a11y-switch {
    display: flex;
    align-items: center;
    gap: .65rem;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: .95rem;
    padding: .62rem .75rem;
    margin: .48rem 0;
    background: rgba(2, 6, 23, .28);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 700;
}
.pi-a11y-switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--pi-a11y-primary); }

.pi-a11y-keyboard-card {
    border: 1px solid rgba(251, 191, 36, .35);
    border-radius: 1rem;
    background: rgba(251, 191, 36, .1);
    color: #fde68a;
    padding: .75rem;
    margin: .65rem 0;
    font-size: .75rem;
}
.pi-a11y-keyboard-card[hidden] { display: none !important; }
.pi-a11y-keyboard-card ul { margin: .45rem 0 0; padding-left: 1.1rem; }
.pi-a11y-keyboard-card kbd {
    border: 1px solid rgba(251, 191, 36, .45);
    border-radius: .35rem;
    padding: .08rem .28rem;
    background: rgba(15, 23, 42, .7);
    color: #fff7ed;
    font-weight: 900;
}

.pi-a11y-read-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .85rem; }
.pi-a11y-read-actions button:first-child { background: rgba(34, 197, 94, .16); border-color: rgba(34, 197, 94, .36); }
.pi-a11y-reset { width: 100%; margin-top: .5rem; background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .28); }
.pi-a11y-note { display: block; margin-top: .65rem; color: var(--pi-a11y-muted); font-size: .68rem; }

html.pi-a11y-focus *:focus-visible,
html.pi-a11y-keyboard-user *:focus-visible,
.pi-a11y-panel button:focus-visible,
.pi-a11y-panel input:focus-visible,
.pi-a11y-toggle:focus-visible {
    outline: 3px solid var(--pi-a11y-warning) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, .18) !important;
}

html.pi-a11y-reduce-motion *,
html.pi-a11y-reduce-motion *::before,
html.pi-a11y-reduce-motion *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Modo claro opcional: solo se aplica si el usuario lo activa desde el panel. */
html.pi-a11y-light body {
    background: #f8fafc !important;
    color: #0f172a !important;
}
html.pi-a11y-light .bg-slate-950,
html.pi-a11y-light .bg-slate-900,
html.pi-a11y-light .bg-slate-800,
html.pi-a11y-light .bg-slate-950\/80,
html.pi-a11y-light .bg-slate-900\/80,
html.pi-a11y-light .bg-slate-900\/70 {
    background-color: #ffffff !important;
}
html.pi-a11y-light .text-slate-100,
html.pi-a11y-light .text-slate-200,
html.pi-a11y-light .text-slate-300,
html.pi-a11y-light .text-white {
    color: #0f172a !important;
}
html.pi-a11y-light .text-slate-400,
html.pi-a11y-light .text-slate-500 {
    color: #475569 !important;
}
html.pi-a11y-light .border-slate-900,
html.pi-a11y-light .border-slate-800,
html.pi-a11y-light .border-slate-700,
html.pi-a11y-light .divide-slate-800 > :not([hidden]) ~ :not([hidden]) {
    border-color: #cbd5e1 !important;
}
html.pi-a11y-light .shadow-2xl,
html.pi-a11y-light .shadow-xl,
html.pi-a11y-light .shadow-lg {
    box-shadow: 0 20px 55px rgba(15, 23, 42, .12) !important;
}
html.pi-a11y-light input,
html.pi-a11y-light select,
html.pi-a11y-light textarea {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}
html.pi-a11y-light .pi-a11y-panel,
html.pi-a11y-light .pi-a11y-widget * {
    color: inherit;
}

html.pi-a11y-dark body {
    background: #020617 !important;
    color: #f8fafc !important;
}

html.pi-a11y-high-contrast body {
    background: #000 !important;
    color: #fff !important;
}
html.pi-a11y-high-contrast a { text-decoration: underline !important; text-decoration-thickness: 2px !important; }
html.pi-a11y-high-contrast button,
html.pi-a11y-high-contrast input,
html.pi-a11y-high-contrast select,
html.pi-a11y-high-contrast textarea,
html.pi-a11y-high-contrast .rounded-xl,
html.pi-a11y-high-contrast .rounded-2xl,
html.pi-a11y-high-contrast .rounded-3xl {
    border-color: #fff !important;
}
html.pi-a11y-high-contrast .text-slate-400,
html.pi-a11y-high-contrast .text-slate-500,
html.pi-a11y-high-contrast .text-gray-400,
html.pi-a11y-high-contrast .text-gray-500 {
    color: #f8fafc !important;
}
html.pi-a11y-high-contrast .pi-a11y-toggle {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}
html.pi-a11y-high-contrast .pi-a11y-toggle-icon { background: #000; color: #fff; }
html.pi-a11y-high-contrast .pi-a11y-panel {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}
html.pi-a11y-high-contrast *:focus-visible {
    outline: 4px solid #ffff00 !important;
    outline-offset: 4px !important;
}

@media (max-width: 640px) {
    .pi-a11y-widget { right: 5.35rem; bottom: .875rem; }
    .pi-a11y-toggle { width: 3.5rem; height: 3.5rem; flex-basis: 3.5rem; }
    .pi-a11y-panel { width: calc(100vw - 1.3rem); }
}

.pi-a11y-branding {
    width: 100%;
    margin-top: .65rem;
    border: 1px solid rgba(16, 185, 129, .38);
    border-radius: .8rem;
    background: rgba(16, 185, 129, .14);
    color: #d1fae5;
    padding: .65rem .75rem;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 850;
}
.pi-a11y-branding:hover,
.pi-a11y-branding:focus-visible { background: rgba(16, 185, 129, .24); outline: 2px solid rgba(52, 211, 153, .72); outline-offset: 2px; }
