/**
 * Portfolio Section - Visual Enhancements
 * Comparador Antes/Después + Grid Masonry + Efectos Avanzados
 * Versión: 2.0
 */

/* ========================================
   PORTFOLIO GRID MASONRY
   ======================================== */

.portfolio-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
  padding: 20px 0;
}

@media (max-width: 767.98px) {
  .portfolio-masonry {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* ========================================
   PORTFOLIO CARD BASE
   ======================================== */

.portfolio-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.5s var(--ease-in-out-smooth);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  background: white;
}

.portfolio-card:hover {
  transform: translateY(-15px) scale(1.02);
  box-shadow: var(--shadow-2xl), var(--shadow-gold-md);
  z-index: 10;
}

/* Borde dorado animado en hover */
.portfolio-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--radius-xl);
  padding: 3px;
  background: linear-gradient(135deg, #d4af37, #f4d03f, #d4af37);
  background-size: 200% 200%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.5s ease;
  animation: borderGlow 3s linear infinite;
  pointer-events: none;
}

.portfolio-card:hover::before {
  opacity: 1;
}

/* ========================================
   COMPARADOR ANTES/DESPUÉS
   ======================================== */

.before-after-slider {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: ew-resize;
  background: var(--piano-light);
}

@media (max-width: 767.98px) {
  .before-after-slider {
    height: 300px;
  }
}

.before-after-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.before-image,
.after-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: all 0.3s ease;
}

/* Filtro para la imagen "antes" */
.before-image {
  filter: brightness(0.95) saturate(0.9);
}

/* La imagen "después" se recorta con clip-path */
.after-image {
  clip-path: inset(0 50% 0 0);
  filter: brightness(1.05) saturate(1.1);
}

/* Labels flotantes para ANTES/DESPUÉS */
.before-label,
.after-label {
  position: absolute;
  top: 20px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: var(--radius-round);
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.before-label {
  left: 20px;
  background: rgba(220, 53, 69, 0.9);
}

.after-label {
  right: 20px;
  background: rgba(40, 167, 69, 0.9);
}

.before-label i,
.after-label i {
  font-size: 1rem;
}

/* Línea divisoria del slider */
.slider-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: var(--piano-gold);
  transform: translateX(-50%);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.8), 0 0 40px rgba(212, 175, 55, 0.4);
  z-index: 10;
  transition: box-shadow 0.3s ease;
  pointer-events: none;
}

.before-after-slider:active .slider-line {
  box-shadow: 0 0 30px rgba(212, 175, 55, 1), 0 0 60px rgba(212, 175, 55, 0.6);
}

/* Botón del slider */
.slider-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #d4af37, #f4d03f);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--piano-dark);
  font-size: 1.5rem;
  box-shadow: var(--shadow-gold-lg), var(--shadow-inset-md);
  cursor: ew-resize;
  transition: all 0.3s var(--ease-in-out-smooth);
  pointer-events: none;
}

.slider-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

.before-after-slider:hover .slider-button {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: var(--shadow-gold-xl), var(--shadow-inset-md);
}

.before-after-slider:active .slider-button {
  transform: translate(-50%, -50%) scale(1.1);
}

.slider-button i {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Input range invisible */
.slider-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 20;
  margin: 0;
}

/* Remover estilos por defecto del input range */
.slider-handle::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 100%;
  cursor: ew-resize;
}

.slider-handle::-moz-range-thumb {
  width: 60px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
  border: none;
}

/* ========================================
   PORTFOLIO CARD CONTENT
   ======================================== */

.portfolio-card-body {
  padding: 1.5rem;
  position: relative;
  background: white;
}

/* Categorías y badges */
.portfolio-badges {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.portfolio-category-badge {
  background: rgba(212, 175, 55, 0.1);
  color: var(--piano-dark);
  padding: 6px 14px;
  border-radius: var(--radius-round);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  transition: all 0.3s ease;
}

.portfolio-card:hover .portfolio-category-badge {
  background: rgba(212, 175, 55, 0.2);
  border-color: rgba(212, 175, 55, 0.5);
  transform: scale(1.05);
}

.portfolio-featured-badge {
  background: linear-gradient(135deg, #ff6b6b, #ffd93d);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-round);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
  animation: bounce 2s ease-in-out infinite;
}

.portfolio-featured-badge i {
  animation: rotate 3s linear infinite;
}

/* Título del portfolio */
.portfolio-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--piano-dark);
  margin-bottom: 0.75rem;
  line-height: var(--line-height-snug);
  transition: color 0.3s ease;
}

.portfolio-card:hover .portfolio-card-title {
  color: var(--piano-gold);
}

/* Descripción */
.portfolio-card-description {
  color: var(--piano-accent);
  font-size: 0.95rem;
  line-height: var(--line-height-relaxed);
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Metadata (duración, dificultad, etc.) */
.portfolio-metadata {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
}

.portfolio-metadata-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--piano-accent);
}

.portfolio-metadata-item i {
  color: var(--piano-gold);
}

.portfolio-difficulty-badge {
  padding: 4px 12px;
  border-radius: var(--radius-round);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.portfolio-difficulty-badge.easy {
  background: rgba(40, 167, 69, 0.1);
  color: #28a745;
  border: 1px solid rgba(40, 167, 69, 0.3);
}

.portfolio-difficulty-badge.intermediate {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.portfolio-difficulty-badge.advanced {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

/* ========================================
   PORTFOLIO OVERLAY (INFO EN HOVER)
   ======================================== */

.portfolio-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 0, 0, 0.3) 40%,
    rgba(0, 0, 0, 0.95) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 5;
}

.portfolio-card:hover .portfolio-overlay {
  opacity: 1;
}

.portfolio-overlay-content {
  transform: translateY(30px);
  transition: transform 0.4s var(--ease-in-out-smooth);
  color: white;
}

.portfolio-card:hover .portfolio-overlay-content {
  transform: translateY(0);
}

.portfolio-overlay-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: white;
}

.portfolio-overlay-description {
  font-size: 1rem;
  line-height: var(--line-height-relaxed);
  margin-bottom: 1rem;
  opacity: 0.9;
}

.portfolio-overlay-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--piano-gold-gradient);
  color: var(--piano-dark);
  padding: 10px 24px;
  border-radius: var(--radius-round);
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s var(--ease-in-out-smooth);
  box-shadow: var(--shadow-gold-md);
  pointer-events: auto;
}

.portfolio-overlay-button:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-gold-lg);
  color: var(--piano-dark);
}

/* ========================================
   PORTFOLIO CARD FOOTER
   ======================================== */

.portfolio-card-footer {
  background: rgba(248, 249, 250, 0.5);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1rem 1.5rem;
}

.portfolio-action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 20px;
  background: transparent;
  border: 2px solid var(--piano-gold);
  color: var(--piano-dark);
  font-weight: 700;
  border-radius: var(--radius-round);
  transition: all 0.3s var(--ease-in-out-smooth);
  cursor: pointer;
}

.portfolio-action-button:hover {
  background: var(--piano-gold-gradient);
  border-color: var(--piano-gold-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold-md);
}

/* ========================================
   PORTFOLIO SIN COMPARADOR (IMAGEN SIMPLE)
   ======================================== */

.portfolio-single-image {
  position: relative;
  height: 400px;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (max-width: 767.98px) {
  .portfolio-single-image {
    height: 300px;
  }
}

.portfolio-single-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-in-out-smooth), filter 0.3s ease;
  filter: brightness(0.95);
}

.portfolio-card:hover .portfolio-single-image img {
  transform: scale(1.1) rotate(2deg);
  filter: brightness(1) saturate(1.1);
}

/* Icono de overlay indicando que hay más información */
.portfolio-info-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: rgba(212, 175, 55, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--piano-dark);
  font-size: 2rem;
  opacity: 0;
  transition: all 0.4s var(--ease-in-out-smooth);
  pointer-events: none;
  box-shadow: 0 10px 40px rgba(212, 175, 55, 0.6);
}

.portfolio-card:hover .portfolio-info-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 991.98px) {
  .portfolio-masonry {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 767.98px) {
  .portfolio-card-body {
    padding: 1.25rem;
  }

  .portfolio-card-title {
    font-size: 1.1rem;
  }

  .portfolio-metadata {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .slider-button {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .before-label,
  .after-label {
    font-size: 0.75rem;
    padding: 6px 12px;
    top: 15px;
  }

  .before-label {
    left: 15px;
  }

  .after-label {
    right: 15px;
  }
}

/* ========================================
   LOADING STATE
   ======================================== */

.portfolio-card.loading {
  pointer-events: none;
}

.portfolio-card.loading .before-after-slider,
.portfolio-card.loading .portfolio-single-image {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ========================================
   HOVER EFFECTS ADICIONALES
   ======================================== */

/* Efecto de brillo en el card */
.portfolio-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.portfolio-card:hover::after {
  opacity: 1;
  animation: shine 3s ease-in-out infinite;
}
