/* Tags e categorie con effetto shimmer migliorato */

/* Tag base */
.tag, .category, .post-tags .tag, .post-categories .category {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  text-transform: capitalize;
}

/* Pagine taxonomy (tags e categories) */
.terms-tags li a, .terms-categories li a {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--entry);
  color: var(--content);
  margin: 0.25rem;
  text-transform: capitalize;
}

/* Effetto shimmer per tutti i tag e categorie */
.tag::before, 
.category::before,
.post-tags .tag::before,
.post-categories .category::before,
.term-card::before,
.category-tag::before,
.terms-tags li a::before,
.terms-categories li a::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.6s ease;
  z-index: 1;
}

/* Attivazione effetto shimmer al hover */
.tag:hover::before,
.category:hover::before,
.post-tags .tag:hover::before,
.post-categories .category:hover::before,
.term-card:hover::before,
.category-tag:hover::before,
.terms-tags li a:hover::before,
.terms-categories li a:hover::before {
  left: 100%;
}

/* Assicura che il testo rimanga sopra l'effetto shimmer */
.tag > *,
.category > *,
.post-tags .tag > *,
.post-categories .category > *,
.term-card > *,
.category-tag > * {
  position: relative;
  z-index: 2;
}

/* Stili specifici per tag */
.tag, .post-tags .tag {
  background: var(--code-bg);
  color: var(--secondary);
  border-color: var(--border);
}

.tag:hover, .post-tags .tag:hover {
  background: var(--primary);
  color: var(--theme);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Stili specifici per categorie */
.category, .post-categories .category, .category-tag {
  background: var(--primary);
  color: var(--theme);
  border-color: var(--primary);
}

.category:hover, 
.post-categories .category:hover,
.category-tag:hover {
  background: var(--primary-dark, var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Term cards (pagine categorie/tag) con effetto migliorato */
.term-card {
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--content);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: block;
}

.term-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* Tag nei post con dimensioni diverse */
.post-meta .tag,
.post-meta .category {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  margin-right: 0.5rem;
}

/* Tag nella sidebar o widget */
.widget-tags .tag,
.sidebar-tags .tag {
  margin: 0.25rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

/* Archive tags */
.archive-post .tag,
.archive-post .category-tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  margin: 0 0.25rem 0.25rem 0;
}

/* Lista tag/categorie nelle pagine taxonomy */
.taxonomy-list .tag,
.taxonomy-list .category {
  display: inline-block;
  margin: 0.5rem 0.5rem 0.5rem 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* Contatore post per tag/categorie */
.tag .count,
.category .count {
  margin-left: 0.5rem;
  opacity: 0.8;
  font-size: 0.85em;
  background: rgba(255,255,255,0.2);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 500;
}

/* Effetti speciali per tema scuro */
[data-theme="dark"] .tag::before,
[data-theme="dark"] .category::before,
[data-theme="dark"] .term-card::before {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

[data-theme="dark"] .tag:hover,
[data-theme="dark"] .category:hover,
[data-theme="dark"] .term-card:hover {
  box-shadow: 0 8px 25px rgba(255,255,255,0.1);
}

/* Tag cloud effect (se hai una tag cloud) */
.tag-cloud .tag {
  animation: tagFloat 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.tag-cloud .tag:nth-child(odd) {
  --delay: 1s;
}

.tag-cloud .tag:nth-child(3n) {
  --delay: 2s;
}

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

/* Hover effect più pronunciato per tag importanti */
.tag.featured,
.category.featured {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light, var(--primary)) 100%);
  color: var(--theme);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tag.featured:hover,
.category.featured:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* Effetto pulsante per tag interattivi */
.tag.interactive,
.category.interactive {
  cursor: pointer;
  user-select: none;
}

.tag.interactive:active,
.category.interactive:active {
  transform: translateY(-1px) scale(0.98);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tag, .category {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
  }
  
  .term-card {
    padding: 1rem;
  }
  
  .tag:hover, .category:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 480px) {
  .tag, .category {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    margin: 0.2rem 0.2rem 0.2rem 0;
  }
}

/* Animazione di entrata per tag caricati dinamicamente */
@keyframes tagSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.tag.animate-in,
.category.animate-in {
  animation: tagSlideIn 0.4s ease-out;
}

/* Stagger animation per liste di tag */
.post-tags .tag:nth-child(1) { animation-delay: 0s; }
.post-tags .tag:nth-child(2) { animation-delay: 0.1s; }
.post-tags .tag:nth-child(3) { animation-delay: 0.2s; }
.post-tags .tag:nth-child(4) { animation-delay: 0.3s; }
.post-tags .tag:nth-child(5) { animation-delay: 0.4s; }

.post-categories .category:nth-child(1) { animation-delay: 0s; }
.post-categories .category:nth-child(2) { animation-delay: 0.1s; }
.post-categories .category:nth-child(3) { animation-delay: 0.2s; }

/* Accessibilità */
.tag:focus,
.category:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Stati speciali */
.tag.active,
.category.active {
  background: var(--primary);
  color: var(--theme);
  border-color: var(--primary);
}

.tag.disabled,
.category.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Micro-interazioni */
.tag:hover {
  animation: tagPulse 0.6s ease-in-out;
}

.category:hover {
  animation: categoryGlow 0.6s ease-in-out;
}

@keyframes tagPulse {
  0% { transform: translateY(-2px) scale(1); }
  50% { transform: translateY(-2px) scale(1.05); }
  100% { transform: translateY(-2px) scale(1); }
}

@keyframes categoryGlow {
  0% { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
  50% { box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
  100% { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
}

.dark .callout {
  --primary: rgb(143, 161, 240); /* blu-grigio pastello solo nei callout */
  --link-color: #82aaff;
  --link-hover-color: #b4ccff;
  --highlight-bg: rgba(255, 215, 0, 0.18);
}
