/* ========================================
   PORTFOLIO PAGE - CSS OPTIMIZADO
   Diseño profesional con mejoras visuales y responsive
======================================== */

/* ========================================
   VARIABLES ESPECÍFICAS PORTFOLIO
======================================== */
:root {
  /* Colores específicos para portfolio */
  --portfolio-primary: #3b82f6;
  --portfolio-secondary: #06b6d4;
  --portfolio-accent: #10b981;
  --portfolio-featured: #8b5cf6;
  --portfolio-warning: #386e9d;
  
  /* Gradientes para portfolio */
  --gradient-portfolio-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  --gradient-overlay: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(139, 92, 246, 0.9) 100%);
  --gradient-card: linear-gradient(145deg, #ffffff 0%, rgba(248, 250, 252, 0.8) 100%);
  --gradient-filter-active: linear-gradient(45deg, var(--portfolio-primary) 0%, var(--portfolio-secondary) 100%);
  
  /* Efectos específicos */
  --filter-border-radius: 50px;
  --card-border-radius: 20px;
  --overlay-transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   SECCIÓN PORTFOLIO PRINCIPAL
======================================== */
.portfolio.section {
  padding: var(--space-20) 0;
  background: var(--gradient-portfolio-bg);
  position: relative;
  overflow: hidden;
}

.portfolio-actions {
  display: flex;
  align-items: center;   /* centra verticalmente botón y badge */
  gap: var(--space-2);   /* separación entre el ojo y el texto */
}

.portfolio.section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

/* ========================================
   HEADER DE PORTFOLIO
======================================== */
.portfolio-header {
  text-align: center;
  margin-bottom: var(--space-16);
  position: relative;
  z-index: 1;
}

.section-title {
  font-size: var(--text-4xl);
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: var(--space-4);
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: var(--gradient-filter-active);
  border-radius: 2px;
}

.section-subtitle {
  font-size: var(--text-xl);
  color: var(--medium-gray);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 300;
}

/* ========================================
   FILTROS DE PORTFOLIO
======================================== */
.portfolio-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-16);
  position: relative;
  z-index: 1;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(59, 130, 246, 0.1);
  color: var(--dark-gray);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--filter-border-radius);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--overlay-transition);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.filter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--gradient-filter-active);
  transition: left 0.3s ease;
  z-index: -1;
}

.filter-btn:hover::before,
.filter-btn.active::before {
  left: 0;
}

.filter-btn:hover,
.filter-btn.active {
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ========================================
   GRID DE PORTFOLIO
======================================== */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: var(--space-8);
  margin-bottom: var(--space-20);
  position: relative;
  z-index: 1;
}

/* ========================================
   ITEMS DE PORTFOLIO
======================================== */
.portfolio-item {
  background: var(--gradient-card);
  border-radius: var(--card-border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  transition: var(--overlay-transition);
  position: relative;
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.6s ease-out forwards;
}

.portfolio-item:nth-child(1) { animation-delay: 0.1s; }
.portfolio-item:nth-child(2) { animation-delay: 0.2s; }
.portfolio-item:nth-child(3) { animation-delay: 0.3s; }
.portfolio-item:nth-child(4) { animation-delay: 0.4s; }

.portfolio-item:hover {
  transform: translateY(-12px);
  box-shadow: var(--shadow-2xl);
}

/* ========================================
   IMÁGENES DE PORTFOLIO
======================================== */
.portfolio-image {
  position: relative;
  overflow: hidden;
  height: 250px;
  background: var(--light-gray);
}

.portfolio-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.portfolio-item:hover .portfolio-image img {
  transform: scale(1.1);
}

/* ========================================
   OVERLAY DE PORTFOLIO
======================================== */
.portfolio-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-overlay);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: var(--overlay-transition);
}

.portfolio-item:hover .portfolio-overlay {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   ACCIONES DE PORTFOLIO
======================================== */
.portfolio-actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.portfolio-btn {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--portfolio-primary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--overlay-transition);
  backdrop-filter: blur(10px);
  text-decoration: none;
}

.portfolio-btn:hover {
  background: white;
  transform: translateY(-3px) scale(1.1);
  box-shadow: var(--shadow-xl);
  color: var(--portfolio-primary);
}

.portfolio-status {
  display: inline-block;      /* que se ajuste al contenido */
  width: auto;                /* evita que herede anchos de padres */
  background: rgba(23, 112, 208, 0.95);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: 9999px;      /* redondeo total tipo píldora */
  font-size: var(--text-xs);
  font-weight: 600;
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;        /* evita que se parta en varias líneas */
}
/* ========================================
   TECNOLOGÍAS
======================================== */
.portfolio-tech {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-4);
}

.tech-tag {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ========================================
   CONTENIDO DE PORTFOLIO
======================================== */
.portfolio-content {
  padding: var(--space-6);
}

.portfolio-category {
  color: var(--portfolio-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.portfolio-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: var(--space-3);
  line-height: 1.3;
}

.portfolio-description {
  color: var(--medium-gray);
  line-height: 1.6;
  margin-bottom: var(--space-4);
  font-size: var(--text-base);
}

.portfolio-meta {
  display: flex;
  gap: var(--space-6);
  font-size: var(--text-sm);
  color: var(--dark-gray);
}

.portfolio-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.portfolio-meta i {
  color: var(--portfolio-secondary);
  font-size: 0.875rem;
}

/* ========================================
   CTA DE PORTFOLIO
======================================== */
.portfolio-cta {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  background: var(--gradient-overlay);
  color: white;
  border-radius: var(--card-border-radius);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.portfolio-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23dots)"/></svg>');
  opacity: 0.3;
}

.portfolio-cta-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}

.portfolio-cta-content h3 {
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
  font-family: 'Playfair Display', serif;
}

.portfolio-cta-content p {
  font-size: var(--text-lg);
  line-height: 1.6;
  margin-bottom: var(--space-8);
  opacity: 0.9;
}

.portfolio-cta-buttons {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

.portfolio-cta-buttons .btn {
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-lg);
  font-weight: 700;
  border-radius: var(--radius-xl);
  gap: var(--space-3);
  min-height: 56px;
  transition: var(--overlay-transition);
}

.portfolio-cta-buttons .btn-primary {
  background: white;
  color: var(--portfolio-primary);
  box-shadow: var(--shadow-xl);
}

.portfolio-cta-buttons .btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2xl);
  background: rgba(255, 255, 255, 0.95);
}

.portfolio-cta-buttons .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
}

.portfolio-cta-buttons .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ========================================
   MODAL DE PROYECTO
======================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--overlay-transition);
}

.modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: white;
  border-radius: var(--card-border-radius);
  max-width: 900px;
  max-height: 90vh;
  margin: var(--space-4);
  overflow: hidden;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-2xl);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal[aria-hidden="false"] .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--light-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gradient-card);
}

.modal-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(59, 130, 246, 0.1);
  color: var(--portfolio-primary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--overlay-transition);
}

.modal-close:hover {
  background: var(--portfolio-primary);
  color: white;
  transform: scale(1.1);
}

.modal-body {
  padding: var(--space-8);
  overflow-y: auto;
  max-height: calc(90vh - 100px);
}

/* ========================================
   RESPONSIVE DESIGN - PORTFOLIO
======================================== */

/* Tablets */
@media (max-width: 991.98px) {
  .portfolio-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-6);
  }
  
  .portfolio-filters {
    gap: var(--space-2);
  }
  
  .filter-btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
  }
}

/* Móviles */
@media (max-width: 575.98px) {
  .portfolio.section {
    padding: var(--space-16) 0;
  }
  
  .portfolio-header {
    margin-bottom: var(--space-12);
    padding: 0 var(--space-4);
  }
  
  .section-title {
    font-size: var(--text-3xl);
  }
  
  .section-subtitle {
    font-size: var(--text-lg);
    padding: 0 var(--space-2);
  }
  
  .portfolio-filters {
    margin-bottom: var(--space-12);
    padding: 0 var(--space-4);
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .portfolio-filters::-webkit-scrollbar {
    display: none;
  }
  
  .filter-btn {
    flex-shrink: 0;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    min-width: auto;
  }
  
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-16);
  }
  
  .portfolio-image {
    height: 200px;
  }
  
  .portfolio-content {
    padding: var(--space-5);
  }
  
  .portfolio-title {
    font-size: var(--text-xl);
  }
  
  .portfolio-description {
    font-size: var(--text-sm);
  }
  
  .portfolio-meta {
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .portfolio-cta {
    margin-bottom: var(--space-12);
    padding: var(--space-12) var(--space-4);
    border-radius: var(--radius-xl);
  }
  
  .portfolio-cta-content h3 {
    font-size: var(--text-2xl);
  }
  
  .portfolio-cta-content p {
    font-size: var(--text-base);
  }
  
  .portfolio-cta-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .portfolio-cta-buttons .btn {
    width: 100%;
    max-width: 280px;
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
  }
  
  /* Modal móvil */
  .modal-content {
    margin: var(--space-2);
    max-height: 95vh;
    border-radius: var(--radius-xl);
  }
  
  .modal-header {
    padding: var(--space-4) var(--space-5);
  }
  
  .modal-title {
    font-size: var(--text-xl);
  }
  
  .modal-body {
    padding: var(--space-5);
    max-height: calc(95vh - 80px);
  }
  
  /* Overlay móvil - siempre visible */
  .portfolio-overlay {
    opacity: 1;
    visibility: visible;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    justify-content: flex-end;
    align-items: stretch;
  }
  
  .portfolio-actions {
    justify-content: center;
    margin-top: 0;
  }
  
  .portfolio-tech {
    display: none; /* Ocultar en móvil para simplificar */
  }
  
  .portfolio-btn {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
}

/* Landscape móvil */
@media (max-width: 991.98px) and (orientation: landscape) {
  .portfolio.section {
    padding: var(--space-12) 0;
  }
  
  .portfolio-header {
    margin-bottom: var(--space-10);
  }
  
  .portfolio-cta {
    padding: var(--space-10) var(--space-4);
  }
  
  .portfolio-image {
    height: 180px;
  }
}

/* ========================================
   ANIMACIONES
======================================== */
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animación de filtro */
@keyframes filterPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.filter-btn.active {
  animation: filterPulse 0.3s ease;
}

/* Animaciones suaves en móvil */
@media (max-width: 575.98px) {
  @keyframes fadeInUp {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .portfolio-item:hover {
    transform: translateY(-4px);
  }
}

/* ========================================
   MEJORAS DE ACCESIBILIDAD
======================================== */
.portfolio-item:focus-within {
  outline: 3px solid var(--portfolio-primary);
  outline-offset: 2px;
}

.filter-btn:focus,
.portfolio-btn:focus,
.modal-close:focus {
  outline: 3px solid var(--portfolio-primary);
  outline-offset: 2px;
}

/* Estados de loading */
.portfolio-item.loading {
  opacity: 0.7;
  pointer-events: none;
}

.portfolio-item.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid var(--portfolio-primary);
  border-top: 3px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

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

/* Reducir animaciones para usuarios con preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .portfolio-item,
  .filter-btn,
  .portfolio-btn,
  .modal-content {
    transition: none;
    animation: none;
  }
  
  .portfolio-item:hover,
  .filter-btn:hover,
  .portfolio-btn:hover {
    transform: none;
  }
  
  .portfolio-image img {
    transition: none;
  }
  
  .portfolio-item:hover .portfolio-image img {
    transform: none;
  }
}

/* ========================================
   ESTADOS HOVER MEJORADOS DESKTOP
======================================== */
@media (min-width: 992px) {
  .portfolio-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
    z-index: 1;
    pointer-events: none;
  }
  
  .portfolio-item:hover::after {
    left: 100%;
  }
  
  .portfolio-content {
    position: relative;
    z-index: 2;
  }
}

/* ========================================
   DARK MODE SUPPORT
======================================== */
@media (prefers-color-scheme: dark) {
  .portfolio.section {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1a202c 100%);
  }
  
  .portfolio-item {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
  }
  
  .portfolio-title {
    color: #f8fafc;
  }
  
  .portfolio-description {
    color: #cbd5e1;
  }
  
  .filter-btn {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
  }
  
  .modal-content {
    background: #1e293b;
    color: #f1f5f9;
  }
  
  .modal-header {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.5);
  }
}