/* =========================================
   LEGENDARY TECH GRID (2026 Mobile/PC)
   ========================================= */

/* Main Grid Container */
.magma-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

/* Card Wrapper */
.legend-card {
    position: relative;
    background: transparent;
    border-radius: 0;
    overflow: visible;
    transition: transform 0.3s ease;
}

/* Inner Wrapper for Flex Control */
.legend-inner {
    display: block;
}

/* 1. Poster Area */
.legend-poster {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.legend-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease, filter 0.5s ease;
}

/* Hover Effect */
.legend-poster:hover .legend-img {
    transform: scale(1.1);
    filter: brightness(0.6);
}

/* Overlay & Play Button */
.legend-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.legend-poster:hover .legend-overlay {
    opacity: 1;
}

.legend-play {
    width: 50px;
    height: 50px;
    background: #ff0055;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.legend-poster:hover .legend-play {
    transform: scale(1);
}

/* Badges on Image */
.legend-rating {
    display: none !important;
}

.legend-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff0055;
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 5;
    box-shadow: 0 2px 10px rgba(255, 0, 85, 0.4);
}

/* 2. Content Area */
.legend-content {
    position: relative;
    padding: 0 2px;
}

.legend-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-title a {
    color: #fff;
    transition: color 0.2s;
    text-decoration: none;
}

.legend-title a:hover {
    color: #ff0055;
}

.legend-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.legend-genre {
    color: #888;
    font-size: 11px;
    font-weight: 600;
}

/* Chapter Links */
.legend-chapters {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-ch-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    text-decoration: none;
}

.legend-ch-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(-2px);
}

.ch-txt {
    color: #ddd;
    font-size: 11px;
    font-weight: 600;
}

.legend-ch-link:hover .ch-txt {
    color: white;
}

.ch-time {
    color: #666;
    font-size: 10px;
}

/* Locked Chapter Style */
.legend-ch-link.locked-chapter {
    border-color: rgba(255, 204, 0, 0.3);
    background: rgba(255, 204, 0, 0.05);
    /* Slight Gold Tint */
}

.legend-ch-link.locked-chapter .ch-txt {
    color: #ffcc00;
    /* Gold Text */
}

.legend-ch-link.locked-chapter:hover {
    background: rgba(255, 204, 0, 0.1);
}

/* === STATUS RIBBON (Interactive & Colors) === */
.legend-poster {
    overflow: hidden;
    /* Ensure ribbon stays inside */
}

.legend-ribbon {
    position: absolute;
    top: 15px;
    right: -25px;
    width: 100px;
    background: linear-gradient(90deg, #ff0055, #ff5500);
    color: white;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    transform: rotate(45deg);
    padding: 5px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Tajawal', sans-serif;
    /* Nice Arabic Font */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Shine Effect */
.legend-ribbon::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: rib-shine 3s infinite;
}

@keyframes rib-shine {
    0% {
        left: -100%;
    }

    20% {
        left: 100%;
    }

    100% {
        left: 100%;
    }
}

.legend-poster:hover .legend-ribbon {
    transform: rotate(45deg) scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
}

/* Colors by Status (Vibrant Gradients) */
.legend-ribbon.completed {
    background: linear-gradient(45deg, #00c6ff, #0072ff);
    /* Blue/Cyan */
}

.legend-ribbon.ongoing {
    background: linear-gradient(45deg, #11998e, #38ef7d);
    /* Green/Emerald */
}

.legend-ribbon.hiatus {
    background: linear-gradient(45deg, #ffb347, #ffcc33);
    /* Gold/Orange */
    color: #000;
    text-shadow: none;
}

.legend-ribbon.dropped {
    background: linear-gradient(45deg, #cb2d3e, #ef473a);
    /* Red/Crimson */
}

/* === MOBILE OPTIMIZATION === */
@media (max-width: 900px) {

    /* 1 Column Grid */
    .magma-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        padding: 10px;
    }

    /* Flex Container: Side by Side */
    .legend-inner {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 15px !important;
        background: rgba(255, 255, 255, 0.03);
        padding: 12px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    /* Image Side */
    .legend-poster {
        width: 110px !important;
        min-width: 110px !important;
        flex: 0 0 110px !important;
        aspect-ratio: 2/3;
        margin-bottom: 0 !important;
        border-radius: 8px;
    }

    /* Content Side */
    .legend-content {
        flex: 1 !important;
        width: auto !important;
        min-width: 0;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center;
        padding: 0 !important;
    }

    .legend-title {
        font-size: 16px;
        margin-bottom: 8px;
        white-space: normal;
        /* Allow title wrapping */
        line-height: 1.3;
    }

    .legend-chapters {
        gap: 6px;
    }

    .legend-ch-link {
        padding: 8px 10px;
        background: rgba(0, 0, 0, 0.3);
    }

    /* Clean up visual noise */
    .legend-play,
    .legend-overlay {
        display: none !important;
    }

    /* Ensure ribbon shows on mobile but scaled down if needed */
    .legend-ribbon {
        top: 10px;
        right: -25px;
        width: 90px;
        font-size: 8px;
        padding: 3px 0;
    }

    .legend-rating {
        top: 5px;
        left: 5px;
        font-size: 9px;
        padding: 2px 5px;
    }
}