/* ========================================================================== 
   ACCESIBILIDAD Y NAVEGACIÓN — PORTAL DE HORARIOS
   IESTP 24 de Julio de Zarumilla
   Compatible con horario-portal-premium.css
   ========================================================================== */

:root {
  --a11y-focus: var(--focus, #2563eb);
  --a11y-focus-soft: rgba(37, 99, 235, 0.20);
  --a11y-danger: #dc2626;
  --a11y-danger-soft: rgba(220, 38, 38, 0.16);
  --a11y-ink: var(--ink, #0b1739);
  --a11y-muted: var(--muted, #64748b);
  --a11y-paper: var(--paper, #ffffff);
  --a11y-radius: var(--radius-sm, 12px);
  --a11y-ease: var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

/* --------------------------------------------------------------------------
   Enlace para saltar directamente al contenido
   -------------------------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10000;
  display: inline-flex;
  min-height: 44px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 13px;
  outline: 0;
  background: linear-gradient(135deg, #0b1d46 0%, #163b82 100%);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.01em;
  text-decoration: none;
  box-shadow:
    0 18px 40px rgba(3, 16, 46, 0.30),
    inset 0 1px rgba(255, 255, 255, 0.12);
  transform: translateY(calc(-100% - 28px));
  visibility: hidden;
  transition:
    transform 220ms var(--a11y-ease),
    visibility 220ms var(--a11y-ease),
    box-shadow 180ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  color: #ffffff;
  outline: 3px solid #7dd3fc !important;
  outline-offset: 3px !important;
  box-shadow:
    0 20px 48px rgba(3, 16, 46, 0.36),
    0 0 0 6px rgba(14, 165, 233, 0.20) !important;
  transform: translateY(0);
  visibility: visible;
}

/* --------------------------------------------------------------------------
   Foco visible coherente con el nuevo portal institucional
   -------------------------------------------------------------------------- */
:where(
  a[href],
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"]),
  .select2-selection,
  .schedule-class,
  .day-tab,
  .day-open
):focus-visible {
  outline: 3px solid var(--a11y-focus) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px var(--a11y-focus-soft) !important;
}

/* El foco de controles ubicados sobre fondos oscuros necesita más contraste. */
:where(
  .app-topbar,
  .dialog-head,
  .program-band
) :where(a[href], button, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline-color: #7dd3fc !important;
  box-shadow: 0 0 0 6px rgba(125, 211, 252, 0.22) !important;
}

/* No mostrar el anillo al hacer clic con mouse en navegadores compatibles. */
:where(a, button, input, select, textarea, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   Campos y validaciones
   -------------------------------------------------------------------------- */
:where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--a11y-danger) !important;
  box-shadow: 0 0 0 4px var(--a11y-danger-soft) !important;
}

:where(input, select, textarea)[aria-invalid="true"]:focus-visible {
  outline-color: var(--a11y-danger) !important;
  box-shadow: 0 0 0 6px var(--a11y-danger-soft) !important;
}

:where(input, textarea)::placeholder {
  color: #77849a;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Áreas táctiles: controles reales del portal
   -------------------------------------------------------------------------- */
:where(
  .icon-button,
  .topbar-action,
  .mobile-picker-trigger,
  .picker-done,
  .empty-picker-action,
  .primary-action,
  .secondary-action,
  .toolbar-download,
  .search-clear,
  .view-switch button,
  .day-tab,
  .day-open,
  .schedule-class,
  .mobile-actionbar button,
  .sheet-close
) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:where(
  .icon-button,
  .topbar-action,
  .search-clear,
  .view-switch button,
  .day-tab,
  .day-open,
  .mobile-actionbar button,
  .sheet-close
) {
  min-width: 44px;
  min-height: 44px;
}

/* --------------------------------------------------------------------------
   Estados seleccionados, actuales y deshabilitados
   -------------------------------------------------------------------------- */
:where(
  .view-switch button[aria-pressed="true"],
  .day-tab[aria-selected="true"],
  .schedule-class[aria-pressed="true"]
) {
  position: relative;
}

:where(
  .view-switch button[aria-pressed="true"],
  .day-tab[aria-selected="true"]
)::after {
  position: absolute;
  width: 6px;
  height: 6px;
  border: 2px solid var(--a11y-paper);
  border-radius: 999px;
  content: "";
  background: #38bdf8;
  box-shadow: 0 0 0 1px rgba(8, 26, 61, 0.18);
}

.view-switch button[aria-pressed="true"]::after {
  top: 5px;
  right: 5px;
}

.day-tab[aria-selected="true"]::after {
  top: 5px;
  right: 7px;
}

:where(button, input, select, textarea):disabled,
:where(button, input, select, textarea)[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.58;
}

/* --------------------------------------------------------------------------
   Utilidades para lectores de pantalla
   -------------------------------------------------------------------------- */
.a11y-live-region,
.visually-hidden,
.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;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Permite que un contenido oculto visualmente vuelva a mostrarse al enfocarlo. */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  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;
}

.a11y-menu-empty {
  padding: 14px 20px;
  color: var(--a11y-muted);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Diálogo y contenido dinámico
   -------------------------------------------------------------------------- */
.class-dialog[open] {
  overscroll-behavior: contain;
}

.class-dialog:focus-visible {
  outline: 3px solid var(--a11y-focus);
  outline-offset: 4px;
}

.app-toast[role="status"] {
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Preferencias del usuario
   -------------------------------------------------------------------------- */
@media (prefers-contrast: more) {
  :root {
    --a11y-focus-soft: rgba(37, 99, 235, 0.30);
  }

  :where(input, select, textarea, button, .schedule-class, .day-class) {
    border-width: 2px;
  }

  .context-chip,
  .schedule-kpi,
  .day-tab {
    color: #07132f;
    border-color: #718096;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  :where(
    a[href],
    button,
    input,
    select,
    textarea,
    [tabindex]:not([tabindex="-1"])
  ):focus-visible {
    outline: 3px solid Highlight !important;
    box-shadow: none !important;
    forced-color-adjust: auto;
  }

  :where(
    .view-switch button[aria-pressed="true"],
    .day-tab[aria-selected="true"],
    .schedule-class[aria-pressed="true"]
  ) {
    border: 2px solid Highlight !important;
  }

  :where(
    .view-switch button[aria-pressed="true"],
    .day-tab[aria-selected="true"]
  )::after {
    background: Highlight;
    border-color: Canvas;
  }

  .status-dot,
  .day-accent,
  .dialog-accent {
    forced-color-adjust: none;
  }
}

@media print {
  .skip-link,
  .a11y-live-region {
    display: none !important;
  }
}