/* Responsive Behaviors CSS
 * Touch-friendly controls, active states, and loading indicators
 */

/* Touch-friendly minimum sizes - WCAG 2.1 AA requires 44x44px minimum */
.touch-target {
  min-width: 44px;
  min-height: 44px;
}

/* Enhanced active states for touch feedback */
button:active,
input[type="submit"]:active,
input[type="button"]:active,
a.btn:active {
  transform: scale(0.98);
  transition: transform 0.1s ease-in-out;
}

/* Touch-friendly link areas with adequate spacing */
a {
  /* Links should have enough padding for comfortable tapping */
  @apply inline-block;
}

/* Enhanced focus visible for keyboard navigation */
*:focus-visible {
  outline: 3px solid #3B82F6;
  outline-offset: 2px;
}

/* Loading state animations */
@keyframes pulse-fade {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading-pulse {
  animation: pulse-fade 1.5s ease-in-out infinite;
}

/* Disabled state styling */
button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Smooth transitions for interactive elements */
button,
input[type="submit"],
input[type="button"],
a,
select {
  transition: all 0.2s ease-in-out;
}

/* Mobile-specific touch enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch target sizes on touch devices */
  button,
  input[type="submit"],
  input[type="button"],
  a.btn {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }

  /* Remove hover effects on touch devices (they can be sticky) */
  button:hover,
  input[type="submit"]:hover,
  input[type="button"]:hover,
  a:hover {
    /* Keep the base color, don't change on hover */
    transition: none;
  }

  /* More prominent active states for touch */
  button:active,
  input[type="submit"]:active,
  input[type="button"]:active,
  a.btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
  }
}

/* Desktop-specific hover enhancements */
@media (hover: hover) and (pointer: fine) {
  /* Subtle hover effects for mouse users */
  button:hover,
  input[type="submit"]:hover,
  input[type="button"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  a:hover {
    text-decoration-thickness: 2px;
  }
}

/* Loading spinner animation classes (for use with Stimulus) */
.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Error message transitions */
.error-message-enter {
  opacity: 0;
  transform: translateY(-10px);
}

.error-message-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 300ms ease-in, transform 300ms ease-in;
}

.error-message-exit {
  opacity: 1;
}

.error-message-exit-active {
  opacity: 0;
  transition: opacity 300ms ease-out;
}

/* Ensure forms don't shift layout when loading indicators appear */
form {
  position: relative;
}

/* Prevent double-tap zoom on buttons and inputs */
button,
input,
select,
textarea {
  touch-action: manipulation;
}
