/* ===================================================================
   Like — overlay button on gallery thumbs + floating count animation
   Loaded on pages that use likes (gallery, resources). Not on /index.
   =================================================================== */

.gallery-item.liked .like-button,
.article-gallery-link.liked .like-button {
    display: flex; /* Changed to flex to keep the image centered without stretching */
    transform: scale(1.1);
}

.like-button {
    position: absolute;
    top: 5%;
    right: 5%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    cursor: cell;
    display: none;
    transition: transform 0.2s ease-in;
    opacity: 0.8;
    justify-content: center;
    align-items: center;
    z-index: 20; /* FIX 4: Forces the heart above the image */
}

.like-button img {
    /* Aggressively locked dimensions so flex/grid parents can't squish it */
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    object-fit: contain;
    aspect-ratio: 1 / 1;
    vertical-align: middle;
}

.like-button:hover {
    opacity: 1;
    scale: 1.2;
}

.like-animation-floater {
    position: absolute;
    z-index: 9999;
    pointer-events: none;

    color: white;
    padding: 10px;
    font-size: calc(0.5rem + 1vw);
    font-weight: bolder;
    font-family: 'Press Start 2P', cursive;
    text-shadow:
        -1px -1px 0 #000, 1px -1px 0 #000,
        -1px 1px 0 #000, 1px 1px 0 #000,
        -1px 0 0 #000, 1px 0 0 #000,
        0 -1px 0 #000, 0 1px 0 #000;

    animation: scale-up 3s forwards;
}

/* Hidden placeholder that JS reads from to know the count for the floater */
.like-count {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    color: white;
    padding: 10px;
    font-size: calc(0.5rem + 1vw);
    font-weight: bolder;
    z-index: 100;
    font-family: 'Press Start 2P', cursive;
    text-shadow:
        -1px -1px 0 #000, 1px -1px 0 #000,
        -1px 1px 0 #000, 1px 1px 0 #000,
        -1px 0 0 #000, 1px 0 0 #000,
        0 -1px 0 #000, 0 1px 0 #000;
}

@keyframes scale-up {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(4) translateY(-20px);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(4) translateY(-300px);
    }
}

@media (hover: hover) and (pointer: fine) {
    .gallery-item:hover .like-button,
    .article-gallery-link:hover .like-button {
        display: flex; /* Changed from block to flex */
        transform: scale(1.1);
    }
}

@media (max-width: 768px) {
    .like-button img {
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        min-height: 16px !important;
        vertical-align: middle;
    }

    .gallery-item.liked .like-button,
    .article-gallery-link.liked .like-button {
        display: none;
    }
}

/* ===================================================================
   Article Gallery Fixes (Square highlights & Grid enforcement)
   =================================================================== */



/* Ensure :::gallery items fit evenly without breaking the grid */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 1), 1fr);
    gap: 1rem;
    width: 100%;
}

/* Base wrapper: Uses inline-block to perfectly and safely shrink-wrap the image */
.article-gallery-link {
    display: inline-block;  /* FIX: The most reliable way to create a bounding box */
    position: relative;
    box-sizing: border-box;
    text-decoration: none;
    line-height: 0;
    max-width: 100%;
    vertical-align: top;
}

/* Ensure the art itself fills the wrapper cleanly */
.article-gallery-link img.article-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 !important;
}


/* ===================================================================
   Like Button Size Adjustments for Small Images
   =================================================================== */

/* Scale heart down for 's' (32px) images */
.article-gallery-link:has(.img-s) .like-button img {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
}

/* Scale heart down for 'm' (64px) images */
.article-gallery-link:has(.img-m) .like-button img {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
}