/* ============================================
   Cases Gallery — 动态酷炫瀑布流画廊
   ============================================ */

/* ============ Stats Strip ============ */
.cases-stats {
  display: flex;
  justify-content: center;
  gap: 64px;
  margin-top: 48px;
  flex-wrap: wrap;
  position: relative;
}
.cases-stat {
  text-align: left;
  position: relative;
  padding-left: 16px;
}
.cases-stat::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 2px;
}
.cases-stat-num {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  display: inline-block;
}
.cases-stat-plus {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-left: 2px;
}
.cases-stat > div:last-child {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

/* ============ Masonry Gallery ============ */
.gallery-masonry {
  columns: 3;
  column-gap: 24px;
  margin-top: 32px;
}
.gallery-item {
  break-inside: avoid;
  margin-bottom: 24px;
  display: block;
  cursor: pointer;
  position: relative;
}

.gallery-card {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transform: translateY(40px);
  opacity: 0;
  animation: cardReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.5s ease,
              border-color 0.5s ease;
}
.gallery-item:nth-child(1) .gallery-card { animation-delay: 0.05s; }
.gallery-item:nth-child(2) .gallery-card { animation-delay: 0.1s; }
.gallery-item:nth-child(3) .gallery-card { animation-delay: 0.15s; }
.gallery-item:nth-child(4) .gallery-card { animation-delay: 0.2s; }
.gallery-item:nth-child(5) .gallery-card { animation-delay: 0.25s; }
.gallery-item:nth-child(6) .gallery-card { animation-delay: 0.3s; }
.gallery-item:nth-child(7) .gallery-card { animation-delay: 0.35s; }
.gallery-item:nth-child(8) .gallery-card { animation-delay: 0.4s; }
.gallery-item:nth-child(9) .gallery-card { animation-delay: 0.45s; }
.gallery-item:nth-child(10) .gallery-card { animation-delay: 0.5s; }
.gallery-item:nth-child(11) .gallery-card { animation-delay: 0.55s; }
.gallery-item:nth-child(12) .gallery-card { animation-delay: 0.6s; }

@keyframes cardReveal {
  to { transform: translateY(0); opacity: 1; }
}

.gallery-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  border-color: var(--primary);
}

.gallery-image {
  position: relative;
  overflow: hidden;
  background: var(--bg-muted);
  display: block;
}
.gallery-image::before {
  content: '';
  display: block;
  padding-bottom: 66%;
}
.gallery-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.gallery-card:hover .gallery-image img {
  transform: scale(1.08);
}

/* Overlay */
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(15, 23, 42, 0) 0%,
    rgba(15, 23, 42, 0.4) 50%,
    rgba(15, 23, 42, 0.92) 100%);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: white;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.gallery-card:hover .gallery-overlay,
.gallery-card.is-touched .gallery-overlay {
  opacity: 1;
  transform: translateY(0);
}

.gallery-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  border-radius: 4px;
  margin-bottom: 12px;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.4s ease 0.05s, transform 0.4s ease 0.05s;
}
.gallery-card:hover .gallery-tag,
.gallery-card.is-touched .gallery-tag {
  transform: translateY(0);
  opacity: 1;
}
.gallery-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  line-height: 1.3;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.4s ease 0.1s, transform 0.4s ease 0.1s;
}
.gallery-card:hover .gallery-title,
.gallery-card.is-touched .gallery-title {
  transform: translateY(0);
  opacity: 1;
}
.gallery-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  line-height: 1.5;
  margin-bottom: 12px;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.4s ease 0.15s, transform 0.4s ease 0.15s;
}
.gallery-card:hover .gallery-desc,
.gallery-card.is-touched .gallery-desc {
  transform: translateY(0);
  opacity: 1;
}
.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.4s ease 0.2s, transform 0.4s ease 0.2s;
}
.gallery-card:hover .gallery-tags,
.gallery-card.is-touched .gallery-tags {
  transform: translateY(0);
  opacity: 1;
}
.gallery-tags span {
  font-size: 11px;
  color: rgba(255,255,255,0.9);
  padding: 3px 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  backdrop-filter: blur(8px);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.gallery-zoom {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: scale(0.5) rotate(-45deg);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.gallery-card:hover .gallery-zoom,
.gallery-card.is-touched .gallery-zoom {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}
.gallery-zoom svg { width: 18px; height: 18px; }

/* Subtle inner shine on hover */
.gallery-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.gallery-card:hover::after { opacity: 1; }

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.96);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(20px);
}
.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-content {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 48px;
  max-width: 1400px;
  width: 100%;
  max-height: 80vh;
  align-items: center;
  transform: scale(0.95);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox.open .lightbox-content { transform: scale(1); }
.lightbox-content img {
  width: 100%;
  height: 80vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  background: var(--bg-deep);
}
.lightbox-info { color: white; }
.lightbox-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  border-radius: 4px;
  margin-bottom: 16px;
  text-transform: uppercase;
}
.lightbox-title {
  font-size: 32px;
  color: white;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.lightbox-desc {
  font-size: 16px;
  color: rgba(255,255,255,0.75);
  line-height: 1.7;
  margin-bottom: 24px;
}
.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lightbox-tags span {
  font-size: 12px;
  color: var(--accent);
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 4px;
  font-family: var(--font-display);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 300;
}
.lightbox-close {
  top: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 32px;
  line-height: 1;
}
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 32px;
  line-height: 1;
}
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: var(--primary);
  border-color: var(--primary);
}
.lightbox-counter {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 100px;
  backdrop-filter: blur(12px);
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .gallery-masonry { columns: 2; }
  .lightbox-content { grid-template-columns: 1fr; gap: 24px; }
  .lightbox-content img { height: 50vh; }
  .lightbox-info { text-align: center; }
  .lightbox-tags { justify-content: center; }
  .lightbox-prev, .lightbox-next { width: 44px; height: 44px; font-size: 24px; }
  .cases-stats { gap: 32px; }
  .cases-stat-num { font-size: 32px; }
}
@media (max-width: 640px) {
  .gallery-masonry { columns: 1; }
  .lightbox { padding: 20px; }
  .lightbox-close { top: 12px; right: 12px; width: 40px; height: 40px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .cases-stats { gap: 24px; }
  .cases-stat-num { font-size: 28px; }
  .gallery-overlay {
    opacity: 1;
    transform: translateY(0);
    background: linear-gradient(180deg, transparent 40%, rgba(15, 23, 42, 0.95) 100%);
  }
  .gallery-tag, .gallery-title, .gallery-desc, .gallery-tags {
    opacity: 1;
    transform: translateY(0);
  }
  .gallery-zoom { display: none; }
}

/* ============ Filter Animation ============ */
.gallery-item.is-hidden {
  display: none;
}
.gallery-item.is-shown {
  animation: cardReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
