/* FontAwesome Icons */
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css");
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css");

/* ----- 1. Global & Theme ----- */
:root {
    --color-primary-black: #121212;
    --color-secondary-black: #1a1a1a;
    --color-surface: #2a2a2a;
    --color-primary-red: #e60000;
    --color-text-primary: #f0f0f0;
    --color-text-secondary: #aaaaaa;
    --header-height-desktop: 80px; 
    --header-height-mobile: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Sansation", serif;
    font-weight: 300;
    font-style: normal;
    background-color: var(--color-primary-black);
    color: var(--color-text-primary);
    line-height: 1.6;
    position: relative;
}

body.modal-open > *:not(#signup-modal):not(#search-overlay) {
    filter: blur(5px);
    pointer-events: none;
}

a {
    color: var(--color-primary-red);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #ff4d4d;
}

img {
    max-width: 100%;
    display: block;
}

img.blur-load {
    filter: blur(8px);
    opacity: 0.6;
    transition: filter 0.4s ease-out, opacity 0.4s ease-out;
}

img.blur-load.loaded {
    filter: blur(0);
    opacity: 1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ----- 2. Header (Desktop-First) ----- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    height: var(--header-height-desktop);
    background-color: var(--color-secondary-black);
    border-bottom: 1px solid #333;
}

.logo-link {
    order: -1; 
    flex-shrink: 0;
}

.logo-img {
    height: 85px;
    width: auto;
    object-fit: contain;
}

.desktop-header-left {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-left: 35px;
}

.desktop-nav-links .nav-list {
    display: flex;
    gap: 25px;
    list-style: none;
}

.desktop-nav-links .nav-link,
#signup-open-btn-desktop {
    color: var(--color-text-primary);
    font-weight: 300;
    font-size: 1rem;
    padding: 10px 0;
    position: relative;
}

.desktop-nav-links .nav-link::after,
#signup-open-btn-desktop::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-primary-red);
    transition: width 0.3s ease;
}

.desktop-nav-links .nav-link:hover::after,
#signup-open-btn-desktop:hover::after {
    width: 100%;
}

.desktop-header-right {
     /* container for search */
}

.nav-search-btn {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.nav-search-btn:hover {
    color: var(--color-primary-red);
}

button.nav-link {
    background: none;
    border: none;
    cursor: pointer;
    font-family: "Sansation", serif;
}

.mobile-nav-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.8rem;
    cursor: pointer;
}

/* ----- 3. Mobile Nav Drawer ----- */
.mobile-nav-drawer {
    position: fixed;
    top: var(--header-height-mobile);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height-mobile));
    background-color: var(--color-secondary-black);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    padding: 20px;
    overflow-y: auto;
    border-top: 1px solid #333;
}

.mobile-nav-drawer.open {
    transform: translateX(0);
}

.mobile-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.mobile-nav-list li {
    border-bottom: 1px solid #333;
}

.mobile-nav-list .nav-link {
    display: block;
    width: 100%; 
    padding: 18px 10px;
    color: var(--color-text-primary);
    font-size: 1.2rem;
    font-weight: 300;
    text-align: left; 
}

.mobile-nav-list .nav-link:hover {
    background-color: #333;
}

.mobile-nav-extras {
    padding: 20px 10px;
}

.mobile-nav-extras .nav-link {
     display: block;
    padding: 12px 0;
    color: var(--color-text-secondary);
    font-size: 1rem;
}

.mobile-nav-extras .nav-link:hover {
    color: var(--color-text-primary);
}

.mobile-social-header {
    color: var(--color-text-secondary);
    font-size: 1rem;
    font-weight: 300;
    margin-top: 20px;
    margin-bottom: 15px;
}

.mobile-social-links {
    display: flex;
    gap: 25px;
    list-style: none;
}

.mobile-social-links a {
    font-size: 1.8rem;
    color: var(--color-text-secondary);
}

.mobile-social-links a:hover {
    color: #fff;
}

/* ----- 4. Search Overlay ----- */
#search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#search-overlay.visible {
    opacity: 1;
}

#search-close-btn {
    position: absolute;
    top: 30px;
    right: 40px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 3rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

#search-close-btn:hover {
    color: var(--color-primary-red);
}

.search-container {
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    margin-top: 5vh;
}

.search-header {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--color-primary-red);
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 2rem;
    padding: 10px 0;
}

#search-input::placeholder {
    color: #777;
}

#search-results {
    margin-top: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding-right: 10px;
}

#search-results::-webkit-scrollbar {
    width: 8px;
}
#search-results::-webkit-scrollbar-track {
    background: var(--color-secondary-black);
    border-radius: 4px;
}
#search-results::-webkit-scrollbar-thumb {
    background-color: var(--color-primary-red);
    border-radius: 4px;
}

.search-result-card {
    background-color: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
    text-decoration: none;
}
.search-result-card:hover {
    transform: translateY(-5px);
}
.search-card-image {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
}
.search-card-content {
    padding: 10px;
}
.search-card-title {
    font-size: 1rem;
    font-weight: 300;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-card-chapter {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 5px;
}

#search-results .no-results {
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    text-align: center;
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    grid-column: 1 / -1;
}

.chibi-img {
    width: auto;
    height: 150px;
}


/* ----- 5. Signup / Login Modal ----- */
#signup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    display: none;
    overflow: auto;
}

.modal-content {
    background-color: var(--color-surface);
    margin: 10vh auto;
    padding: 25px;
    border: 1px solid #444;
    width: 90%;
    max-width: 450px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #fff;
}

#form-title {
    text-align: center;
    font-weight: 300;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

#error-message {
    color: var(--color-primary-red);
    background-color: rgba(230, 0, 0, 0.1);
    border: 1px solid var(--color-primary-red);
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: 300;
    min-height: 1.5em;
}

#error-message:empty {
    display: none;
}

#signup-form input[type="text"],
#signup-form input[type="email"],
#signup-form input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 5px;
    font-weight: 300;
    font-size: 1rem;
}

#signup-form input[type="email"] {
    text-transform: lowercase;
}

#signup-form input[type="text"]:focus,
#signup-form input[type="email"]:focus,
#signup-form input[type="password"]:focus {
    outline: none;
    border-color: var(--color-primary-red);
}

.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    margin-top: -7.5px;
    color: #888;
    cursor: pointer;
}

#signup-form #submit-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--color-primary-red);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 300;
    transition: background-color 0.3s ease;
}

#signup-form #submit-btn:hover {
    background-color: #c00;
}

.form-disclaimer {
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 15px;
    text-align: center;
}

.form-disclaimer a {
    color: var(--color-primary-red);
    font-weight: 300;
}

#switch-form {
    text-align: center;
    margin-top: 20px;
    color: var(--color-text-secondary);
    cursor: pointer;
}

#switch-form span {
    color: var(--color-primary-red);
    font-weight: 300;
}

/* ----- 10. Footer (from index-style.css) ----- */
.main-footer {
    background-color: var(--color-secondary-black);
    border-top: 1px solid #333;
    padding: 40px 20px;
    margin-top: 40px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    text-align: left;
}

.footer-logo {
    width: 150px;
    margin-bottom: 20px;
}

.footer-column {
    display: flex;
    flex-direction: column;
}

.footer-column h4 {
    font-weight: 300;
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #fff;
}

.footer-column a,
.footer-column p {
    color: var(--color-text-secondary);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.footer-column a:hover {
    color: #fff;
}

.social-links {
    display: flex;
    gap: 15px;
}

.social-links a {
    font-size: 1.5rem;
    color: var(--color-text-secondary);
}

.footer-bottom {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #444;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--color-text-secondary);
}

/* ----- 11. Media Queries (Mobile Responsive) ----- */
@media (max-width: 768px) {
    .main-header {
        height: var(--header-height-mobile);
        display: grid;
        grid-template-columns: 50px 1fr 50px;
        padding: 0 15px;
        align-items: center;
    }

    .desktop-header-left,
    .desktop-header-right {
        display: none;
    }

    .mobile-nav-btn {
        display: block;
        font-size: 1.6rem;
    }

    #hamburger-btn {
        grid-column: 1;
        justify-self: start;
    }

    .logo-link {
        order: 0;
        grid-column: 2;
        justify-self: center;
    }

    .logo-img {
        height: 70px;
    }

    #search-btn-mobile {
        grid-column: 3;
        justify-self: end;
    }

    .search-container {
        height: 90vh;
    }
    #search-results {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    .search-card-title {
        font-size: 0.9rem;
    }
    #search-input {
        font-size: 1.5rem;
    }
    #search-close-btn {
        top: 20px;
        right: 20px;
    }

    .footer-container {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .footer-logo {
        margin: 0 auto 20px;
    }
    .social-links {
        justify-content: center;
    }
}

/* ===== 12. Background Scroller (Not used on this page) ===== */
.background-scroller {
    display: none;
}

/*
=====================================================
NEW RANKING STYLES
=====================================================
*/

.section-title {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-primary-red);
    display: inline-block;
}

/* ----- 1. Top 3 Ranking (Desktop) ----- */
.ranking-top-3 {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr; 
    gap: 15px;
    align-items: flex-end; /* Keeps 1 taller than 2 & 3 on Desktop */
    margin-bottom: 40px;
    padding-top: 20px;
}

.rank-card {
    background-color: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-decoration: none;
    color: var(--color-text-primary);
    transition: transform 0.3s ease;
    border-bottom: 3px solid var(--color-surface);
}
.rank-card:hover {
    transform: translateY(-5px);
}

.rank-1 { order: 2; border-color: #ffd700; }
.rank-2 { order: 1; border-color: #c0c0c0; }
.rank-3 { order: 3; border-color: #cd7f32; }

.rank-card .card-image {
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}
.rank-card .card-content {
    padding: 15px;
}
.rank-card .rank-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.rank-1 .rank-number { color: #ffd700; }
.rank-2 .rank-number { color: #c0c0c0; }
.rank-3 .rank-number { color: #cd7f32; }

.rank-card .card-title {
    font-size: 1.1rem;
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 5px;
}
.rank-card .card-info {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 8px;
}
.rank-card .card-info i {
    margin-right: 5px;
}

/* Desktop: Rank 1 is bigger than 2 & 3 */
.rank-1 .rank-number { font-size: 2.5rem; }
.rank-1 .card-title { font-size: 1.2rem; }


/* ----- 2. Ranks 4-50 (Shared Manga Card styles) ----- */
.manga-card {
    background-color: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}
.manga-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.5);
}
.new-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #555; /* Rank number background */
    color: #fff;
    padding: 3px 8px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 5px;
    z-index: 2;
}
.card-image-link {
    display: block;
    position: relative;
}
.card-image {
    width: 100%;
    aspect-ratio: 2 / 3; 
    object-fit: cover;
}
.card-image-link::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 40%);
}
.card-content {
    padding: 15px;
}
.card-title {
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-info {
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
}

/* Grid for Ranks 4-10 */
.ranking-grid-large {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
    gap: 25px;
}

/* Grid for Ranks 11-50 */
.ranking-grid-small {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
    gap: 25px;
}

/* Smaller card variant for ranks 11-50 */
.manga-card-small .card-content {
    padding: 10px;
}
.manga-card-small .card-title {
    font-size: 1rem;
}
.manga-card-small .card-info {
    font-size: 0.8rem;
    margin-top: 5px;
}
.manga-card-small .new-badge {
    font-size: 0.8rem;
    padding: 2px 6px;
}


/* ----- 3. Mobile ----- */
@media (max-width: 768px) {
    /* MODIFIED: Ranks 1-3 are now 3-col */
    .ranking-top-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        align-items: stretch; /* FIX: Changed from flex-end to stretch so they are same height */
    }
    
    /* MODIFIED: Re-apply order for 2, 1, 3 layout */
    .rank-1 { order: 2; }
    .rank-2 { order: 1; }
    .rank-3 { order: 3; }
    
    /* FIX: Force equal height on cards */
    .rank-card {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    /* FIX: Push content to fill space */
    .rank-card .card-content {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 10px;
    }
    
    /* MODIFIED: Make all Top 3 cards the same size */
    .rank-card .rank-number,
    .rank-1 .rank-number { /* Override desktop rules */
        font-size: 1.5rem;
    }
    
    .rank-card .card-title,
    .rank-1 .card-title { /* Override desktop rules */
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .rank-card .card-info {
        font-size: 0.7rem;
        margin-top: 4px;
    }
    
    /* MODIFIED: Ranks 4-10 are 3-col */
    .ranking-grid-large {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    /* MODIFIED: Ranks 11-50 are 4-col */
    .ranking-grid-small {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    /* Mobile styles for the main cards (4-10) */
    .ranking-grid-large .card-content {
        padding: 10px;
    }
    .ranking-grid-large .card-title {
        font-weight: 300;
        font-size: 0.8rem;
    }
    .ranking-grid-large .card-info {
        font-weight: 300;
        font-size: 0.7rem;
    }
    
    /* Mobile styles for the small cards (11-50) */
    .ranking-grid-small .manga-card-small .card-content {
        padding: 5px;
    }
    .ranking-grid-small .manga-card-small .card-title {
        font-size: 0.7rem;
    }
    .ranking-grid-small .manga-card-small .card-info {
        font-size: 0.6rem;
        margin-top: 3px;
    }
    .ranking-grid-small .manga-card-small .new-badge {
        font-size: 0.6rem;
        padding: 1px 4px;
        top: 5px;
        left: 5px;
    }
}