/* ═══════════════════════════════════════════════════════════
   AVIONICS WORKS — GALLERY PREMIUM EFFECTS
   Showcase-level visual polish for the project gallery
   ═══════════════════════════════════════════════════════════ */

/* ── Page Hero Cinematic Entrance ── */
.page-hero {
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 40%;
  background: linear-gradient(to top, var(--bg-primary), transparent);
  pointer-events: none;
  z-index: 1;
}
.page-hero .section-label {
  animation: gp-labelSlide .8s cubic-bezier(.16,1,.3,1) .2s both;
}
.page-hero-title {
  animation: gp-titleReveal 1s cubic-bezier(.16,1,.3,1) .35s both;
}
.page-hero-subtitle {
  animation: gp-subtitleReveal 1s cubic-bezier(.16,1,.3,1) .5s both;
}
@keyframes gp-labelSlide {
  from { opacity: 0; transform: translateY(12px); letter-spacing: .4em; }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes gp-titleReveal {
  from { opacity: 0; transform: translateY(30px); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes gp-subtitleReveal {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Filter Bar Premium Styling ── */
.filter-bar {
  position: relative;
  padding-bottom: 2px;
}
.filter-bar::after {
  content: '';
  position: absolute;
  bottom: -8px; left: 50%;
  transform: translateX(-50%);
  width: 80%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}
.filter-btn {
  position: relative;
  overflow: hidden;
  transition: all .35s cubic-bezier(.16,1,.3,1) !important;
}
/* Shine sweep on active filter */
.filter-btn.active::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  animation: gp-filterShine 2.5s ease-in-out infinite;
}
@keyframes gp-filterShine {
  0%, 60%, 100% { left: -100%; }
  80% { left: 160%; }
}
/* Count badges on filter buttons */
.filter-btn .gp-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,.08);
  color: var(--text-muted);
  transition: all .35s;
  line-height: 1;
}
.filter-btn.active .gp-count {
  background: rgba(10,10,10,.3);
  color: var(--bg-primary);
}

/* ── Gallery Grid — Cursor Spotlight ── */
.gallery-grid {
  position: relative;
}
.gallery-grid::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(252,212,98,.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  left: var(--gp-mx, -999px);
  top: var(--gp-my, -999px);
  transition: left .15s, top .15s, opacity .3s;
  opacity: 0;
}
.gallery-grid:hover::before {
  opacity: 1;
}

/* ── Gallery Items — Staggered Scroll Reveal ── */
.gallery-item {
  position: relative;
  z-index: 1;
  transform-style: preserve-3d;
  perspective: 800px;
}
.gallery-item.gp-hidden {
  opacity: 0;
  transform: translateY(40px) scale(.96);
}
.gallery-item.gp-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1);
}

/* ── 3D Tilt Effect on Hover ── */
.gallery-item .gallery-item-img {
  transition: transform .6s cubic-bezier(.16,1,.3,1);
  will-change: transform;
}
.gallery-item.gp-tilt .gallery-item-img {
  /* JS sets --rx, --ry for 3D rotation */
  transform: scale(1.04) rotateX(var(--gp-rx, 0deg)) rotateY(var(--gp-ry, 0deg));
}

/* ── Animated Gold Border Glow ── */
.gallery-item::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s;
  background: conic-gradient(
    from var(--gp-angle, 0deg),
    transparent 0%,
    rgba(252,212,98,.5) 10%,
    transparent 20%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1.5px;
  animation: gp-borderRotate 3s linear infinite;
}
.gallery-item:hover::before {
  opacity: 1;
}
@keyframes gp-borderRotate {
  to { --gp-angle: 360deg; }
}
/* Register CSS custom property for animation */
@property --gp-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* ── Featured Items — Spotlight Pulse ── */
.gallery-item.featured {
  position: relative;
}
.gallery-item.featured::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(252,212,98,.08) 0%, transparent 50%, rgba(252,212,98,.04) 100%);
  opacity: 0;
  animation: gp-featuredPulse 4s ease-in-out infinite;
}
@keyframes gp-featuredPulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ── Featured Badge ── */
.gallery-item.featured .gallery-item-overlay::before {
  content: '★ FEATURED';
  position: absolute;
  top: 16px; left: 16px;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--bg-primary);
  background: var(--gold);
  border-radius: 4px;
  z-index: 3;
  animation: gp-badgePulse 3s ease-in-out infinite;
}
@keyframes gp-badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(252,212,98,.4); }
  50% { box-shadow: 0 0 12px 4px rgba(252,212,98,.2); }
}

/* ── Image Parallax Inner Movement ── */
.gallery-item-img {
  transform-origin: center center;
}
.gallery-item:hover .gallery-item-img {
  /* JS will set --gp-px, --gp-py for parallax offset */
  transform: scale(1.06) translate(var(--gp-px, 0px), var(--gp-py, 0px));
}

/* ── Overlay Slide-Up Effect ── */
.gallery-item-overlay {
  transform: translateY(8px);
  transition: opacity .4s cubic-bezier(.16,1,.3,1), transform .4s cubic-bezier(.16,1,.3,1) !important;
}
.gallery-item:hover .gallery-item-overlay {
  opacity: 1 !important;
  transform: translateY(0);
}
.gallery-item-sub {
  transform: translateY(6px);
  opacity: 0;
  transition: all .35s cubic-bezier(.16,1,.3,1) .05s;
}
.gallery-item:hover .gallery-item-sub {
  transform: translateY(0);
  opacity: 1;
}
.gallery-item-title {
  transform: translateY(6px);
  opacity: 0;
  transition: all .35s cubic-bezier(.16,1,.3,1) .12s;
}
.gallery-item:hover .gallery-item-title {
  transform: translateY(0);
  opacity: 1;
}

/* ── Lightbox Cinematic Upgrade ── */
.lightbox {
  backdrop-filter: blur(16px) saturate(.5);
  -webkit-backdrop-filter: blur(16px) saturate(.5);
  transition: opacity .4s cubic-bezier(.16,1,.3,1) !important;
}
.lightbox.active .lightbox-img {
  animation: gp-lightboxIn .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes gp-lightboxIn {
  from { opacity: 0; transform: scale(.85) translateY(20px); filter: blur(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
.lightbox-caption {
  animation: gp-captionIn .6s cubic-bezier(.16,1,.3,1) .2s both;
}
.lightbox.active .lightbox-caption {
  animation: gp-captionIn .6s cubic-bezier(.16,1,.3,1) .2s both;
}
@keyframes gp-captionIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Lightbox nav buttons glow */
.lightbox-nav {
  transition: all .3s !important;
}
.lightbox-nav:hover {
  background: rgba(252,212,98,.15) !important;
  border-color: rgba(252,212,98,.4) !important;
  color: var(--gold) !important;
  box-shadow: 0 0 20px rgba(252,212,98,.15);
}
.lightbox-close:hover {
  background: rgba(252,212,98,.15) !important;
  border-color: rgba(252,212,98,.4) !important;
  color: var(--gold) !important;
}

/* ── Filter Transition — Smooth Layout Morph ── */
.gallery-item[style*="display: none"] {
  /* handled by JS */
}
.gallery-item.gp-filtering-out {
  opacity: 0 !important;
  transform: scale(.92) translateY(10px) !important;
  transition: all .3s cubic-bezier(.4,0,1,1) !important;
}
.gallery-item.gp-filtering-in {
  animation: gp-filterIn .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes gp-filterIn {
  from { opacity: 0; transform: scale(.94) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── CTA Section — Gallery-specific ── */
.cta-section .cta-title {
  background: linear-gradient(135deg, #fff 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Gallery Stats Bar ── */
.gp-stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: var(--space-xl);
  padding: 16px 0;
  border-top: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
  animation: gp-statsReveal .8s cubic-bezier(.16,1,.3,1) .6s both;
}
@keyframes gp-statsReveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.gp-stat {
  text-align: center;
}
.gp-stat-number {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.gp-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 2px;
}

/* ── Mobile Optimizations ── */
@media (max-width: 768px) {
  .gallery-grid::before { display: none; }
  .gallery-item::before { display: none; } /* no rotating border on mobile */
  .gp-stats-bar { gap: 20px; }
  .gp-stat-number { font-size: 1.2rem; }
  .gallery-item.featured .gallery-item-overlay::before {
    top: 10px; left: 10px;
    padding: 3px 8px;
    font-size: 9px;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .gallery-item.gp-hidden { opacity: 1; transform: none; }
  .gallery-item::before { animation: none; }
  .gallery-item.featured::after { animation: none; }
  .filter-btn.active::after { animation: none; }
  .page-hero .section-label,
  .page-hero-title,
  .page-hero-subtitle { animation: none; }
  .gp-stats-bar { animation: none; }
  .lightbox.active .lightbox-img { animation: none; }
}
