/**
 * EaseMart Blog - Custom CSS
 * Additional styles beyond TailwindCSS
 * 
 * @package EaseMart_Blog
 * @since 1.0.0
 */

/* ============================================
   CUSTOM ANIMATIONS
   ============================================ */

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

@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 pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

.slide-in-left {
  animation: slideInFromLeft 0.6s ease-out;
}

.slide-in-right {
  animation: slideInFromRight 0.6s ease-out;
}

/* ============================================
   LOADING STATES
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

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

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */

/* For Webkit browsers (Chrome, Safari) */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #059669, #10b981);
  border-radius: 6px;
  border: 2px solid #f9fafb;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

/* For Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #059669 #f9fafb;
}

/* ============================================
   SELECTION STYLES
   ============================================ */

::selection {
  background-color: #059669;
  color: white;
}

::-moz-selection {
  background-color: #059669;
  color: white;
}

/* ============================================
   FOCUS STYLES (Accessibility)
   ============================================ */

*:focus-visible {
  outline: 3px solid #059669;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* ============================================
   CODE COPY BUTTON HOVER
   ============================================ */

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
  transform: translateY(-2px);
}

/* ============================================
   IMAGE ZOOM ON HOVER
   ============================================ */

.image-zoom {
  overflow: hidden;
  position: relative;
}

.image-zoom img {
  transition: transform 0.5s ease;
}

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

/* ============================================
   CATEGORY BADGE STYLES
   ============================================ */

.category-badge {
  position: relative;
  overflow: hidden;
}

.category-badge::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;
}

.category-badge:hover::before {
  left: 100%;
}

/* ============================================
   CARD HOVER EFFECTS
   ============================================ */

.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   GRADIENT BORDER ANIMATION
   ============================================ */

.gradient-border {
  position: relative;
  border-radius: 0.75rem;
  background: white;
  padding: 2px;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0.75rem;
  padding: 2px;
  background: linear-gradient(135deg, #059669, #10b981, #34d399);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: rotate 3s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   SHARE BUTTON STYLES
   ============================================ */

.share-btn {
  position: relative;
  overflow: hidden;
}

.share-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.share-btn:hover::after {
  width: 300px;
  height: 300px;
}

/* ============================================
   READING PROGRESS BAR
   ============================================ */

#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  z-index: 9999;
  transition: width 0.2s ease;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */

#back-to-top {
  animation: fadeInUp 0.3s ease;
}

#back-to-top:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 8px 16px rgba(5, 150, 105, 0.3);
}

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

/* ============================================
   TOOLTIP STYLES
   ============================================ */

[data-tooltip] {
  position: relative;
  cursor: pointer;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 0.5rem 0.75rem;
  background: #1f2937;
  color: white;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-12px);
}

/* ============================================
   NEWSLETTER FORM STYLES
   ============================================ */

.newsletter-input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.newsletter-button {
  background: linear-gradient(135deg, #059669, #10b981);
  transition: all 0.3s ease;
}

.newsletter-button:hover {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(5, 150, 105, 0.3);
}

.newsletter-button:active {
  transform: translateY(0);
}

/* ============================================
   SEARCH FORM ANIMATION
   ============================================ */

.search-form {
  position: relative;
}

.search-form input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.search-form button {
  transition: all 0.3s ease;
}

.search-form button:hover {
  background: #047857;
  transform: scale(1.05);
}

/* ============================================
   SIDEBAR WIDGET ANIMATIONS
   ============================================ */

.widget {
  animation: fadeIn 0.6s ease-out;
}

.widget:nth-child(1) {
  animation-delay: 0.1s;
}

.widget:nth-child(2) {
  animation-delay: 0.2s;
}

.widget:nth-child(3) {
  animation-delay: 0.3s;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
  /* Adjust scrollbar for mobile */
  ::-webkit-scrollbar {
    width: 6px;
  }
  
  /* Larger tap targets */
  button,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Reduce animations on mobile for performance */
  * {
    animation-duration: 0.3s !important;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  /* Hide interactive elements */
  #back-to-top,
  #reading-progress,
  .code-copy-btn,
  .share-btn,
  .no-print {
    display: none !important;
  }
  
  /* Optimize for printing */
  body {
    background: white;
    color: black;
  }
  
  a {
    color: black;
    text-decoration: underline;
  }
  
  /* Show URLs for links */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  /* Prevent page breaks inside elements */
  h1, h2, h3, h4, h5, h6,
  p, blockquote, pre, ul, ol {
    page-break-inside: avoid;
  }
  
  /* Prevent page breaks after headings */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  body {
    background: white;
    color: black;
  }
  
  .gradient-text {
    -webkit-text-fill-color: #047857;
  }
  
  button,
  a {
    border: 2px solid currentColor;
  }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  #reading-progress {
    transition: none;
  }
}