/**
 * SUPERMIX UTILITIES
 * Additional utility classes and helpers
 */

/* ============================================
   SCROLL BEHAVIOR
   ============================================ */

html {
  scroll-padding-top: 80px; /* Account for fixed navbar */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

/* ============================================
   SELECTION
   ============================================ */

::selection {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

/* ============================================
   FOCUS STYLES
   ============================================ */

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ============================================
   LOADING STATES
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--bg-elevated) 50%,
    var(--bg-tertiary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

/* ============================================
   TOOLTIPS
   ============================================ */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--text-xs);
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::before {
  opacity: 1;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .navbar,
  .footer,
  .search-modal,
  .progress-bar,
  .btn,
  .newsletter-form {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    border: 1px solid #ddd;
    box-shadow: none;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.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;
}

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-primary);
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: var(--z-tooltip);
}

.skip-to-content:focus {
  top: 0;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@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;
  }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  :root {
    --border-soft: rgba(255, 255, 255, 0.3);
    --border-medium: rgba(255, 255, 255, 0.5);
    --border-strong: rgba(255, 255, 255, 0.7);
  }
  
  .card {
    border-width: 2px;
  }
}

/* ============================================
   ADDITIONAL ANIMATIONS
   ============================================ */

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.animate-slide-in-left {
  animation: slideInFromLeft 0.6s ease-out;
}

.animate-slide-in-right {
  animation: slideInFromRight 0.6s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease-out;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* ============================================
   GRADIENT TEXT
   ============================================ */

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   GLASS EFFECT VARIATIONS
   ============================================ */

.glass-strong {
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--border-medium);
}

[data-theme="dark"] .glass-strong {
  background: rgba(15, 23, 42, 0.8);
}

[data-theme="light"] .glass-strong {
  background: rgba(255, 255, 255, 0.8);
}

.glass-light {
  background: var(--bg-tertiary);
  backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--border-soft);
}

[data-theme="dark"] .glass-light {
  background: rgba(15, 23, 42, 0.4);
}

[data-theme="light"] .glass-light {
  background: rgba(255, 255, 255, 0.4);
}

/* ============================================
   DIVIDERS
   ============================================ */

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: var(--space-xl) 0;
}

.divider-gradient {
  height: 1px;
  background: var(--gradient-primary);
  opacity: 0.3;
  margin: var(--space-xl) 0;
}

/* ============================================
   ASPECT RATIOS
   ============================================ */

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-portrait {
  aspect-ratio: 3 / 4;
}

/* ============================================
   TRUNCATE TEXT
   ============================================ */

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   BACKDROP EFFECTS
   ============================================ */

.backdrop-blur-sm {
  backdrop-filter: blur(var(--blur-sm));
}

.backdrop-blur-md {
  backdrop-filter: blur(var(--blur-md));
}

.backdrop-blur-lg {
  backdrop-filter: blur(var(--blur-lg));
}

/* ============================================
   GLOW EFFECTS
   ============================================ */

.glow {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.glow-strong {
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.5);
}

.text-glow {
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* ============================================
   PRELOADER: TERMINAL BOOT
   ============================================ */

.preloader-terminal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

body:not(.loading-state) .preloader-terminal {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.terminal-window {
    width: 600px;
    max-width: 90vw;
    height: 360px;
    background: rgba(10, 15, 28, 0.95);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.terminal-header {
    background: rgba(255,255,255,0.03);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
}

.terminal-controls {
    display: flex;
    gap: 8px;
    margin-right: 16px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.control.red { background: #ff5f56; }
.control.yellow { background: #ffbd2e; }
.control.green { background: #27c93f; }

.terminal-title {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    text-align: center;
}

.terminal-body {
    flex: 1;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--accent-primary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.boot-sequence {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.boot-line {
    opacity: 0;
    animation: fadeIn 0.1s forwards;
}

.boot-line.success { color: var(--accent-success); }
.boot-line.warning { color: var(--accent-warning); }

.active-line {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.prompt {
    color: var(--accent-success);
}

.cursor-blink {
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.system-status {
    padding: 12px 20px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.status-progress {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.2s linear;
    box-shadow: 0 0 10px var(--accent-primary);
}

.status-text {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* ============================================
   GLOBAL ATMOSPHERE
   ============================================ */

.global-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-negative);
    overflow: hidden;
    pointer-events: none;
    background: var(--bg-primary);
}

.mesh-gradient-animated {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: var(--gradient-mesh);
    filter: blur(100px);
    opacity: 0.4;
    animation: rotateMesh 20s linear infinite;
}

@keyframes rotateMesh {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    opacity: 0.07;
    mix-blend-mode: overlay;
}

.grid-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
}

.floating-orbs .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: floatOrb 10s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.orb-1 {
    width: 300px; height: 300px;
    background: var(--accent-primary);
    top: 10%; left: 20%;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px; height: 400px;
    background: var(--accent-secondary);
    bottom: 20%; right: 10%;
    animation-delay: -2s;
}

.orb-3 {
    width: 200px; height: 200px;
    background: var(--accent-tertiary);
    top: 40%; left: 60%;
    animation-delay: -4s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -50px) scale(1.1); }
}

/* ============================================
   LIQUID GLASS UTILITIES
   ============================================ */

.glass-panel {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(
        to right,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    transform: skewX(-25deg);
    transition: 0.5s;
}

.glass-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.4),
        0 0 20px rgba(0, 243, 255, 0.1);
}

.glass-card:hover::before {
    left: 150%;
}

.glass-morphism {
    background: rgba( 255, 255, 255, 0.05 );
    box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
    backdrop-filter: blur( 14px );
    -webkit-backdrop-filter: blur( 14px );
    border-radius: 10px;
    border: 1px solid rgba( 255, 255, 255, 0.18 );
}
