/**
 * JFF Galleries — Lightweight justified-row gallery
 */

/* ---------- Reset & base ---------- */
.jff-gallery {
    --jff-gap: 6px;
    --jff-row-height: 280px;
    --jff-text: #1a1a1a;
    --jff-muted: #666;
    --jff-overlay: rgba(0, 0, 0, 0.55);
    --jff-card-radius: 4px;
    --jff-brand: #44AF41;

    font-family: inherit;
    color: var(--jff-text);
    max-width: 100%;
    margin: 0 auto;
}

.jff-gallery * {
    box-sizing: border-box;
}

.jff-empty {
    text-align: center;
    color: var(--jff-muted);
    padding: 3rem 1rem;
}

/* ---------- Album grid (the 70-album thumbnail view) ---------- */
.jff-album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

@media (max-width: 600px) {
    .jff-album-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
}

.jff-album-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
}

.jff-album-card:hover {
    transform: translateY(-2px);
}

.jff-album-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background-size: cover;
    background-position: center;
    background-color: #eee;
    border-radius: var(--jff-card-radius);
    overflow: hidden;
}

.jff-album-card-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.5) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.jff-album-card:hover .jff-album-card-image::after {
    opacity: 1;
}

.jff-album-card-count {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--jff-overlay);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 3px;
    letter-spacing: 0.02em;
    z-index: 1;
}

.jff-album-card-title {
    margin: 12px 0 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--jff-text);
}

@media (max-width: 600px) {
    .jff-album-card-title {
        font-size: 13px;
    }
}

/* ---------- Single album view ---------- */
.jff-back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--jff-text);
    font-size: 14px;
    font-family: inherit;
    padding: 8px 14px;
    margin-bottom: 16px;
    border-radius: 4px;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.jff-back-button > span {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.jff-back-button:hover {
    background-color: var(--jff-brand);
    color: #fff;
}

.jff-back-button:hover > span {
    transform: translateX(-10px);
}

.jff-back-button:active {
    transform: translateY(1px);
}

.jff-back-button:focus-visible {
    outline: 2px solid var(--jff-brand);
    outline-offset: 2px;
}

.jff-album-header {
    margin-bottom: 24px;
}

.jff-album-header h2 {
    margin: 0 0 4px;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
}

.jff-album-header .jff-album-meta {
    color: var(--jff-muted);
    font-size: 14px;
}

.jff-album-header p {
    margin-top: 12px;
    color: var(--jff-muted);
    line-height: 1.5;
}

/* ---------- Justified flex grid (Flickr-style layout) ---------- */
.jff-justified-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--jff-gap);
}

.jff-photo {
    position: relative;
    flex-grow: 1;
    flex-basis: 250px;
    height: var(--jff-row-height);
    overflow: hidden;
    background: #f0f0f0;
    border-radius: 2px;
    cursor: zoom-in;
    text-decoration: none;
}

.jff-photo span {
    /* Aspect ratio spacer — fallback for older browsers */
    display: block;
    width: 100%;
    pointer-events: none;
}

.jff-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
}

.jff-photo:hover img {
    transform: scale(1.04);
}

@media (max-width: 600px) {
    .jff-gallery {
        --jff-row-height: 180px;
        --jff-gap: 4px;
    }
}

/* Prevents last row from stretching awkwardly when fewer items */
.jff-justified-grid::after {
    content: "";
    flex-grow: 999;
}

/* ---------- Loading / sentinel ---------- */
.jff-sentinel {
    height: 1px;
    width: 100%;
}

.jff-loading {
    text-align: center;
    color: var(--jff-muted);
    padding: 24px;
    font-size: 14px;
}

/* ---------- View toggle helpers ---------- */
.jff-view[hidden] {
    display: none !important;
}

/* ---------- PhotoSwipe overrides ---------- */
.pswp__bg {
    background: #0f0f0f;
}