/* ─── UI Gallery Stylesheet ─────────────────────────────────────────────── */

/* ── Container with Safe Negative Space ───────────────────────────────────── */
.gallery-container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

@media (min-width: 640px) {
  .gallery-container {
    padding-inline: 2.25rem;
  }
}

@media (min-width: 1024px) {
  .gallery-container {
    padding-inline: 3.5rem;
  }
}

/* ── Hero Section ────────────────────────────────────────────────────────── */
.gallery-hero {
  padding-top: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: none;
}

@media (min-width: 768px) {
  .gallery-hero {
    padding-top: 3rem;
    padding-bottom: 2rem;
  }
}

.gallery-hero-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 1.25rem;
  transition: color 0.2s ease;
}

.gallery-hero-back:hover {
  color: var(--foreground);
}

.gallery-hero-back svg {
  transition: transform 0.2s ease;
}

.gallery-hero-back:hover svg {
  transform: translateX(-3px);
}

.gallery-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--foreground);
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* ── Gallery Content Section ─────────────────────────────────────────────── */
.gallery-content-section {
  border-top: none !important;
  padding-top: 1.5rem;
  padding-bottom: 5rem;
}

/* ── Dynamic Masonry Gallery Grid ────────────────────────────────────────── */
.gallery-masonry {
  column-count: 1;
  column-gap: 2rem;
}

@media (min-width: 680px) {
  .gallery-masonry {
    column-count: 2;
    column-gap: 2rem;
  }
}

@media (min-width: 1100px) {
  .gallery-masonry {
    column-count: 2;
    column-gap: 2.5rem;
  }
}

/* Featured panoramic cards that span both columns on wide viewports */
.gallery-card.featured-panoramic {
  column-span: all;
  margin-bottom: 2.5rem;
}

/* ── Gallery Card ────────────────────────────────────────────────────────── */
.gallery-card {
  break-inside: avoid;
  margin-bottom: 2rem;
  background-color: #ffffff;
  border: 1px solid rgba(228, 228, 228, 0.5);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 1.25rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.gallery-card:hover {
  transform: translateY(-3px);
  border-color: var(--border);
  background-color: #ffffff;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.08),
              0 4px 10px -2px rgba(0, 0, 0, 0.04);
}

.gallery-card:active {
  transform: translateY(-1px) scale(0.995);
  border-color: var(--border);
  background-color: #ffffff;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
  transition-duration: 0.1s;
}

/* Card Visual Frame */
.gallery-card-visual {
  position: relative;
  width: 100%;
  background-color: #f7f7f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.gallery-card-visual img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card:hover .gallery-card-visual img {
  transform: scale(1.02);
}

/* Hover Zoom Pill */
.gallery-card-zoom-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background-color: rgba(26, 26, 26, 0.82);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.gallery-card:hover .gallery-card-zoom-badge {
  opacity: 1;
  transform: translateY(0);
}

/* Card Content / Caption */
.gallery-card-info {
  padding: 1.35rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.gallery-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.125rem;
}

.gallery-card-category {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.gallery-card-platform {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  background-color: #f6f6f6;
  background-color: color-mix(in srgb, var(--secondary) 50%, transparent);
  padding: 0.2rem 0.625rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.gallery-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--foreground);
  line-height: 1.3;
}

.gallery-card-desc {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted-foreground);
}

/* Special treatment for vertical / device cards (Apple Watch & Wallet) */
.gallery-card.device-card .gallery-card-visual {
  padding: 2rem 1.5rem;
  background: radial-gradient(circle, #fafafa 0%, #eaeaea 100%);
}

.gallery-card.device-card .gallery-card-visual img {
  max-height: 480px;
  width: auto;
  margin-inline: auto;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.12));
}

/* Special treatment for panoramic totum icon card (white space around icons) */
.gallery-card.featured-panoramic .gallery-card-visual {
  background-color: #ffffff;
  padding: 2.25rem 1.5rem;
}

@media (min-width: 640px) {
  .gallery-card.featured-panoramic .gallery-card-visual {
    padding: 3rem 2.5rem;
  }
}

@media (min-width: 1024px) {
  .gallery-card.featured-panoramic .gallery-card-visual {
    padding: 3.75rem 3.5rem;
  }
}

.gallery-card.featured-panoramic .gallery-card-visual img {
  width: 100%;
  max-width: 860px;
  height: auto;
  margin-inline: auto;
}


/* ── Lightbox Modal ──────────────────────────────────────────────────────── */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lightbox-modal.is-open {
  display: flex;
  opacity: 1;
}

body.lightbox-open {
  overflow: hidden;
}

/* Lightbox Top Bar */
.lightbox-topbar {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  color: #ffffff;
}

.lightbox-counter {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  background-color: rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.lightbox-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Lightbox Content */
.lightbox-stage {
  position: relative;
  width: 100%;
  max-width: 1200px;
  max-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.lightbox-img-wrapper {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.25s ease;
}

/* Lightbox Navigation Controls */
.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.2s, transform 0.2s;
}

.lightbox-arrow:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-arrow.prev {
  left: 0.5rem;
}

.lightbox-arrow.next {
  right: 0.5rem;
}

@media (min-width: 768px) {
  .lightbox-arrow.prev { left: -4rem; }
  .lightbox-arrow.next { right: -4rem; }
}

/* Lightbox Bottom Caption */
.lightbox-caption {
  position: absolute;
  bottom: 1.25rem;
  left: 1.5rem;
  right: 1.5rem;
  text-align: center;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

.lightbox-caption-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lightbox-caption-sub {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 38rem;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .gallery-card-visual img {
    max-height: 320px;
  }
  .lightbox-arrow {
    width: 2.25rem;
    height: 2.25rem;
  }
  .lightbox-arrow.prev { left: 0.25rem; }
  .lightbox-arrow.next { right: 0.25rem; }
}
