/**
 * Ben Live TV - Utility Classes
 * Reusable patterns for layout, glass effects, and performance
 */

/* ============================================================================
   Skip Navigation (WCAG 2.4.1)
   ============================================================================ */

.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: 0;
  left: 1rem;
  z-index: 10000;
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  background: var(--color-bg, #111);
  color: var(--color-fg, #fff);
  border: 2px solid var(--color-accent, #6cf);
  border-radius: 0 0 0.5rem 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  outline: 3px solid var(--color-accent, #6cf);
  outline-offset: 2px;
}

/* ============================================================================
   Container & Layout
   ============================================================================ */

.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Wider container for some sections */
.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Full-width container */
.container-full {
  width: 100%;
  padding: 0 var(--container-padding);
}

/* ============================================================================
   Glass Effect (Glassmorphism)
   ============================================================================ */

.glass {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    inset 0 1px 0 var(--light-subtle),
    0 4px 16px var(--shadow-deep);
}

/* Glass variants with different blur strengths */
.glass-subtle {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.glass-strong {
  background: rgba(26, 31, 38, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Glass card with hover effect */
.glass-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    inset 0 1px 0 var(--light-subtle),
    0 4px 16px var(--shadow-deep);
  transition: transform 0.3s var(--ease-in-out), border-color 0.3s var(--ease-in-out), box-shadow 0.3s var(--ease-in-out);
}

.glass-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 12px 32px rgba(0, 0, 0, 0.4);
}

/* ============================================================================
   GPU Acceleration & Performance
   ============================================================================ */

/*
  Force GPU compositing for smooth animations
  Use sparingly - only for animated elements
*/
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

/* GPU acceleration for opacity changes */
.gpu-accelerated-opacity {
  transform: translateZ(0);
  will-change: opacity;
  backface-visibility: hidden;
}

/* Disable GPU acceleration (useful for debugging) */
.cpu-rendering {
  transform: none;
  will-change: auto;
  backface-visibility: visible;
}

/* ============================================================================
   Off-screen Animation Pausing (animation-observer.js)
   Elements with [data-animate-on-visible] get this class when off-screen
   ============================================================================ */
.animation-paused {
  animation-play-state: paused !important;
}

/* ============================================================================
   Gradient Text
   ============================================================================ */

.gradient-text {
  background: linear-gradient(
    135deg,
    var(--accent-orange),
    var(--accent-cyan),
    var(--accent-blue)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
}

.gradient-text-animated {
  background: linear-gradient(
    135deg,
    var(--accent-orange),
    var(--accent-cyan),
    var(--accent-blue)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: logoShimmer 8s ease infinite;
}

/* Rainbow gradient (all 7 colors) */
.gradient-rainbow {
  background: linear-gradient(
    135deg,
    var(--accent-red),
    var(--accent-orange),
    var(--accent-yellow),
    var(--accent-green),
    var(--accent-cyan),
    var(--accent-blue),
    var(--accent-purple)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
}

/* ============================================================================
   Flexbox Utilities
   ============================================================================ */

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ============================================================================
   Grid Utilities
   ============================================================================ */

.grid {
  display: grid;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

/* Responsive grid - auto-fit with minimum size */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

/* ============================================================================
   Visibility & Display
   ============================================================================ */

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   Text Utilities
   ============================================================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Overflow & Scrolling
   ============================================================================ */

/*
  Prevent horizontal scroll on mobile
  Already applied to html/body in base styles, but available as utility
*/
.overflow-hidden {
  overflow: hidden;
}

.overflow-x-hidden {
  overflow-x: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

/* Smooth scrolling container */
.scroll-smooth {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   Positioning
   ============================================================================ */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* ============================================================================
   Background Gradients
   ============================================================================ */

/* Subtle animated gradient background */
.bg-gradient-radial {
  position: relative;
}

.bg-gradient-radial::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: var(--z-background);
}

html[data-theme="light"] .bg-gradient-radial::before {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.1) 0%, transparent 50%);
}

/* ============================================================================
   Responsive Image Handling
   ============================================================================ */

/*
  Ensure images and media don't cause horizontal scroll
  Already applied globally in base styles, but available as utility
*/
.responsive-media {
  max-width: 100%;
  height: auto;
}

/* ============================================================================
   Usage Notes
   ============================================================================ */

/*
  Performance Best Practices:

  1. Use .gpu-accelerated only for elements that are actively animating
  2. Remove will-change after animation completes if possible
  3. Limit the number of elements with backdrop-filter (glass effects)
  4. Use transform and opacity for animations (GPU-accelerated properties)
  5. Avoid animating width, height, top, left (causes layout recalculation)

  Glass Effect Tips:

  1. Test on lower-end devices - backdrop-filter can be expensive
  2. Use .glass-subtle for less critical elements
  3. Consider disabling glass effects on mobile if performance suffers
  4. Always provide fallback background color for browsers without support
*/
