/* Accessibility Improvements for WCAG AA Compliance */

/* Skip-to-Content Link */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background-color: var(--accent-gold);
  color: var(--primary-charcoal);
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  font-weight: 600;
  z-index: 9999;
  border-radius: 0 0 8px 0;
}

.skip-to-content:focus {
  top: 0;
}

/* Enhanced Focus States */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 2px;
}

/* Icon-only buttons need visible text labels */
button[aria-label]:not(:has(span)),
a[aria-label]:not(:has(span)) {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Improve color contrast for accent gold on light backgrounds */
/* Gold accent text on white/light backgrounds */
a:not(:hover):not(:focus),
.text-accent,
.pro-badge span {
  color: #A08850; /* Darker gold for better contrast */
}

a:hover {
  color: var(--accent-gold-light);
}

/* Ensure buttons meet minimum touch target size */
button, a.btn, input[type="button"], input[type="submit"],
.marketplace-chip, a.preset-chip {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

/* Error message association */
.form-error {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #B71C1C;
  display: block;
}

input:invalid:not(:placeholder-shown) + .form-error {
  display: block;
}

input[aria-invalid="true"] {
  border-color: #B71C1C;
  background-color: #FFF5F5;
}

/* Improve contrast for score badges */
.score-number.excellent {
  color: #0B6623; /* Darker green */
}

.score-number.strong {
  color: #B8511A; /* Darker orange */
}

.score-number.decent {
  color: #5A1B7C; /* Darker purple */
}

.score-number.risky {
  color: #B91C1C; /* Darker red */
}

.score-badge.excellent {
  background-color: #D1F0D9;
  color: #0B6623;
  border-color: #52A860;
}

.score-badge.strong {
  background-color: #FED7B2;
  color: #B8511A;
  border-color: #F7A53E;
}

.score-badge.decent {
  background-color: #E8D9F0;
  color: #5A1B7C;
  border-color: #D299D1;
}

.score-badge.risky {
  background-color: #FDD5D5;
  color: #B91C1C;
  border-color: #F56666;
}

/* Modal accessibility */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-content {
  position: relative;
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Modal close button */
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Close button for quick tips */
.quick-tips-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition-smooth);
  line-height: 1;
  padding: 0.5rem;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-tips-close:hover {
  color: var(--accent-gold);
}

.quick-tips-close:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* Alert messages with better contrast */
.feature-alert {
  background-color: var(--background-pearl);
  border-left: 4px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
}

.feature-alert.error {
  background-color: #FFF5F5;
  border-color: #B91C1C;
  color: #5A0B0B;
}

.feature-alert.success {
  background-color: #F0FDF4;
  border-color: #16A34A;
  color: #1B4332;
}

/* Links in alerts must be visible */
.feature-alert a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.feature-alert a:hover {
  text-decoration: none;
}

/* Search filters and form controls */
.filter-group label {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.filter-group input[type="number"] {
  padding: 0.75rem;
  border: 2px solid var(--border-light);
  border-radius: 6px;
  width: 100px;
  font-size: 0.9rem;
  min-height: 44px;
}

.filter-group input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  min-height: 44px;
  min-width: 44px;
  accent-color: var(--accent-gold);
}

/* Keyboard visible focus for action buttons */
.action-btn {
  background: none;
  border: 1px solid #ddd;
  color: #1f4f7b;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background-color: #1f4f7b;
  color: white;
  border-color: #1f4f7b;
}

.action-btn:focus-visible {
  outline: 2px solid #1f4f7b;
  outline-offset: 2px;
}

/* Ensure info icons are keyboard accessible */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background-color: #666;
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: help;
  position: relative;
  min-height: 44px;
  min-width: 44px;
}

.info-icon:hover::after,
.info-icon:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: normal;
  width: 200px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Marketplace chips keyboard accessibility */
.marketplace-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--background-pearl);
  border: 2px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: 24px;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

.marketplace-chip:hover {
  border-color: var(--accent-gold);
  background-color: var(--background-white);
}

.marketplace-chip:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.marketplace-chip.active {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--primary-charcoal);
}

/* Preset chips */
.preset-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--background-white);
  border: 2px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(26, 26, 26, 0.04);
  min-height: 44px;
}

.preset-chip:hover {
  background-color: var(--accent-gold);
  color: var(--primary-charcoal);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 12px rgba(201, 168, 106, 0.2);
  transform: translateY(-2px);
}

.preset-chip:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* View button accessibility */
.view-btn {
  background-color: #1f4f7b;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  min-height: 44px;
  min-width: 44px;
}

.view-btn:hover {
  background-color: #15334f;
}

.view-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Ensure demo buttons are accessible */
.demo-btn-next, .demo-btn-end {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.demo-btn-next {
  background-color: #27ae60;
  color: white;
}

.demo-btn-next:hover {
  background-color: #229954;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.demo-btn-next:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.demo-btn-end {
  background-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.demo-btn-end:hover {
  background-color: rgba(255, 255, 255, 0.5);
}

.demo-btn-end:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Toggle breakdown button */
.toggle-breakdown {
  background: none;
  border: none;
  color: #1f4f7b;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 0.85rem;
  text-decoration: underline;
  font-weight: 600;
  margin-top: 0.5rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.toggle-breakdown:hover {
  text-decoration: none;
}

.toggle-breakdown:focus-visible {
  outline: 2px solid #1f4f7b;
  outline-offset: 2px;
}

/* Responsive improvements for touch targets on mobile */
@media (max-width: 768px) {
  button, a.btn, input[type="button"], input[type="submit"],
  .marketplace-chip, a.preset-chip, .action-btn {
    min-height: 48px;
    min-width: 48px;
  }
  
  .filter-group input[type="checkbox"] {
    min-height: 48px;
    min-width: 48px;
  }
}
