/* Masonry Gallery Style - Inspired by senseiswagminiart.com */

html {
  scroll-behavior: smooth;
}

.works{
  padding-top: 18px;
  padding-bottom: 60px;
}

.works-hero{
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  gap: 6px;
  text-transform: uppercase;
  margin-bottom: 48px;
  animation: fadeIn 0.7s ease both;
}

.works-title{
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.8rem, 4.6vw, 4.5rem);
  letter-spacing: 0em;
  line-height: 0.95;
}

.works-subtitle{
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 16px;
  color: var(--muted);
  margin-top: 8px;
}

.works-add-btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px dashed var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  width: fit-content;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.works-add-btn:hover{
  transform: translateY(-1px);
  background: rgba(11,11,11,.04);
  border-color: var(--ink);
}

#empty-works {
  color: var(--ink);
  font-weight: 600;
}

/* Search and Filter Section */
.search-filter-section{
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 48px;
  animation: fadeIn 0.7s ease both;
}

.search-bar{
  position: relative;
  width: 100%;
}

.search-bar input{
  width: 100%;
  padding: 14px 48px 14px 20px;
  border: 2px solid var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
  transition: all 0.3s ease;
}

.search-bar input:focus{
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-bar input::placeholder{
  color: var(--muted);
}

.search-icon{
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.filter-buttons{
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-btn{
  padding: 10px 24px;
  border: 2px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover{
  border-color: var(--ink);
  background: rgba(11,11,11,.04);
  transform: translateY(-1px);
}

.filter-btn.active{
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.project-section.hidden{
  display: none;
}

.no-results{
  text-align: center;
  padding: 60px 20px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--muted);
  display: none;
}

.no-results.show{
  display: block;
}

/* Masonry Grid Layout */
.works-gallery-grid{
  display: flex;
  flex-direction: column;
  gap: 80px;
  animation: fadeIn 0.8s ease both;
}

.project-section{
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
  width: 100%;
}

.project-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.project-actions{
  display: flex;
  gap: 8px;
}

.btn-edit, .btn-delete{
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
}

.btn-edit{
  color: var(--ink);
}

.btn-edit:hover{
  background: var(--ink);
  color: var(--bg);
}

.btn-delete{
  color: #dc3545;
  border-color: #dc3545;
}

.btn-delete:hover{
  background: #dc3545;
  color: white;
}

.project-title{
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(18px, 2.5vw, 24px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  width: 100%;
  word-wrap: break-word;
}

.project-description{
  margin: -12px 0 0 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  width: 100%;
  word-wrap: break-word;
}

.no-projects{
  text-align: center;
  padding: 60px 20px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--muted);
}

/* Carousel Styles */
.project-carousel{
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.carousel-container{
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--rule);
  border-radius: 8px;
  overflow: hidden;
}

.carousel-track{
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-slide{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
  cursor: pointer;
}

.carousel-slide.active{
  opacity: 1;
  z-index: 1;
}

.carousel-slide img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.carousel-btn{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.3s ease;
  opacity: 0;
}

.carousel-container:hover .carousel-btn{
  opacity: 1;
}

.carousel-btn:hover{
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-50%) scale(1.1);
}

.carousel-prev{
  left: 16px;
}

.carousel-next{
  right: 16px;
}

.carousel-pagination{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px;
  flex-wrap: wrap;
}

.pagination-thumb{
  width: 80px;
  height: 60px;
  border-radius: 4px;
  border: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.pagination-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.pagination-thumb::after{
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s ease;
}

.pagination-thumb:hover{
  border-color: var(--ink);
  transform: translateY(-2px);
}

.pagination-thumb:hover img{
  transform: scale(1.1);
}

.pagination-thumb:hover::after{
  opacity: 0;
}

.pagination-thumb.active{
  border-color: var(--ink);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pagination-thumb.active::after{
  opacity: 0;
}

.project-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
}

.grid-item{
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.grid-item:hover{
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.grid-item img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.grid-item:hover img{
  transform: scale(1.05);
}

/* Responsive adjustments */
@media (max-width: 768px){
  .works-gallery-grid{
    gap: 60px;
  }
  
  .project-grid{
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
  }
  
  .project-section{
    gap: 18px;
  }
}

@media (max-width: 480px){
  .works-gallery-grid{
    gap: 48px;
  }
  
  .project-grid{
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .works-hero{
    margin-bottom: 32px;
  }
}

/* Lightbox Styles */
.lightbox{
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.lightbox.is-open{
  display: flex;
}

.lightbox-content{
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img{
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close{
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 48px;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10000;
  transition: opacity 0.2s ease;
}

.lightbox-close:hover{
  opacity: 0.7;
}

.lightbox-prev,
.lightbox-next{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 60px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: background 0.2s ease;
}

.lightbox-prev:hover,
.lightbox-next:hover{
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev{
  left: 30px;
}

.lightbox-next{
  right: 30px;
}

@media (max-width: 768px){
  .lightbox-close{
    top: 10px;
    right: 15px;
    font-size: 36px;
  }
  
  .lightbox-prev,
  .lightbox-next{
    font-size: 40px;
    width: 50px;
    height: 50px;
  }
  
  .lightbox-prev{
    left: 15px;
  }
  
  .lightbox-next{
    right: 15px;
  }
}

.works-search{
  display: flex;
  gap: 6px;
  align-items: center;
}
.works-search input{
  border: 1px solid var(--rule);
  padding: 8px 10px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
}
.works-search button{
  border: 1px solid var(--rule);
  background: var(--bg);
  padding: 8px 12px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.works-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag-chip{
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--bg);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tag-chip.is-active{
  background: var(--ink);
  color: var(--bg);
}

.works-masonry{
  column-count: 3;
  column-gap: 16px;
}

.work-item{
  break-inside: avoid;
  margin: 0 0 16px;
  display: inline-block;
  width: 100%;
  cursor: pointer;
  opacity: 0;
  transform: translateY(24px);
}

.work-item.is-visible{
  animation: cascadeUp 0.65s ease forwards;
  animation-delay: var(--cascade-delay, 0s);
}

.work-img{
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
  background: #111;
}

.work-img img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1);
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.work-img::after{
  content:"";
  position:absolute;
  inset:0;
  background: rgba(0,0,0,0.08);
  opacity:0;
  transition: opacity 0.3s ease;
}

.work-item:hover .work-img img{
  transform: scale(1.03);
  opacity: 0.95;
}

.work-item:hover .work-img::after{
  opacity:1;
}

.work-item figcaption{
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  text-align: left;
  margin-top: 6px;
  transition: color 0.3s ease, transform 0.3s ease;
}

@media (min-width: 1100px){
  .works-masonry{
    column-count: 4;
  }
}

@media (max-width: 900px){
  .works-masonry{
    column-count: 2;
  }
}

@media (max-width: 600px){
  .works-masonry{
    column-count: 1;
  }
}

/* Animations */
@keyframes fadeIn{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}

@keyframes popIn{
  from{ opacity:0; transform: scale(0.96); }
  to{ opacity:1; transform: scale(1); }
}

@keyframes cascadeUp{
  from{ opacity:0; transform: translateY(28px); }
  to{ opacity:1; transform: translateY(0); }
}

/* Stagger work items */
.work-item:nth-child(1){ --cascade-delay: 0.05s; }
.work-item:nth-child(2){ --cascade-delay: 0.1s; }
.work-item:nth-child(3){ --cascade-delay: 0.15s; }
.work-item:nth-child(4){ --cascade-delay: 0.2s; }
.work-item:nth-child(5){ --cascade-delay: 0.25s; }
.work-item:nth-child(6){ --cascade-delay: 0.3s; }
.work-item:nth-child(7){ --cascade-delay: 0.35s; }
.work-item:nth-child(8){ --cascade-delay: 0.4s; }

/* Responsive Carousel Styles */
@media (max-width: 768px){
  .carousel-container{
    aspect-ratio: 4/3;
  }
  
  .carousel-btn{
    width: 40px;
    height: 40px;
    opacity: 0.8;
  }
  
  .carousel-prev{
    left: 8px;
  }
  
  .carousel-next{
    right: 8px;
  }
  
  .pagination-thumb{
    width: 60px;
    height: 45px;
  }
  
  .carousel-pagination{
    gap: 8px;
  }
  
  .search-filter-section{
    margin-bottom: 32px;
  }
  
  .filter-buttons{
    gap: 8px;
  }
  
  .filter-btn{
    padding: 8px 16px;
    font-size: 12px;
  }
}

@media (max-width: 480px){
  .carousel-container{
    aspect-ratio: 1/1;
  }
  
  .carousel-btn{
    width: 36px;
    height: 36px;
  }
  
  .carousel-btn svg{
    width: 18px;
    height: 18px;
  }
  
  .pagination-thumb{
    width: 50px;
    height: 38px;
  }
  
  .carousel-pagination{
    gap: 6px;
  }
  
  .search-bar input{
    padding: 12px 40px 12px 16px;
    font-size: 14px;
  }
  
  .filter-btn{
    padding: 7px 14px;
    font-size: 11px;
  }
}

.filter-bar{
  margin: 0 0 32px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.filter-bar__top{
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.filter-bar__label{
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.filter-bar__chips{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip{
  padding: 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  transition: all 0.2s ease;
}
.filter-chip:hover{
  border-color: var(--ink);
  background: rgba(11,11,11,.04);
}
.filter-chip.is-active{
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.filter-bar__note{
  margin-top: 8px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}

[data-theme="dark"] .filter-chip:hover{
  background: rgba(255,255,255,.08);
}

.filter-search{
  display: flex;
  gap: 8px;
  align-items: center;
}
.filter-search input{
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.2s ease;
}
.filter-search input:focus{
  outline: none;
  border-color: var(--ink);
}
.filter-search button{
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  padding: 8px 14px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-search button:hover{
  border-color: var(--ink);
  background: rgba(11,11,11,.04);
}

[data-theme="dark"] .filter-search button:hover{
  background: rgba(255,255,255,.08);
}