/* ========================================
   Counterfactual Learning Task Styles
   ======================================== */

/* Base styles and background */
body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Comic Sans MS', 'Arial', sans-serif;
}

#jspsych-target {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animal helper display (top right corner) */
.animal-helper {
  position: fixed;
  top: 2vh;
  right: 2vw;
  width: 12vw;
  height: 12vw;
  max-width: 200px;
  max-height: 200px;
  min-width: 80px;
  min-height: 80px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  border: 3px solid #4CAF50;
  padding: 1vh;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.animal-helper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fixation cross */
.cf-fixation {
  font-size: 10vw;
  font-weight: bold;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* Choice phase container */
.cf-choice-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8vw;
  width: 100%;
  max-width: 1200px;
  padding: 0 5vw;
  min-height: 100vh;
}

/* Individual location boxes (stimuli) - SQUARE */
.cf-location {
  background: white;
  border: 5px solid white;
  border-radius: 20px;
  padding: 2vh;
  width: 20vw;
  height: 20vw;
  max-width: 250px;
  max-height: 250px;
  min-width: 180px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.cf-location:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.cf-location-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Outcome phase container */
.cf-outcome-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8vw;  /* Same as choice phase for consistent horizontal spacing */
  width: 100%;
  max-width: 1200px;
  padding: 0 5vw;
  min-height: 100vh;
}

/* Individual outcome column - contains both stimulus square and outcome rectangle */
.cf-outcome-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3vh;  /* Increased from 2vh to maintain spacing when items scale to 1.1x */
  transform-origin: center center;
}

/* Stimulus square in outcome phase - MATCHES choice phase exactly */
.cf-stimulus-square {
  background: white;
  border: 5px solid white;
  border-radius: 20px;
  padding: 2vh;
  width: 20vw;
  height: 20vw;
  max-width: 250px;
  max-height: 250px;
  min-width: 180px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

/* Outcome rectangle - for number and visual outcomes */
.cf-outcome-rectangle {
  background: white;
  border: 5px solid white;
  border-radius: 20px;
  padding: 2vh 1.5vw;
  width: 25vw;
  max-width: 300px;
  min-width: 200px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  gap: 1vh;
}

/* Empty outcome rectangle (before counterfactual reveal) */
.cf-outcome-rectangle:empty {
  opacity: 0;
}

/* Outcome images (stimulus in square) */
.cf-outcome-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  transition: all 0.3s ease;
}

/* Chosen outcome styling and animation */
.chosen-outcome {
  border: 5px solid #0E49B5 !important;
}

/* Chosen stimulus square gets green border and floats */
.cf-stimulus-square.chosen-outcome {
  border-color: #0E49B5;
  transform: scale(1.1);
  animation: float 2s ease-in-out infinite;
}

/* Chosen outcome rectangle gets green border and floats */
.cf-outcome-rectangle.chosen-outcome {
  border-color: #0E49B5;
  transform: scale(1.1);
  animation: float 2s ease-in-out infinite;
}

/* Floating animation for chosen option */
@keyframes float {
  0%, 100% {
    transform: scale(1.1) translateY(0);
  }
  50% {
    transform: scale(1.1) translateY(-10px);
  }
}

/* Unchosen (counterfactual) outcome styling */
.unchosen-outcome {
  border: 3px solid #999999 !important;
  opacity: 0.85;
  animation: ease-in-out infinite;
}

/* Unchosen stimulus square and rectangle get gray border */
.cf-stimulus-square.unchosen-outcome,
.cf-outcome-rectangle.unchosen-outcome {
  border-color: #999999;
  animation: ease-in-out infinite;
}

/* Outcome value (number) */
.cf-outcome-value {
  font-size: 5vh;
  font-weight: bold;
  color: #333;
  text-align: center;
  padding: 1vh 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  animation: ease-in-out infinite;
}

/* Acorns/outcomes display container */
.cf-acorns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3vw;
  max-width: 100%;
  padding: 1vh;
  max-height: 20vh;
  overflow-y: auto;
}

/* Individual outcome icons (acorns, berries, etc.) */
.outcome-icon {
  width: 2vw !important;
  height: 2vw !important;
  min-width: 15px;
  min-height: 15px;
  max-width: 25px;
  max-height: 25px;
  margin: 0.2vh !important;
  object-fit: contain;
}

/* Warning/error messages (missed response) */
.cf-warning {
  background: rgba(255, 255, 255, 0.95);
  border: 0.5vh solid #f44336;
  border-radius: 2.5vh;
  padding: 5vh 5vw;
  text-align: center;
  box-shadow: 0 1vh 2vh rgba(0, 0, 0, 0.4);
  max-width: 100vw;  
  min-width: 50vw;  
}

.cf-warning p {
  font-size: 3vh;
  color: #333;
  margin: 3vh 0;
}

/* Responsive adjustments for tablets */
@media (max-width: 1024px) and (min-width: 768px) {
  .cf-choice-container,
  .cf-outcome-container {
    gap: 6vw;  /* Horizontal gap between columns */
  }

  .cf-location,
  .cf-stimulus-square {
    width: 25vw;
    height: 25vw;
    padding: 2vh;
  }

  .cf-outcome-rectangle {
    width: 25vw;
    padding: 2vh 1.5vw;
  }

  .animal-helper {
    width: 15vw;
    height: 15vw;
  }

  .cf-outcome-value {
    font-size: 4.5vh;
  }

  .outcome-icon {
    width: 2.5vw !important;
    height: 2.5vw !important;
  }
}

/* Responsive adjustments for mobile/small tablets */
@media (max-width: 767px) {
  .cf-choice-container,
  .cf-outcome-container {
    flex-direction: column;
    gap: 4vh;  /* Vertical gap between stacked columns */
    padding: 2vh 3vw;
  }

  .cf-location,
  .cf-stimulus-square {
    width: 60vw;
    height: 60vw;
    max-width: 280px;
    max-height: 280px;
    min-width: 200px;
    min-height: 200px;
    padding: 2vh;
  }

  .cf-outcome-rectangle {
    width: 60vw;
    max-width: 280px;
    min-width: 200px;
    padding: 2vh 2vw;
  }

  .cf-outcome-column {
    gap: 3vh;  /* Increased from 2vh to maintain spacing when scaled */
  }

  .animal-helper {
    width: 20vw;
    height: 20vw;
    top: 1vh;
    right: 1vw;
  }

  .cf-fixation {
    font-size: 15vw;
  }

  .cf-outcome-value {
    font-size: 6vh;
  }

  .outcome-icon {
    width: 4vw !important;
    height: 4vw !important;
    max-width: 20px;
    max-height: 20px;
  }

  .cf-acorns {
    max-height: 15vh;
  }
}

/* Prevent text selection during task */
.cf-choice-container,
.cf-outcome-container,
.cf-location,
.cf-outcome-column,
.cf-stimulus-square,
.cf-outcome-rectangle {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Smooth transitions for all interactive elements */
* {
  box-sizing: border-box;
}

/* Loading state */
.cf-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4vh;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Fade-in animation for trial start */
.cf-choice-container,
.cf-outcome-container {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* High contrast mode adjustments (accessibility) */
@media (prefers-contrast: high) {
  .cf-location,
  .cf-outcome-box {
    border-width: 6px;
  }

  .chosen-outcome {
    border-width: 7px !important;
  }

  .unchosen-outcome {
    border-width: 5px !important;
  }
}

/* Reduced motion adjustments (accessibility) */
@media (prefers-reduced-motion: reduce) {
  .cf-stimulus-square.chosen-outcome,
  .cf-outcome-rectangle.chosen-outcome {
    animation: none;
    transform: scale(1.1);
  }

  .cf-location:hover {
    transform: scale(1.02);
  }

  .cf-choice-container,
  .cf-outcome-container {
    animation: none;
  }
}