/* ============================================
   BUBBLE FIELD CONTAINER
   ============================================ */
#bubble-field {
    position: fixed;
    inset: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
    touch-action: none;
    cursor: grab;
}

#bubble-field.field-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Soft parallax glare that follows the camera orbit (drag the background) */
#bubble-field::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: radial-gradient(
        circle at var(--cam-x, 50%) var(--cam-y, 50%),
        rgba(124, 92, 255, 0.10) 0%,
        rgba(0, 232, 157, 0.04) 38%,
        transparent 68%
    );
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#bubble-field.bg-dragging {
    cursor: grabbing;
}

/* During a background-drag orbit the engine drives position and depth
   every frame via inline styles — no CSS transitions, so the ring never
   lags behind the camera (previously depth "caught up" only as you kept
   dragging, which read as blobs of blur). */
.bubble-wrap.orbit-live {
    transition: none !important;
}

/* ============================================
   BUBBLE WRAPPER
   Positions the sphere and applies the
   depth-of-focus layer. Depth is expressed as
   uniform scale + blur + opacity so that pointer
   drag deltas map 1:1 to on-screen movement at
   any depth (scale commutes with translation).
   ============================================ */
.bubble-wrap {
    position: absolute;
    will-change: left, top, scale;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    scale: 1;
    opacity: 1;
    filter: blur(0);
    transition: scale 1.4s ease, filter 1.4s ease, opacity 1.4s ease;
}

/* Depth layers - closer = sharper, bigger, on top */
.bubble-wrap.depth-far {
    scale: 0.82;
    z-index: 1;
    filter: blur(3px);
    opacity: 0.45;
}

.bubble-wrap.depth-mid {
    scale: 0.92;
    z-index: 2;
    filter: blur(1.2px);
    opacity: 0.75;
}

.bubble-wrap.depth-near {
    scale: 1;
    z-index: 3;
    filter: none;
    opacity: 1;
}

/* ============================================
   SPLASH POP-IN ("boing" greeting)
   Added via staggerReveal(); each sphere pops
   in one at a time with an inline animation
   delay. The class is removed on animationend.
   ============================================ */
.bubble-wrap.intro {
    scale: 0;
    opacity: 0;
    animation: bubbleBoing 1.05s cubic-bezier(0.18, 1.4, 0.32, 1) forwards;
}

@keyframes bubbleBoing {
    0%   { scale: 0;    opacity: 0; }
    40%  { scale: 1.2;  opacity: 1; }
    65%  { scale: 0.88; opacity: 1; }
    100% { scale: 1;    opacity: 1; }
}

/* ============================================
   SPHERE (inner floating element)
   ============================================ */
.bubble {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    cursor: grab;
    will-change: transform, scale;
    backface-visibility: hidden;
}

.bubble-wrap:hover .bubble {
    animation-play-state: paused;
    scale: 1.12;
}

.bubble-wrap:hover {
    scale: 1;
    filter: none !important;
    opacity: 1 !important;
    z-index: 9998;
}

/* Images wrapped around the sphere */
.bubble-image {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

/* Glossy highlight overlay for 3D roundness */
.bubble-image::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 30% 25%,
        rgba(255, 255, 255, 0.25) 0%,
        rgba(255, 255, 255, 0.08) 30%,
        transparent 60%
    );
    pointer-events: none;
}

/* ============================================
   FEATURED SPHERES (max 3 accents at once)
   Businesses that paid to be featured / were
   validated. The engine toggles `.featured` on
   up to FEATURED_LIMIT wraps. The accent lives
   inside .bubble so it rides the sphere's drift
   wobble; a glint of light sweeps the rim
   (slim masked conic) and a glossy gold star
   twinkles on the shoulder. Travels in the ad
   data today; MySQL `featured` column + admin
   section later.
   ============================================ */
.featured-accent,
.featured-tag {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Slim rim glint that pirouettes around the sphere's edge */
.featured-accent {
    position: absolute;
    z-index: 2;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(255, 230, 160, 0) 0deg,
        rgba(255, 230, 160, 0.05) 40deg,
        #ffe9ac 88deg,
        #fff9e8 118deg,
        #ffd87e 150deg,
        rgba(255, 230, 160, 0) 205deg,
        rgba(255, 230, 160, 0) 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 2px));
            mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 2px));
}

/* Glossy gold star badge pinning "featured partner" */
.featured-tag {
    position: absolute;
    z-index: 3;
    top: 6%;
    right: 6%;
    width: 22%;
    height: 22%;
    min-width: 13px;
    min-height: 13px;
    max-width: 24px;
    max-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #fff6dc, #ffce6e 72%, #ef9b36);
    box-shadow:
        0 0 10px rgba(255, 208, 116, 0.7),
        0 2px 5px rgba(0, 0, 0, 0.35),
        inset 0 0 0 1.5px rgba(255, 255, 255, 0.7);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(180, 100, 20, 0.6);
}

.bubble-wrap.featured .featured-accent {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(255, 216, 126, 0.6));
    animation: badgeSpin 9s linear infinite, featPulse 3.2s ease-in-out infinite;
}

.bubble-wrap.featured .featured-tag {
    opacity: 1;
    animation: featTwinkle 3.2s ease-in-out infinite;
}

@keyframes featPulse {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

@keyframes featTwinkle {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.14); }
}

/* ============================================
   DRAGGING STATE
   ============================================ */
.bubble-wrap.dragging {
    transition: none;
    cursor: grabbing;
    z-index: 99999 !important;
    filter: none !important;
    opacity: 1 !important;
}

.bubble.dragging {
    cursor: grabbing;
}

/* ============================================
   FLOAT ANIMATIONS (base drift paths)
   ============================================ */
@keyframes floatDrift1 {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    25% { transform: translate3d(30px, -20px, 0) rotate(2deg); }
    50% { transform: translate3d(-15px, -40px, 0) rotate(-1deg); }
    75% { transform: translate3d(20px, 10px, 0) rotate(3deg); }
}

@keyframes floatDrift2 {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    33% { transform: translate3d(-25px, 30px, 0) rotate(-2deg); }
    66% { transform: translate3d(20px, -15px, 0) rotate(1deg); }
}

@keyframes floatDrift3 {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    20% { transform: translate3d(15px, 25px, 0) rotate(1.5deg); }
    40% { transform: translate3d(-20px, 10px, 0) rotate(-2deg); }
    60% { transform: translate3d(10px, -30px, 0) rotate(0.5deg); }
    80% { transform: translate3d(-15px, -10px, 0) rotate(-1deg); }
}

@keyframes floatDrift4 {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50% { transform: translate3d(-35px, 20px, 0) rotate(3deg); }
}

@keyframes floatDrift5 {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    25% { transform: translate3d(20px, -35px, 0) rotate(-2.5deg); }
    50% { transform: translate3d(-10px, 15px, 0) rotate(1deg); }
    75% { transform: translate3d(25px, 25px, 0) rotate(-1deg); }
}

/* ============================================
   SEARCH FILTER STATES
   ============================================ */
.bubble-wrap.search-dim {
    opacity: 0.08 !important;
    filter: blur(6px) !important;
    pointer-events: none;
    transition: opacity 0.5s ease, filter 0.5s ease;
}

.bubble-wrap.search-match {
    z-index: 9997;
    filter: none !important;
    opacity: 1 !important;
}

.bubble-wrap.search-match .bubble {
    scale: 1.06;
}

/* ============================================
   ROTATION FADE STATES
   Rotates different businesses in and out.
   ============================================ */
.bubble-wrap.fading-out {
    opacity: 0 !important;
    scale: 0.55 !important;
    filter: blur(4px) !important;
    pointer-events: none;
    z-index: 0;
    transition-duration: 0.7s !important;
}

.bubble-wrap.fading-in {
    transition-duration: 0.9s !important;
}

/* ============================================
   SEARCH CONTROL (Top-Left)
   Magnifying glass that expands into a search bar.
   ============================================ */
#search-control {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 9500;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 40px;
    padding: 6px 8px;
    backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease, background 0.3s ease, border-color 0.3s ease;
}

#search-control.search-visible {
    opacity: 1;
    pointer-events: auto;
}

#search-control:hover,
#search-control:focus-within {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(124, 92, 255, 0.45);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.search-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    flex: 0 0 auto;
    transition: color 0.3s ease;
}

#search-control:hover .search-icon,
#search-control:focus-within .search-icon {
    color: #ffffff;
}

.search-icon svg {
    width: 18px;
    height: 18px;
}

#search-input {
    width: 0;
    opacity: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    padding: 0;
    caret-color: #7c5cff;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.35s ease;
}

#search-control:hover #search-input,
#search-control:focus-within #search-input {
    width: 230px;
    opacity: 1;
    padding: 0 10px;
}

#search-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */
#search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    overflow-y: auto;
    max-height: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#search-control:focus-within #search-results:not(:empty) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-result {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: rgba(124, 92, 255, 0.18);
}

.search-result-title {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-author {
    font-size: 10px;
    color: rgba(0, 232, 157, 0.7);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-empty {
    padding: 14px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
}