
/* ===============================
   VARIABILI CSS PERSONALIZZATE
   =============================== */
:root {
  /* Colors */
  --primary-blue: #3b5998;
  --tech-blue: #3b82f6;
  --ethics-red: #ef4444;
  --culture-teal: #14b8a6;
  --environment-green: #10b981;
  --events-purple: #8b5cf6;
  
  /* Animations */
  --animation-duration: 300ms;
  --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --float-duration: 6s;
  --pulse-duration: 2s;
}

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

/* Float Animation for Background Elements */
@keyframes float {
  0%, 100% {
    transform: translateY(0px) scale(1);
    opacity: 0.1;
  }
  50% {
    transform: translateY(-20px) scale(1.05);
    opacity: 0.2;
  }
}

/* Slide In Animation */
@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fade In Up */
@keyframes fadeInUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Pulse Glow */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px currentColor;
  }
  50% {
    box-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
  }
}

/* Scale Bounce */
@keyframes scaleBounce {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Breaking News Scroll */
@keyframes breakingScroll {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Progress Fill */
@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: var(--progress-width, 100%);
  }
}

/* ===============================
   UTILITY ANIMATION CLASSES
   =============================== */

.animate-float {
  animation: float var(--float-duration) ease-in-out infinite;
}

.animate-float-delayed {
  animation: float var(--float-duration) ease-in-out infinite;
  animation-delay: 2s;
}

.animate-slide-in {
  animation: slideIn 0.6s var(--animation-easing);
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s var(--animation-easing);
}

.animate-pulse-glow {
  animation: pulseGlow var(--pulse-duration) ease-in-out infinite;
}

.animate-scale-bounce {
  animation: scaleBounce 0.3s var(--animation-easing);
}

/* ===============================
   HOVER EFFECTS AVANZATI
   =============================== */

/* Article Card Hover Effects */
.article-card {
  transition: all var(--animation-duration) var(--animation-easing);
  transform: translateY(0);
}

.article-card:hover {
  transform: translateY(-8px);
  box-shadow: 
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.article-card:hover .article-image {
  transform: scale(1.05);
}

.article-card .article-image {
  transition: transform 0.5s var(--animation-easing);
}

/* Category Badge Hover */
.category-badge {
  transition: all var(--animation-duration) var(--animation-easing);
  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.2), transparent);
  transition: left 0.5s;
}

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

.category-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

/* Button Hover Effects */
.btn-primary {
  transition: all var(--animation-duration) var(--animation-easing);
  position: relative;
  overflow: hidden;
}

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

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

/* ===============================
   BREAKING NEWS BAR - IDENTICO al React
   =============================== */

/* Animation for breaking news scroll - IDENTICO React */
@keyframes scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

.animate-scroll {
  animation: scroll 30s linear infinite;
}

.breaking-news-bar {
  position: relative;
  overflow: hidden;
}

.breaking-news-content {
  transition: all var(--animation-duration) var(--animation-easing);
}

.breaking-news-content:hover {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
}

.breaking-news-arrow {
  transition: all var(--animation-duration) var(--animation-easing);
}

.breaking-news-content:hover .breaking-news-arrow {
  transform: translateX(4px);
}

/* Progress Bar */
.breaking-progress {
  height: 2px;
  background: rgba(255,255,255,0.3);
  overflow: hidden;
  position: relative;
}

.breaking-progress::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: white;
  animation: progressFill 10s linear infinite;
  --progress-width: 100%;
}

/* Mobile responsive classes - IDENTICO al React */
@media (max-width: 768px) {
  .category-grid-mobile {
    grid-template-columns: 1fr;
  }
  
  .pagination-text-mobile {
    display: none;
  }
  
  .hero-image {
    aspect-ratio: 16/10;
    object-fit: cover;
  }
  
  .breaking-news-bar .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .animate-scroll {
    animation-duration: 20s; /* Più veloce su mobile */
  }
}

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

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  z-index: 40;
  background: linear-gradient(90deg, var(--tech-blue), var(--primary-blue));
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* ===============================
   MASONRY FEED EFFECTS
   =============================== */

.masonry-item {
  transition: all var(--animation-duration) var(--animation-easing);
  opacity: 0;
  transform: translateY(30px);
}

.masonry-item.loaded {
  opacity: 1;
  transform: translateY(0);
}

.masonry-item:nth-child(odd) {
  animation-delay: 0.1s;
}

.masonry-item:nth-child(even) {
  animation-delay: 0.2s;
}

/* ===============================
   ASYMMETRIC HERO EFFECTS
   =============================== */

.hero-main-article {
  transition: all var(--animation-duration) var(--animation-easing);
}

.hero-main-article:hover {
  transform: scale(1.02);
}

.hero-side-article {
  transition: all var(--animation-duration) var(--animation-easing);
  border-left: 3px solid transparent;
}

.hero-side-article:hover {
  border-left-color: var(--primary-blue);
  background: rgba(59, 89, 152, 0.05);
  transform: translateX(5px);
}

/* ===============================
   CATEGORY SECTIONS BACKGROUNDS
   =============================== */

/* Tech Section Background */
.tech-bg-effect {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  pointer-events: none;
}

.tech-bg-effect::before,
.tech-bg-effect::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  animation: float var(--float-duration) ease-in-out infinite;
}

.tech-bg-effect::before {
  top: 0;
  left: 25%;
  width: 256px;
  height: 256px;
  background: var(--tech-blue);
}

.tech-bg-effect::after {
  bottom: 0;
  right: 25%;
  width: 320px;
  height: 320px;
  background: #06b6d4;
  animation-delay: 2s;
}

/* Environment Section Background */
.environment-bg-effect {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  pointer-events: none;
}

.environment-bg-effect::before,
.environment-bg-effect::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  animation: float var(--float-duration) ease-in-out infinite;
}

.environment-bg-effect::before {
  top: 40px;
  left: 40px;
  width: 192px;
  height: 192px;
  background: var(--environment-green);
}

.environment-bg-effect::after {
  bottom: 40px;
  right: 40px;
  width: 256px;
  height: 256px;
  background: #10b981;
  animation-delay: 2s;
}

/* ===============================
   FORM ENHANCEMENTS
   =============================== */

.form-input {
  transition: all var(--animation-duration) var(--animation-easing);
  border: 2px solid #e5e7eb;
  position: relative;
}

.form-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 89, 152, 0.1);
  transform: translateY(-2px);
}

.form-label {
  transition: all var(--animation-duration) var(--animation-easing);
}

.form-input:focus + .form-label {
  color: var(--primary-blue);
  transform: scale(0.95);
}

/* ===============================
   NEWSLETTER SIGNUP
   =============================== */

.newsletter-container {
  position: relative;
  overflow: hidden;
}

.newsletter-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ===============================
   RESPONSIVE ANIMATIONS
   =============================== */

/* Riduce animazioni su dispositivi con motion ridotta */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ottimizzazioni mobile */
@media (max-width: 768px) {
  .article-card:hover {
    transform: translateY(-4px);
  }
  
  .hero-side-article:hover {
    transform: translateX(2px);
  }
  
  .tech-bg-effect::before,
  .tech-bg-effect::after,
  .environment-bg-effect::before,
  .environment-bg-effect::after {
    filter: blur(40px);
  }
  
  /* MOBILE RESPONSIVE FIXES */
  
  /* Pagination mobile fixes */
  nav[aria-label="Paginazione"] {
    padding: 0 1rem;
  }
  
  nav[aria-label="Paginazione"] ul {
    gap: 0.25rem !important;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.5rem 0;
  }
  
  /* Hide pagination text on mobile, keep only icons */
  .pagination-text-mobile {
    display: none !important;
  }
  
  /* Smaller pagination buttons */
  nav[aria-label="Paginazione"] a,
  nav[aria-label="Paginazione"] span {
    min-width: 44px !important;
    height: 44px !important;
    padding: 0.75rem 0.5rem !important;
    font-size: 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Article page mobile layout */
  .article-page-mobile {
    padding: 1rem !important;
  }
  
  .article-grid-mobile {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
  
  .article-sidebar-mobile {
    order: 2 !important;
    margin-top: 2rem !important;
  }
  
  .article-content-mobile {
    font-size: 1rem !important;
    line-height: 1.75 !important;
  }
  
  /* Category page mobile */
  .category-grid-mobile {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  
  /* Search page mobile */
  .search-results-mobile {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  
  /* Mobile text adjustments */
  .mobile-text-base {
    font-size: 1rem !important;
    line-height: 1.5 !important;
  }
  
  .mobile-text-sm {
    font-size: 0.875rem !important;
    line-height: 1.25 !important;
  }
  
  .mobile-text-xs {
    font-size: 0.75rem !important;
    line-height: 1 !important;
  }
  
  /* Mobile spacing fixes */
  .mobile-p-4 {
    padding: 1rem !important;
  }
  
  .mobile-mt-8 {
    margin-top: 2rem !important;
  }
  
  .mobile-mb-8 {
    margin-bottom: 2rem !important;
  }
  
  /* Mobile button improvements */
  .mobile-btn-compact {
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Related articles mobile */
  .related-articles-mobile {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Comment section mobile */
  .comments-mobile {
    padding: 1rem !important;
    margin-top: 2rem !important;
  }
  
  /* Social sharing mobile */
  .social-share-mobile {
    flex-direction: column !important;
    gap: 0.75rem !important;
    align-items: stretch !important;
  }
  
  /* TTS controls mobile */
  .tts-controls-mobile {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    justify-content: center !important;
  }
  
  /* Image responsive */
  .article-image-mobile {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/9 !important;
    object-fit: cover !important;
  }
  
  /* Navigation mobile */
  .breadcrumb-mobile {
    font-size: 0.75rem !important;
    flex-wrap: wrap !important;
  }
  
  .breadcrumb-mobile li {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 120px !important;
  }
}

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

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

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

/* ===============================
   SCROLL TRIGGERED ANIMATIONS
   =============================== */

.scroll-reveal {
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.8s var(--animation-easing);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ===============================
   DARK MODE SPECIFIC EFFECTS
   =============================== */

@media (prefers-color-scheme: dark) {
  .article-card:hover {
    box-shadow: 
      0 20px 25px -5px rgba(0, 0, 0, 0.3),
      0 10px 10px -5px rgba(0, 0, 0, 0.15);
  }
  
  .reading-progress {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
  }
}

/* ===============================
   HIGH PERFORMANCE OPTIMIZATIONS
   =============================== */

/* Force GPU acceleration for smooth animations */
.article-card,
.hero-main-article,
.hero-side-article,
.category-badge,
.btn-primary {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Contain layout shifts */
.masonry-item,
.article-card {
  contain: layout style paint;
}

/* === Keep header sticky on mobile with iOS fallback === */
header.sticky {
  position: sticky;
  top: 0;
  z-index: 100; /* above progress bar */
  /* Improve paint stability on mobile */
  contain: layout paint style;
}

@supports (position: -webkit-sticky) {
  header.sticky { position: -webkit-sticky; top: 0; }
}

/* Neutralize transforms on header contents that could break sticky */
header.sticky, header.sticky * {
  transform: none !important;
}

/* Prefer small viewport units to avoid 100vh jumps */
@supports (height: 100svh) {
  body.min-h-screen { min-height: 100svh; }
}

/* Riserva sempre lo spazio della scrollbar verticale */
html { scrollbar-gutter: stable; }
