/* ============================================
   NIVEAU 27 — L'ACCESSIBILITÉ (A11Y)
   Styles spécifiques au chapitre
   ============================================ */

/* ---------- CONTRASTE DEMO ---------- */
.contrast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.contrast-card {
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contrast-card .ratio {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-weight: 700;
  font-size: 0.85rem;
}

.contrast-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.contrast-pass { border: 2px solid #16a34a; }
.contrast-fail { border: 2px solid #dc2626; }

/* ---------- FOCUS DEMO ---------- */
.focus-demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.focus-demo-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.focus-demo-card .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.focus-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #2563eb;
  background: white;
  color: #2563eb;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.focus-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.focus-btn:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  box-shadow: none;
}

.focus-btn-no-outline:focus {
  outline: none;
}

.focus-btn-custom:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #2563eb, 0 0 0 6px white;
}

.focus-btn-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #2563eb;
}

/* ---------- SKIP LINK DEMO ---------- */
.skip-link-demo {
  background: #1e293b;
  border-radius: 8px;
  padding: 1rem;
  position: relative;
  overflow: hidden;
  min-height: 80px;
}

.skip-link-demo a.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: #2563eb;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0 0 6px 6px;
  font-weight: 600;
  text-decoration: none;
  z-index: 10;
  transition: top 0.2s;
}

.skip-link-demo a.skip-link:focus {
  top: 0;
}

/* ---------- SR-ONLY DEMO ---------- */
.sr-only-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------- PREFERS MEDIA QUERIES DEMO ---------- */
.media-query-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.media-query-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.25rem;
}

.media-query-card h4 {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #2563eb;
  margin-bottom: 0.5rem;
}

.media-query-card p {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0;
}

/* ---------- TOUCH TARGET DEMO ---------- */
.touch-target-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.touch-target-grid .touch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
}

.touch-target-grid .touch-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.touch-target-grid .touch-btn-bad {
  min-width: 28px;
  min-height: 28px;
  border-color: #fca5a5;
  background: #fef2f2;
}

.touch-target-grid .touch-btn-bad:hover {
  border-color: #dc2626;
}

/* ---------- REDUCED MOTION DEMO ---------- */
.motion-demo {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  align-items: center;
}

.motion-box {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.motion-box.animated {
  animation: motion-demo-move 2s ease-in-out infinite;
}

@keyframes motion-demo-move {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(40px); }
}

@media (prefers-reduced-motion: reduce) {
  .motion-box.animated {
    animation: none;
  }
}

/* ---------- HIGH CONTRAST DEMO ---------- */
.high-contrast-box {
  padding: 1rem;
  border: 2px solid #1e293b;
  border-radius: 8px;
  background: #f8fafc;
}

@media (forced-colors: active) {
  .high-contrast-box {
    border: 2px solid ButtonText;
  }
}

/* ---------- ARIA DEMO ---------- */
.aria-demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.aria-demo-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
}

.aria-demo-card h4 {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

/* Accessible button */
.a11y-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.a11y-btn:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Accessible form */
.a11y-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.a11y-form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.a11y-form-group input {
  padding: 0.5rem 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  min-height: 44px;
}

.a11y-form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.a11y-form-group .hint {
  font-size: 0.8rem;
  color: #64748b;
}

/* ---------- ACCESSIBLE COMPONENT EXAMPLES ---------- */
.a11y-component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.a11y-component-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
}

.a11y-component-card h4 {
  margin-bottom: 1rem;
  color: #1e293b;
}

/* Accessible alert */
.a11y-alert {
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid;
  font-weight: 500;
}

.a11y-alert-success {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #166534;
}

.a11y-alert-error {
  background: #fef2f2;
  border-color: #dc2626;
  color: #991b1b;
}

.a11y-alert-info {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e40af;
}

/* Accessible progress */
.a11y-progress {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.a11y-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* Accessible tabs */
.a11y-tabs {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  gap: 0;
}

.a11y-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  min-height: 44px;
}

.a11y-tab[aria-selected="true"] {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.a11y-tab:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: -3px;
}

.a11y-tab-panel {
  padding: 1rem 0;
}

/* ---------- CONTRAST CHECKER TOOL ---------- */
.contrast-checker {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
}

.contrast-checker-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

.contrast-checker-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contrast-checker-form label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #64748b;
}

.contrast-checker-form input[type="color"] {
  width: 50px;
  height: 40px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.contrast-checker-form input[type="text"] {
  padding: 0.5rem 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
  width: 120px;
}

.contrast-preview {
  margin-top: 1rem;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

.contrast-result {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.contrast-pass-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #dcfce7;
  color: #16a34a;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.contrast-fail-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- FOCUS TRAPPING DEMO ---------- */
.modal-a11y-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-a11y-overlay.active {
  display: flex;
}

.modal-a11y-content {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 450px;
  width: 90%;
  position: relative;
}

.modal-a11y-content h3 {
  margin-bottom: 1rem;
}

.modal-a11y-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-a11y-close:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* ---------- RESPONSIVE ACCESSIBILITY ---------- */
@media (max-width: 600px) {
  .contrast-grid {
    grid-template-columns: 1fr;
  }
  .focus-demo-grid {
    grid-template-columns: 1fr;
  }
  .media-query-grid {
    grid-template-columns: 1fr;
  }
  .a11y-component-grid {
    grid-template-columns: 1fr;
  }
}
