/* Non-critical styles - loaded after initial render */

@layer base {
  /* Article prose content - light mode */
  .prose {
    @apply text-light-text;
  }

  .prose h1,
  .prose h2,
  .prose h3,
  .prose h4,
  .prose h5,
  .prose h6 {
    @apply text-light-text;
  }

  .prose p,
  .prose li,
  .prose td,
  .prose th {
    @apply text-light-text;
  }

  .prose strong {
    @apply text-light-text;
  }

  /* Article prose content - dark mode */
  html.dark .prose {
    @apply text-cream;
  }

  html.dark .prose h1,
  html.dark .prose h2,
  html.dark .prose h3,
  html.dark .prose h4,
  html.dark .prose h5,
  html.dark .prose h6 {
    @apply text-cream;
  }

  html.dark .prose p,
  html.dark .prose li,
  html.dark .prose td,
  html.dark .prose th {
    @apply text-cream;
  }

  html.dark .prose strong {
    @apply text-cream;
  }

  /* Respect 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;
    }
  }

  /* Code blocks */
  pre {
    @apply border border-light-border dark:border-orange/20 rounded-lg p-4 overflow-x-auto;
    @apply bg-light-hover dark:bg-black/30;
  }

  pre code {
    font-family: var(--font-mono), 'Menlo', 'Monaco', 'Courier New', monospace;
    @apply text-sm leading-relaxed;
  }

  code {
    font-family: var(--font-mono), 'Menlo', 'Monaco', 'Courier New', monospace;
  }

  /* Syntax highlighting */
  .line--highlighted {
    @apply border-l-4 border-orange bg-orange/10 -ml-4 -mr-4 pl-2 pr-4;
  }

  .chars--highlighted {
    @apply bg-orange/20 rounded px-1;
  }

  /* Command menu overlay */
  [cmdk-overlay] {
    @apply fixed inset-0 z-40 bg-black/20 dark:bg-navy/80;
  }
}

/* Split Cause Graph Animations */
@keyframes edgeFlow {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -40; }
}

svg .edge-animated {
  animation: edgeFlow 4s linear infinite;
  animation-play-state: running;
}

svg .edge-animated:not(.paused) {
  animation-play-state: running;
}

@keyframes statusPulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(1.1);
  }
}

@keyframes failurePulse {
  0%, 100% {
    opacity: 0.8;
    stroke-width: 2;
  }
  50% {
    opacity: 1;
    stroke-width: 3;
  }
}

.edge-flow {
  animation: edgeFlow 2s linear infinite;
}

.status-pulse {
  animation: statusPulse 2s ease-in-out infinite;
}

.failure-pulse {
  animation: failurePulse 1.5s ease-in-out infinite;
}

/* Dashboard & UI Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes scale-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Animation utility classes */
.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.6s ease-out;
}

.animate-slide-down {
  animation: slideDown 0.6s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.4s ease-out;
}

.animate-shimmer {
  background: linear-gradient(
    to right,
    rgba(232, 152, 65, 0) 0%,
    rgba(232, 152, 65, 0.1) 50%,
    rgba(232, 152, 65, 0) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

/* Stagger animation delays for lists */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* Hover effects */
.hover-lift {
  @apply transition-all duration-300;
}

.hover-lift:hover {
  @apply -translate-y-1 shadow-[0_10px_25px_-5px_rgba(232,152,65,0.3)];
}

.hover-glow {
  @apply transition-shadow duration-300;
}

.hover-glow:hover {
  @apply shadow-[0_0_20px_rgba(232,152,65,0.4)];
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(232, 152, 65, 0.1) 25%,
    rgba(232, 152, 65, 0.2) 50%,
    rgba(232, 152, 65, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  @apply rounded;
}

/* Performance optimizations - LCP and INP improvements */
/* Content Visibility for below-the-fold sections */
@media (min-width: 1024px) {
  .below-fold-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
  }
}

/* Will-change hints for interactive elements - improves INP */
.interactive-element {
  will-change: transform, opacity;
}

.interactive-element:hover,
.interactive-element:focus {
  will-change: auto;
}
