/* ==========================================================================
   WaifuVerse Shared UI, Browser Surfaces, Adaptive Spacing & Motion Layer
   ========================================================================== */

:root {
    --nx-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --nx-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --nx-accent: #d4a853;
    --nx-accent-rgb: 212, 168, 83;
    --nx-surface-border: rgba(255, 255, 255, 0.08);
    --nx-surface-highlight: rgba(255, 255, 255, 0.14);
    /* Dynamically updated by nexus-ui.js in Telegram Mobile Fullscreen; 0px on PC */
    --tg-header-offset: 0px;
    --tg-bottom-offset: env(safe-area-inset-bottom, 0px);
}

/* Browser Surface Polish */
::selection {
    background: rgba(var(--nx-accent-rgb), 0.28);
    color: #ffffff;
}

::-moz-selection {
    background: rgba(var(--nx-accent-rgb), 0.28);
    color: #ffffff;
}

/* Custom sleek thin scrollbar across desktop & mobile */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--nx-accent-rgb), 0.45);
}

/* Keyboard accessibility focus rings */
:focus-visible {
    outline: 2px solid var(--nx-accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[tabindex]:focus:not(:focus-visible) {
    outline: none;
}

/* Prevent horizontal overflow & eliminate tap delay */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Tabular numerals for animated stats, coins, sparks & timers */
.coins-value,
.stat-value,
.mv2-coins-value,
.mv2-stat-num,
.sparks-amount,
.header-sparks-value,
.currency-amount,
.er-sparks-badge,
.dt-chat-score-pill,
#ad-timer-countdown,
.banner-timer,
.featured-timer,
.tile-reward {
    font-variant-numeric: tabular-nums;
}

/* Interactive cursor & tactile click feedback */
button,
a,
[role="button"],
.nav-item,
.waifu-card,
.game-card,
.banner-card,
.featured-banner-card,
.er-card,
.dt-waifu-card,
.mv-chip,
.carousel-dot {
    cursor: pointer;
    touch-action: manipulation;
}

/* Ensure touch targets >= 44px on coarse pointer devices */
@media (pointer: coarse) {
    .mv2-filter-btn,
    .mv2-search-btn,
    .ad-banner-btn,
    .daily-btn,
    .claim-btn,
    .er-history-btn,
    .er-rewind-btn,
    .dt-send-btn,
    .close-modal,
    .banner-info-btn {
        min-height: 44px;
    }

    .banner-info-btn,
    .close-modal {
        min-width: 44px;
    }

    .carousel-dot {
        position: relative;
    }
    .carousel-dot::after {
        content: '';
        position: absolute;
        inset: -12px;
    }
}

/* Desktop hover polish & cursor spotlight */
@media (hover: hover) and (pointer: fine) {
    .nx-spotlight {
        position: relative;
    }

    .nx-spotlight::after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        pointer-events: none;
        background: radial-gradient(
            320px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            rgba(255, 255, 255, 0.08),
            transparent 65%
        );
        opacity: 0;
        transition: opacity 0.25s var(--nx-ease-out);
        z-index: 4;
    }

    .nx-spotlight:hover::after {
        opacity: 1;
    }

    .stat-card:hover,
    .profile:hover,
    .ad-banner-section:hover,
    .badges-section:hover,
    .recent-section:hover,
    .favorite-section:hover {
        border-color: rgba(var(--nx-accent-rgb), 0.28);
        transition: border-color 0.25s var(--nx-ease-out), transform 0.25s var(--nx-ease-out);
    }
}

/* Tactile active scale */
.waifu-card:active,
.game-card:active,
.banner-card:active,
.er-card:active,
.dt-waifu-card:active,
.mv2-filter-btn:active,
.mv2-search-btn:active,
.ad-banner-btn:active:not(:disabled) {
    transform: scale(0.97) !important;
    transition: transform 0.12s var(--nx-ease-out) !important;
}

/* Authored entrance animation (safe: content stays visible by default) */
@keyframes nxEnter {
    from {
        opacity: 0;
        transform: translate3d(0, 14px, 0) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

.nx-stagger-in {
    animation: nxEnter 0.48s var(--nx-ease-out) both;
    animation-delay: var(--nx-delay, 0ms);
}

/* SVG icon utility */
.nx-icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.12s !important;
        scroll-behavior: auto !important;
    }

    .nx-spotlight:hover {
        transform: none !important;
    }
}
