/**
 * STYLING FÜR DIE LIVE-FILTER & RESPONSIVE LAYOUTS
 * Datei: assets/css/filter.css
 */

/* ==========================================================================
   CORE DROPDOWN & CHECKBOX STYLES (Fixes für Dark Mode / Brave / Chromium)
   ========================================================================== */

.escape-filter-container select,
.escape-filter-dropdown-wrapper select,
select.escape-custom-dropdown {
    background-color: #141414 !important;
    color: #ffffff !important;
    color-scheme: dark !important;
}

/* JETZT SAUBER ISOLIERT: Greift nur noch in deinen Filter-Containern */
.escape-filter-container select option,
.escape-filter-dropdown-wrapper select option,
select.escape-custom-dropdown option { 
    background-color: #1c1c1c !important;
    color: #ffffff !important;
}

.escape-filter-title {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-color, #fff);
}

.escape-custom-dropdown {
    position: relative;
    user-select: none;
}

.escape-dropdown-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #141414;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.escape-dropdown-trigger:hover {
    border-color: #555;
}

.escape-custom-dropdown.is-open .escape-dropdown-trigger {
    border-color: var(--accent-color, #ff007f);
    box-shadow: 0 0 0 2px rgba(255, 0, 127, 0.2);
}

.escape-dropdown-trigger .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}
.escape-custom-dropdown.is-open .escape-dropdown-trigger .dashicons {
    transform: rotate(180deg);
}

.escape-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background-color: #141414 !important;
    border: 1px solid #333333 !important;
    border-radius: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    color-scheme: dark !important;
}

.escape-dropdown-item,
.escape-dropdown-item *,
.escape-dropdown-list .escape-dropdown-item {
    display: flex !important;
    align-items: center !important;
    padding: 8px 12px;
    margin: 0;
    cursor: pointer;
    background: #141414 !important;
    color: #ffffff !important;
    font-size: 14px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.escape-dropdown-item:hover,
.escape-dropdown-item:hover * {
    background: #1a1a1a !important;
    color: var(--accent-color, #ff007f) !important;
}

.escape-dropdown-item:hover {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

.escape-dropdown-item input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.escape-filter-container input[type="checkbox"],
.escape-dropdown-item input[type="checkbox"],
#escape-live-book-grid-wrapper input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    accent-color: var(--accent-color, #ff007f) !important;
    color-scheme: dark !important; 
}

#bookshelf-loader {
    text-align: center;
    padding: 20px;
    font-size: 16px;
    color: #888;
    width: 100%;
}

/**
 * ==========================================================================
 * MASTER GRID SYSTEM (Korrigierte display: contents Steuerung)
 * ==========================================================================
 */

/* 1. Das übergeordnete Element wird zum echten Grid-Verteiler */
html body #escape-live-book-grid.bookshelf-grid {
    display: grid !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 20px !important;
    padding: 15px !important;
}

/* 2. Der Injektions-Container MUSS contents bleiben, damit die Karten direkt im Haupt-Grid landen */
.escape-grid-results {
    display: contents !important;
}

/* DESKTOP (Ab 1025px) -> Knallhart 6 Spalten auf dem Haupt-Grid */
@media (min-width: 1025px) {
    html body #escape-live-book-grid.bookshelf-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

/* TABLET (768px bis 1024px) -> Knallhart 3 Spalten auf dem Haupt-Grid */
@media (max-width: 1024px) and (min-width: 768px) {
    html body #escape-live-book-grid.bookshelf-grid {
        grid-template-columns: repeat(3, 1fr) !important;
		gap: 35px !important;
    }
}

/* SMARTPHONE (Unter 767px) -> Knallhart 2 Spalten nebeneinander */
@media (max-width: 767px) {
    html body #escape-live-book-grid.bookshelf-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 35px !important;
    }
}

/**
 * ==========================================================================
 * CARDS & DESKTOP HOVER-EFFECTS
 * ==========================================================================
 */

.escape-grid-results .book-card {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

@media (max-width: 767px) {
    .escape-grid-results .book-card {
        text-align: left !important;
        align-items: flex-start !important;
    }
}

/* Desktop-Effekt: Hovern mit Vergrößern */
@media (min-width: 768px) {
    .escape-grid-results .book-card:hover {
        transform: scale(1.05) !important;
        z-index: 99 !important;
    }
}

.escape-grid-results .book-card .cover-container {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 5 / 8 !important;
    border-radius: 8px !important;
    background-color: #111111 !important;
    display: block !important;
    height: auto !important;
}

.escape-grid-results .book-card .book-cover {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 8px !important;
    margin: 0 !important;
}

.escape-grid-results .book-card .book-title {
    margin: 12px 0 6px 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    color: #ffffff !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

@media (max-width: 767px) {
    .escape-grid-results .book-card .book-title {
        font-size: 13px !important;
        line-height: 1.3 !important;
        margin: 8px 0 4px 0 !important;
        -webkit-line-clamp: 2 !important;
    }
}

.escape-grid-results .book-card .book-series {
    font-size: 13px;
    color: #aaaaaa;
    margin-top: 4px;
}

@media (max-width: 767px) {
    .escape-grid-results .book-card .book-series {
        font-size: 11px !important;
        margin-top: 0px !important;
    }
}

/**
 * ==========================================================================
 * VISUAL ASSETS: SPRACHFLAGGE & HERZ-LOGIK
 * ==========================================================================
 */

/* Die Sprachflagge links oben (-8px) */
.book-language-flag {
    position: absolute !important;
    top: -8px !important;   
    left: -8px !important;  
    z-index: 110 !important; 
    width: 34px !important;
    height: 34px !important;
    background: #ffffff !important; 
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px !important;
    line-height: 1 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

@media (max-width: 767px) {
    .book-language-flag {
        width: 28px !important;
        height: 28px !important;
        font-size: 16px !important;
        top: -6px !important;
        left: -6px !important;
    }
}

/* Der Herz-Button: Gespiegelt zur Flagge (-8px top/right) */
.escape-grid-results .book-card .book-action-btn {
    position: absolute !important;
    top: -8px !important;    
    right: -8px !important;  
    left: auto !important;   
    z-index: 110 !important; 
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    
    /* Farbeffekt: Hintergrund Weiß, Herz #DA3258 */
    background: #ffffff !important; 
    color: #DA3258 !important;
    
    /* Desktop: Standardmäßig unsichtbar */
    opacity: 0;
    transform: none !important; /* KEINE EIGENE SKALIERUNG */
    transition: opacity 0.25s ease !important;
}

/* Desktop Hover (Nur für echte Desktops ab 1025px mit Maus) */
@media (min-width: 1025px) {
    .escape-grid-results .book-card:hover .book-action-btn {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Tablet & Handy Touch-Schutz (Alles unter 1025px): Herzen DAUERHAFT fest einblenden */
@media (max-width: 1024px) {
    .escape-grid-results .book-card .book-action-btn {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Spezifischer Feinschliff nur für sehr kleine Smartphones (unter 767px) */
@media (max-width: 767px) {
    .escape-grid-results .book-card .book-action-btn {
        top: -6px !important;
        right: -6px !important;
    }
}

/* ZUSTAND FIXIERT: Wenn Buch im Shelf liegt oder gedrückt wird */
.escape-grid-results .book-card.is-in-shelf .book-action-btn,
.escape-grid-results .book-card .book-action-btn:active {
    opacity: 1 !important;
    background: #ffffff !important; 
    color: #DA3258 !important;
    transform: none !important;
}

.escape-grid-results .book-card * {
    overflow: visible !important;
}

/**
 * ==========================================================================
 * MOBILE SIDEBAR DROPDOWN ACCORDION (Neu geschrieben für acf-sidebar-mobil-wrapper)
 * ==========================================================================
 */

@media (max-width: 767px) {
    
    /* 1. Die Filter-Sidebar im Standardzustand (GESCHLOSSEN) */
    .acf-sidebar-mobil-wrapper {
        display: block !important; 
        max-height: 0 !important;   
        overflow: hidden !important; 
        opacity: 0 !important;       
        transform: translateY(-10px);
        transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out, transform 0.3s ease-in-out;
        
        background-color: #000000 !important; 
        padding: 0 20px !important; 
        margin-top: 0px !important;
        box-sizing: border-box;
    }
    
    /* 2. Wenn das JS die Klasse hinzufügt (OFFEN) */
    .acf-sidebar-mobil-wrapper.ist-offen {
        max-height: 2500px !important; /* Genug Höhe für alle Filterblöcke */
        opacity: 1 !important;
        transform: translateY(0);
        padding: 20px !important; 
        overflow: visible !important; /* Wichtig für ausbrechende Dropdowns! */
    }

    /* 3. Der Toggle-Button */
    .filter-toggle-button {
        display: block !important;
        width: 100% !important;
        padding: 15px !important;
        background-color: #102b45 !important; 
        color: #ffffff !important;
        text-align: center !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 4px;
        cursor: pointer;
        font-weight: bold;
        font-size: 16px;
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 5px;
        box-sizing: border-box;
    }
    
    .filter-toggle-button.aktiv {
        border-radius: 4px 4px 0 0;
        margin-bottom: 0px;
    }
    
    .filter-toggle-button::after {
        content: ' ▼';
        font-size: 12px;
        margin-left: 8px;
    }
    .filter-toggle-button.aktiv::after {
        content: ' ▲';
    }
    
    .acf-sidebar-mobil-wrapper label,
    .acf-sidebar-mobil-wrapper .escape-filter-label,
    .acf-sidebar-mobil-wrapper .escape-dropdown-item {
        color: #ffffff !important;
    }
}

/* Desktop-Sicherung für die Sidebar */
@media (min-width: 768px) {
    .filter-toggle-button {
        display: none !important;
    }
    .acf-sidebar-mobil-wrapper {
        opacity: 1 !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }
}