/* ==========================================================================
   DOME GALLERY — 3D Course Universe Background for Elite Toolistic Hero
   Based on React Bits <DomeGallery /> with 3D Spherical CSS Transforms
   ========================================================================== */

.sphere-root {
  position: relative;
  width: 100%;
  height: 100%;
  --radius: 620px;
  --viewer-pad: 40px;
  --circ: calc(var(--radius) * 3.14159);
  --rot-y: calc((360deg / var(--segments-x)) / 2);
  --rot-x: calc((360deg / var(--segments-y)) / 2);
  --item-width: calc(var(--circ) / var(--segments-x));
  --item-height: calc(var(--circ) / var(--segments-y));
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.sphere-root * {
  box-sizing: border-box;
}

.sphere,
.item,
.item__image {
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

main.sphere-main {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: var(--overlay-blur-color, #ffffff);
  cursor: grab;
}

main.sphere-main:active {
  cursor: grabbing;
}

.stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  perspective: calc(var(--radius) * 2.2);
  perspective-origin: 50% 50%;
  contain: layout paint size;
}

.sphere {
  transform: translateZ(calc(var(--radius) * -1));
  will-change: transform;
  transition: transform 0ms linear;
}

/* Ambient Vignettes & Radial Gradients (Disabled: keeps 100% of cards completely sharp and crisp across entire dome) */
.overlay,
.overlay--blur {
  display: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: transparent !important;
}

.edge-fade {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

/* Horizontal edge fades (top & bottom) */
.edge-fade--top,
.edge-fade--bottom {
  left: 0;
  right: 0;
  height: 120px;
}

.edge-fade--top {
  top: 0;
  background: linear-gradient(to top, transparent, var(--overlay-blur-color, #ffffff));
}

.edge-fade--bottom {
  bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--overlay-blur-color, #ffffff));
}

/* Vertical edge fades (left & right) — soft dissolve so sides don't clip to blank white */
.edge-fade--left,
.edge-fade--right {
  top: 0;
  bottom: 0;
  width: 160px;
}

.edge-fade--left {
  left: 0;
  background: linear-gradient(to left, transparent, var(--overlay-blur-color, #ffffff));
}

.edge-fade--right {
  right: 0;
  background: linear-gradient(to right, transparent, var(--overlay-blur-color, #ffffff));
}

/* 3D Dome Items */
.item {
  width: calc(var(--item-width) * var(--item-size-x));
  height: calc(var(--item-height) * var(--item-size-y));
  position: absolute;
  top: -999px;
  bottom: -999px;
  left: -999px;
  right: -999px;
  margin: auto;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 300ms ease;
  transform: rotateY(calc(var(--rot-y) * (var(--offset-x) + ((var(--item-size-x) - 1) / 2)) + var(--rot-y-delta, 0deg)))
    rotateX(calc(var(--rot-x) * (var(--offset-y) - ((var(--item-size-y) - 1) / 2)) + var(--rot-x-delta, 0deg)))
    translateZ(var(--radius));
}

.item__image {
  position: absolute;
  display: block;
  inset: 7px;
  border-radius: var(--tile-radius, 14px) !important;
  background: #ffffff;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
  transform: translateZ(0);
  border: 1px solid rgba(6, 44, 99, 0.12);
  box-shadow: 0 10px 24px rgba(6, 44, 99, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

.item:hover {
  z-index: 50;
}

.item__image:hover {
  transform: translateZ(24px) scale(1.08);
  border-color: rgba(0, 108, 254, 0.95);
  box-shadow: 0 18px 40px rgba(0, 108, 254, 0.28) !important;
  z-index: 60;
}

.item__image.tile-clicked {
  transform: translateZ(28px) scale(0.96) !important;
  border-color: #006cfe !important;
  box-shadow: 0 0 0 3px rgba(0, 108, 254, 0.4), 0 14px 28px rgba(6, 44, 99, 0.22) !important;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease !important;
}

.item__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px 12px 34px 12px;
  background: #ffffff;
  pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  filter: var(--image-filter, none);
  transition: transform 0.4s ease, filter 0.3s ease;
}

.item__image:hover img {
  transform: scale(1.08);
}

/* ── Bottom Course Name on 3D Tiles (Clean Light Mode) ── */
.tile-corner-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  padding: 16px 6px 6px 6px;
  background: linear-gradient(
    to top,
    #ffffff 0%,
    rgba(255, 255, 255, 0.96) 55%,
    rgba(255, 255, 255, 0.75) 80%,
    rgba(255, 255, 255, 0) 100%
  );
  border-bottom-left-radius: var(--tile-radius, 14px);
  border-bottom-right-radius: var(--tile-radius, 14px);
  pointer-events: none;
  overflow: hidden;
  transition: all 0.25s ease;
}

.tile-title-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: break-word;
  color: #0f172a;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.1px;
  text-align: center;
  max-height: calc(0.68rem * 1.22 * 2 + 1px);
  text-shadow: none;
  transition: color 0.25s ease;
}

/* Fallback if rendered without span */
.tile-corner-title:not(:has(.tile-title-text)) {
  color: #0f172a;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.1px;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  max-height: calc(0.68rem * 1.22 * 2 + 25px);
  text-shadow: none;
  transition: color 0.25s ease;
}

.item__image:hover .tile-corner-title {
  background: linear-gradient(
    to top,
    #ffffff 0%,
    rgba(255, 255, 255, 0.98) 70%,
    rgba(255, 255, 255, 0) 100%
  );
}

.item__image:hover .tile-title-text,
.item__image:hover .tile-corner-title:not(:has(.tile-title-text)) {
  color: #006cfe;
}

/* ── Viewer & Enlarge Overlay Modal ── */
.viewer {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--viewer-pad, 30px);
}

.viewer .frame {
  height: 100%;
  max-height: 520px;
  max-width: 520px;
  aspect-ratio: 1;
  border-radius: var(--enlarge-radius, 20px) !important;
  display: flex;
}

@media (max-aspect-ratio: 1/1) {
  .viewer .frame {
    height: auto;
    width: 100%;
  }
}

.viewer .scrim {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(1, 6, 17, 0.78);
  pointer-events: none;
  opacity: 0;
  transition: opacity 350ms ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.sphere-root[data-enlarging='true'] .viewer .scrim {
  opacity: 1;
  pointer-events: all;
}

/* Enlarged Modal Card */
.viewer .enlarge {
  position: absolute;
  z-index: 60;
  border-radius: var(--enlarge-radius, 20px) !important;
  overflow: hidden;
  transition:
    transform 350ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 350ms ease;
  transform-origin: top left;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
  background: #040e24;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.viewer .enlarge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: var(--image-filter, none);
  display: block;
}

.sphere-root .enlarge-closing img {
  filter: var(--image-filter, none);
}

/* Rich Course Meta inside Enlarge Modal */
.enlarge-card-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(
    to bottom,
    rgba(2, 8, 20, 0.2) 0%,
    rgba(2, 8, 20, 0.75) 55%,
    rgba(2, 8, 20, 0.98) 100%
  );
  padding: 1.5rem;
  color: #ffffff;
  pointer-events: auto;
}

.enlarge-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 108, 254, 0.25);
  border: 1px solid rgba(0, 108, 254, 0.5);
  color: #60a5fa;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px !important;
  margin-bottom: 0.5rem;
  align-self: flex-start;
}

.enlarge-title {
  font-family: var(--font-serif, serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.enlarge-desc {
  font-family: var(--font-sans, sans-serif);
  font-size: 0.85rem;
  line-height: 1.45;
  color: #cbd5e1;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.enlarge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.enlarge-price {
  font-family: var(--font-mono, monospace);
  font-size: 1.1rem;
  font-weight: 700;
  color: #38bdf8;
}

.enlarge-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-accent, #006cfe);
  color: #ffffff !important;
  padding: 9px 18px;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 4px !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background 0.15s ease, transform 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

.enlarge-cta:hover {
  background: #0056cc;
  transform: translateY(-1px);
}

.enlarge-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50% !important;
  background: rgba(3, 10, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 70;
  transition: background 0.15s ease, transform 0.15s ease;
}

.enlarge-close-btn:hover {
  background: rgba(220, 38, 38, 0.85);
  transform: scale(1.08);
}

/* Scroll lock when modal enlarged */
body.dg-scroll-lock {
  overflow: hidden;
}
