/* css/genshin-characters.css */

/* --- Main Grid --- */
.character-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.char-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--card-bg, #fff);
    border: 1px solid var(--card-border, #ddd);
    aspect-ratio: 3/4;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.char-card.has-video { cursor: pointer; }
.char-card.has-video:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 10; }
.char-card.no-video { cursor: not-allowed; opacity: 0.7; filter: grayscale(0.8); }

.char-card.rarity-5 { background: linear-gradient(135deg, #ffd700, #f0e68c); border-color: #ffd700; }
.char-card.rarity-4 { background: linear-gradient(135deg, #9370db, #dda0dd); border-color: #9d5bb0; }

.char-card img.char-portrait { width: 100%; height: 100%; object-fit: cover; object-position: center top; transition: filter 0.3s; }
.char-card.has-video:hover img.char-portrait { filter: brightness(1.1); }

.card-element-icon { position: absolute; top: 5px; left: 5px; width: 30px; height: 30px; background: rgba(0,0,0,0.5); border-radius: 50%; padding: 3px; z-index: 2; }
.card-name { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent); color: white; text-align: center; padding: 20px 5px 5px 5px; font-weight: bold; font-size: 0.9rem; text-shadow: 1px 1px 2px black; }

.status-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.2s; z-index: 5; }
.char-card.has-video:hover .status-overlay { opacity: 1; }
.char-card.no-video .status-overlay { opacity: 1; background: rgba(0,0,0,0.5); }
.status-overlay i { font-size: 3rem; color: white; text-shadow: 0 0 10px rgba(0,0,0,0.8); }
.char-card.no-video .status-overlay i { color: #ccc; }

/* =========================================
   MODAL LAYOUT
   ========================================= */

.btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }
.text-shadow { text-shadow: 0 2px 5px rgba(0,0,0,0.8); }

/* --- RIGHT SIDE: Info Panel --- */
.info-section {
    background-size: cover;
    background-position: center;
    position: relative;
    transition: background 0.3s ease;
    display: flex;
    flex-direction: column;
}

#modal-right-panel.rarity-5 { background: radial-gradient(circle at center, rgba(80, 60, 10, 0.95), #111); border-left: 2px solid #ffd700; }
#modal-right-panel.rarity-4 { background: radial-gradient(circle at center, rgba(60, 30, 80, 0.95), #111); border-left: 2px solid #9d5bb0; }

.element-badge { width: 45px; height: 45px; background: rgba(0,0,0,0.6); border-radius: 50%; padding: 6px; border: 1px solid rgba(255,255,255,0.4); }
.element-badge img { width: 100%; height: 100%; object-fit: contain; }

/* Portrait Image */
.portrait-container img {
    max-height: 100%;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(0,0,0,0.8));
    transition: transform 0.3s;
}
.portrait-container img:hover { transform: scale(1.05); }

/* --- DESKTOP LAYOUT (Min 992px) --- */
@media (min-width: 992px) {
    /* Auto width wrapper */
    .custom-modal-width {
        max-width: fit-content !important; 
        margin: 1.75rem auto;
    }

    /* Fixed Height Container */
    .video-section, .info-section {
        height: 80vh; 
    }

    /* Video Side: 9:16 Ratio */
    .video-section {
        aspect-ratio: 9 / 16;
        background: #000;
        flex-shrink: 0; 
    }

    .shorts-iframe-wrapper {
        width: 100%;
        height: 100%;
    }
    
    .shorts-iframe-wrapper iframe {
        width: 100%;
        height: 100%;
    }

    /* Info Side: Wider width to fix margin issues */
    .info-section {
        width: 450px; /* Increased from 380px to fix spacing */
        flex-shrink: 0;
    }
    
    .portrait-container img {
        max-height: 400px; /* Allow larger image on desktop */
    }
}

/* --- MOBILE LAYOUT (Max 991px) --- */
@media (max-width: 991px) {
    .custom-modal-width { margin: 0.5rem; max-width: none; }
    
    .video-section {
        width: 100%;
        padding: 0;
        background: #000;
    }

    .shorts-iframe-wrapper {
        width: 100%;
        max-width: 400px; 
        aspect-ratio: 9 / 16;
        margin: 0 auto;
    }
    
    .shorts-iframe-wrapper iframe {
        width: 100%;
        height: 100%;
    }

    .info-section {
        width: 100%;
        min-height: auto;
        border-left: none !important;
        border-top: 2px solid rgba(255,255,255,0.2);
    }
    
    .portrait-container img {
        max-height: 250px;
    }
}
/* --- Active Card Highlight (Behind Modal) --- */
.char-card.active-selected {
    border: 3px solid #ffffff !important; /* Bright white border */
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.8) !important; /* Strong glow */
    transform: scale(1.05); /* Slight zoom */
    z-index: 20; /* Ensure it sits above neighbors */
    transition: all 0.3s ease;
}
/* --- Search Bar Container Fix --- */
.search-filter-container {
    max-width: 800px; /* Restrict width so it doesn't stretch */
    margin-left: auto;
    margin-right: auto;
    background-color: rgba(255, 255, 255, 0.05); /* Optional: Subtle background */
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}
/* --- Card Base Design --- */
.char-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--card-bg, #fff);
    border: 1px solid var(--card-border, #ddd);
    aspect-ratio: 3/4;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    cursor: pointer; /* Make ALL cards clickable now */
}

.char-card:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 10;
}

/* --- State: No Video (Wiki Only) --- */
.char-card.no-video {
    /* Removed grayscale and not-allowed cursor */
    /* Only slightly dim the background image to make the book icon pop */
}

.char-card.no-video img.char-portrait {
    filter: sepia(0.3) brightness(0.9); /* Subtle effect to differentiate */
}

/* ... (Keep Rarity Backgrounds) ... */
.char-card.rarity-5 {
    background: var(--genshin-rarity5-bg, linear-gradient(135deg, #ffd700 0%, #f0e68c 100%));
    border-color: #ffd700;
}

.char-card.rarity-4 {
    background: var(--genshin-rarity4-bg, linear-gradient(135deg, #9370db 0%, #dda0dd 100%));
    border-color: #9d5bb0;
}

/* ... (Keep Image and Element Icon styles) ... */
.char-card img.char-portrait { width: 100%; height: 100%; object-fit: cover; object-position: center top; transition: filter 0.3s; }
.char-card.has-video:hover img.char-portrait { filter: brightness(1.1); }
.char-card .card-element-icon { position: absolute; top: 5px; left: 5px; width: 30px; height: 30px; background: rgba(0,0,0,0.5); border-radius: 50%; padding: 3px; z-index: 2; }
.char-card .card-name { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent); color: white; text-align: center; padding: 20px 5px 5px 5px; font-weight: bold; font-size: 0.9rem; text-shadow: 1px 1px 2px black; }

/* --- Icons --- */
.char-card .status-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

/* Show overlay on hover for BOTH types now */
.char-card:hover .status-overlay {
    opacity: 1;
}

.char-card .status-overlay i {
    font-size: 3rem;
    color: white;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    transform: scale(0.8);
    transition: transform 0.2s;
}

.char-card:hover .status-overlay i {
    transform: scale(1);
}

/* Specific styling for the Book icon */
.char-card.no-video .status-overlay i {
    color: #e0e0e0; /* Slightly off-white */
}

/* Active Highlight */
.char-card.active-selected {
    border: 3px solid #ffffff !important; 
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.8) !important;
    transform: scale(1.05); 
    z-index: 20; 
    transition: all 0.3s ease;
}

/* ... (Keep the rest of the Modal CSS exactly as provided in the previous step) ... */
.btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }
.text-shadow { text-shadow: 0 2px 5px rgba(0,0,0,0.8); }
.info-section { background-size: cover; background-position: center; position: relative; transition: background 0.3s ease; display: flex; flex-direction: column; }
#modal-right-panel.rarity-5 { background: radial-gradient(circle at center, rgba(80, 60, 10, 0.95), #111); border-left: 2px solid #ffd700; }
#modal-right-panel.rarity-4 { background: radial-gradient(circle at center, rgba(60, 30, 80, 0.95), #111); border-left: 2px solid #9d5bb0; }
.element-badge { width: 45px; height: 45px; background: rgba(0,0,0,0.6); border-radius: 50%; padding: 6px; border: 1px solid rgba(255,255,255,0.4); }
.element-badge img { width: 100%; height: 100%; object-fit: contain; }
.portrait-container img { max-height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 0 15px rgba(0,0,0,0.8)); transition: transform 0.3s; }
.portrait-container img:hover { transform: scale(1.05); }

@media (min-width: 992px) {
    .custom-modal-width { max-width: fit-content !important; margin: 1.75rem auto; }
    .video-section, .info-section { height: 80vh; }
    .video-section { aspect-ratio: 9 / 16; background: #000; flex-shrink: 0; }
    .shorts-iframe-wrapper { width: 100%; height: 100%; }
    .shorts-iframe-wrapper iframe { width: 100%; height: 100%; }
    .info-section { width: 450px; flex-shrink: 0; }
    .portrait-container img { max-height: 400px; }
}

@media (max-width: 991px) {
    .custom-modal-width { margin: 0.5rem; max-width: none; }
    .video-section { width: 100%; padding: 0; background: #000; }
    .shorts-iframe-wrapper { width: 100%; max-width: 400px; aspect-ratio: 9 / 16; margin: 0 auto; }
    .shorts-iframe-wrapper iframe { width: 100%; height: 100%; }
    .info-section { width: 100%; min-height: auto; border-left: none !important; border-top: 2px solid rgba(255,255,255,0.2); }
    .portrait-container img { max-height: 250px; }
}