/* Portfolio Section */
#portfolio {
  padding: 8rem 0;
  background-color: var(--bg-2);
  position: relative;
}

.portfolio-header {
  text-align: center;
  max-width: 42rem;
  margin: 0 auto 4rem;
}

/* Carousel Styles - Redesigned */
.portfolio-carousel {
  position: relative;
  overflow: hidden;
  margin-top: 3rem;
  padding: 2rem 0 4rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.portfolio-carousel::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 120%;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(132, 75, 222, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(34, 204, 183, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.portfolio-carousel-wrapper {
  position: relative;
  z-index: 1;
  padding: 0 4rem;
}

.portfolio-carousel-track {
  display: flex;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  gap: 0;
}

.portfolio-carousel-item {
  min-width: 100%;
  flex-shrink: 0;
  padding: 0 2rem;
  animation: fadeInScale 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

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

/* Show partial preview of adjacent items */
.portfolio-carousel-item.prev,
.portfolio-carousel-item.next {
  opacity: 0.3;
  transform: scale(0.85);
  pointer-events: none;
  filter: blur(2px);
}

.portfolio-carousel-item.active {
  opacity: 1;
  transform: scale(1);
  z-index: 2;
}

.portfolio-carousel-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding: 0 1rem;
  position: relative;
  z-index: 10;
}

.portfolio-carousel-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.portfolio-carousel-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(132, 75, 222, 0.2);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-heading);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.portfolio-carousel-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: 50%;
}

.portfolio-carousel-btn svg {
  position: relative;
  z-index: 1;
  transition: transform 0.4s ease;
}

.portfolio-carousel-btn:hover:not(:disabled) {
  border-color: transparent;
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(132, 75, 222, 0.25);
}

.portfolio-carousel-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.portfolio-carousel-btn:hover:not(:disabled) svg {
  transform: translateX(var(--arrow-offset, 0));
  color: white;
}

.portfolio-carousel-btn-prev:hover:not(:disabled) svg {
  --arrow-offset: -3px;
}

.portfolio-carousel-btn-next:hover:not(:disabled) svg {
  --arrow-offset: 3px;
}

.portfolio-carousel-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: scale(0.9);
}

.portfolio-carousel-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  padding: 0.75rem 1.25rem;
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.portfolio-carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(132, 75, 222, 0.2);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  padding: 0;
  position: relative;
}

.portfolio-carousel-dot::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(132, 75, 222, 0.1);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.portfolio-carousel-dot:hover::before {
  opacity: 1;
}

.portfolio-carousel-dot.active {
  width: 32px;
  height: 10px;
  border-radius: 5px;
  background: var(--brand-gradient);
  box-shadow: 0 2px 8px rgba(132, 75, 222, 0.3);
}

.portfolio-carousel-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  padding: 0.75rem 1.25rem;
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.portfolio-carousel-counter .current {
  color: var(--color-purple);
  font-size: 1.125rem;
}

.portfolio-carousel-counter .separator {
  color: var(--border);
}

.portfolio-carousel-view-all {
  text-align: center;
  margin-top: 3rem;
  position: relative;
  z-index: 10;
}

.portfolio-carousel-view-all .btn {
  position: relative;
  overflow: hidden;
}

.portfolio-carousel-view-all .btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.portfolio-carousel-view-all .btn:hover::before {
  opacity: 1;
}

.portfolio-carousel-view-all .btn span {
  position: relative;
  z-index: 1;
}

/* Grid Styles (for portfolio page) */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 3rem;
  margin-top: 2rem;
  position: relative;
}

@media (min-width: 1200px) {
  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.portfolio-grid::before {
  content: '';
  position: absolute;
  inset: -2rem;
  background: 
    linear-gradient(135deg, transparent 0%, rgba(132, 75, 222, 0.02) 50%, transparent 100%),
    linear-gradient(45deg, transparent 0%, rgba(34, 204, 183, 0.02) 50%, transparent 100%);
  pointer-events: none;
  z-index: -1;
  border-radius: var(--radius-2xl);
}

.portfolio-grid .portfolio-card {
  animation: cardFloatIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.portfolio-grid .portfolio-card:nth-child(1) {
  animation-delay: 0.1s;
}

.portfolio-grid .portfolio-card:nth-child(2) {
  animation-delay: 0.2s;
}

@keyframes cardFloatIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.portfolio-card {
  background: #FFFFFF;
  border-radius: var(--radius-xl);
  overflow: visible;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  text-decoration: none;
  /* Innovative Frame Design */
  padding: 8px;
  background: linear-gradient(135deg, rgba(132, 75, 222, 0.1) 0%, rgba(34, 204, 183, 0.1) 100%);
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.03),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.portfolio-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-xl);
  padding: 2px;
  background: linear-gradient(135deg, #844BDE 0%, #22CCB7 50%, #844BDE 100%);
  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.6s ease, background-position 3s ease;
  z-index: -1;
  animation: gradient-shift 4s ease infinite;
}

.portfolio-card::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(132, 75, 222, 0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
  z-index: 1;
  filter: blur(8px);
}

.portfolio-card .glow-effect {
  position: absolute;
  inset: -20px;
  border-radius: var(--radius-xl);
  background: radial-gradient(ellipse at center, rgba(132, 75, 222, 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: -2;
  filter: blur(20px);
}

.portfolio-card:hover .glow-effect {
  opacity: 1;
}

.portfolio-card:hover {
  transform: translateY(-12px) rotateX(2deg) rotateY(-1deg);
  box-shadow: 
    0 30px 60px -12px rgba(132, 75, 222, 0.25),
    0 0 0 1px rgba(132, 75, 222, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.portfolio-card:hover::before {
  opacity: 1;
  background-position: 100% 0;
}

.portfolio-card:hover::after {
  opacity: 1;
  transform: scale(1.5);
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.portfolio-card-inner {
  background: #FFFFFF;
  border-radius: calc(var(--radius-xl) - 4px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 0;
}

.portfolio-image {
  width: 100%;
  height: 300px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile Phone Frame */
.portfolio-image.mobile-frame {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  padding: 1.5rem;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-mockup {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 9 / 19.5;
  margin: 0 auto;
  position: relative;
  background: #000;
  border-radius: 2.5rem;
  padding: 0.5rem;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 0 2px rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.phone-mockup::before {
  content: '';
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 24px;
  background: #000;
  border-radius: 0 0 1rem 1rem;
  z-index: 10;
}

.phone-mockup::after {
  content: '';
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  z-index: 10;
}

.phone-screen {
  width: 100%;
  height: 100%;
  border-radius: 2rem;
  overflow: hidden;
  background: #fff;
  position: relative;
  flex: 1;
  min-height: 0;
}

.phone-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

@media (max-width: 768px) {
  .portfolio-image.mobile-frame {
    height: 450px;
    padding: 1rem;
  }
  
  .phone-mockup {
    max-width: 240px;
    aspect-ratio: 9 / 19.5;
  }
}

.portfolio-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(132, 75, 222, 0.05) 0%, rgba(34, 204, 183, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 1;
  pointer-events: none;
}

.portfolio-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 2;
  pointer-events: none;
}

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

.portfolio-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), filter 0.6s ease;
  filter: brightness(1) contrast(1);
  will-change: transform;
}

.portfolio-card:hover .portfolio-image img {
  transform: scale(1.08) translateY(-2px);
  filter: brightness(1.05) contrast(1.1);
}

.portfolio-card:hover .phone-mockup {
  transform: scale(1.05) translateY(-4px);
  box-shadow: 
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(132, 75, 222, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.phone-mockup {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.6s ease;
}

.portfolio-content {
  padding: 2.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(to bottom, #FFFFFF 0%, #FAFBFC 100%);
}

.portfolio-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--color-purple) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.6s ease;
}

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

.portfolio-tags {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.portfolio-tag {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  background: rgba(132, 75, 222, 0.1);
  color: var(--color-purple);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.portfolio-tag::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(132, 75, 222, 0.2) 0%, rgba(34, 204, 183, 0.2) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.portfolio-card:hover .portfolio-tag {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(132, 75, 222, 0.15);
}

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

.portfolio-card h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.portfolio-card p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 1.5rem;
  flex-grow: 1;
}

.portfolio-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--color-purple);
  margin-top: auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 0.5rem 0;
}

.portfolio-link svg {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-card:hover .portfolio-link {
  gap: 0.75rem;
  color: var(--color-purple);
  transform: translateX(4px);
}

.portfolio-card:hover .portfolio-link svg {
  transform: translateX(4px) rotate(-5deg);
}

.portfolio-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-purple) 0%, var(--color-teal) 100%);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-card:hover .portfolio-link::after {
  width: 100%;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .portfolio-grid {
    gap: 1.5rem;
  }
  
  .portfolio-carousel-item {
    min-width: 100%;
  }
}

@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .portfolio-image.mobile-frame {
    height: 450px;
    padding: 1rem;
  }
  
  .phone-mockup {
    max-width: 240px;
    aspect-ratio: 9 / 19.5;
  }
  
  .phone-screen img {
    object-fit: cover;
  }

  .portfolio-image {
    height: 240px;
  }

  .portfolio-content {
    padding: 1.5rem;
  }
  
  .portfolio-card h3 {
    font-size: 1.25rem;
  }
  
  .portfolio-carousel-wrapper {
    padding: 0 1rem;
  }
  
  .portfolio-carousel-item {
    padding: 0 0.5rem;
  }
  
  .portfolio-carousel-controls {
    margin-top: 2rem;
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .portfolio-carousel-nav {
    width: 100%;
    justify-content: space-between;
  }
  
  .portfolio-carousel-btn {
    width: 48px;
    height: 48px;
  }
  
  .portfolio-card {
    padding: 6px;
  }
  
  .portfolio-grid {
    gap: 2rem;
  }
  
  .portfolio-carousel-item.prev,
  .portfolio-carousel-item.next {
    display: none;
  }
}
