/* Gallery Styles - Adapted from Original with Homme Made Design System */

/* Clean reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Space Mono', monospace;
  background-color: var(--primary-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  height: 600vh; /* Increased to allow scrolling through all portfolio items */
  will-change: scroll-position;
}

/* Main gallery container - fixed position with CSS Grid */
#gallery {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 25% 4% 35.5% 35.5%;
  grid-template-areas: "left nav right1 right2";
  background: var(--primary-dark);
  gap: 0;
  /* padding-top: 80px; Account for floating nav - removed for parallax */
}

/* Column layouts */
.col-left {
  grid-area: left;
  height: 100%;
  padding: 20px 10px 20px 20px;
  overflow: hidden;
}

.col-nav {
  grid-area: nav;
  height: 100%;
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.4s ease;
}

.col-right1 {
  grid-area: right1;
  height: 100vh;
  padding: 20px 10px 20px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Smooth scrolling */
  scroll-behavior: smooth;
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(211, 255, 0, 0.3) transparent;
}

/* Webkit scrollbar styling with feature detection */
@supports (-webkit-appearance: none) {
  .col-right1::-webkit-scrollbar {
    width: 4px;
  }

  .col-right1::-webkit-scrollbar-track {
    background: transparent;
  }

  .col-right1::-webkit-scrollbar-thumb {
    background: rgba(211, 255, 0, 0.3);
    border-radius: 2px;
  }

  .col-right1::-webkit-scrollbar-thumb:hover {
    background: rgba(211, 255, 0, 0.5);
  }
  
  /* Fallback for browsers that don't support hover on scrollbar */
  @supports not (selector(::-webkit-scrollbar-thumb:hover)) {
    .col-right1::-webkit-scrollbar-thumb {
      background: rgba(211, 255, 0, 0.4);
    }
  }
}

.col-right2 {
  grid-area: right2;
  height: 100vh;
  padding: 20px 20px 20px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Smooth scrolling */
  scroll-behavior: smooth;
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(211, 255, 0, 0.3) transparent;
}

@supports (-webkit-appearance: none) {
  .col-right2::-webkit-scrollbar {
    width: 4px;
  }

  .col-right2::-webkit-scrollbar-track {
    background: transparent;
  }

  .col-right2::-webkit-scrollbar-thumb {
    background: rgba(211, 255, 0, 0.3);
    border-radius: 2px;
  }

  .col-right2::-webkit-scrollbar-thumb:hover {
    background: rgba(211, 255, 0, 0.5);
  }
  
  /* Fallback for browsers that don't support hover on scrollbar */
  @supports not (selector(::-webkit-scrollbar-thumb:hover)) {
    .col-right2::-webkit-scrollbar-thumb {
      background: rgba(211, 255, 0, 0.4);
    }
  }
}

/* Column hover effects - only on desktop */
@media (min-width: 769px) {
  .col-nav:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
  }
  
  /* Note: :has() selector is modern - fallback handled via JavaScript */
  #gallery:has(.col-nav:hover) {
    grid-template-columns: 25% 12% 31.5% 31.5%;
  }
  
  /* Fallback for browsers without :has() support */
  #gallery.nav-hovered {
    grid-template-columns: 25% 12% 31.5% 31.5%;
  }
}

/* Image columns */
.img-col {
  flex: 1;
  padding: 0 10px;
  position: relative;
}

.col-right1 .img-col,
.col-right2 .img-col {
  /* Individual column containers handle sizing */
}

/* Reverse column styling */
#col2 {
  display: flex;
  flex-direction: column-reverse;
}

/* Image items - dynamic height to preserve aspect ratios */
.img-item {
  width: 100%;
  min-height: 200px;
  max-height: 80vh;
  margin-bottom: 16px;
  border-radius: 33px;
  overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  transition: all var(--hover-gradient-transition);
  position: relative;
  cursor: pointer;
}

.img-item img,
.img-item video {
  width: 100%;
  height: auto;
  min-height: 200px;
  object-fit: contain;
  border-radius: 33px;
  transition: transform var(--hover-gradient-transition);
  background: var(--glass-bg);
}

.img-item:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--shadow-medium);
}

.img-item:hover img,
.img-item:hover video {
  transform: scale(1.05);
}

/* Image hover overlay with Homme Made glassmorphism */
.img-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border-top: 1px solid var(--glass-border);
  padding: var(--space-sm) var(--space-md);
  transform: translateY(100%);
  transition: transform var(--hover-gradient-transition);
  z-index: 5;
  border-radius: 0 0 33px 33px;
}

.img-item:hover .img-overlay {
  transform: translateY(0);
}

.img-overlay-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: var(--space-xs);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-overlay-description {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

.img-overlay-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.img-overlay-tag {
  font-size: 0.65rem;
  background: rgba(211, 255, 0, 0.2);
  color: var(--accent-lime);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(211, 255, 0, 0.3);
}

/* Navigation styling - Thumbnail Minimap */
.nav-container {
  height: 80%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.nav-item {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 33px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--glass-border);
  transition: all var(--hover-gradient-transition);
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
}

.nav-item.active {
  border-color: var(--accent-lime);
  box-shadow: 0 0 20px rgba(211, 255, 0, 0.3);
}

.nav-item:hover {
  border-color: var(--glass-border-hover);
  transform: scale(1.05);
}

.nav-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--hover-gradient-transition);
}

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

.nav-label {
  position: absolute;
  left: 120%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--hover-gradient-transition);
  font-size: 0.75rem;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 8px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 100;
}

.col-nav:hover .nav-label {
  opacity: 1;
}

/* Minimap hover behavior - only on desktop */
@media (min-width: 769px) {
  .col-nav:hover ~ .col-left .img-item,
  .col-nav:hover ~ .col-right1 .img-item,
  .col-nav:hover ~ .col-right2 .img-item {
    height: calc((100vh - 48px) / 6 - 16px);
    transition: height 0.4s ease;
  }
}

/* PDF preview styles */
.pdf-preview {
  width: 100%;
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 33px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--hover-gradient-transition);
}

.pdf-preview:hover {
  border-color: var(--glass-border-hover);
  background: var(--glass-bg-hover);
}

.pdf-preview .pdf-icon {
  font-size: 3rem;
  color: var(--accent-lime);
  margin-bottom: 10px;
}

.pdf-preview .pdf-title {
  color: var(--text-primary);
  font-weight: 600;
  text-align: center;
  padding: 0 20px;
  font-size: 0.9rem;
}

.pdf-preview .pdf-subtitle {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 5px;
}

/* Fade overlays for smooth scrolling effect */
.fade-top,
.fade-bottom {
  position: fixed;
  left: 0;
  width: 100%;
  height: 120px;
  pointer-events: none;
  z-index: 15; /* Above gallery but below nav */
}

.fade-top {
  top: 0;
  background: linear-gradient(
    to bottom,
    var(--primary-dark) 0%,
    rgba(10, 10, 10, 0.7) 50%,
    transparent 100%
  );
}

.fade-bottom {
  bottom: 0;
  background: linear-gradient(
    to top,
    var(--primary-dark) 0%,
    rgba(10, 10, 10, 0.7) 50%,
    transparent 100%
  );
}

/* Image Modal - Homme Made Glassmorphism Style */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-modal.active {
  display: flex;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  cursor: pointer;
}

.modal-content {
  position: relative;
  width: 95vw;
  height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* Allow clicks to pass through to children */
}

.modal-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 44px;
  height: 44px;
  border: none;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: all var(--hover-gradient-transition);
  pointer-events: auto;
  opacity: 0.7;
}

.modal-close:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-lime);
  color: var(--accent-lime);
  opacity: 1;
}

.modal-nav {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 15;
  pointer-events: none;
}

.modal-prev,
.modal-next {
  width: 54px;
  height: 54px;
  border: none;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--hover-gradient-transition);
  pointer-events: auto;
  opacity: 0.3;
}

.modal-prev:hover,
.modal-next:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-lime);
  color: var(--accent-lime);
  transform: scale(1.1);
  opacity: 1;
}

.modal-image-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  pointer-events: auto;
  border-radius: 33px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#modalImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 33px;
  cursor: zoom-in;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

#modalImage.zoomed {
  cursor: zoom-out;
  /* Transform scale is now applied dynamically via JavaScript */
}

/* Floating Info Overlay */
.modal-info-overlay {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  pointer-events: auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-info-overlay.collapsed {
  bottom: var(--space-lg);
  left: auto;
  right: var(--space-lg);
  transform: none;
}

.modal-info-content {
  position: relative;
  min-width: 350px;
  max-width: 600px;
  padding: calc(var(--space-lg) + 20px) var(--space-lg) var(--space-lg) var(--space-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  margin-bottom: var(--space-sm);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-info-overlay.collapsed .modal-info-content {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.modal-info-toggle {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 36px;
  height: 36px;
  border: none;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--hover-gradient-transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.modal-info-toggle:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-lime);
  color: var(--accent-lime);
  transform: scale(1.1);
}

.modal-info-overlay.collapsed .modal-info-toggle {
  background: rgba(211, 255, 0, 0.2);
  border-color: var(--accent-lime);
  color: var(--accent-lime);
}

#modalTitle {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

#modalDescription {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0 0 var(--space-md) 0;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: center;
  margin-top: var(--space-sm);
}

.modal-tag {
  font-size: 0.75rem;
  background: rgba(211, 255, 0, 0.2);
  color: var(--accent-lime);
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid rgba(211, 255, 0, 0.3);
  backdrop-filter: blur(10px);
  transition: all var(--hover-gradient-transition);
}

.modal-tag:hover {
  background: rgba(211, 255, 0, 0.3);
  border-color: var(--accent-lime);
}

/* Mobile optimizations for modal */
@media (max-width: 768px) {
  .modal-content {
    width: 100vw;
    height: 100vh;
  }
  
  .modal-image-container {
    border-radius: 24px;
  }
  
  .modal-close {
    width: 40px;
    height: 40px;
    font-size: 20px;
    top: var(--space-md);
    right: var(--space-md);
  }
  
  .modal-prev,
  .modal-next {
    width: 48px;
    height: 48px;
    font-size: 28px;
  }
  
  .modal-nav {
    padding: 0 var(--space-md);
  }
  
  .modal-info-content {
    min-width: 280px;
    max-width: 90vw;
    padding: var(--space-md);
    border-radius: 20px;
  }
  
  .modal-info-overlay {
    bottom: var(--space-md);
  }
  
  .modal-info-overlay.collapsed {
    bottom: var(--space-md);
    right: var(--space-md);
  }
  
.modal-info-content {
    position: relative;
    padding-top: calc(var(--space-lg) + 40px);
  }
  
  .modal-info-toggle {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  #modalTitle {
    font-size: 1.1rem;
  }
  
  #modalDescription {
    font-size: 0.85rem;
    margin-bottom: var(--space-sm);
  }
  
  .modal-tag {
    font-size: 0.7rem;
    padding: 3px 6px;
  }
}

/* Responsive adjustments */
/* Tablet breakpoint */
@media (max-width: 1200px) and (min-width: 769px) {
  #gallery {
    grid-template-columns: 30% 5% 32.5% 32.5%;
  }
  
  /* Note: :has() selector is modern - fallback handled via JavaScript */
  #gallery:has(.col-nav:hover) {
    grid-template-columns: 30% 15% 27.5% 27.5%;
  }
  
  /* Fallback for browsers without :has() support */
  #gallery.nav-hovered {
    grid-template-columns: 30% 15% 27.5% 27.5%;
  }
}

/* Mobile breakpoint - complete layout restructure */
@media (max-width: 768px) {
  body {
    height: auto;
    min-height: 100vh;
  }
  
  #gallery {
    position: relative;
    height: auto;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: 
      "nav"
      "main";
    padding: 100px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    padding-top: 120px; /* Account for floating nav on mobile */
  }

  .col-nav {
    grid-area: nav;
    height: auto;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-backdrop-blur));
    position: sticky;
    top: 100px;
    z-index: 100;
    margin: 0 var(--space-sm) var(--space-lg) var(--space-sm);
  }

  .col-left,
  .col-right1,
  .col-right2 {
    grid-area: main;
    height: auto;
    padding: var(--space-sm);
  }

  .col-left {
    display: block;
  }

  .col-right1,
  .col-right2 {
    display: none;
  }

  .nav-container {
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--space-md);
    gap: var(--space-md);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    min-width: 60px;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 24px;
    scroll-snap-align: center;
    touch-action: manipulation;
  }

  .nav-item.active {
    border-color: var(--accent-lime);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(211, 255, 0, 0.4);
  }

  .nav-label {
    display: none;
  }

  .img-col {
    padding: 0;
  }

  .img-item {
    height: auto;
    min-height: 250px;
    max-height: 70vh;
    margin-bottom: var(--space-lg);
    border-radius: 24px;
  }

  .img-item img,
  .img-item video {
    border-radius: 24px;
  }

  .fade-top {
    top: 80px;
    height: 60px;
  }

  .fade-bottom {
    height: 60px;
  }
}

/* Ensure smooth scrolling fallback */
html {
  scroll-behavior: smooth;
}

/* Improve scroll performance */
body {
  will-change: scroll-position;
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  img,
  video {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  
  .img-item {
    contain: layout style paint;
  }
  
  .nav-container {
    will-change: scroll-position;
  }
}

/* Loading states */
.img-item.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
}

.img-item.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--glass-border);
  border-top: 2px solid var(--accent-lime);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}