/* ==========================================================================
   SSR SABARI INTERIORS — Concave 3D Ring Gallery Styles
   Extends the warm-neutral + soft-gold system defined in style.css
   Tokens: --color-charcoal, --color-off-white, --color-gold, --font-primary
   ========================================================================== */

:root {
  /* Ring Gallery Tuning Variables */
  --ring-perspective: 1200px;
  --ring-card-width: 16vw;
  --ring-card-radius: 20px;
  --ring-bg-blur: 24px;
  --ring-bg-darkness: rgba(12, 11, 9, 0.62);
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   FULL-HEIGHT DARK SECTION & BLURRED ACTIVE BACKDROP
   ========================================================================== */
.projects-section {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: #11100E;
  color: var(--color-off-white, #FAF8F4);
  padding: clamp(84px, 9vh, 112px) 0 clamp(44px, 6vh, 72px);
  overflow: hidden;
  isolation: isolate;
}

.projects-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.projects-backdrop-img {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(var(--ring-bg-blur));
  transform: scale(1.08);
  opacity: 0;
  transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}

.projects-backdrop-img.is-active {
  opacity: 1;
}

.projects-backdrop-scrim {
  position: absolute;
  inset: 0;
  background: var(--ring-bg-darkness);
}

.projects-backdrop-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 85% 75% at 50% 52%, transparent 25%, rgba(10, 9, 8, 0.78) 100%),
    linear-gradient(180deg, rgba(14, 13, 11, 0.55) 0%, transparent 22%, transparent 78%, rgba(14, 13, 11, 0.82) 100%);
}

.projects-section-inner {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ==========================================================================
   TOP CENTER HEADER
   ========================================================================== */
.projects-header {
  text-align: center;
  padding: 0 clamp(16px, 4vw, 48px);
  max-width: 780px;
  margin: 0 auto 18px;
}

.projects-eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--color-gold, #C8A46B);
  margin-bottom: 8px;
}

.projects-heading {
  font-size: clamp(1.85rem, 3.6vw, 3.1rem);
  font-weight: 400;
  letter-spacing: 0.05em;
  line-height: 1.12;
  color: var(--color-off-white, #FAF8F4);
  margin-bottom: 10px;
}

.projects-subtext {
  font-size: clamp(0.9rem, 1.15vw, 1.02rem);
  font-weight: 300;
  line-height: 1.55;
  color: rgba(250, 248, 244, 0.78);
  max-width: 58ch;
  margin: 0 auto;
}

/* ==========================================================================
   FILTER TABS (PILLS ABOVE THE RING)
   ========================================================================== */
.proj-filter-wrap {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 clamp(16px, 4vw, 48px) 4px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.proj-filter-wrap::-webkit-scrollbar {
  display: none;
}

.proj-filter-tabs {
  display: inline-flex;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: max-content;
}

.proj-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  min-height: 40px;
  border-radius: 9999px;
  border: 1px solid rgba(250, 248, 244, 0.22);
  background-color: rgba(22, 21, 19, 0.38);
  color: rgba(250, 248, 244, 0.8);
  font-family: var(--font-primary);
  font-size: 0.84rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.22s ease,
    background-color 0.22s ease,
    border-color 0.22s ease,
    transform 0.22s ease;
}

.proj-filter-btn:hover {
  color: var(--color-off-white, #FAF8F4);
  border-color: rgba(200, 164, 107, 0.65);
}

.proj-filter-btn:focus-visible {
  outline: 2px solid var(--color-gold, #C8A46B);
  outline-offset: 3px;
}

.proj-filter-btn.is-active {
  background-color: var(--color-gold, #C8A46B);
  border-color: var(--color-gold, #C8A46B);
  color: #161513;
  font-weight: 500;
}

/* ==========================================================================
   ACTIVE PROJECT CAPTION & DUAL PILL BUTTONS
   ========================================================================== */
.proj-active-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 clamp(16px, 4vw, 48px);
  margin-bottom: clamp(18px, 3vh, 28px);
  min-height: 112px;
}

.proj-active-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.proj-active-caption.is-fading {
  opacity: 0;
  transform: translateY(4px);
}

.proj-active-title {
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--color-off-white, #FAF8F4);
  line-height: 1.25;
}

.proj-active-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.proj-tag {
  display: inline-block;
  padding: 3px 12px;
  border: 1px solid rgba(250, 248, 244, 0.34);
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(250, 248, 244, 0.9);
  background-color: rgba(22, 21, 19, 0.32);
  white-space: nowrap;
}

.projects-cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   CONCAVE 3D RING GALLERY STAGE
   ========================================================================== */
.ring-gallery {
  position: relative;
  width: 100%;
  height: clamp(320px, 44svh, 490px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.ring-gallery:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(200, 164, 107, 0.45);
}

.ring-stage {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: var(--ring-perspective);
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  cursor: grab;
  touch-action: pan-y;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.ring-stage.is-dragging {
  cursor: grabbing;
}

.ring-stage.is-rebuilding {
  opacity: 0;
  transform: scale(0.97);
}

/* Individual 3D Ring Card */
.ring-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--ring-card-width);
  aspect-ratio: 3 / 4;
  margin: 0;
  padding: 0;
  border-radius: var(--ring-card-radius);
  overflow: hidden;
  border: 1px solid rgba(250, 248, 244, 0.28);
  background-color: #1A1815;
  box-shadow:
    0 24px 56px rgba(0, 0, 0, 0.62),
    inset 0 0 22px rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transform-origin: center center;
  will-change: transform, opacity;
  /* Initial state before IntersectionObserver reveal */
  opacity: 0;
  outline: none;
}

.ring-card:focus-visible {
  border-color: var(--color-gold, #C8A46B);
  box-shadow:
    0 0 0 3px rgba(200, 164, 107, 0.75),
    0 24px 56px rgba(0, 0, 0, 0.65);
}

.ring-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: filter 0.35s ease;
}

/* Subtle dimming on non-active cards that sit further back; full brightness & glow on active front card */
.ring-card[aria-current="false"] .ring-card-img {
  filter: brightness(0.68);
}

.ring-card[aria-current="true"] {
  border-color: rgba(200, 164, 107, 0.65);
  box-shadow:
    0 34px 76px rgba(0, 0, 0, 0.82),
    0 0 36px rgba(200, 164, 107, 0.14),
    inset 0 0 28px rgba(255, 255, 255, 0.16);
}

.ring-card[aria-current="true"] .ring-card-img {
  filter: brightness(1.03);
}

/* Subtle bottom vignette on cards for depth */
.ring-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 24%,
    transparent 74%,
    rgba(0, 0, 0, 0.32) 100%
  );
  pointer-events: none;
}

/* Prev / Next Ring Buttons */
.ring-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(12px, 2.5vw, 32px);
  z-index: 20;
}

.ring-nav-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  border: 1px solid rgba(250, 248, 244, 0.28);
  background-color: rgba(22, 21, 19, 0.56);
  color: var(--color-off-white, #FAF8F4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color 0.22s ease,
    border-color 0.22s ease,
    transform 0.22s ease;
}

.ring-nav-btn:hover {
  background-color: var(--color-off-white, #FAF8F4);
  border-color: var(--color-off-white, #FAF8F4);
  color: #161513;
  transform: scale(1.06);
}

.ring-nav-btn:focus-visible {
  outline: 2px solid var(--color-gold, #C8A46B);
  outline-offset: 3px;
}

/* ==========================================================================
   NORMAL CAROUSEL VIEW (Toggled via "View project" button)
   ========================================================================== */
.ring-gallery[hidden],
.proj-carousel-wrap[hidden] {
  display: none !important;
}

.proj-carousel-wrap {
  position: relative;
  width: 100%;
  animation: carouselFadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes carouselFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.proj-carousel-track {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 8px clamp(20px, 5vw, 64px) 16px;
}

.proj-carousel-card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(250, 248, 244, 0.24);
  background-color: #1A1815;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
  padding: 0;
  text-align: left;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s ease;
}

@media (max-width: 1023px) {
  .proj-carousel-track {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .proj-carousel-track {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

.proj-carousel-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-gold, #C8A46B);
}

.proj-carousel-card:focus-visible {
  outline: 2px solid var(--color-gold, #C8A46B);
  outline-offset: 3px;
}

.proj-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.proj-carousel-card:hover .proj-carousel-img {
  transform: scale(1.05);
}

.proj-carousel-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 44px 16px 16px;
  background: linear-gradient(180deg, transparent 0%, rgba(12, 11, 9, 0.88) 70%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proj-carousel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.proj-carousel-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--color-off-white, #FAF8F4);
  line-height: 1.25;
}

.proj-carousel-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

/* ==========================================================================
   LIGHTBOX (PRESERVED)
   ========================================================================== */
.proj-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.proj-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(14, 13, 11, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lb-container {
  position: relative;
  z-index: 1;
  width: min(900px, 94vw);
  max-height: 92svh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background-color: var(--color-off-white, #FAF8F4);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
}

.lb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  border: 1px solid rgba(22, 21, 19, 0.16);
  background-color: rgba(250, 248, 244, 0.92);
  color: var(--color-charcoal, #161513);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lb-close:hover {
  background-color: var(--color-charcoal, #161513);
  border-color: var(--color-charcoal, #161513);
  color: var(--color-off-white, #FAF8F4);
  transform: rotate(90deg);
}

.lb-close:focus-visible {
  outline: 2px solid var(--color-gold, #C8A46B);
  outline-offset: 3px;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  border: 1px solid rgba(22, 21, 19, 0.16);
  background-color: rgba(250, 248, 244, 0.92);
  color: var(--color-charcoal, #161513);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.lb-prev { left: 14px; }
.lb-next { right: 14px; }

.lb-nav:hover {
  background-color: var(--color-charcoal, #161513);
  color: var(--color-off-white, #FAF8F4);
}

.lb-nav:focus-visible {
  outline: 2px solid var(--color-gold, #C8A46B);
  outline-offset: 3px;
}

.lb-figure {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  margin: 0;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.lb-figure.is-ready {
  opacity: 1;
}

.lb-img {
  width: 100%;
  max-height: 60svh;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.lb-caption {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lb-tags .proj-tag {
  border-color: rgba(22, 21, 19, 0.2);
  color: var(--color-charcoal, #161513);
  background-color: rgba(22, 21, 19, 0.06);
}

.lb-title {
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--color-charcoal, #161513);
}

.lb-desc {
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.65;
  color: #5A5650;
  max-width: 60ch;
}

body.lb-open {
  overflow: hidden;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Tablet (768px - 1023px): 3 full cards + edge partials */
@media (max-width: 1023px) {
  :root {
    --ring-card-width: 25vw;
  }

  .ring-gallery {
    height: clamp(320px, 42svh, 460px);
  }
}

/* Mobile (< 768px): 58vw center card + curved 3D neighbor slivers, no blurred image for perf */
@media (max-width: 767px) {
  :root {
    --ring-perspective: 880px;
    --ring-card-width: 58vw;
  }

  .projects-section {
    background: radial-gradient(circle at 50% 35%, #24211C 0%, #141311 55%, #0B0A09 100%);
    padding: 76px 0 44px;
  }

  .projects-backdrop-img {
    display: none;
  }

  .proj-filter-wrap {
    justify-content: flex-start;
  }

  .ring-gallery {
    height: clamp(330px, 48svh, 430px);
  }

  .ring-controls {
    padding: 0 10px;
  }

  .ring-nav-btn {
    width: 44px;
    height: 44px;
    background-color: rgba(16, 15, 13, 0.72);
  }

  .projects-cta-row {
    flex-direction: column;
    width: 100%;
    max-width: 340px;
    gap: 10px;
  }

  .projects-cta-row .btn {
    width: 100%;
    min-height: 48px;
  }

  .lb-container {
    width: 100%;
    max-height: 100svh;
    border-radius: 0;
  }

  .lb-prev { top: auto; bottom: 16px; left: 50%; transform: translateX(calc(-50% - 30px)); }
  .lb-next { top: auto; bottom: 16px; right: auto; left: 50%; transform: translateX(calc(-50% + 30px)); }
}

/* ==========================================================================
   REDUCED MOTION: Horizontal scroll-snap row, no 3D, no idle drift
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .projects-backdrop-img,
  .proj-active-caption,
  .ring-stage,
  .ring-card,
  .ring-card-img,
  .proj-lightbox,
  .lb-figure,
  .proj-filter-btn {
    transition: none !important;
    animation: none !important;
  }

  .ring-gallery {
    height: auto;
    padding: 12px 0;
  }

  .ring-stage {
    perspective: none;
    transform-style: flat;
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 12px clamp(16px, 5vw, 48px);
    cursor: auto;
  }

  .ring-card {
    position: relative;
    top: auto;
    left: auto;
    flex: 0 0 auto;
    width: clamp(220px, 24vw, 300px);
    transform: none !important;
    opacity: 1 !important;
    scroll-snap-align: center;
  }

  .ring-controls {
    display: none;
  }
}
