/* style.css v2.2 - Rank Position Final Fix */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #00aaff; /* This will be overridden by user's choice */
    --background-color: #0B0C10;
    --surface-color: #1F2833;
    --surface-color-darker: #161d25;
    --text-color: #C5C6C7;
    --text-color-heading: #FFFFFF;
    --border-color: #2c3a47;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

main {
    padding: 1rem;
}

/* --- HOMEPAGE STYLES --- */

/* --- Spotlight Section --- */
.spotlight-section {
    margin-bottom: 3rem;
}

.spotlight-section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color-heading);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
}

.spotlight-slider-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    background-color: var(--surface-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.spotlight-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 1;
    cursor: pointer;
}

.spotlight-slide.active {
    opacity: 1;
    z-index: 2;
}

.spotlight-slide .slide-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease-in-out;
}

.spotlight-slide.active .slide-poster {
    transform: scale(1.05);
}

.spotlight-slide .slide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(11, 12, 16, 0.9) 15%, rgba(11, 12, 16, 0.5) 50%, transparent 100%);
    z-index: 2;
}

/* FIX: Correct selector for .rank */
.spotlight-slide .rank {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 4; /* Ensure it's on top of other elements */
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    background: var(--primary-color);
    padding: 0.5rem 1rem;
    border-bottom-right-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.spotlight-slide .slide-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2rem;
    z-index: 3;
    color: white;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.6s ease-out;
    transition-delay: 0.3s;
}

.spotlight-slide.active .slide-content {
    transform: translateY(0);
    opacity: 1;
}

.slide-content .slide-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slide-content .slide-rating {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffc107;
    margin-bottom: 1rem;
}

.slide-content .slide-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.slide-content .genre-badge {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    color: #f0f0f0;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Latest Anime Section --- */
.anime-list-section {
    margin-bottom: 3rem;
}

.anime-list-section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color-heading);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
}

.anime-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem 1rem;
}

.anime-card {
    background-color: transparent;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.3s ease;
}

.anime-card:hover {
    transform: translateY(-8px);
}

.anime-card .card-img-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    background-color: var(--surface-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.3s ease;
}

.anime-card:hover .card-img-container {
    box-shadow: 0 10px 25px rgba(0,0,0,0.5), 0 0 0 3px var(--primary-color);
}

.anime-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.anime-card:hover img {
    transform: scale(1.05);
}

.anime-card h3 {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4em;
    height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Skeletons for Homepage --- */
@keyframes shimmer {
    0% { background-position: -480px 0; }
    100% { background-position: 480px 0; }
}

.skeleton-card, .skeleton-spotlight-card {
    position: relative;
    overflow: hidden;
    background-color: var(--surface-color);
}

.skeleton-card::after, .skeleton-spotlight-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    background-size: 1000px 100%;
    animation: shimmer 1.5s infinite linear;
}

.skeleton-spotlight-card {
    width: 100%;
    height: 100%;
    border-radius: 16px;
}

.anime-card.skeleton {
    background: none;
}
.anime-card.skeleton .skeleton-img {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    background-color: var(--surface-color);
}
.anime-card.skeleton .skeleton-title {
    height: 1rem;
    width: 80%;
    border-radius: 4px;
    background-color: var(--surface-color);
}


/* --- APK Banner --- */
.apk-banner {
    display: none; /* Hidden by default, JS will show it */
    background: linear-gradient(45deg, var(--primary-color), #0077b3);
    color: white;
    text-align: center;
    padding: 1rem;
    margin: 0 0 2rem 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    position: relative;
    font-weight: 500;
}
.apk-banner p { margin: 0; }
.apk-banner a { color: white; font-weight: bold; text-decoration: underline; }
.apk-banner .close-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    opacity: 0.8;
}
.apk-banner .close-btn:hover { opacity: 1; }

/* --- Responsive --- */
@media (max-width: 768px) {
    main {
        padding: 0.5rem;
    }
    .spotlight-section h2, .anime-list-section h2 {
        font-size: 1.5rem;
    }
    .slide-content .slide-title {
        font-size: 1.8rem;
    }
    .anime-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem 0.75rem;
    }
    .anime-card h3 {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .anime-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem 0.5rem;
    }
}