/* ===========================
   Portfolio stylesheet
   =========================== */

/* Reset & base setup */
* {
  box-sizing: border-box; /* include padding & border in element width/height */
}

html, body {
  height: 100%; /* full height so flex and vh calculations work properly */
}

body {
  margin: 0; /* remove browser default margin */
  font-family: Helvetica, Arial, sans-serif; /* clean sans-serif font */
  background: white; /* white page background */
  color: black; /* default text color */
  overflow-y: auto; /* ensure only one scrollbar (page-level scroll only) */
  -webkit-font-smoothing: antialiased; /* smoother text on macOS */
}

/* Main container: sidebar on the left, gallery on the right */
.container {
  display: flex;
  min-height: 100vh; /* allow scrolling if gallery is long */
}

/* -----------------------
   Sidebar (fixed left nav)
   ----------------------- */
.sidebar {
  width: 250px; /* fixed sidebar width */
  /* padding shrinks with viewport size:
     top uses vh so it shrinks with height,
     left/right use vw so they shrink with width */
  padding: clamp(20px, 6vh, 80px)   /* top */
           clamp(20px, 6vh, 80px)   /* right → same as top now */
           clamp(20px, 3vh, 40px)   /* bottom */
           clamp(30px, 5vw, 80px);  /* left */
  position: fixed; /* sidebar stays in place while scrolling */
  height: 100%;    /* full viewport height */
}

.sidebar nav {
  margin-top: 20px; /* push nav links down a bit */
}

.sidebar ul {
  list-style: none; /* no bullets */
  padding: 0;
  margin: 0;
}

.sidebar ul li {
  margin-bottom: 15px; /* spacing between links */
}

.sidebar ul li a {
  text-decoration: none; /* remove underline */
  color: black; /* black links */
}

.sidebar ul li a.active {
  font-weight: 700; /* bold current gallery */
}

/* -----------------------
   Content & gallery area
   ----------------------- */
.content,
.gallery {
  margin-left: 280px; /* leave space for the fixed sidebar */
  /* top and right paddings are now equal for symmetry */
  padding: clamp(20px, 6vh, 80px) /* top & bottom */
           clamp(20px, 6vh, 80px); /* left & right */
}

/* -----------------------
   Gallery grid layout
   ----------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 images per row */
  gap: 20px; /* space between items */
  align-content: start; /* start items at the top of the grid */
}

/* Wrapper around each image */
.thumb {
  overflow: hidden; /* clip if child grows */
  transition: transform 0.28s ease, box-shadow 0.28s ease; /* animate growth */
}

/* Hover effect on the wrapper (instead of zooming the image) */
.thumb:hover {
  transform: scale(1.03); /* grow slightly */
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* Gallery images */
.gallery img {
  display: block; /* remove inline gap below images */
  width: 100%; /* fill the cell width */
  height: auto; /* preserve aspect ratio */
  object-fit: cover; /* crop gracefully if aspect ratio differs */
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

.gallery img.loaded {
  opacity: 1;
}

/* Progressive loading container */
.thumb {
  position: relative;
  background-color: #f0f0f0; /* Light placeholder color */
}

/* Loading indicator */
.thumb::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  animation: loading-spinner 0.8s linear infinite;
  z-index: 1;
}

.thumb.loaded::before {
  display: none;
}

@keyframes loading-spinner {
  to { transform: rotate(360deg); }
}

/* Error handling styles */
.thumb.error::before {
  display: none;
}

.error-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 15px;
  border-radius: 4px;
  font-size: 14px;
  color: #555;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* -----------------------
   Lightbox overlay
   ----------------------- */
.lightbox {
  display: none; /* hidden until opened */
  position: fixed;
  z-index: 2000; /* above everything */
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.97); /* white semi-transparent bg */
  justify-content: center; /* center image horizontally */
  align-items: center; /* center image vertically */
}

/* Download button */
.download-btn {
  position: absolute;
  bottom: 18px;
  right: 20px;
  font-size: 28px;
  cursor: pointer;
  color: black;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 12px;
  border-radius: 50%;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.download-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lightbox-content {
  max-width: 92vw; /* keep inside viewport */
  max-height: 92vh; /* keep inside viewport */
  box-shadow: 0 8px 30px rgba(0,0,0,0.2); /* give photo some depth */
}

/* Close button (X) */
.close {
  position: absolute;
  top: 18px;
  right: 30px;
  font-size: 38px;
  cursor: pointer;
  color: black; /* visible against white bg */
}

/* Navigation arrows */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%); /* center vertically */
  font-size: 48px;
  cursor: pointer;
  color: black; /* visible on white bg */
  padding: 8px;
  user-select: none; /* prevent text selection */
}

.prev { left: 18px; }
.next { right: 18px; }

/* -----------------------
   Responsive adjustments
   ----------------------- */
@media (max-width: 800px) {
  .container {
    flex-direction: row; /* Change to row to allow sidebar and content side by side */
  }

  .sidebar {
    position: fixed; /* Keep sidebar fixed */
    width: 180px; /* Smaller width on mobile */
    padding: 18px 12px; /* Compact padding */
    height: 100%; /* Full height */
    overflow-y: auto; /* Allow scrolling within sidebar if needed */
    z-index: 10; /* Ensure sidebar is above content */
  }

  .sidebar nav {
    margin-top: 10px; /* Tighter spacing */
  }

  .content,
  .gallery {
    margin-left: 180px; /* Match the sidebar width */
    padding: 18px; /* Equal padding around content */
    width: calc(100% - 180px); /* Adjust width to account for sidebar */
  }

  .gallery {
    grid-template-columns: 1fr; /* One image per row */
    gap: 24px; /* Slightly tighter gap on small screens */
  }

  .thumb:hover {
    transform: scale(1.01); /* Smaller growth on mobile */
  }
}

/* Extra small screens (phones) */
@media (max-width: 480px) {
  .sidebar {
    width: 120px; /* Even smaller sidebar on phones */
  }
  
  .content,
  .gallery {
    margin-left: 120px; /* Match the new sidebar width */
    width: calc(100% - 120px); /* Adjust width accordingly */
    padding: 12px; /* Even smaller padding */
  }
  
  .gallery {
    gap: 16px; /* Tighter spacing between images */
  }
}
