/**
 * Pixel Gallery - Favorites UI Styles (favorites.css)
 * สไตล์สำหรับปุ่มรายการโปรด (❤️) บนการ์ดภาพถ่ายใน Masonry Grid และใน Lightbox
 * รองรับทั้ง Light/Dark Mode และแอนิเมชันหัวใจเต้น (Heart Pulse) ระดับพรีเมียม
 */

/* ==========================================================================
   1. ปุ่ม ❤️ บนการ์ดรูปภาพใน Gallery (.gallery-item)
   ========================================================================== */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    padding: 0;
    outline: none;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s, border-color 0.2s;
    user-select: none;
}

/* แสดงปุ่มเมื่อกดถูกใจอยู่แล้ว หรือโฟกัสคีย์บอร์ด (ส่วน hover แยกไว้เฉพาะอุปกรณ์ที่มีเมาส์ เพื่อไม่ให้ iPad ติด sticky hover) */
.favorite-btn.active,
.favorite-btn:focus-visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
    .favorite-btn:not(.active) {
        pointer-events: none;
    }

    .gallery-item:hover .favorite-btn {
        opacity: 1;
        transform: scale(1);
        pointer-events: auto;
    }

    .favorite-btn:hover {
        background: rgba(15, 23, 42, 0.85);
        transform: scale(1.12);
        border-color: rgba(255, 255, 255, 0.5);
    }

    .favorite-btn.active:hover {
        background: #dc2626;
        border-color: #dc2626;
    }
}

/* บนอุปกรณ์จอสัมผัส / มือถือ / iPad ให้ปุ่มคงอยู่เสมอ และลด backdrop-filter ที่ซ้อนบนรูปการ์ดทุกใบ */
@media (hover: none), (pointer: coarse), (max-width: 768px) {
    .favorite-btn {
        opacity: 0.94;
        transform: scale(1);
        pointer-events: auto;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .favorite-btn:not(.active) {
        background: rgba(15, 23, 42, 0.78);
    }
}

.favorite-btn:active {
    transform: scale(0.9);
}

.favorite-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
    transition: fill 0.2s ease, stroke 0.2s ease, transform 0.2s ease;
}

/* สถานะเมื่อถูกกดถูกใจแล้ว (Active / Favorited) */
.favorite-btn.active {
    background: rgba(239, 68, 68, 0.95);
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45);
}

.favorite-btn.active svg {
    fill: #ffffff;
    stroke: #ffffff;
}

/* แอนิเมชันหัวใจเต้นเมื่อกดถูกใจ */
.favorite-btn.pulse {
    animation: pgHeartBeat 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pgHeartBeat {
    0% { transform: scale(1); }
    30% { transform: scale(1.35); }
    50% { transform: scale(0.92); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   2. ปุ่ม ❤️ ในแถบเครื่องมือ Lightbox (Minimal Borderless)
   ========================================================================== */
.lightbox-fav-btn {
    position: relative;
    top: auto;
    right: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 9999px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-sans, 'Kanit', sans-serif);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    z-index: 10003;
    outline: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
    user-select: none;
    box-shadow: none;
    box-sizing: border-box;
    white-space: nowrap;
}

/* Fallback กรณีไม่ได้อยู่ใน .lightbox-top-actions */
#lightbox > .lightbox-fav-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    height: 38px;
    background: rgba(24, 24, 27, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

@media (hover: hover) and (pointer: fine) {
    .lightbox-fav-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }
}

.lightbox-fav-btn:active {
    transform: scale(0.96);
}

.lightbox-fav-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.lightbox-fav-btn.active {
    background: #ef4444;
    border: none;
    color: #ffffff;
    box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
    .lightbox-fav-btn.active:hover {
        background: #dc2626;
    }
}

.lightbox-fav-btn.active svg {
    fill: #ffffff;
    stroke: #ffffff;
}

@media (max-width: 680px) {
    .lightbox-fav-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }
    #lightbox > .lightbox-fav-btn {
        top: 16px;
        right: 16px;
    }
    .lightbox-fav-btn span,
    .lightbox-fav-btn .lightbox-fav-text {
        display: none !important;
    }
}
