/**
 * @file
 * Directory View - WCAG 2.0 AA 1.4.3 Contrast Compliance
 * Ensures text placed over images or gradients has sufficient contrast
 */

/* ==========================================================================
   Profile Image Text Overlays - Ensure Sufficient Contrast
   ========================================================================== */

/* If profile photo has any overlays or hover text */
.directory-profile-item .profile-photo-wrapper,
.directory-profile-item .field--name-field-dir-profile-photo {
  position: relative;
}

/* Any text overlaid on profile images needs proper contrast */
.directory-profile-item .profile-photo-wrapper::after,
.directory-profile-item img[src*="profile"]::after {
  /* Ensure dark overlay if text is present */
  background: rgba(0, 0, 0, 0.6);
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Text over images must have proper shadows for readability */
.directory-profile-item .profile-photo-wrapper [class*="text"],
.directory-profile-item .profile-photo-wrapper .profile-name,
.directory-profile-item .profile-photo-wrapper .profile-title,
.directory-profile-item [class*="overlay"] {
  color: #ffffff !important;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.8),
    0 2px 6px rgba(0, 0, 0, 0.6),
    1px 1px 2px rgba(0, 0, 0, 0.9);
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   Card Backgrounds with Images - Ensure Text Contrast
   ========================================================================== */

/* If cards have background images */
.directory-profile-item.card[style*="background-image"],
.directory-profile-item .card-body[style*="background-image"],
.directory-profile-item [style*="background-image"] {
  position: relative;
}

.directory-profile-item.card[style*="background-image"]::before,
.directory-profile-item .card-body[style*="background-image"]::before,
.directory-profile-item [style*="background-image"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  z-index: 1;
  pointer-events: none;
}

.directory-profile-item.card[style*="background-image"] *,
.directory-profile-item .card-body[style*="background-image"] *,
.directory-profile-item [style*="background-image"] * {
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   Gradient Backgrounds - Ensure Text Contrast
   ========================================================================== */

/* Primary department with background - ensure contrast */
.directory-profile-item .primary-dept-info {
  background-color: #18453b !important;
  color: #ffffff !important;
  /* WCAG AA compliant contrast ratio: 7.15:1 */
}

.directory-profile-item .primary-dept-info * {
  color: #ffffff !important;
}

/* Other department sections with backgrounds */
.directory-profile-item .profile-dept.other-departments {
  background-color: transparent !important;
}

/* Ensure department text has sufficient contrast on light backgrounds */
.directory-profile-item .dir-page-dept {
  color: #000000 !important;
  /* WCAG AA compliant on white: 21:1 */
  font-weight: 500;
}

.directory-profile-item .dir-primary-dept-title {
  color: #0d5c2e !important;
  /* WCAG AA compliant on white: 7.09:1 */
  font-style: italic;
}

/* ==========================================================================
   Hover States - Maintain Contrast
   ========================================================================== */

/* Ensure hover states maintain proper contrast */
.directory-profile-item .card:hover {
  background-color: #ffffff;
}

.directory-profile-item a:hover {
  color: #157347 !important;
  /* WCAG AA compliant on white: 7.5:1 */
  text-decoration: underline;
}

/* ==========================================================================
   Link Contrast Over Various Backgrounds
   ========================================================================== */

/* Email and phone links must have sufficient contrast */
.directory-profile-item address a {
  color: #008208 !important;
  /* WCAG AA compliant on white: 4.5:1 */
  text-decoration: none;
}

.directory-profile-item address a:hover,
.directory-profile-item address a:focus {
  color: #006506 !important;
  /* Even higher contrast: 6.2:1 */
  text-decoration: underline;
  outline: 2px solid #0d5c2e;
  outline-offset: 2px;
}

/* ==========================================================================
   Profile Title and Position Text - High Contrast
   ========================================================================== */

.directory-profile-item .profile-title {
  color: #000000 !important;
  /* Maximum contrast: 21:1 */
  font-weight: 700;
}

.directory-profile-item .profile-position {
  color: #555555 !important;
  /* WCAG AA compliant: 7.41:1 */
}

/* ==========================================================================
   Image Alt Text and Missing Images
   ========================================================================== */

/* If profile image fails to load, ensure alt text is readable */
.directory-profile-item img[alt] {
  background-color: #f5f5f5;
  color: #000000;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 150px;
}

/* ==========================================================================
   Dark Mode / High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
  /* Increase contrast even more for high contrast mode */
  .directory-profile-item .primary-dept-info {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff;
  }

  .directory-profile-item .dir-page-dept {
    color: #000000 !important;
    font-weight: 700 !important;
  }

  .directory-profile-item a {
    text-decoration: underline !important;
    font-weight: 600 !important;
  }
}

/* Dark mode disabled for directory page */

/* ==========================================================================
   Focus States - WCAG 2.4.7
   ========================================================================== */

.directory-profile-item a:focus,
.directory-profile-item button:focus,
.directory-profile-item [tabindex]:focus {
  outline: 3px solid #0d5c2e !important;
  outline-offset: 2px !important;
  background-color: rgba(13, 92, 46, 0.1);
}

/* ==========================================================================
   Print Styles - Maintain Contrast
   ========================================================================== */

@media print {
  .directory-profile-item .primary-dept-info {
    background-color: #000000 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .directory-profile-item * {
    color: #000000 !important;
  }

  .directory-profile-item .primary-dept-info * {
    color: #ffffff !important;
  }
}

/* ==========================================================================
   Additional Safeguards for Text Over Images
   ========================================================================== */

/* Any absolutely positioned text needs protection */
.directory-profile-item [style*="position: absolute"],
.directory-profile-item .position-absolute {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Ensure sufficient contrast for any badge or label overlays */
.directory-profile-item .badge,
.directory-profile-item .label,
.directory-profile-item [class*="badge"],
.directory-profile-item [class*="tag"] {
  background-color: #18453b !important;
  color: #ffffff !important;
  padding: 0.25rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 767px) {
  /* Maintain contrast on mobile */
  .directory-profile-item .primary-dept-info {
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  /* Ensure touch targets and contrast on mobile */
  .directory-profile-item a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
  }
}
