/* Spillsenteret - UX polish layer
   Loaded after the inline base styles to extend (not replace) them. */

/* ---------- Smooth page entrance ---------- */
@keyframes scFadeUp { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform:none; } }
@keyframes scFadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes scScaleIn { from { opacity:0; transform: scale(.96); } to { opacity:1; transform:none; } }

.topbar { animation: scFadeIn .45s ease both; }
.sidebar { animation: scFadeIn .55s ease both; }
.section-title { animation: scFadeUp .5s cubic-bezier(.2,.8,.2,1) both; }

/* Stagger card entrance - CSS-only via :nth-child */
.games-grid .game-card {
    animation: scFadeUp .55s cubic-bezier(.2,.8,.2,1) backwards;
    will-change: transform, opacity;
}
.games-grid .game-card:nth-child(1){animation-delay:.02s}
.games-grid .game-card:nth-child(2){animation-delay:.05s}
.games-grid .game-card:nth-child(3){animation-delay:.08s}
.games-grid .game-card:nth-child(4){animation-delay:.11s}
.games-grid .game-card:nth-child(5){animation-delay:.14s}
.games-grid .game-card:nth-child(6){animation-delay:.17s}
.games-grid .game-card:nth-child(7){animation-delay:.20s}
.games-grid .game-card:nth-child(8){animation-delay:.23s}
.games-grid .game-card:nth-child(9){animation-delay:.26s}
.games-grid .game-card:nth-child(10){animation-delay:.29s}
.games-grid .game-card:nth-child(11){animation-delay:.32s}
.games-grid .game-card:nth-child(12){animation-delay:.35s}
.games-grid .game-card:nth-child(13){animation-delay:.38s}
.games-grid .game-card:nth-child(14){animation-delay:.41s}
.games-grid .game-card:nth-child(15){animation-delay:.44s}
.games-grid .game-card:nth-child(n+16){animation-delay:.47s}

/* ---------- Card tilt + glossy hover ---------- */
.game-card{
    transform-style: preserve-3d;
    perspective: 800px;
    transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .3s, border-color .25s;
}
.game-card .preview-wrap,
.game-card .card-info{
    transition: transform .35s cubic-bezier(.2,.8,.2,1);
    transform: translateZ(0);
}
.game-card.tilting{
    transform:
        perspective(800px)
        rotateX(var(--tx,0deg))
        rotateY(var(--ty,0deg))
        translateY(-4px) scale(1.015);
    box-shadow:
        0 24px 56px rgba(0,0,0,0.6),
        0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
        0 0 30px color-mix(in srgb, var(--accent) 22%, transparent);
}
.game-card.tilting .preview-canvas{ transform: translateZ(20px) scale(1.06); }
.game-card.tilting .card-info{ transform: translateZ(30px); }

/* Glare overlay */
.game-card::before{
    content:'';
    position:absolute; inset:0; border-radius:16px;
    background: radial-gradient(circle at var(--mx,50%) var(--my,50%),
        rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 25%, transparent 55%);
    opacity:0; transition: opacity .25s;
    pointer-events:none; z-index:3; mix-blend-mode: overlay;
}
.game-card.tilting::before{ opacity: 1; }

/* Card "Play" hint that appears on hover */
.game-card .sc-play-hint{
    position:absolute;
    top:14px; right:14px;
    width:36px; height:36px; border-radius:50%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display:flex; align-items:center; justify-content:center;
    color:#fff; opacity:0;
    transform: translateY(-6px) scale(.85);
    transition: opacity .25s, transform .3s cubic-bezier(.2,.8,.2,1);
    z-index:4;
    border:1px solid rgba(255,255,255,0.15);
    pointer-events:none;
}
.game-card .sc-play-hint svg{ width:14px; height:14px; fill:currentColor; margin-left:2px; }
.game-card:hover .sc-play-hint,
.game-card.tilting .sc-play-hint{
    opacity:1; transform: translateY(0) scale(1);
}

/* ---------- Click ripple ---------- */
.sc-ripple{
    position:absolute; border-radius:50%;
    background: radial-gradient(circle, rgba(255,255,255,0.55), rgba(255,255,255,0) 70%);
    transform: translate(-50%,-50%) scale(0);
    pointer-events:none;
    animation: scRipple .55s ease-out forwards;
    z-index: 999;
    mix-blend-mode: screen;
}
@keyframes scRipple{
    to{ transform: translate(-50%,-50%) scale(20); opacity:0; }
}

/* ---------- Page fade-out for navigation ---------- */
body.sc-leaving .main-wrap{
    animation: scFadeOut .25s ease forwards;
}
@keyframes scFadeOut{
    to { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Language switcher ---------- */
.lang-switch{
    display:inline-flex;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    transition: background .2s, border-color .2s;
}
.lang-switch:hover{
    background: rgba(255,255,255,0.07);
    border-color: rgba(129,140,248,0.4);
}
.lang-switch span{
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    padding: 4px 9px;
    border-radius: 999px;
    color: rgba(255,255,255,0.5);
    transition: background .25s cubic-bezier(.2,.8,.2,1), color .25s;
}
.lang-switch span.active{
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

/* ---------- Toast notifications ---------- */
.sc-toast-stack{
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex; flex-direction: column-reverse;
    gap: 8px;
    z-index: 99999;
    pointer-events: none;
}
.sc-toast{
    background: rgba(20,20,40,0.92);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 11px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .2px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    animation: scToastIn .35s cubic-bezier(.2,.8,.2,1) both;
    pointer-events: auto;
    max-width: 90vw;
    display: inline-flex; align-items: center; gap: 10px;
}
.sc-toast.leaving{ animation: scToastOut .25s ease forwards; }
.sc-toast.success{ border-color: rgba(74,222,128,0.35); }
.sc-toast.success::before{ content:''; width:8px; height:8px; border-radius:50%; background:#4ade80; box-shadow:0 0 10px #4ade80; }
.sc-toast.error{ border-color: rgba(239,68,68,0.35); }
.sc-toast.error::before{ content:''; width:8px; height:8px; border-radius:50%; background:#ef4444; box-shadow:0 0 10px #ef4444; }
.sc-toast.info::before{ content:''; width:8px; height:8px; border-radius:50%; background:#818cf8; box-shadow:0 0 10px #818cf8; }
@keyframes scToastIn { from { opacity:0; transform: translateY(20px) scale(.95); } to { opacity:1; transform: none; } }
@keyframes scToastOut { to { opacity:0; transform: translateY(20px) scale(.95); } }

/* ---------- Better focus rings (a11y) ---------- */
:focus{ outline: none; }
:focus-visible{
    outline: 2px solid #818cf8;
    outline-offset: 2px;
    border-radius: 8px;
}
.game-card:focus-visible{
    outline-offset: 4px;
}

/* ---------- Search input upgrades ---------- */
.search-wrap{ position: relative; }
.search-wrap::after{
    content: "/";
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    width: 20px; height: 20px;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4);
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    transition: opacity .2s;
}
.search-wrap:focus-within::after{ opacity: 0; }
.search-input{ padding-right: 38px; }

/* ---------- Sidebar tooltip popouts ---------- */
.sidebar-btn{ position: relative; }
.sidebar-btn::after{
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: rgba(20,20,40,0.95);
    color: #fff;
    font-size: 11px; font-weight: 700;
    letter-spacing: .3px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 200;
}
.sidebar-btn:hover::after{
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ---------- Mobile bottom-bar sidebar (replaces hidden sidebar on small) ---------- */
@media(max-width:640px){
    .sidebar{
        display: flex !important;
        width: 100% !important;
        height: 60px;
        top: auto !important; bottom: 0;
        left: 0; right: 0;
        flex-direction: row !important;
        padding: 6px 8px !important;
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.06);
        background: rgba(15,15,35,0.95) !important;
        gap: 4px !important;
        overflow-x: auto;
        z-index: 100;
        scrollbar-width: none;
    }
    .sidebar::-webkit-scrollbar{ display:none; }
    .sidebar-spacer{ display: none !important; }
    .sidebar-btn::before{
        left: 8px !important; top: auto !important; bottom: -3px !important;
        width: 16px !important; height: 3px !important;
        border-radius: 3px 3px 0 0 !important;
        transform: scaleX(0) !important;
    }
    .sidebar-btn.active::before{ transform: scaleX(1) !important; }
    .sidebar-btn::after{
        left: 50% !important; top: -32px !important;
        transform: translateX(-50%) !important;
    }
    .sidebar-btn:hover::after{
        transform: translateX(-50%) translateY(-2px) !important;
    }
    .main-wrap{ margin-left: 0 !important; padding-bottom: 70px; }
    .content{ padding-bottom: 80px !important; }
    #chatToggle, #chatPanel{ bottom: 76px !important; }
}

/* ---------- Smoother scrollbar ---------- */
::-webkit-scrollbar-thumb{
    background: linear-gradient(180deg, rgba(129,140,248,0.25), rgba(124,58,237,0.25));
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover{
    background: linear-gradient(180deg, rgba(129,140,248,0.5), rgba(124,58,237,0.5));
}

/* ---------- Reduced motion respect ---------- */
@media (prefers-reduced-motion: reduce){
    *, *::before, *::after{
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .game-card.tilting{ transform: none !important; }
}

/* ---------- Subtle ambient glow behind hovered card ---------- */
.games-grid{ position: relative; }

/* ---------- Better disabled state ---------- */
button:disabled, .casino-btn:disabled{ filter: saturate(.4); }

/* ---------- Topbar polish ---------- */
.topbar{ transition: background .25s; }
.topbar.scrolled{
    background: rgba(15,15,35,0.85) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

/* ---------- Game-card best-score chip subtle pulse on update ---------- */
.card-best.flash{ animation: scFlash 1.2s ease; }
@keyframes scFlash{
    0%{ background: rgba(129,140,248,0.5); transform: scale(1.05); }
    100%{ background: rgba(0,0,0,0.35); transform: scale(1); }
}
