/* ═════════════════════════════════════════════════════════════
   GALLERY STYLE SHEET
   Handles Grid Layout, Hover States, and Admin Panel Buttons
   ═════════════════════════════════════════════════════════════ */

/* ── Gallery Header Layout ──────────────────────────────────── */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ── Justified Left-to-Right Gallery Layout ─────────────────── */
.gallery-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 10px; /* Breaks the grid into tiny 10px vertical steps */
    gap: 5px 10px;
    align-items: start;
    width: 100%;
}

.gallery-item {
    width: 100%;
}
.gallery-item__wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    /* Removed height: 100% so the wrapper shrinks to perfectly hug the image */
}

.gallery-item__wrapper img {
    width: 100%;
    height: auto; /* Image scales naturally */
    display: block;
}
.gallery-item__wrapper:hover img {
    transform: scale(1.03);
}

/* ── Hover Overlay Panel ────────────────────────────────────── */
.gallery-item__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Deep semi-transparent backdrop */
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes text to top, buttons to bottom */
    align-items: center;
    padding: 1.25rem;
    text-align: center;
    box-sizing: border-box;

    overflow-y: auto;

    /* Initially hidden */
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

/* Triggers when hovering over the wrapper element */
.gallery-item__wrapper:hover .gallery-item__overlay {
    opacity: 1;
}

/* Overlay Typography */
.gallery-item__overlay h3 {
    font-size: 1.1rem;
    margin: 0 0 0.25rem 0;
    color: #ffffff;
}

.gallery-item__overlay p {
    font-size: 0.85rem;
    margin: 0;
    color: #e5e7eb; /* Soft muted gray */
}

/* ── Admin Operations (Appears Only on Overlay Hover) ───────── */
.gallery-admin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem; /* Tight utility gap between control items */
    width: 100%;
    margin-top: 0.5rem;
}

.gallery-admin-actions form {
    width: 100%;
    margin: 0;
}

/* Base styling overrides for overlay interaction actions */
.gallery-admin-actions .btn {
    display: block;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    border-radius: 4px;
    font-size: 0.75rem;
    padding: 0.45rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

/* Insertion Anchor Specifics */
.btn-admin {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
}

.btn-admin:hover {
    background: #ffffff;
}

/* Deletion Button Specifics */
.btn-danger {
    background: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ── Responsive Screen Adjustments ──────────────────────────── */
@media (max-width: 768px) {
    .gallery-item {
        width: calc(50% - 5px); /* Scales cleanly down to 2 columns on mobile devices */
    }
}

@media (max-width: 480px) {
    .gallery-item {
        width: 100%; /* Stacks into single items on ultra narrow viewport breaks */
    }
}