/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background-color: #e8e8e8;
  color: #333;
  line-height: 1.6;
}

/* Container */
.container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 300px;
  background-color: #e8e8e8;
  padding: 70px 70px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar h1 {
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 60px;
  color: #000;
}

/* Navigation */
nav ul {
  list-style: none;
  margin-bottom: 50px;
}

nav ul li {
  margin-bottom: 8px;
}

nav ul li a {
  color: #888;
  text-decoration: none;
  font-size: 15px;
  transition: color 0.3s ease;
}

nav ul li a:hover,
nav ul li a.active {
  color: #000;
}

/* Secondary Links */
.secondary-nav {
  margin-top: 100px;
}

.secondary-nav a {
  display: block;
  color: #aaa;
  text-decoration: none;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  transition: color 0.3s ease;
}

.secondary-nav a:hover {
  color: #666;
}

/* Main Content Area */
.main-content {
  margin-left: 300px;
  flex: 1;
  padding: 60px 60px 60px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh; /* Ensures full viewport height */
}

/* Image Container */
.image-container {
  max-width: 1200px;
  max-height: calc(100vh - 120px); /* 120px accounts for padding (60px top + 60px bottom) */
  width: 100%;
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.image-container img {
  max-width: 100%;
  max-height: calc(100vh - 120px); /* Constrains height to viewport */
  width: auto;
  height: auto;
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s ease;
  object-fit: contain; /* Preserves aspect ratio */
}

/* Navigation Controls */
.image-controls {
  margin-top: 20px;
  display: flex;
  gap: 20px;
  align-items: center;
}

.image-controls button {
  background: none;
  border: none;
  color: #000;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.3s ease;
  font-family: inherit;
}

.image-controls button:hover:not(:disabled) {
  color: #666;
}

.image-controls button:disabled {
  color: #ccc;
  cursor: not-allowed;
}

.thumbnail-toggle {
  color: #888;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.thumbnail-toggle:hover {
  color: #000;
}

/* Thumbnail Grid - Masonry Layout */
.thumbnail-grid {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 1200px;
  padding: 0;
  align-self: flex-start; /* Allows grid to scroll if needed */
  max-height: none; /* Remove height constraint for thumbnails */
}

.thumbnail-grid.active {
  display: grid;
}

.thumbnail-item {
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background-color: #ccc;
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: block;
}

.thumbnail-item:hover img {
  transform: scale(1.02);
  opacity: 0.85;
}

/* Masonry-style sizing - different sizes for variety */
.thumbnail-item:nth-child(1) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(2) {
  grid-column: span 1;
  grid-row: span 2; /* Tall */
}

.thumbnail-item:nth-child(3) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(4) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(5) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(6) {
  grid-column: span 1;
  grid-row: span 1;
}

/* Repeat pattern for more items */
.thumbnail-item:nth-child(6n+1) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(6n+2) {
  grid-column: span 1;
  grid-row: span 2;
}

.thumbnail-item:nth-child(6n+3) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(6n+4) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(6n+5) {
  grid-column: span 1;
  grid-row: span 1;
}

.thumbnail-item:nth-child(6n+6) {
  grid-column: span 1;
  grid-row: span 1;
}

/* Hide single image view when thumbnails are shown */
.image-container.hidden {
  display: none;
}

/* Thumbnail toggle active state */
.thumbnail-toggle.active {
  color: #000;
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1400px) {
  .thumbnail-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 968px) {
  .sidebar {
    width: 200px;
    padding: 50px 30px;
  }
  
  .main-content {
    margin-left: 200px;
    padding: 40px 40px 40px 20px;
  }
  
  .image-container {
    max-height: calc(100vh - 80px);
  }
  
  .image-container img {
    max-height: calc(100vh - 80px);
  }
  
  .thumbnail-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  /* Adjust masonry pattern for 2 columns */
  .thumbnail-item:nth-child(4n+1) {
    grid-row: span 1;
  }
  
  .thumbnail-item:nth-child(4n+2) {
    grid-row: span 2;
  }
  
  .thumbnail-item:nth-child(4n+3) {
    grid-row: span 1;
  }
  
  .thumbnail-item:nth-child(4n+4) {
    grid-row: span 1;
  }
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
    padding: 30px 20px;
  }
  
  .main-content {
    margin-left: 0;
    padding: 40px;
    min-height: auto;
  }
  
  .image-container {
    max-height: calc(100vh - 80px);
  }
  
  .image-container img {
    max-height: calc(100vh - 80px);
  }
  
  .sidebar h1 {
    margin-bottom: 30px;
  }
  
  nav ul {
    margin-bottom: 30px;
  }

  .thumbnail-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  /* Simpler pattern for mobile */
  .thumbnail-item:nth-child(odd) {
    grid-row: span 1;
  }
  
  .thumbnail-item:nth-child(even) {
    grid-row: span 1;
  }
}

@media (max-width: 480px) {
  .thumbnail-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .thumbnail-item {
    grid-row: span 1 !important;
  }
}