/* =========================================================
   CRAZY MODERN PORTFOLIO - DIAGONAL + 3D CARD EFFECTS
   Combines Option 2 & 3 for Maximum Impact
   ========================================================= */

/* Reset Portfolio Area for New Layout */
.td-portfolio-area {
  position: relative;
  overflow: hidden;
  perspective: 2000px;
}

/* Diagonal Background Strips */
.td-portfolio-area::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -10%;
  right: -10%;
  height: 150%;
  background: linear-gradient(
    125deg,
    transparent 0%,
    rgba(233, 11, 11, 0.02) 25%,
    transparent 50%,
    rgba(233, 11, 11, 0.03) 75%,
    transparent 100%
  );
  transform: rotate(-3deg);
  pointer-events: none;
  z-index: 0;
}

.td-portfolio-area > .container {
  position: relative;
  z-index: 1;
}

/* =====================
   3D CARD CONTAINER
   ===================== */
.td-portfolio-6-thumb-wrap {
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
  margin-bottom: 80px !important;
}

/* Diagonal Tilt Effect - Alternating */
.col-lg-6:nth-child(odd) .td-portfolio-6-thumb-wrap {
  transform: perspective(1000px) rotateY(-2deg) rotateX(1deg);
}

.col-lg-6:nth-child(even) .td-portfolio-6-thumb-wrap {
  transform: perspective(1000px) rotateY(2deg) rotateX(-1deg);
}

/* 3D Hover Lift & Rotate */
.td-portfolio-6-thumb-wrap:hover {
  transform: perspective(1000px) translateZ(60px) translateY(-20px) rotateY(0deg) rotateX(0deg) !important;
  z-index: 10 !important;
}

/* =====================
   CARD INNER STRUCTURE
   ===================== */
.td-portfolio-6-thumb {
  position: relative;
  transform-style: preserve-3d;
}

/* Image Container with Diagonal Clip */
.td-portfolio-6-thumb .roun {
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
  transform-style: preserve-3d;
}

/* Diagonal Corner Accent */
.td-portfolio-6-thumb .roun::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 180px;
  height: 180px;
  background: linear-gradient(135deg, rgba(233, 11, 11, 0.9) 0%, rgba(233, 11, 11, 0.6) 100%);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 2;
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-thumb .roun::before {
  opacity: 1;
  width: 220px;
  height: 220px;
}

/* Animated Border Gradient */
.td-portfolio-6-thumb .roun::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 24px;
  padding: 3px;
  background: linear-gradient(
    135deg,
    rgba(233, 11, 11, 0.5),
    rgba(233, 11, 11, 0.1),
    rgba(233, 11, 11, 0.5)
  );
  -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;
  pointer-events: none;
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-thumb .roun::after {
  opacity: 1;
  animation: borderRotate 3s linear infinite;
}

@keyframes borderRotate {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

/* Enhanced Shadow on Hover */
.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-thumb .roun {
  box-shadow: 
    0 40px 100px rgba(233, 11, 11, 0.25),
    0 0 0 1px rgba(233, 11, 11, 0.2) inset,
    0 0 60px rgba(233, 11, 11, 0.1);
  transform: translateZ(30px);
}

/* =====================
   IMAGE EFFECTS
   ===================== */
.portfolio-img {
  width: 450px;
  height: 400px;
  object-fit: cover;
  object-position: center;
  border-radius: 24px;
  transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
  filter: brightness(0.95) contrast(1.05) saturate(0.9);
  transform: scale(1.05);
}

/* Split Reveal Effect */
.td-portfolio-6-thumb-wrap:hover .portfolio-img {
  transform: scale(1.15) translateZ(20px);
  filter: brightness(0.85) contrast(1.1) saturate(1.1);
}

/* Diagonal Overlay Gradient */
.td-portfolio-6-thumb .roun .portfolio-img::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(233, 11, 11, 0.4) 0%,
    transparent 40%,
    transparent 60%,
    rgba(0, 0, 0, 0.5) 100%
  );
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}

/* =====================
   TRANSPARENT NUMBER
   ===================== */
.td-portfolio-6-transparent {
  font-family: var(--td-ff-body);
  font-weight: 900;
  font-size: 180px;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, rgba(233, 11, 11, 0.15) 0%, rgba(233, 11, 11, 0.05) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke-color: rgba(233, 11, 11, 0.25);
  -webkit-text-stroke-width: 2px;
  position: absolute;
  top: -140px;
  left: -20px;
  z-index: -1;
  transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1);
  transform: translateZ(-50px);
  filter: blur(0px);
}

/* 3D Number Movement on Hover */
.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-transparent {
  -webkit-text-fill-color: rgba(233, 11, 11, 0.12);
  -webkit-text-stroke-color: rgba(233, 11, 11, 0.5);
  transform: translateZ(-30px) translateX(10px) scale(1.08);
  filter: blur(1px);
  text-shadow: 
    0 0 40px rgba(233, 11, 11, 0.4),
    0 0 80px rgba(233, 11, 11, 0.2);
}

@media (max-width: 575px) {
  .td-portfolio-6-transparent {
    font-size: 100px;
    top: -80px;
    left: -10px;
  }
}

/* =====================
   3D BUTTON DESIGN
   ===================== */
.td-portfolio-6-btn {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 80px;
  height: 80px;
  text-align: center;
  line-height: 76px;
  background: linear-gradient(135deg, rgba(233, 11, 11, 1) 0%, rgba(200, 10, 10, 1) 100%);
  display: inline-block;
  position: absolute;
  top: 60%;
  transform: translateY(-50%) translateZ(0) scale(0.7) rotate(-45deg);
  left: 0;
  right: 0;
  margin: 0 auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  z-index: 10;
  box-shadow: 
    0 20px 50px rgba(233, 11, 11, 0.4),
    0 0 0 0 rgba(233, 11, 11, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 
      0 20px 50px rgba(233, 11, 11, 0.4),
      0 0 0 0 rgba(233, 11, 11, 0.4);
  }
  50% {
    box-shadow: 
      0 20px 50px rgba(233, 11, 11, 0.6),
      0 0 0 15px rgba(233, 11, 11, 0);
  }
}

/* Button Hover State */
.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-btn {
  opacity: 1;
  visibility: visible;
  top: 50%;
  transform: translateY(-50%) translateZ(40px) scale(1) rotate(0deg);
  animation: float 3s ease-in-out infinite;
}

.td-portfolio-6-thumb-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
}

@keyframes float {
  0%, 100% {
    transform: translateY(-50%) translateZ(40px) scale(1) rotate(0deg);
  }
  50% {
    transform: translateY(-55%) translateZ(45px) scale(1.05) rotate(5deg);
  }
}

/* Button Inner Hover */
.td-portfolio-6-btn:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(240, 240, 240, 1) 100%);
  border-color: rgba(233, 11, 11, 1);
  transform: translateY(-50%) translateZ(50px) scale(1.15) rotate(90deg) !important;
  box-shadow: 
    0 30px 70px rgba(233, 11, 11, 0.6),
    0 0 0 8px rgba(233, 11, 11, 0.2);
}

.td-portfolio-6-btn svg {
  transition: all 0.4s ease;
  display: inline-block;
}

.td-portfolio-6-btn:hover svg {
  transform: rotate(-90deg);
}

.td-portfolio-6-btn:hover svg path {
  stroke: rgba(233, 11, 11, 1);
}

/* =====================
   CONTENT AREA
   ===================== */
.td-portfolio-6-content {
  position: relative;
  padding-top: 20px;
  transform-style: preserve-3d;
  transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-content {
  transform: translateZ(25px) translateX(8px);
}

/* TAG BADGE - Diagonal Cut */
.td-portfolio-6-content .tag {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: rgba(233, 11, 11, 1);
  text-transform: uppercase;
  display: inline-block;
  padding: 8px 20px;
  background: linear-gradient(135deg, rgba(233, 11, 11, 0.1) 0%, rgba(233, 11, 11, 0.05) 100%);
  border: 1px solid rgba(233, 11, 11, 0.2);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  margin-bottom: 15px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  overflow: hidden;
}

/* Tag Hover Fill Animation */
.td-portfolio-6-content .tag::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(233, 11, 11, 1) 0%, rgba(200, 10, 10, 1) 100%);
  transition: left 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: -1;
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-content .tag {
  color: white;
  transform: translateX(10px) translateZ(5px);
  border-color: rgba(233, 11, 11, 0.6);
  box-shadow: 0 5px 20px rgba(233, 11, 11, 0.3);
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-content .tag::before {
  left: 0;
}

/* TITLE with Underline Animation */
.td-portfolio-6-content .title {
  font-family: var(--td-ff-manrope);
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -0.03em;
  color: var(--td-theme-3);
  margin-top: 10px;
  margin-bottom: 15px;
  transition: all 0.4s ease;
}

.td-portfolio-6-content .title a {
  position: relative;
  display: inline-block;
  transition: color 0.4s ease;
  background: linear-gradient(135deg, currentColor 0%, currentColor 100%);
  background-clip: text;
  -webkit-background-clip: text;
}

/* Diagonal Underline Effect */
.td-portfolio-6-content .title a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(233, 11, 11, 1) 0%, rgba(233, 11, 11, 0.5) 100%);
  transition: width 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  transform: skewX(-15deg);
  transform-origin: left;
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-content .title a::after {
  width: 100%;
}

/* DESCRIPTION */
.td-portfolio-6-content .portfolio-description {
  font-size: 15px;
  line-height: 1.8;
  color: var(--td-grey-5);
  opacity: 0.85;
  transition: all 0.4s ease;
  transform: translateZ(0);
}

.td-portfolio-6-thumb-wrap:hover .td-portfolio-6-content .portfolio-description {
  opacity: 1;
  color: var(--td-theme-3);
  transform: translateZ(10px);
}

/* =====================
   STAGGERED ANIMATIONS
   ===================== */
@keyframes fadeInDiagonal {
  0% {
    opacity: 0;
    transform: perspective(1000px) translateY(60px) translateZ(-100px) rotateX(20deg);
  }
  100% {
    opacity: 1;
    transform: perspective(1000px) translateY(0) translateZ(0) rotateX(0deg);
  }
}

.wow.fadeInLeft,
.wow.fadeInRight {
  animation-name: fadeInDiagonal !important;
}

/* Alternating Delays */
.td-portfolio-area .col-lg-6:nth-child(1) {
  animation-delay: 0.1s !important;
}

.td-portfolio-area .col-lg-6:nth-child(2) {
  animation-delay: 0.25s !important;
}

.td-portfolio-area .col-lg-6:nth-child(3) {
  animation-delay: 0.4s !important;
}

.td-portfolio-area .col-lg-6:nth-child(4) {
  animation-delay: 0.55s !important;
}

.td-portfolio-area .col-lg-6:nth-child(5) {
  animation-delay: 0.7s !important;
}

.td-portfolio-area .col-lg-6:nth-child(6) {
  animation-delay: 0.85s !important;
}

/* =====================
   SPACING ADJUSTMENTS
   ===================== */
.td-portfolio-6-thumb-wrap.spacing {
  margin-top: 200px !important;
}

@media only screen and (min-width: 768px) and (max-width: 991px) {
  .td-portfolio-6-thumb-wrap.spacing {
    margin-top: 100px !important;
  }
}

@media (max-width: 575px) {
  .td-portfolio-6-thumb-wrap.spacing {
    margin-top: 60px !important;
  }
}

/* =====================
   RESPONSIVE DESIGN
   ===================== */
@media (max-width: 991px) {
  .col-lg-6:nth-child(odd) .td-portfolio-6-thumb-wrap,
  .col-lg-6:nth-child(even) .td-portfolio-6-thumb-wrap {
    transform: perspective(1000px) rotateY(0deg) rotateX(0deg);
  }
  
  .td-portfolio-6-thumb-wrap {
    margin-bottom: 60px !important;
    cursor: pointer;
  }
}

@media (max-width: 575px) {
  .td-portfolio-6-thumb {
    margin-left: 30px;
  }
  
  .portfolio-img {
    width: 100%;
    height: 300px;
  }
  
  .td-portfolio-6-content .title {
    font-size: 24px;
  }
  
  .td-portfolio-6-btn {
    width: 70px;
    height: 70px;
    line-height: 66px;
  }
  
  .td-portfolio-6-transparent {
    font-size: 90px;
  }
}

/* =====================
   PERFORMANCE OPTIMIZATION
   ===================== */
.td-portfolio-6-thumb-wrap,
.td-portfolio-6-thumb .roun,
.portfolio-img,
.td-portfolio-6-btn,
.td-portfolio-6-transparent,
.td-portfolio-6-content {
  will-change: transform;
}

/* Disable 3D on low-end devices */
@media (prefers-reduced-motion: reduce) {
  .td-portfolio-6-thumb-wrap,
  .td-portfolio-6-thumb-wrap:hover {
    transform: none !important;
  }
  
  .td-portfolio-6-btn {
    animation: none !important;
  }
}

/* =====================
   SCROLL-TRIGGERED PARALLAX
   (Optional - needs JS)
   ===================== */
@keyframes scrollParallax {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-30px);
  }
}

/* Add parallax class via JS on scroll */
.parallax-active .td-portfolio-6-transparent {
  animation: scrollParallax 0.5s ease-out forwards;
}

/* =============================================
   LINK FIX - Z-INDEX & POINTER EVENTS
   ============================================= */

/* Make sure links are clickable */
.td-portfolio-6-content .title a {
  position: relative;
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
  display: inline-block;
}

/* Button should be clickable */
.td-portfolio-6-btn {
  z-index: 100 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Make sure parent containers don't block clicks */
.td-portfolio-6-thumb .roun {
  position: relative;
  z-index: 1;
}

.td-portfolio-6-thumb .roun::before,
.td-portfolio-6-thumb .roun::after {
  pointer-events: none;
}

.td-portfolio-6-content {
  position: relative;
  z-index: 5;
  pointer-events: auto;
}

/* Fix any overlay blocking */
.td-portfolio-6-thumb-wrap::before,
.td-portfolio-6-thumb-wrap::after {
  pointer-events: none;
}

/* Ensure tag doesn't block title */
.td-portfolio-6-content .tag {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

/* Title should be above everything in content */
.td-portfolio-6-content .title {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

/* Description below */
.td-portfolio-6-content .portfolio-description {
  position: relative;
  z-index: 1;
}

/* Make sure transparent number doesn't block */
.td-portfolio-6-transparent {
  pointer-events: none;
  z-index: -1;
}

/* Image shouldn't block button */
.portfolio-img {
  position: relative;
  z-index: 0;
}

/* Debug Mode - Uncomment to see clickable areas */
/*
.td-portfolio-6-content .title a {
  background: rgba(255, 0, 0, 0.2) !important;
  outline: 2px solid red !important;
}

.td-portfolio-6-btn {
  background: rgba(0, 255, 0, 0.5) !important;
}
*/