/**
 * FURI Spherical Infinite Product Gallery
 *
 * All rules are scoped under [data-furi-sphere-catalog].
 * The original non-JS catalog remains the fallback before enhancement.
 */

[data-furi-sphere-catalog] {
  --furi-sphere-bg: #050505;
  --furi-sphere-panel: rgba(7, 7, 7, 0.94);
  --furi-sphere-line: rgba(231, 226, 212, 0.23);
  --furi-sphere-line-strong: rgba(244, 239, 224, 0.58);
  --furi-sphere-text: #f2eee4;
  --furi-sphere-muted: rgba(242, 238, 228, 0.56);
  --furi-sphere-accent: #cbb36f;
  --furi-sphere-tile-width: 320px;
  --furi-sphere-tile-height: 270px;
  --furi-sphere-rail-top: 38px;
  --furi-sphere-rail-bottom: 50px;
  --furi-sphere-media-inset-x: 16px;
  --furi-sphere-media-inset-y: 13px;
  --furi-sphere-perspective: 1220px;
  --furi-sphere-motion: 0;
  --furi-sphere-pullback: 0;
  --furi-sphere-camera-z: 0px;
  --furi-sphere-velocity-x: 0;
  --furi-sphere-velocity-y: 0;

  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  min-height: min(100svh, 980px);
  background:
    radial-gradient(
      ellipse at 50% 48%,
      rgba(
        53,
        48,
        36,
        calc(
          0.055 +
          var(--furi-sphere-motion) * 0.04 +
          var(--furi-sphere-pullback) * 0.025
        )
      ),
      transparent 46%
    ),
    var(--furi-sphere-bg);
  color: var(--furi-sphere-text);
  perspective: var(--furi-sphere-perspective);
  perspective-origin: 50% 50%;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.furi-sphere-viewport[data-furi-sphere-catalog] {
  position: fixed;
  inset: 0;
  z-index: 4;
  width: 100vw;
  height: 100svh;
  margin: 0;
}

.furi-catalog-stage:has(.furi-sphere-viewport.furi-sphere-catalog) .furi-three-vault {
  display: none !important;
}

/* The legacy catalog controller remains the sole owner of layout/search
 * visibility. Hide the entire isolated visual layer (including its ambient
 * pseudo-elements), so it cannot cover the existing list or search results. */
.furi-catalog-mockup.is-list:not(.is-searching) .furi-sphere-viewport,
.furi-catalog-mockup.is-list-view:not(.is-searching) .furi-sphere-viewport,
.furi-catalog-mockup.is-searching .furi-sphere-viewport,
.furi-catalog-mockup[data-furi-catalog-state="list"] .furi-sphere-viewport,
.furi-catalog-mockup[data-furi-catalog-state="searching"] .furi-sphere-viewport {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

[data-furi-sphere-catalog]::before,
[data-furi-sphere-catalog]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

/* The in-context ::before cannot shade the sphere: 3D-transformed tiles
   composite in front of it (edge tiles have the largest translateZ). The
   corner/perimeter vignette lives on the .furi-vault-vignette overlay
   OUTSIDE the sphere stacking context instead. */
[data-furi-sphere-catalog]::before {
  background: none;
}

/* Phantom-style optical aperture: a single, legible oval falloff makes
   the four corners and perimeter recede while leaving a broad transparent
   reading window through the centre. The hairline warmth marks the lens
   boundary without becoming a hard ring. This fixed sibling sits above
   the 3D wall (z 4), below every floating control, and never receives input. */
.furi-vault-vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(ellipse 48% 52% at top left, rgba(0, 0, 0, 0.84), transparent 70%),
    radial-gradient(ellipse 48% 52% at top right, rgba(0, 0, 0, 0.82), transparent 70%),
    radial-gradient(ellipse 48% 52% at bottom left, rgba(0, 0, 0, 0.8), transparent 70%),
    radial-gradient(ellipse 48% 52% at bottom right, rgba(0, 0, 0, 0.8), transparent 70%),
    radial-gradient(ellipse 78% 76% at 50% 49%,
      transparent 0 53%,
      rgba(226, 180, 58, 0.045) 53.35%,
      rgba(0, 0, 0, 0.08) 54.1%,
      rgba(0, 0, 0, 0.24) 66%,
      rgba(0, 0, 0, 0.58) 83%,
      rgba(0, 0, 0, 0.94) 100%);
}

.furi-catalog-mockup[data-furi-catalog-state="list"] .furi-vault-vignette,
.furi-catalog-mockup[data-furi-catalog-state="searching"] .furi-vault-vignette,
.furi-catalog-mockup.is-searching .furi-vault-vignette {
  display: none;
}

[data-furi-sphere-catalog]::after {
  opacity: calc(0.19 + var(--furi-sphere-motion) * 0.08);
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: soft-light;
}

[data-furi-sphere-catalog].is-furi-sphere-pointer-down,
[data-furi-sphere-catalog].is-furi-sphere-dragging {
  cursor: grabbing;
}

.furi-catalog-stage:has(.furi-sphere-viewport.furi-sphere-catalog) .furi-catalog-label {
  isolation: isolate;
}

.furi-catalog-stage:has(.furi-sphere-viewport.furi-sphere-catalog) .furi-catalog-label::before {
  display: none;
}

.furi-catalog-stage:has(.furi-sphere-viewport.furi-sphere-catalog) .furi-catalog-searchbar {
  background: #0c0a07 !important;
  backdrop-filter: none !important;
}


[data-furi-sphere-catalog] [data-furi-sphere-items],
[data-furi-sphere-catalog].furi-sphere-items,
[data-furi-sphere-catalog] .furi-sphere-items {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: translate3d(0, 0, var(--furi-sphere-camera-z)) rotateX(var(--furi-sphere-tilt-x, 0deg)) rotateY(var(--furi-sphere-tilt-y, 0deg)) !important;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  will-change: transform;
  list-style: none !important;
  z-index: 4;
}

[data-furi-sphere-catalog] .furi-sphere-item {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  float: none !important;
  clear: none !important;
  display: block;
  width: var(--furi-sphere-tile-width) !important;
  min-width: 0 !important;
  max-width: none !important;
  height: var(--furi-sphere-tile-height) !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--furi-sphere-panel) !important;
  box-shadow: none !important;
  overflow: hidden;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  contain: layout paint style;
  will-change: transform, opacity;
  filter:
    brightness(var(--furi-sphere-brightness, 1))
    blur(var(--furi-sphere-blur, 0px));
  transition:
    outline-color 160ms ease,
    background-color 160ms ease;
}

[data-furi-sphere-catalog] .furi-sphere-item.is-furi-sphere-inactive {
  display: none !important;
}

[data-furi-sphere-catalog] .furi-sphere-item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  border: 1px solid var(--furi-sphere-line);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.018),
      transparent 34%,
      rgba(255, 255, 255, 0.009) 72%,
      transparent
    );
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.54),
    inset 0 -34px 60px rgba(0, 0, 0, 0.16);
}

[data-furi-sphere-catalog] .furi-sphere-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  opacity: calc(0.07 + var(--furi-sphere-edge, 0) * 0.23);
  background:
    radial-gradient(circle at 50% 50%, transparent 38%, rgba(0, 0, 0, 0.68) 100%);
}

[data-furi-sphere-catalog] .furi-sphere-item:hover::before,
[data-furi-sphere-catalog] .furi-sphere-item:focus-within::before,
[data-furi-sphere-catalog] .furi-sphere-item.is-furi-sphere-center::before {
  border-color: var(--furi-sphere-line-strong);
}

[data-furi-sphere-catalog] .furi-sphere-product-link {
  position: absolute !important;
  z-index: 5;
  top: var(--furi-sphere-rail-top) !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  transform: translateX(-50%);
  display: grid !important;
  place-items: center;
  /* Square artwork well that can NEVER invade the bottom rail where the
     title and price live: width-driven like before, but hard-capped by
     the space between the rails so the name always stays beneath the
     image on every tile size. */
  width: min(
    calc(100% - (var(--furi-sphere-media-inset-x) * 2)),
    calc(var(--furi-sphere-tile-height, 1000px) - var(--furi-sphere-rail-top) - var(--furi-sphere-rail-bottom) - 6px)
  ) !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden;
  color: inherit;
  text-decoration: none !important;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.025), transparent 65%),
    rgba(0, 0, 0, 0.08);
  outline: none;
}

[data-furi-sphere-catalog] .furi-sphere-product-link:focus-visible {
  outline: 1px solid var(--furi-sphere-accent);
  outline-offset: -1px;
}

[data-furi-sphere-catalog] .furi-sphere-product-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: translateZ(1px) scale(1);
  transition:
    transform 260ms cubic-bezier(0.22, 0.74, 0.2, 1),
    filter 240ms ease,
    opacity 240ms ease;
  backface-visibility: hidden;
  filter: saturate(1.04) contrast(1.02) brightness(1.04);
  pointer-events: none;
}

[data-furi-sphere-catalog] .furi-sphere-item:hover .furi-sphere-product-image,
[data-furi-sphere-catalog] .furi-sphere-item:focus-within .furi-sphere-product-image {
  transform: translateZ(2px) scale(1.025);
  filter: saturate(1.08) contrast(1.04) brightness(1.06);
}

[data-furi-sphere-catalog] .furi-sphere-item.is-furi-sphere-center .furi-sphere-product-image {
  filter: saturate(1) contrast(1.025) brightness(1);
}

[data-furi-sphere-catalog] .furi-sphere-source-meta {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[data-furi-sphere-catalog] .furi-sphere-generated-meta {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  font-family: inherit;
  text-transform: uppercase;
}

[data-furi-sphere-catalog] .furi-sphere-rail {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--furi-sphere-muted);
  font-size: clamp(8px, 0.62vw, 10px);
  line-height: 1;
  letter-spacing: 0.075em;
  white-space: nowrap;
}

[data-furi-sphere-catalog] .furi-sphere-rail--top {
  top: 0;
  height: var(--furi-sphere-rail-top);
  gap: 9px;
  padding: 0 11px;
}

[data-furi-sphere-catalog] .furi-sphere-rail--bottom {
  bottom: 0;
  height: var(--furi-sphere-rail-bottom);
  gap: 12px;
  padding: 0 12px;
}

[data-furi-sphere-catalog] .furi-sphere-eyebrow {
  flex: 0 1 auto;
  max-width: 28%;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-furi-sphere-catalog] .furi-sphere-categories {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
}

[data-furi-sphere-catalog] .furi-sphere-category {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  padding: 2px 5px 1px;
  border: 1px solid rgba(232, 226, 211, 0.19);
  border-radius: 999px;
  color: rgba(242, 238, 228, 0.65);
  font-size: 0.86em;
  letter-spacing: 0.045em;
}

[data-furi-sphere-catalog] .furi-sphere-year {
  flex: 0 0 auto;
  margin-left: auto;
  color: rgba(242, 238, 228, 0.45);
  font-variant-numeric: tabular-nums;
}

[data-furi-sphere-catalog] .furi-sphere-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--furi-sphere-text);
  font-size: clamp(9px, 0.72vw, 12px);
  font-weight: 500;
  letter-spacing: 0.055em;
  text-overflow: ellipsis;
}

[data-furi-sphere-catalog] .furi-sphere-price {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--furi-sphere-muted);
  font-variant-numeric: tabular-nums;
}

[data-furi-sphere-catalog] .furi-sphere-rule {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  z-index: 3;
  background: var(--furi-sphere-line);
}

[data-furi-sphere-catalog] .furi-sphere-rule--top {
  top: var(--furi-sphere-rail-top);
}

[data-furi-sphere-catalog] .furi-sphere-rule--bottom {
  bottom: var(--furi-sphere-rail-bottom);
}

[data-furi-sphere-catalog] .furi-sphere-corner {
  position: absolute;
  width: 7px;
  height: 7px;
  z-index: 31;
  opacity: 0.62;
}

[data-furi-sphere-catalog] .furi-sphere-corner--tl {
  top: 0;
  left: 0;
  border-top: 1px solid var(--furi-sphere-line-strong);
  border-left: 1px solid var(--furi-sphere-line-strong);
}

[data-furi-sphere-catalog] .furi-sphere-corner--tr {
  top: 0;
  right: 0;
  border-top: 1px solid var(--furi-sphere-line-strong);
  border-right: 1px solid var(--furi-sphere-line-strong);
}

[data-furi-sphere-catalog] .furi-sphere-corner--bl {
  bottom: 0;
  left: 0;
  border-bottom: 1px solid var(--furi-sphere-line-strong);
  border-left: 1px solid var(--furi-sphere-line-strong);
}

[data-furi-sphere-catalog] .furi-sphere-corner--br {
  right: 0;
  bottom: 0;
  border-right: 1px solid var(--furi-sphere-line-strong);
  border-bottom: 1px solid var(--furi-sphere-line-strong);
}

[data-furi-sphere-catalog] .furi-sphere-favorite {
  position: absolute !important;
  z-index: 40 !important;
  top: calc(var(--furi-sphere-rail-top) + var(--furi-sphere-media-inset-y) + 8px) !important;
  right: calc(var(--furi-sphere-media-inset-x) + 8px) !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: auto !important;
}

[data-furi-sphere-catalog] .furi-sphere-item:hover .furi-sphere-rail,
[data-furi-sphere-catalog] .furi-sphere-item:focus-within .furi-sphere-rail,
[data-furi-sphere-catalog] .furi-sphere-item.is-furi-sphere-center .furi-sphere-rail {
  color: rgba(242, 238, 228, 0.74);
}

[data-furi-sphere-catalog] .furi-sphere-item:hover .furi-sphere-title,
[data-furi-sphere-catalog] .furi-sphere-item:focus-within .furi-sphere-title {
  color: var(--furi-sphere-accent);
}

[data-furi-sphere-catalog].furi-sphere-is-empty::before {
  content: "No products match the current filters";
  display: grid;
  place-items: center;
  z-index: 10;
  color: var(--furi-sphere-muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 1179px) {
  [data-furi-sphere-catalog] {
    min-height: 100svh;
  }

  [data-furi-sphere-catalog] .furi-sphere-rail {
    font-size: 8.5px;
  }

  [data-furi-sphere-catalog] .furi-sphere-title {
    font-size: 9.5px;
  }
}

@media (max-width: 699px) {
  [data-furi-sphere-catalog] {
    min-height: 100svh;
  }

  /* A taller aperture on mobile keeps the central two-column rhythm clear
     while a visible oval falloff curls over the top/bottom and four corners. */
  .furi-vault-vignette {
    background:
      radial-gradient(ellipse 72% 42% at top left, rgba(0, 0, 0, 0.84), transparent 68%),
      radial-gradient(ellipse 72% 42% at top right, rgba(0, 0, 0, 0.82), transparent 68%),
      radial-gradient(ellipse 72% 42% at bottom left, rgba(0, 0, 0, 0.82), transparent 68%),
      radial-gradient(ellipse 72% 42% at bottom right, rgba(0, 0, 0, 0.82), transparent 68%),
      radial-gradient(ellipse 92% 78% at 50% 48%,
        transparent 0 48%,
        rgba(226, 180, 58, 0.075) 48.35%,
        rgba(0, 0, 0, 0.08) 49.1%,
        rgba(0, 0, 0, 0.25) 62%,
        rgba(0, 0, 0, 0.62) 82%,
        rgba(0, 0, 0, 0.94) 100%);
  }

  [data-furi-sphere-catalog] .furi-sphere-rail--top {
    gap: 5px;
    padding-inline: 8px;
  }

  [data-furi-sphere-catalog] .furi-sphere-rail--bottom {
    gap: 7px;
    padding-inline: 9px;
  }

  [data-furi-sphere-catalog] .furi-sphere-rail {
    font-size: 7.5px;
    letter-spacing: 0.06em;
  }

  [data-furi-sphere-catalog] .furi-sphere-title {
    font-size: 8.5px;
    letter-spacing: 0.045em;
  }

  [data-furi-sphere-catalog] .furi-sphere-category {
    min-height: 14px;
    padding: 1px 4px;
  }

  [data-furi-sphere-catalog] .furi-sphere-eyebrow {
    max-width: 22%;
  }

  [data-furi-sphere-catalog] .furi-sphere-product-image {
    max-width: 91% !important;
    max-height: 91% !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-furi-sphere-catalog] .furi-sphere-product-image {
    transition-duration: 0.01ms !important;
  }

  [data-furi-sphere-catalog]::after {
    display: none;
  }
}

[data-furi-sphere-catalog].furi-sphere-catalog .furi-three-vault {
  display: none !important;
}

[data-furi-sphere-catalog] > [data-furi-sphere-items] {
  display: block;
}
