:root {
    --bg: #0b0b10;
    --yellow: #FFBF26;
    --blue: #6392EE;
    --orange: #FF9D5E;
    --red: #FF6464;
    --green: #3AC884;
    --purple: #BF67FF;
    --teal: #3AACC8;
    --black: #1B1B1B;
    --dark-gray: #666666;
    --light-gray: #A8A8A8;
    --separator-gray: #EFEFEF;
}

body {
    --dot-color: #D3D3D3;
    --dot-size: .8px;
    --dot-spacing: 16px;
    --off-black: #1b1b1b;

    font-family: "SF Pro Rounded", "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    background-image: radial-gradient(circle, var(--dot-color) var(--dot-size), transparent var(--dot-size));
    background-size: var(--dot-spacing) var(--dot-spacing);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
    body {
        --dot-color: #4a4a4a;
        background-color: #0b0b10;
    }

    .filter-toggle {
        background: #1a1a1f;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    .filter-btn {
        color: var(--light-gray);
    }

    .filter-btn:hover {
        color: white;
    }

    .explore-header {
        background-color: #1a1a1f;
        box-shadow: 0px 2px 19px 0px rgba(0, 0, 0, 0.3);
    }

    .explore-title {
        color: white;
    }

    .explore-subtitle {
        color: var(--light-gray);
    }
}

.top-logo {
    display: block;
    margin: 0 auto 20px;
    height: 40px;
    max-width: 120px;
    width: auto;
    object-fit: contain;
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: transform 0.3s ease;
}

.top-logo:hover {
    transform: rotate(-5deg) scale(1.1);
    animation: wiggle 0.5s ease;
}

/* Filter toggle */
.filter-toggle {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    background: white;
    border-radius: 50px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 4px;
    z-index: 1000;
    animation: filterToggleBounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.filter-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--dark-gray);
    font-family: "SF Pro Rounded", "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.filter-btn:hover {
    transform: scale(1.05);
    color: var(--black);
}

.filter-btn.active {
    background: var(--green);
    color: white;
    box-shadow: 0 4px 12px rgba(58, 200, 132, 0.3);
    transform: scale(1);
}

.filter-btn.active:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(58, 200, 132, 0.4);
}

.page-container {
    width: 100%;
    position: relative;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-20px);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) translateY(0);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes filterToggleBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(var(--initial-rotation)) scale(1);
    }
    25% {
        transform: rotate(calc(var(--initial-rotation) - 3deg)) scale(1);
    }
    75% {
        transform: rotate(calc(var(--initial-rotation) + 3deg)) scale(1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes rainbowShimmer {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Explore Header */
.explore-header {
    background-color: white;
    border-radius: 32px;
    box-shadow: 0px 2px 19px 0px rgba(0,0,0,0.1);
    padding: 28px 32px;
    margin-bottom: 24px;
    text-align: center;
    animation: fadeInScale 0.5s ease-out forwards;
}

.explore-title {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 800;
    color: var(--off-black);
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.explore-subtitle {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--dark-gray);
    line-height: 1.4;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.post-cell {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 25px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.3s ease,
                filter 0.3s ease;
    background-color: #eee;
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.25);
    text-decoration: none;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    filter: brightness(1);
    --initial-rotation: 0deg;
    transform: rotate(var(--initial-rotation));
}

.post-cell:active {
    transform: scale(0.95) rotate(0deg);
    transition: transform 0.1s ease;
}

.post-cell:nth-child(1) { animation-delay: 0.05s; }
.post-cell:nth-child(2) { animation-delay: 0.1s; }
.post-cell:nth-child(3) { animation-delay: 0.15s; }
.post-cell:nth-child(4) { animation-delay: 0.2s; }
.post-cell:nth-child(5) { animation-delay: 0.25s; }
.post-cell:nth-child(6) { animation-delay: 0.3s; }
.post-cell:nth-child(7) { animation-delay: 0.35s; }
.post-cell:nth-child(8) { animation-delay: 0.4s; }
.post-cell:nth-child(9) { animation-delay: 0.45s; }
.post-cell:nth-child(10) { animation-delay: 0.5s; }
.post-cell:nth-child(11) { animation-delay: 0.55s; }
.post-cell:nth-child(12) { animation-delay: 0.6s; }
.post-cell:nth-child(13) { animation-delay: 0.65s; }
.post-cell:nth-child(14) { animation-delay: 0.7s; }
.post-cell:nth-child(15) { animation-delay: 0.75s; }
.post-cell:nth-child(16) { animation-delay: 0.8s; }
.post-cell:nth-child(17) { animation-delay: 0.85s; }
.post-cell:nth-child(18) { animation-delay: 0.9s; }

.post-cell:hover {
    transform: scale(1.08) rotate(3deg) translateY(-8px);
    box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.3), 
                0 0 0 4px rgba(255, 255, 255, 0.8),
                0 0 20px rgba(99, 146, 238, 0.3);
    z-index: 100;
    filter: brightness(1.1) saturate(1.1);
}


.post-cell-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.post-cell:hover .post-cell-image {
    transform: scale(1.05);
    filter: saturate(1.2) contrast(1.05);
}

.post-cell-avatar-container {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    overflow: hidden;
    background-color: #ccc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                border-color 0.3s ease;
}

.post-cell:hover .post-cell-avatar-container {
    transform: scale(1.3) translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: #fff;
    border-width: 2px;
}

.post-cell-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-cell:hover .post-cell-avatar {
    transform: rotate(5deg) scale(1.1);
}

/* Loading placeholders */
.post-cell.placeholder {
    background: linear-gradient(
        90deg,
        #FFBF26 0%,
        #FF9D5E 14%,
        #FF6464 28%,
        #BF67FF 42%,
        #6392EE 57%,
        #3AACC8 71%,
        #3AC884 85%,
        #FFBF26 100%
    );
    background-size: 300% 100%;
    animation: rainbowShimmer 3s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.4;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .explore-header {
        padding: 20px 24px;
        margin-bottom: 16px;
    }

    .explore-title {
        font-size: 24px;
    }

    .explore-subtitle {
        font-size: 14px;
    }

    .filter-toggle {
        top: auto;
        bottom: 20px;
        padding: 4px;
    }
    
    .filter-btn {
        padding: 8px 20px;
        font-size: 14px;
    }

    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .post-cell {
        border-radius: 20px;
    }
    
    .post-cell:hover {
        transform: scale(1.05) rotate(2deg) translateY(-5px);
    }

    .post-cell-avatar-container {
        width: 28px;
        height: 28px;
        bottom: 6px;
        right: 6px;
    }
    
    .top-logo {
        height: 36px;
    }
}

@media (max-width: 400px) {
    .posts-grid {
        gap: 6px;
    }
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--purple), var(--blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease,
                box-shadow 0.3s ease;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    color: white;
    font-size: 24px;
    text-decoration: none;
    border: 3px solid white;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: scale(1.15) translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    animation: bounce 0.6s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1.15) translateY(-5px);
    }
    50% {
        transform: scale(1.15) translateY(-10px);
    }
}

@media (max-width: 600px) {
    .back-to-top {
        width: 48px;
        height: 48px;
        bottom: 20px;
        right: 20px;
        font-size: 20px;
    }
}

/* Sparkle effect */
.sparkle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: sparkleAnimation 0.8s ease-out forwards;
    --tx: 0px;
    --ty: 0px;
}

@keyframes sparkleAnimation {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0);
        opacity: 0;
    }
}

/* Cursor trail effect */
.cursor-trail {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    animation: cursorTrailAnimation 0.6s ease-out forwards;
    transform: translate(-50%, -50%);
    opacity: 0.6;
}

@keyframes cursorTrailAnimation {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
}

