/**
 * AI Ethics Explorer Styles
 * Clean, educational interface for exploring AI bias scenarios
 */

/* Main Layout */
.ethics-explorer-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.explorer-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
  margin-bottom: 1.5rem;
}

.explorer-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2.5rem;
  font-weight: 700;
}

.explorer-subtitle {
  margin: 0;
  font-size: 1.2rem;
  opacity: 0.9;
}

/* Game Progress Bar */
.game-progress {
  max-width: 600px;
  margin: 0 auto;
}

.progress-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.stat-item {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  min-width: 80px;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.2);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.explorer-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  padding: 1.5rem;
  flex: 1;
  overflow: visible;
  height: calc(100% - 120px);
}

/* Scenario Area */
.scenario-area {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 0;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5);
  overflow-y: auto;
  height: 100%;
  position: relative;
  transition: all 0.3s ease;
}

.scenario-area:hover {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.8);
}

.scenario-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
  border-radius: 16px 16px 0 0;
  animation: progress-pulse 3s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

.scenario-selection,
.scenario-exploration,
.comparison-view,
.final-celebration {
  padding: 2rem;
  position: relative;
}

/* Scenario Selection */
.selection-header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
}

.selection-header::after {
  content: '';
  position: absolute;
  bottom: -1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 2px;
}

.scenario-selection h2 {
  color: #2d3748;
  margin-bottom: 1rem;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.selection-subtitle {
  color: #718096;
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

.scenarios-grid {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  /* Only apply scroll snap on horizontal axis and prevent it from affecting page */
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scroll-padding-left: 0; /* Ensures scroll snap starts at left edge */
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
  /* Prevent this element from interfering with page scrolling */
  contain: layout style;
  
  /* Enhanced cursor behavior for horizontal scrolling */
  cursor: grab;
  
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

/* Enhanced states for scenarios grid */
.scenarios-grid:hover {
  cursor: grab;
}

.scenarios-grid:active {
  cursor: grabbing;
}

/* Enhanced scrollbar styles with better hover feedback */
.scenarios-grid::-webkit-scrollbar {
  height: 8px;
  transition: height 0.2s ease;
}

.scenarios-grid:hover::-webkit-scrollbar {
  height: 10px;
}

.scenarios-grid::-webkit-scrollbar-track {
  background: #f7fafc;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.scenarios-grid:hover::-webkit-scrollbar-track {
  background: #edf2f7;
}

.scenarios-grid::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.scenarios-grid::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.scenarios-grid:hover::-webkit-scrollbar-thumb {
  background: #a0aec0;
}

/* Desktop-specific enhancements */
@media (min-width: 769px) {
  .scenarios-grid {
    /* Enhanced scroll performance on desktop */
    scroll-behavior: auto; /* Override smooth for wheel events */
  }
  
  .scenarios-grid:hover {
    /* Subtle indication that horizontal scrolling is available */
    box-shadow: inset 0 0 0 1px rgba(74, 144, 226, 0.15);
    /* Add a subtle gradient overlay to indicate scrollability */
    background: linear-gradient(90deg, 
      transparent 0%, 
      rgba(74, 144, 226, 0.02) 5%, 
      rgba(74, 144, 226, 0.02) 95%, 
      transparent 100%);
  }
  
  /* Enhanced visual feedback when actively scrolling */
  .scenarios-grid:active {
    cursor: grabbing;
    box-shadow: inset 0 0 0 2px rgba(74, 144, 226, 0.2);
  }
  
  /* Smoother transitions on desktop */
  .scenarios-grid {
    transition: box-shadow 0.3s ease, background 0.3s ease;
  }
  
  /* Subtle pulse animation to indicate scrollability */
  .scenarios-grid:hover {
    animation: scroll-hint-pulse 2s ease-in-out infinite;
  }
}

/* Keyframe animation for scroll hint */
@keyframes scroll-hint-pulse {
  0%, 100% { 
    box-shadow: inset 0 0 0 1px rgba(74, 144, 226, 0.15);
  }
  50% { 
    box-shadow: inset 0 0 0 1px rgba(74, 144, 226, 0.25);
  }
}

.scenario-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: #2d3748;
  padding: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(203, 213, 225, 0.3);
  overflow: hidden;
  position: relative;
  border: 1px solid #e2e8f0;
  
  /* Horizontal scroll properties */
  flex: 0 0 320px; /* Fixed width for horizontal scroll */
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.scenario-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(102, 126, 234, 0.2);
  border-color: #667eea;
}

.scenario-card.completed {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-color: #10b981;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(16, 185, 129, 0.3);
}

.scenario-card.completed::after {
  content: '✔️';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  z-index: 10;
  animation: checkmark-bounce 0.6s ease-out;
}

@keyframes checkmark-bounce {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.5rem 0 1.5rem;
}

.scenario-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  filter: grayscale(0.2);
}

.difficulty-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.completion-badge {
  font-size: 1.5rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.card-content {
  padding: 0 1.5rem 1rem 1.5rem;
}

.scenario-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #2d3748;
}

.scenario-description {
  margin-bottom: 1rem;
  line-height: 1.5;
  font-size: 0.95rem;
  color: #4a5568;
}

.scenario-context {
  font-style: italic;
  opacity: 0.8;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #718096;
}

.challenge-info {
  background: rgba(102, 126, 234, 0.05);
  border: 1px solid rgba(102, 126, 234, 0.1);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.challenge-text,
.reward-text {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #4a5568;
}

.challenge-text:last-child,
.reward-text:last-child {
  margin-bottom: 0;
}

.challenge-label,
.reward-label {
  font-weight: 600;
  white-space: nowrap;
  color: #667eea;
}

.scenario-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

.progress-bar-small {
  flex: 1;
  background: rgba(203, 213, 225, 0.3);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill-small {
  background: linear-gradient(90deg, #667eea, #764ba2);
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.scenario-card.completed .progress-fill-small {
  background: linear-gradient(90deg, #10b981, #059669);
}

.progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  color: #4a5568;
}

.scenario-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #718096;
  margin: 1rem 0;
  gap: 1rem;
}

.scenario-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.card-action {
  background: rgba(102, 126, 234, 0.05);
  padding: 1rem 1.5rem;
  text-align: center;
  border-top: 1px solid rgba(203, 213, 225, 0.3);
  margin-top: auto;
}

.action-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: #667eea;
}

.exploration-tips {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border: 2px solid #cbd5e0;
  border-radius: 16px;
  padding: 2rem;
  margin-top: 2rem;
}

.tips-header {
  text-align: center;
  margin-bottom: 2rem;
}

.exploration-tips h3 {
  color: #2d3748;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.tip-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.tip-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.tip-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.tip-content {
  flex: 1;
}

.tip-content strong {
  display: block;
  color: #2d3748;
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.tip-content p {
  color: #718096;
  margin: 0;
  line-height: 1.5;
}

/* Scenario Exploration */
.scenario-exploration .scenario-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 12px;
  border-left: 4px solid #667eea;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.scenario-header::before {
  content: '';
  position: absolute;
  top: -10px;
  right: 1rem;
  font-size: 1.5rem;
  background: white;
  padding: 0.5rem;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scenario-header.completed::before {
  content: '✅';
  opacity: 1;
  animation: checkmark-bounce 0.6s ease-out;
}

@keyframes checkmark-bounce {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.scenario-header h2 {
  color: #2d3748;
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.scenario-setting {
  color: #718096;
  font-size: 1rem;
  margin: 0.5rem 0 0 0;
  font-style: italic;
}

.back-btn {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 1px solid #cbd5e1;
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
}

.back-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: left 0.5s ease;
}

.back-btn:hover {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  transform: translateX(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.back-btn:hover::before {
  left: 100%;
}

.back-btn:active {
  transform: translateX(-3px) scale(0.98);
}

/* Enhanced Focus States for Accessibility */
.back-btn:focus,
.action-btn:focus,
.choice-option input[type='radio']:focus + .option-content {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Scenario Area Loading States */
.scenario-area.loading {
  position: relative;
}

.scenario-area.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.scenario-area.loading::before {
  content: '⏳';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  z-index: 1001;
  animation: loading-spin 1s linear infinite;
}

@keyframes loading-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Print Styles */
@media print {
  .scenario-area {
    box-shadow: none;
    border: 1px solid #000;
  }

  .scenario-area::before,
  .scenario-header::before,
  .scenario-context::before,
  .stakeholders-overview::before,
  .choice-section::before,
  .consequences-display::before {
    display: none;
  }

  .back-btn,
  .exploration-actions {
    display: none;
  }

  .choice-option input[type='radio']:checked + .option-content {
    border: 2px solid #000;
  }
}

/* Responsive Enhancements for Scenario Area */
@media (max-width: 768px) {
  .scenario-area {
    border-radius: 12px;
  }

  .scenario-header {
    padding: 1.5rem;
  }

  .scenario-title-section h2 {
    font-size: 1.6rem;
  }

  .progress-steps {
    flex-direction: column;
    gap: 1rem;
  }

  .progress-steps::before {
    display: none;
  }

  .step {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
  }

  .scenario-context,
  .stakeholders-overview,
  .choice-section,
  .consequences-display,
  .exploration-actions {
    margin: 1rem;
    padding: 1.5rem;
  }

  .context-metadata {
    flex-direction: column;
    gap: 0.75rem;
  }

  .stakeholders-list {
    gap: 0.75rem;
  }

  .stakeholder-tag {
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
  }

  .choice-group {
    padding: 1.5rem;
  }

  .option-implications {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stakeholder-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .exploration-actions {
    flex-direction: column;
    align-items: center;
  }

  .action-btn {
    width: 100%;
    max-width: 280px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .scenario-area {
    border: 2px solid #000;
  }

  .scenario-context,
  .stakeholders-overview,
  .choice-section,
  .consequences-display {
    border: 1px solid #000;
  }

  .stakeholder-tag,
  .action-btn {
    border: 1px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .scenario-area::before,
  .scenario-header::before,
  .scenario-title-section h2,
  .scenario-context::before,
  .stakeholders-overview::before,
  .choice-section::before,
  .consequences-display::before,
  .stakeholder-tag,
  .step.completed .step-number,
  .step.active .step-number,
  .progress-fill-header::after,
  .action-btn.success {
    animation: none;
  }

  .scenario-context,
  .stakeholders-overview,
  .choice-section,
  .consequences-display,
  .choice-group,
  .stakeholder-impact {
    animation: none;
  }

  * {
    transition: none !important;
  }
}
