/* ============================================
   WORKS PAGE
   ============================================ */

/* --- GRID --- */
.works-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}

/* --- GRID ITEM --- */
.works-grid-item {
  aspect-ratio: 1;
  background: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* --- DEFAULT STATE --- */
.item-number {
  position: absolute;
  font-family: 'Ubzidenz', sans-serif;
  font-size: 20px;
  line-height: 20px;
  letter-spacing: 0.02em;
  color: #000;
  left: 12.5%;
  bottom: calc(12.5% + 65% + 8px);
  z-index: 2;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.item-drawing-wrap {
  position: absolute;
  width: 75%;
  height: 75%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.item-drawing-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* --- HOVER STATE --- */
.item-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: scale(1.02);
}

.item-title {
  position: absolute;
  top: 2px;
  left: 0;
  font-family: 'Ubzidenz', sans-serif;
  font-size: 20px;
  line-height: 20px;
  letter-spacing: 0.02em;
  color: #000;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.works-grid-item:hover .item-photo {
  opacity: 1;
  transform: scale(1);
}
.works-grid-item:hover .item-title        { opacity: 1; }
.works-grid-item:hover .item-number       { opacity: 0; }
.works-grid-item:hover .item-drawing-wrap { opacity: 0; }

/* --- REVERT HOVER WHILE OVERLAY IS OPEN --- */
body:has(.overlay-backdrop.active) .works-grid-item:hover .item-photo        { opacity: 0; }
body:has(.overlay-backdrop.active) .works-grid-item:hover .item-title        { opacity: 0; }
body:has(.overlay-backdrop.active) .works-grid-item:hover .item-number       { opacity: 1; }
body:has(.overlay-backdrop.active) .works-grid-item:hover .item-drawing-wrap { opacity: 1; }

/* --- OVERLAY BACKDROP --- */
.overlay-backdrop {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 200;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.overlay-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* --- OVERLAY --- */
.overlay {
  width: calc((100vw - 120px) / 3 + 16px);
  background: #fff;
  padding: 8px;
  transform: scale(0.96);
  transition: transform 0.4s ease;
}

.overlay-backdrop.active .overlay {
  transform: scale(1);
}

.overlay-title {
  font-family: 'Ubzidenz', sans-serif;
  font-size: 20px;
  line-height: 20px;
  letter-spacing: 0.02em;
  color: #000;
  margin-bottom: 8px;
}

.overlay-image-wrap {
  position: relative;
  overflow: hidden;
}

.overlay-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.overlay-zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  z-index: 2;
}

.overlay-zone-left  { left: 0;  cursor: w-resize; }
.overlay-zone-right { right: 0; cursor: e-resize; }

.overlay-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  gap: 8px;
}

.overlay-description {
  font-family: 'SimSong', serif;
  font-size: 18px;
  line-height: 18px;
  color: #000;
}

.overlay-counter {
  font-family: 'SimSong', serif;
  font-size: 18px;
  line-height: 18px;
  color: #000;
  white-space: nowrap;
  flex-shrink: 0;
  padding-left: 16px;
}

/* --- BREAKPOINT 1: 4 columns --- */
@media (max-width: 1200px) {
  .works-grid { grid-template-columns: repeat(4, 1fr); }
  .overlay    { width: calc((100vw - 88px) / 2 + 16px); }
}

/* --- BREAKPOINT 2: 2 columns --- */
@media (max-width: 600px) {
  .works-grid { grid-template-columns: repeat(2, 1fr); }
  .overlay    { width: calc(100vw - 40px); }
  /* disable the hover swap on touch — keep the default drawing/number visible */
  .works-grid-item:hover .item-photo        { opacity: 0; }
  .works-grid-item:hover .item-title        { opacity: 0; }
  .works-grid-item:hover .item-number       { opacity: 1; }
  .works-grid-item:hover .item-drawing-wrap { opacity: 1; }
}
