/* =====================================
   ImageShare - Enhanced Animation Styles
   GSAP & Three.js Visual Effects CSS
   ===================================== */

/* ===== Page Transition Overlay ===== */
.page-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transition-loader {
  display: flex;
  gap: 12px;
}

.loader-circle {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite both;
}

.loader-circle:nth-child(1) {
  animation-delay: -0.32s;
}
.loader-circle:nth-child(2) {
  animation-delay: -0.16s;
}
.loader-circle:nth-child(3) {
  animation-delay: 0s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* ===== Page Loader ===== */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-white);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Three.js Background Container ===== */
#three-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.6;
}

[data-theme="dark"] #three-bg {
  opacity: 0.4;
}

/* ===== Enhanced Navbar ===== */
.navbar {
  backdrop-filter: blur(0px);
  transition: all 0.3s ease, backdrop-filter 0.3s ease;
  z-index: 100000;
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  z-index: 100000;
}

[data-theme="dark"] .navbar.scrolled {
  background: rgba(17, 24, 39, 0.95);
}

/* ===== Button Ripple Effect ===== */
.btn-ripple {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}

/* ===== Word Animation Wrapper ===== */
.word-wrapper {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}

.word {
  display: inline-block;
}

/* ===== Enhanced Masonry Items ===== */
.masonry-item {
  transform-style: preserve-3d;
  perspective: 1000px;
  will-change: transform, box-shadow;
}

.masonry-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1) 0%,
    rgba(139, 92, 246, 0.1) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
}

.masonry-item:hover::before {
  opacity: 1;
}

.masonry-item img {
  will-change: transform;
}

/* ===== Glow Effect on Images ===== */
.masonry-item::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  filter: blur(15px);
  transition: opacity 0.4s ease;
}

.masonry-item:hover::after {
  opacity: 0.4;
}

/* ===== Lightbox Styles ===== */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 10;
  opacity: 0.8;
  transition: opacity 0.3s, transform 0.3s;
}

.lightbox-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.5rem;
  padding: 1rem;
  cursor: pointer;
  border-radius: var(--radius-full);
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

.lightbox-prev {
  left: -60px;
}
.lightbox-next {
  right: -60px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.lightbox-image {
  max-width: 80vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 100px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
  color: white;
  text-align: center;
  margin-top: 1.5rem;
  opacity: 0.9;
}

.lightbox-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.lightbox-description {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* ===== Custom Cursor ===== */
.custom-cursor {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}

.custom-cursor-follower {
  width: 40px;
  height: 40px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%);
  opacity: 0.5;
}

/* Hide default cursor when custom cursor is active */
body.custom-cursor-active {
  cursor: none;
}

body.custom-cursor-active a,
body.custom-cursor-active button,
body.custom-cursor-active .masonry-item {
  cursor: none;
}

/* ===== Enhanced Cards ===== */
.card {
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
}

.card::before {
  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 ease;
}

.card:hover::before {
  left: 100%;
}

/* ===== Floating Action Button Enhanced ===== */
.fab {
  position: relative;
  overflow: visible;
}

.fab::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: fabPulse 2s ease-in-out infinite;
  z-index: -1;
}

@keyframes fabPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.3;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0;
  }
}

/* ===== Enhanced Home Header ===== */
.home-header {
  position: relative;
  overflow: hidden;
}

.home-header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%
  );
  animation: headerShine 10s linear infinite;
}

@keyframes headerShine {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ===== Profile Header Enhanced ===== */
.profile-header {
  position: relative;
  overflow: hidden;
}

.profile-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, var(--bg-white), transparent);
  pointer-events: none;
}

[data-theme="dark"] .profile-header::after {
  background: linear-gradient(to top, var(--bg-white), transparent);
}

/* ===== Stats Animation ===== */
.stat-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ===== Image Detail Page Enhancements ===== */
.image-display {
  position: relative;
  overflow: hidden;
}

.image-display::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 60%
  );
  background-size: 200% 200%;
  animation: imageShine 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes imageShine {
  0% {
    background-position: -100% -100%;
  }
  100% {
    background-position: 200% 200%;
  }
}

.image-display img {
  transition: transform 0.5s ease;
}

.image-display:hover img {
  transform: scale(1.02);
}

/* ===== Skeleton Loading Animation ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-light) 25%,
    var(--border) 50%,
    var(--bg-light) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
}

@keyframes skeleton {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-image {
  aspect-ratio: 4/3;
  border-radius: var(--radius-lg);
}

.skeleton-text {
  height: 1em;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 60%;
}

/* ===== Scroll Indicator ===== */
.scroll-indicator {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  z-index: 9999;
  transform-origin: left;
  transform: scaleX(0);
}

/* ===== Floating Shapes Background ===== */
.floating-shapes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -2;
  overflow: hidden;
}

.floating-shape {
  position: absolute;
  opacity: 0.1;
  animation: float 20s ease-in-out infinite;
}

.floating-shape:nth-child(1) {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.floating-shape:nth-child(2) {
  top: 20%;
  right: 10%;
  animation-delay: -5s;
}

.floating-shape:nth-child(3) {
  bottom: 20%;
  left: 20%;
  animation-delay: -10s;
}

.floating-shape:nth-child(4) {
  bottom: 10%;
  right: 20%;
  animation-delay: -15s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-20px) rotate(5deg);
  }
  50% {
    transform: translateY(0) rotate(0deg);
  }
  75% {
    transform: translateY(20px) rotate(-5deg);
  }
}

/* ===== Gradient Text Animation ===== */
.gradient-text {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--secondary) 50%,
    var(--primary) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientFlow 3s ease infinite;
}

@keyframes gradientFlow {
  0% {
    background-position: 0% center;
  }
  50% {
    background-position: 100% center;
  }
  100% {
    background-position: 0% center;
  }
}

/* ===== Glassmorphism Effects ===== */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ===== Hover Reveal Effect ===== */
.hover-reveal {
  position: relative;
  overflow: hidden;
}

.hover-reveal .reveal-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hover-reveal:hover .reveal-content {
  opacity: 1;
}

/* ===== Smooth Focus Transitions ===== */
input:focus,
textarea:focus,
select:focus {
  transform: scale(1.01);
  transition: all 0.3s ease, transform 0.3s ease;
}

/* ===== Enhanced Badge Animation ===== */
.badge {
  transition: all 0.3s ease;
}

.badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ===== Animated Underline Links ===== */
.animated-link {
  position: relative;
  text-decoration: none;
}

.animated-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.animated-link:hover::after {
  width: 100%;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
  .lightbox-prev,
  .lightbox-next {
    display: none;
  }

  .lightbox-image {
    max-width: 95vw;
    max-height: 70vh;
  }

  .custom-cursor,
  .custom-cursor-follower {
    display: none !important;
  }

  #three-bg {
    opacity: 0.3;
  }
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .page-transition {
    display: none !important;
  }

  #three-bg {
    display: none !important;
  }
}
