/**
 * TrusterLabs Academy Blog - Custom Styles
 * Matches the main site's blue and yellow color scheme
 */

/* Line Clamping Utilities */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

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

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

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

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

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

/* Animation Classes */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

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

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

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

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.animate-shimmer {
  animation: shimmer 2s infinite;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

.dark .skeleton {
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 1000px 100%;
}

/* Lazy Loading Images */
.lazy-load {
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

.lazy-load.loaded {
  opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.dark ::-webkit-scrollbar-track {
  background: #1f2937;
}

::-webkit-scrollbar-thumb {
  background: #1e40af;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #1e3a8a;
}

.dark ::-webkit-scrollbar-thumb {
  background: #3b82f6;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #2563eb;
}

/* Card Hover Effects */
.blog-card,
.featured-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-card:hover,
.featured-card:hover {
  transform: translateY(-8px) scale(1.02);
}

.featured-card {
  border: 2px solid transparent;
}

.featured-card:hover {
  border-color: #fbbf24;
}

/* Category Buttons */
.category-filter {
  cursor: pointer;
  user-select: none;
}

.category-filter:active {
  transform: scale(0.98);
}

/* Focus Styles for Accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .blog-card,
  .featured-card {
    border: 2px solid currentColor;
  }
}

/* Print Styles */
@media print {
  .no-print,
  nav,
  footer,
  #floating-cta,
  #back-to-top,
  #filter-section {
    display: none !important;
  }

  .blog-card,
  .featured-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body {
    background: white;
    color: black;
  }
}

/* Glass Effect */
.glass {
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}

/* GPU Acceleration for Smooth Animations */
.blog-card,
.featured-card,
.category-filter,
.lazy-load {
  transform: translateZ(0);
  will-change: transform;
}

/* Z-Index Management */
.z-hierarchy {
  /* Base layer */
  --z-base: 0;
  /* Content layer */
  --z-content: 10;
  /* Navigation */
  --z-nav: 50;
  /* Floating elements */
  --z-floating: 40;
  /* Modals */
  --z-modal: 100;
}

/* Dark Mode Specific Adjustments */
.dark .bg-white {
  background-color: #1f2937;
}

.dark .text-gray-900 {
  color: #f9fafb;
}

.dark .shadow-lg {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.3),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

.dark .shadow-2xl {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .blog-card,
  .featured-card {
    margin-bottom: 1rem;
  }

  .category-filter {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }
}

/* Tablet Responsiveness */
@media (min-width: 641px) and (max-width: 1024px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Smooth Scroll */
html {
  scroll-behavior: smooth;
}

/* Selection Color */
::selection {
  background-color: #fbbf24;
  color: #1e3a8a;
}

::-moz-selection {
  background-color: #fbbf24;
  color: #1e3a8a;
}

/* Loading State */
.loading-spinner {
  border: 4px solid #f3f4f6;
  border-top: 4px solid #1e40af;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.dark .loading-spinner {
  border-color: #374151;
  border-top-color: #3b82f6;
}

/* Empty State Icon */
#empty-state i {
  opacity: 0.3;
}

/* Floating CTA Pulse Effect */
#floating-cta a {
  position: relative;
}

#floating-cta a::before {
  content: "";
  position: absolute;
  inset: -4px;
  background: #fbbf24;
  border-radius: 9999px;
  opacity: 0.3;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* Image Overlay on Hover */
.blog-card img,
.featured-card img {
  transition: all 0.3s ease;
}

.blog-card:hover img,
.featured-card:hover img {
  filter: brightness(0.9);
}

/* Active Filter Tags */
#filter-tags span {
  animation: slideDown 0.2s ease-out;
}

/* Smooth transitions for all interactive elements */
a,
button,
input,
select {
  transition: all 0.2s ease;
}

.nav-link {
  position: relative;
}

.nav-link::after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #e1a609;
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

/* Aspect Ratio Utility */
.aspect-video {
  aspect-ratio: 16 / 9;
}

/* Card Shadow Variations */
.shadow-soft {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dark .shadow-soft {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Gradient Text */
.gradient-text {
  background: linear-gradient(135deg, #1e40af, #3b82f6, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Accessibility: Screen Reader Only */
.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;
}

/* Focus Trap for Modals */
.focus-trap {
  position: relative;
}

.focus-trap::before,
.focus-trap::after {
  content: "";
  position: fixed;
  width: 0;
  height: 0;
}

/* Performance Optimization */
.optimize-rendering {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Backdrop Image Hover Slideshow */
.card-cover-img {
  transition: opacity 0.5s ease;
}

.backdrop-slide {
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.backdrop-dots {
  pointer-events: none;
  gap: 6px;
}

.backdrop-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: rgba(255, 255, 255, 0.5);
  transition: background-color 0.3s ease, transform 0.3s ease;
}
