/* ==========================================
   ACCESSIBILITY ENHANCEMENTS
   ARIA labels, skip-links, и другие a11y улучшения
   ========================================== */

/* ==========================================
   SKIP LINK (WCAG 2.4.1)
   Первый фокусируемый элемент
   ========================================== */

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  background: #0052cc;
  color: #ffffff;
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10000;
  
  /* Скрыт по умолчанию */
  transform: translateY(-100%);
  transition: transform 0.2s ease;
}

/* ✅ Показать при фокусе */
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

/* ==========================================
   VISUALLY HIDDEN TEXT
   Скрыто визуально, но доступно скринридерам
   ========================================== */

.sr-only,
.screen-reader-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-width: 0 !important;
}

/* ==========================================
   ARIA-LABEL SUPPORT
   ========================================== */

[aria-label] {
  /* Все элементы с aria-label должны быть в focus order */
}

[aria-labelledby] {
  /* Все элементы с aria-labelledby должны быть в focus order */
}

[aria-describedby] {
  /* Все элементы с aria-describedby должны быть в focus order */
}

/* ==========================================
   ARIA-LIVE REGIONS
   ========================================== */

[aria-live="polite"],
[aria-live="assertive"] {
  /* Видимо скринридерам, не требует фокуса */
}

/* Для loading/processing состояний */
[aria-busy="true"] {
  position: relative;
}

/* ==========================================
   ARIA-DISABLED vs :disabled
   ========================================== */

[aria-disabled="true"],
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================
   MAIN CONTENT WRAPPER
   Для skip-link */

main,
[role="main"] {
  outline: none;
  scroll-margin-top: 60px;  /* Для фиксированного header */
}

/* ==========================================
   FORM LABELS
   Всегда связывать label с input
   ========================================== */

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

label[for] {
  cursor: pointer;
}

input[type="checkbox"] + label,
input[type="radio"] + label {
  display: inline;
  margin-left: 8px;
  margin-bottom: 0;
  cursor: pointer;
}

/* ==========================================
   REQUIRED FIELD INDICATOR
   ========================================== */

[required]::after,
.required::after {
  content: " *";
  color: #b91c1c;
  font-weight: 700;
}

/* ==========================================
   ERROR MESSAGES
   Свяжи с input через aria-describedby
   ========================================== */

[aria-invalid="true"] {
  border-color: #b91c1c !important;
}

[role="alert"] {
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-left: 4px solid #b91c1c;
  color: #991b1b;
  border-radius: 4px;
  margin-bottom: 16px;
}

/* ==========================================
   SUCCESS MESSAGES
   ========================================== */

[role="status"] {
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #059669;
  color: #166534;
  border-radius: 4px;
}

/* ==========================================
   HEADING HIERARCHY
   H1 -> H2 -> H3 (не пропускай уровни)
   ========================================== */

h1 {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 800;
  line-height: 1.2;
  margin-block: 1em 0.5em;
}

h2 {
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  line-height: 1.2;
  margin-block: 1.2em 0.6em;
}

h3 {
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  line-height: 1.2;
  margin-block: 1em 0.4em;
}

h4, h5, h6 {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  margin-block: 0.8em 0.3em;
}

/* ==========================================
   FOCUS MANAGEMENT
   ========================================== */

/* Avoid global visual hiding for aria-hidden: controlled per-component only. */

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */

@media (prefers-color-scheme: dark) {
  .skip-link {
    background: #60a5fa;
  }
  
  [role="alert"] {
    background: #7f1d1d;
    color: #fecaca;
  }
  
  [role="status"] {
    background: #064e3b;
    color: #d1fae5;
  }
}

/* ==========================================
   REDUCED MOTION SUPPORT
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
