/**
 * Learning Upgrade — WCAG 2.1 AA baseline (platform-wide)
 * Linked from _Head.cshtml for all authenticated and anonymous layouts.
 */

:root {
  --lu-focus-ring-color: #0f6e8c;
  --lu-focus-ring-offset: 2px;
  --lu-focus-ring-width: 3px;
  --lu-text-primary: #1e293b;
  --lu-text-secondary: #475569;
  --lu-skip-link-bg: #0f6e8c;
  --lu-skip-link-fg: #ffffff;
}

/* —— Skip link (2.4.1 Bypass Blocks) —— */
.lu-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 100000;
  padding: 0.75rem 1.25rem;
  background: var(--lu-skip-link-bg);
  color: var(--lu-skip-link-fg) !important;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.lu-skip-link:focus,
.lu-skip-link:focus-visible {
  left: 0.5rem;
  top: 0.5rem;
  width: auto;
  height: auto;
  overflow: visible;
  outline: none;
  box-shadow:
    0 0 0 var(--lu-focus-ring-offset) #fff,
    0 0 0 calc(var(--lu-focus-ring-offset) + var(--lu-focus-ring-width)) var(--lu-focus-ring-color);
}

/* —— Screen reader only (1.3.1 Info and Relationships) —— */
.lu-sr-only,
.lu-visually-hidden {
  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;
}

.lu-sr-only-focusable:focus,
.lu-sr-only-focusable:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* —— Focus visible (2.4.7) —— */
:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"]),
  .dropdown-toggle,
  .app-nav-link,
  .app-top-nav-link,
  .app-header-btn,
  .app-sidebar-toggle-btn,
  .app-menu-toggle,
  .student-nav-link,
  .student-top-nav-link,
  .student-header-btn,
  .student-menu-toggle,
  .student-sidebar-toggle-btn
):focus {
  outline: none;
}

:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"]),
  .dropdown-toggle,
  .app-nav-link,
  .app-top-nav-link,
  .app-header-btn,
  .app-sidebar-toggle-btn,
  .app-menu-toggle,
  .student-nav-link,
  .student-top-nav-link,
  .student-header-btn,
  .student-menu-toggle,
  .student-sidebar-toggle-btn
):focus-visible {
  outline: var(--lu-focus-ring-width) solid var(--lu-focus-ring-color);
  outline-offset: var(--lu-focus-ring-offset);
  box-shadow: 0 0 0 calc(var(--lu-focus-ring-offset) + 1px) #fff;
}

/* —— Text resize up to 200% (1.4.4) —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: auto;
}

.app-portal-wrapper,
.student-portal-wrapper,
.page-wrapper,
.app-main,
.student-main,
.app-body-content,
.student-body-content {
  max-width: 100%;
}

img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

/* —— Contrast helpers (1.4.3) —— */
.app-portal,
.student-portal {
  --app-text-secondary: var(--lu-text-secondary);
}

.app-nav-divider-text,
.app-portal .app-nav-divider-text {
  color: var(--lu-text-secondary) !important;
  opacity: 1 !important;
}

.app-header-user-greeting,
.app-portal .app-header-user-greeting {
  color: var(--lu-text-secondary) !important;
}

/* Status / errors must not rely on color alone (1.4.1) */
.lu-status-error::before {
  content: "Error: ";
  font-weight: 600;
}

.lu-status-success::before {
  content: "Success: ";
  font-weight: 600;
}

/* —— Reduced motion (2.3.3) —— */
@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;
  }
}

/* —— Mobile drawer open: dim main for context —— */
body.app-sidebar-open .app-main,
body.student-sidebar-open .student-main {
  outline: none;
}

body.lu-modal-open {
  overflow: hidden;
}

/* ASB toolbar: preserve focus ring */
#accessibilityBar button:focus-visible,
#accessibilityBar a:focus-visible {
  outline: var(--lu-focus-ring-width) solid var(--lu-focus-ring-color) !important;
  outline-offset: 2px !important;
}

.student-header-school-text,
.app-header-school-text {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #202124 !important;
  font-size: 0.75rem;
  font-weight: 500;
}

.app-menu-toggle,
.student-menu-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  color: inherit;
  font: inherit;
}

/* Phase 3: media upload guidance */
.lu-a11y-media-hint {
  margin-top: 0.35rem;
  max-width: 42rem;
}

.lu-chart-summary {
  margin: 0;
}
