/* ======= SHARED NAVIGATION BAR STYLES ======= */

html {
    /* Prevents horizontal "jump" when navigating between pages with/without scrollbars */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 transparent;
}

/* Custom Scrollbar Styles (Universal) */
* {
    scrollbar-width: thin;
    scrollbar-color: #d1d1d6 transparent;
}
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.3s ease;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #514099 !important;
    border: 0px;
}



.topnav {
    width: 100% !important;
    min-height: 80px; 
    height: auto;
    padding: 10px 40px; 
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex !important;
    flex-wrap: wrap; 
    align-items: center;
    gap: 20px;
    flex-shrink: 0 !important;
    border-bottom: 1px solid #f0f0f2;
    position: sticky;
    top: 0;
    z-index: 2000;
}

body.detail-view-active .topnav {
    display: none !important;
}

.nav-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 30px;
    text-decoration: none;
}

.nav-logo img {
    height: 100%;
    width: auto;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f5f5f7;
    border-radius: 100px;
    padding: 10px 20px;
    flex: 1;
    max-width: 500px;
    border: 1px solid #e8e8ed;
}

.search-bar svg {
    width: 20px;
    height: 20px;
    color: #86868b;
    flex-shrink: 0;
}

.search-bar input {
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    color: #1d1d1f;
    background: transparent;
    border: none;
    outline: none;
    flex: 1;
    min-width: 0;
}

.search-bar input::placeholder {
    color: #86868b;
}

.site-nav, .nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-auth {
    display: flex;
    align-items: center;
    gap: 24px;
    width: auto;
    justify-content: flex-end;
}

.site-nav {
    margin-left: auto;
    flex-shrink: 0;
}

.nav-pill {
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: #1d1d1f;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.nav-pill:hover {
    color: #514099;
}

.nav-pill.active {
    color: #514099;
    /* font-weight removed to prevent horizontal shift when switching pages */
}

.nav-pill.signup {
    background: linear-gradient(90deg, #35a2ff 0%, #9254de 100%);
    color: #fff !important;
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(146, 84, 222, 0.25);
    text-decoration: none;
}

.nav-pill.signup:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(146, 84, 222, 0.35);
    color: #fff !important;
}

/* ======= USER AVATAR & DROPDOWN ======= */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Added hex fallbacks in case variables are missing */
    background: #514099;
    background: linear-gradient(135deg, var(--brand-purple, #514099) 0%, var(--brand-pink, #C74586) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(81, 64, 153, 0.2);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid white;
}

.user-profile:hover .user-avatar {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(146, 84, 222, 0.3);
}

.avatar-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 200px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 18px;
    padding: 8px;
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.user-profile.active .avatar-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: all;
    z-index: 2001;
}

.dropdown-user-info {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
}

.dropdown-user-info .user-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-info .user-email {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-download-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(81, 64, 153, 0.08);
    border-radius: 8px;
    color: #514099;
    width: fit-content;
}

.user-download-stats .material-icons-outlined {
    font-size: 14px;
}

.download-count-text {
    font-size: 11px;
    font-weight: 700;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-mid);
    text-decoration: none;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: rgba(81, 64, 153, 0.06);
    color: var(--brand-purple);
}

.dropdown-item.logout {
    color: #e63946;
}

.dropdown-item.logout:hover {
    background: rgba(230, 57, 70, 0.06);
    color: #e63946;
}

.dropdown-item span {
    font-size: 18px;
}

/* ======= MOBILE DRAWER & HAMBURGER ======= */
.hamburger-menu {
    width: 40px;
    height: 40px;
    display: none; /* Hide by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s;
    color: #514099;
}

.hamburger-menu:hover {
    background: rgba(81, 64, 153, 0.08);
}

.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 30, 0.4);
    backdrop-filter: blur(4px);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: #fff;
    z-index: 3001;
    display: flex;
    flex-direction: column;
    transform: translateX(-110%); /* Start completely off-screen */
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); /* Ultra-smooth quintic transition */
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.15);
}

.mobile-drawer.active {
    transform: translateX(0);
}

/* Staggered item animations when active */
.mobile-drawer .drawer-item {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-drawer.active .drawer-item {
    opacity: 1;
    transform: translateX(0);
}

/* Add delays for staggering */
.mobile-drawer.active .drawer-item:nth-child(1) { transition-delay: 0.1s; }
.mobile-drawer.active .drawer-item:nth-child(2) { transition-delay: 0.15s; }
.mobile-drawer.active .drawer-item:nth-child(3) { transition-delay: 0.2s; }
.mobile-drawer.active .drawer-item:nth-child(4) { transition-delay: 0.25s; }
.mobile-drawer.active .drawer-auth .drawer-item:nth-child(1) { transition-delay: 0.35s; }
.mobile-drawer.active .drawer-auth .drawer-item:nth-child(2) { transition-delay: 0.4s; }
.mobile-drawer.active .drawer-user-info { 
    opacity: 1; transform: translateX(0); transition: all 0.4s ease 0.3s;
}
.mobile-drawer .drawer-user-info {
    opacity: 0; transform: translateX(-20px);
}

.drawer-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f4;
}

.drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f5f5f7;
    color: #514099;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 24px;
    color: #1d1d1f;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
}

.drawer-item:hover {
    background: rgba(81, 64, 153, 0.05);
    color: #514099;
}

.drawer-item.active {
    color: #514099;
    background: rgba(81, 64, 153, 0.08);
}

.drawer-item .material-icons-outlined {
    font-size: 22px;
}

.drawer-divider {
    height: 1px;
    background: #f0f0f4;
    margin: 15px 24px;
}

.drawer-user-info {
    padding: 0 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-user-info .user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.drawer-user-info .user-name {
    font-weight: 700;
    font-size: 15px;
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-user-info .user-email {
    font-size: 12px;
    color: #86868b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-item.logout {
    color: #e63946;
}

.signup-promo {
    color: #9254de !important;
}

/* ======= RESPONSIVE MEDIA QUERIES ======= */

@media (max-width: 900px) {
    .topnav {
        width: 100% !important;
        height: auto;
        min-height: 60px;
        padding: 8px 15px;
        gap: 15px;
        flex-wrap: nowrap; /* Keep logo and hamburger on one line */
        position: sticky;
        top: 0;
        z-index: 2000;
        display: flex !important;
    }

    .nav-logo img {
        height: 24px;
        max-width: 140px;
        object-fit: contain;
    }

    .search-bar {
        display: none; /* Hide main search bar on mobile, maybe add a search icon instead? */
    }

    .site-nav {
        display: none !important; /* Hide desktop nav links */
    }

    .hamburger-menu {
        display: flex !important;
    }

    .nav-auth {
        display: none !important; /* Hide desktop auth buttons */
    }
}

/* Authentication Flicker Prevention */
.auth-pre-check .guest-only {
    display: none !important;
}

/* Hide placeholder by default (for guests) */
.nav-auth-placeholder {
    display: none;
}

/* Show placeholder ONLY when auth pre-check assumes logged in */
.auth-pre-check .nav-auth-placeholder {
    display: block;
}

/* Zero-Delay Placeholder Initials */
.nav-auth-placeholder .user-avatar::after {
    content: var(--cached-initials, '');
}

/* ======= CARD SAVE BUTTON ======= */
.game-thumb, .ws-thumb {
    position: relative;
}

.card-save-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
    z-index: 20;
    /* Always visible on touch devices; hidden only on hover-capable devices */
    opacity: 1;
    transform: scale(1);
}

@media (hover: hover) {
    .card-save-btn {
        opacity: 0;
        transform: scale(0.8);
    }

    .game-card:hover .card-save-btn,
    .ws-card:hover .card-save-btn {
        opacity: 1;
        transform: scale(1);
    }
}

.card-save-btn .material-icons-outlined {
    font-size: 18px;
    color: #514099;
}

.card-save-btn.saved {
    background: #514099;
    opacity: 1;
    transform: scale(1);
}

.card-save-btn.saved .material-icons-outlined {
    color: #fff;
}

.card-save-btn:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 4px 16px rgba(81,64,153,0.3);
}

/* ======= DETAIL PAGE SAVE BUTTON ======= */
.btn-detail-save {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 30px;
    border: 2px solid #514099;
    background: transparent;
    color: #514099;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.btn-detail-save:hover {
    background: rgba(81,64,153,0.08);
    transform: scale(1.03);
}

.btn-detail-save.saved {
    background: #514099;
    color: #fff;
    border-color: #514099;
}

.btn-detail-save.saved:hover {
    background: #3d2f7a;
}

.save-btn-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
    line-height: 1;
    transition: background 0.2s;
    cursor: pointer;
    vertical-align: middle;
}

.btn-detail-save.saved:hover .save-btn-remove {
    background: rgba(255,255,255,0.45);
}

/* ======= LOGIN PROMPT OVERLAY ======= */
#login-prompt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 30, 0.6);
    backdrop-filter: blur(6px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

#login-prompt-box {
    background: #fff;
    border-radius: 24px;
    padding: 40px 36px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.2);
    animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.lp-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #514099, #C74586);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.lp-icon .material-icons-outlined {
    font-size: 30px;
    color: #fff;
}

.lp-title {
    font-size: 22px;
    font-weight: 800;
    color: #111;
    margin-bottom: 10px;
    font-family: 'Outfit', sans-serif;
}

.lp-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
}

.lp-btn-primary {
    display: block;
    background: linear-gradient(90deg, #35a2ff 0%, #9254de 100%);
    color: #fff;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 20px rgba(146,84,222,0.3);
}

.lp-btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 28px rgba(146,84,222,0.4);
}

.lp-btn-close {
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    padding: 8px;
    transition: color 0.2s;
}

.lp-btn-close:hover { color: #333; }

/* ======= SAVED ITEMS POPUP ======= */
#saved-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 30, 0.55);
    backdrop-filter: blur(8px);
    z-index: 99997;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

#saved-popup-box {
    background: #fff;
    border-radius: 24px;
    width: 560px;
    max-width: 94vw;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,0.2);
    animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
    overflow: hidden;
}

.sp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f4;
    flex-shrink: 0;
}

.sp-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 800;
    color: #111;
    font-family: 'Outfit', sans-serif;
}

.sp-title .material-icons-outlined {
    font-size: 22px;
    color: #514099;
}

.sp-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f5f5f7;
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sp-close:hover { background: #e8e8ec; }

.sp-tabs {
    display: flex;
    padding: 12px 24px 0;
    gap: 8px;
    border-bottom: 1px solid #f0f0f4;
    flex-shrink: 0;
}

.sp-tab {
    padding: 10px 18px;
    border-radius: 12px 12px 0 0;
    border: none;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.sp-tab:hover { color: #514099; background: rgba(81,64,153,0.05); }

.sp-tab.active {
    color: #514099;
    border-bottom-color: #514099;
    background: rgba(81,64,153,0.06);
}

.sp-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.sp-panel {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    overflow-y: auto;
    max-height: calc(82vh - 160px);
}

.sp-panel.active { display: flex; }

.sp-empty {
    text-align: center;
    color: #aaa;
    font-size: 15px;
    padding: 48px 20px;
}

.sp-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.sp-item:hover { background: rgba(81,64,153,0.05); }

.sp-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0edf8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sp-info {
    flex: 1;
    min-width: 0;
}

.sp-item-title {
    font-size: 14px;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-item-sub {
    font-size: 12px;
    color: #888;
    margin-top: 3px;
}

.sp-unsave {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sp-unsave:hover {
    background: rgba(230,57,70,0.08);
    color: #e63946;
}

.sp-unsave .material-icons-outlined { font-size: 20px; }

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ======= SHARED FOOTER STYLES ======= */
.footer {
    background: #ffffff;
    border-top: 1px solid #eaeaea;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 100;
    margin-top: auto;
}

.footer-copy {
    font-size: 14px;
    color: #86868b;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: #86868b;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    color: #514099;
}

@media (max-width: 768px) {
    .footer {
        flex-direction: column-reverse;
        gap: 16px;
        text-align: center;
        padding: 30px 20px;
    }
    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px 20px;
    }
}

