/**
 * Utility Classes for noviCEV
 * Mobile-first utility classes that complement Bootstrap 5
 */

/* ====================================================================
   GAP UTILITIES
   Flexbox and Grid gap utilities
   ==================================================================== */
.gap-0 { gap: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.gap-x-1 { column-gap: var(--space-1); }
.gap-x-2 { column-gap: var(--space-2); }
.gap-x-3 { column-gap: var(--space-3); }
.gap-x-4 { column-gap: var(--space-4); }

.gap-y-1 { row-gap: var(--space-1); }
.gap-y-2 { row-gap: var(--space-2); }
.gap-y-3 { row-gap: var(--space-3); }
.gap-y-4 { row-gap: var(--space-4); }

/* ====================================================================
   TEXT TRUNCATION
   Multi-line text truncation with ellipsis
   ==================================================================== */
.text-truncate-1,
.text-truncate-2,
.text-truncate-3,
.text-truncate-4 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-truncate-1 { -webkit-line-clamp: 1; }
.text-truncate-2 { -webkit-line-clamp: 2; }
.text-truncate-3 { -webkit-line-clamp: 3; }
.text-truncate-4 { -webkit-line-clamp: 4; }

/* ====================================================================
   ASPECT RATIOS
   Maintain aspect ratio for responsive images/containers
   ==================================================================== */
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-16-9 { aspect-ratio: 16 / 9; }
.aspect-4-3 { aspect-ratio: 4 / 3; }
.aspect-3-2 { aspect-ratio: 3 / 2; }
.aspect-2-1 { aspect-ratio: 2 / 1; }
.aspect-3-4 { aspect-ratio: 3 / 4; }

/* ====================================================================
   TOUCH TARGETS
   Ensure minimum 44px touch target for accessibility
   ==================================================================== */
.touch-target {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.touch-target-comfortable {
  min-height: var(--touch-target-comfortable);
  min-width: var(--touch-target-comfortable);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ====================================================================
   GLASSMORPHISM
   Frosted glass effect for overlays and cards
   ==================================================================== */
.glass {
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-subtle {
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ====================================================================
   REDUCED MOTION SUPPORT
   Respect user's motion preferences
   ==================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ====================================================================
   SCROLL UTILITIES
   ==================================================================== */
.scroll-smooth {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: no-preference) {
  .scroll-smooth-motion {
    scroll-behavior: smooth;
  }
}

.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ====================================================================
   FOCUS STATES (Accessibility)
   ==================================================================== */
.focus-ring:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Remove default focus for mouse users, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ====================================================================
   SKIP LINK (Accessibility)
   ==================================================================== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary-500);
  color: white;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  z-index: 9999;
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
  outline: var(--focus-ring-width) solid white;
  outline-offset: var(--focus-ring-offset);
}

/* ====================================================================
   HOVER EFFECTS
   ==================================================================== */
.hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--transition-normal);
}

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

.hover-brightness {
  transition: filter var(--transition-normal);
}

.hover-brightness:hover {
  filter: brightness(1.05);
}

/* ====================================================================
   IMAGE UTILITIES
   ==================================================================== */
.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.img-zoom {
  transition: transform var(--transition-slow);
}

.img-zoom:hover {
  transform: scale(1.05);
}

/* Image container with zoom effect */
.img-zoom-container {
  overflow: hidden;
}

.img-zoom-container img {
  transition: transform var(--transition-slow);
}

.img-zoom-container:hover img {
  transform: scale(1.05);
}

/* ====================================================================
   LOADING STATES
   ==================================================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-neutral-100) 0%,
    var(--color-neutral-200) 50%,
    var(--color-neutral-100) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--color-neutral-200);
  }
}

/* ====================================================================
   ANIMATION UTILITIES
   ==================================================================== */
.fade-in {
  animation: fadeIn var(--transition-normal) var(--ease-out);
}

.fade-in-up {
  animation: fadeInUp var(--transition-slow) var(--ease-out);
}

.fade-in-down {
  animation: fadeInDown var(--transition-slow) var(--ease-out);
}

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation helper - use with JS to set --stagger-delay */
.stagger-item {
  animation: fadeInUp var(--transition-slow) var(--ease-out);
  animation-delay: calc(var(--stagger-index, 0) * 50ms);
  animation-fill-mode: both;
}

/* ====================================================================
   BUTTON EFFECTS
   ==================================================================== */
.btn-shine {
  position: relative;
  overflow: hidden;
}

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

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

@media (prefers-reduced-motion: reduce) {
  .btn-shine::before {
    display: none;
  }
}

/* ====================================================================
   RESPONSIVE VISIBILITY
   ==================================================================== */
.hide-on-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-on-mobile {
    display: block;
  }

  .show-on-mobile {
    display: none;
  }
}

/* ====================================================================
   CONTAINER UTILITIES
   ==================================================================== */
.container-narrow {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.container-wide {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* ====================================================================
   CARD UTILITIES
   ==================================================================== */
.card-interactive {
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-interactive:active {
  transform: translateY(0);
}

/* ====================================================================
   BADGE UTILITIES
   ==================================================================== */
.badge-floating {
  position: absolute;
  z-index: 10;
}

.badge-floating-top-left {
  top: var(--space-2);
  left: var(--space-2);
}

.badge-floating-top-right {
  top: var(--space-2);
  right: var(--space-2);
}

.badge-floating-bottom-left {
  bottom: var(--space-2);
  left: var(--space-2);
}

.badge-floating-bottom-right {
  bottom: var(--space-2);
  right: var(--space-2);
}

/* ====================================================================
   DETAILS/SUMMARY (Expandable sections)
   ==================================================================== */
details.expandable > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  color: var(--color-primary-500);
  font-weight: var(--font-weight-medium);
  transition: color var(--transition-fast);
}

details.expandable > summary::-webkit-details-marker {
  display: none;
}

details.expandable > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}

details.expandable[open] > summary::before {
  transform: rotate(90deg);
}

details.expandable > summary:hover {
  color: var(--color-primary-600);
}

details.expandable > .expandable-content {
  padding: var(--space-3) 0;
  animation: fadeInDown var(--transition-fast) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  details.expandable > .expandable-content {
    animation: none;
  }
}
