/* Gallery — 3D coverflow (phone-style cards) */
.gallery-section.gallery-coverflow {
  position: relative;
  padding: clamp(3.5rem, 8vw, 6.5rem) 0 clamp(3rem, 7vw, 5.5rem);
  overflow: hidden;
}

.gallery-section.gallery-coverflow::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 40% at 50% 0%, rgba(234, 59, 6, 0.12), transparent 60%),
    radial-gradient(ellipse 40% 35% at 15% 80%, rgba(139, 92, 246, 0.08), transparent 55%);
  pointer-events: none;
}

.gallery-coverflow__head {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-bottom: clamp(1.5rem, 4vw, 2.75rem);
  max-width: 36rem;
  margin-inline: auto;
}

.gallery-coverflow__head h2 {
  font-size: clamp(1.65rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 0.55rem;
  color: var(--text-primary, #fff);
  unicode-bidi: plaintext;
}

.gallery-coverflow__head h2 .accent {
  color: var(--primary, #ea3b06);
}

.gallery-coverflow__head p {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--text-secondary, #9ca3af);
  letter-spacing: 0.04em;
  unicode-bidi: plaintext;
}

.gallery-coverflow__viewport {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  height: clamp(340px, 58vw, 520px);
  perspective: 1200px;
  perspective-origin: 50% 50%;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.gallery-coverflow__viewport.is-dragging {
  cursor: grabbing;
}

.gallery-coverflow__track {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.gallery-coverflow__card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(140px, 22vw, 220px);
  aspect-ratio: 9 / 16;
  margin: 0;
  padding: 0;
  border: none;
  background: #111;
  border-radius: 18px;
  overflow: hidden;
  transform-origin: center center;
  transform-style: preserve-3d;
  transition:
    transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.45s ease,
    box-shadow 0.45s ease,
    filter 0.45s ease;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  will-change: transform, opacity;
  cursor: pointer;
}

.gallery-coverflow__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.gallery-coverflow__card.is-center {
  box-shadow:
    0 0 0 1px rgba(234, 59, 6, 0.35),
    0 22px 50px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(234, 59, 6, 0.18);
  cursor: default;
}

.gallery-coverflow__card.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.gallery-coverflow__nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.35rem;
}

.gallery-coverflow__btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.gallery-coverflow__btn:hover {
  background: rgba(234, 59, 6, 0.2);
  border-color: rgba(234, 59, 6, 0.55);
}

.gallery-coverflow__btn:active {
  transform: scale(0.96);
}

.gallery-coverflow__btn:focus-visible {
  outline: 2px solid var(--primary, #ea3b06);
  outline-offset: 3px;
}

.gallery-coverflow__dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 220px;
}

.gallery-coverflow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.gallery-coverflow__dot.is-active {
  background: var(--primary, #ea3b06);
  transform: scale(1.25);
}

/* Legacy size classes kept harmless for CMS size flag */
.gallery-coverflow .gallery-inner.size-small .gallery-coverflow__card {
  width: clamp(120px, 18vw, 170px);
}
.gallery-coverflow .gallery-inner.size-large .gallery-coverflow__card {
  width: clamp(160px, 24vw, 250px);
}

@media (max-width: 640px) {
  .gallery-coverflow__viewport {
    height: clamp(300px, 78vw, 420px);
  }
  .gallery-coverflow__card {
    border-radius: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-coverflow__card {
    transition: none !important;
  }
}
