/* =========================================
   LCNL PHOTO GALLERY
   -----------------------------------------
   Album cards, the justified photo grid and
   the admin photo manager.
   ========================================= */

/* --- Album cards --- */
.gallery-album-card {
    border-radius: 12px;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
}

.gallery-album-card:hover,
.gallery-album-card:focus-within {
    transform: translateY(-3px);
    box-shadow: 0 .75rem 1.5rem rgba(0, 0, 0, .12) !important;
}

.gallery-album-cover {
    aspect-ratio: 4 / 3;
    background: #f1ecee;
    overflow: hidden;
}

.gallery-album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- Justified grid ---
   Every photo in a row ends up the same height: each item grows in
   proportion to its aspect ratio (--r = width / height), and the padding
   trick holds the box at that ratio before the image arrives, so nothing
   jumps while loading. The ::after filler stops the last row stretching. */
.gallery-grid {
    --row: 170px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

@media (min-width: 768px) {
    .gallery-grid { --row: 230px; }
}

.gallery-grid::after {
    content: "";
    flex-grow: 999999;
}

.gallery-item {
    position: relative;
    display: block;
    flex-grow: calc(var(--r) * 100);
    flex-basis: calc(var(--r) * var(--row));
    overflow: hidden;
    border-radius: 6px;
    background: #f1ecee;
}

.gallery-item::before {
    content: "";
    display: block;
    padding-bottom: calc(100% / var(--r));
}

.gallery-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.03);
}

.gallery-item:focus-visible {
    outline: 3px solid var(--brand, #7a1d3c);
    outline-offset: 2px;
}

/* --- Admin photo manager --- */
.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.gallery-admin-photo {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: #f1ecee;
    cursor: grab;
}

.gallery-admin-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-admin-photo .form-check-input {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .8);
}

.gallery-admin-photo .gallery-cover-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
}

.gallery-admin-photo .gallery-photo-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    opacity: 0;
    transition: opacity .15s ease;
}

.gallery-admin-photo:hover .gallery-photo-actions,
.gallery-admin-photo:focus-within .gallery-photo-actions {
    opacity: 1;
}

@media (hover: none) {
    .gallery-admin-photo .gallery-photo-actions { opacity: 1; }
}

.gallery-admin-photo.is-selected {
    outline: 3px solid var(--bs-danger);
    outline-offset: -3px;
}

.gallery-admin-photo.sortable-ghost {
    opacity: .4;
}

.gallery-dropzone {
    border: 2px dashed #c9b3bb;
    border-radius: 12px;
    background: #fbf8f9;
    transition: background .15s ease, border-color .15s ease;
}

.gallery-dropzone.is-dragover {
    background: #f4e9ed;
    border-color: var(--brand, #7a1d3c);
}

.gallery-upload-log {
    max-height: 220px;
    overflow-y: auto;
}

/* --- Home page "Latest Photos" cards --- */
.gallery-home-card {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius, 14px);
    background: #f1ecee;
    box-shadow: 0 .125rem .5rem rgba(0, 0, 0, .08);
    color: #fff;
    text-decoration: none;
}

.gallery-home-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.gallery-home-card:hover img,
.gallery-home-card:focus-visible img {
    transform: scale(1.04);
}

.gallery-home-card:focus-visible {
    outline: 3px solid var(--brand, #7a1d3c);
    outline-offset: 2px;
}

.gallery-home-count {
    position: absolute;
    top: .5rem;
    right: .5rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    font-size: .75rem;
    font-weight: 600;
}

.gallery-home-caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 2rem .75rem .6rem;
    background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0));
    display: flex;
    flex-direction: column;
}

.gallery-home-title {
    font-weight: 700;
    line-height: 1.2;
    /* Two lines at most; long titles end in an ellipsis. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-home-date {
    font-size: .8rem;
    opacity: .9;
}

@media (max-width: 575.98px) {
    .gallery-home-title { font-size: .875rem; }
}
