/* ============================================================
   Safi Gallery – front-end styles
   ============================================================ */

/* ---------- Section wrapper ---------- */
.safi-gallery-section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 20px;
    box-sizing: border-box;
}

/* ---------- Header ---------- */
.safi-gallery-header {
    text-align: center;
    margin-bottom: 40px;
}
.safi-gallery-heading {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 12px;
    line-height: 1.2;
}
.safi-gallery-subheading {
    font-size: 1rem;
    color: #555;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---------- Grid ---------- */
.safi-gallery-grid {
    display: grid;
    gap: 20px;
}
.safi-cols-1 { grid-template-columns: 1fr; }
.safi-cols-2 { grid-template-columns: repeat(2, 1fr); }
.safi-cols-3 { grid-template-columns: repeat(3, 1fr); }
.safi-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .safi-cols-3,
    .safi-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .safi-cols-2,
    .safi-cols-3,
    .safi-cols-4 { grid-template-columns: 1fr; }
}

/* ---------- Card ---------- */
.safi-gallery-card {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    aspect-ratio: 4 / 3;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    transition: transform .25s ease, box-shadow .25s ease;
}
.safi-gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0,0,0,.25);
}
.safi-gallery-card:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
}

/* Gradient overlay */
.safi-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 40%,
        rgba(0,0,0,.72) 100%
    );
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 18px 20px;
    transition: background .25s;
}
.safi-gallery-card:hover .safi-card-overlay {
    background: linear-gradient(
        to bottom,
        transparent 20%,
        rgba(0,0,0,.80) 100%
    );
}

.safi-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.safi-card-title {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.safi-card-count {
    color: rgba(255,255,255,.85);
    font-size: .82rem;
}
.safi-card-arrow {
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    transition: transform .2s;
}
.safi-gallery-card:hover .safi-card-arrow {
    transform: translateX(4px);
}

/* ---------- Lightbox ---------- */
.safi-lb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.92);
    z-index: 9998;
    animation: safi-fade-in .2s ease;
}

.safi-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.safi-lightbox[hidden],
.safi-lb-backdrop[hidden] { display: none !important; }

/* Close button */
.safi-lb-close {
    position: fixed;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
    padding: 4px 8px;
    opacity: .85;
    transition: opacity .15s;
}
.safi-lb-close:hover { opacity: 1; }

/* Prev / Next */
.safi-lb-prev,
.safi-lb-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    font-size: 2.4rem;
    line-height: 1;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    z-index: 10001;
}
.safi-lb-prev { left: 16px; }
.safi-lb-next { right: 16px; }
.safi-lb-prev:hover,
.safi-lb-next:hover { background: rgba(255,255,255,.28); }
.safi-lb-prev.safi-hidden,
.safi-lb-next.safi-hidden { opacity: 0; pointer-events: none; }

/* Inner panel */
.safi-lb-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 860px;
    width: 100%;
    animation: safi-pop-in .22s ease;
}

/* Main image */
.safi-lb-img {
    max-height: 65vh;
    max-width: 100%;
    border-radius: 10px;
    object-fit: contain;
    display: block;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* Caption bar */
.safi-lb-caption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 4px 8px;
}
.safi-lb-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
}
.safi-lb-counter {
    color: rgba(255,255,255,.7);
    font-size: .85rem;
}

/* Thumbnails */
.safi-lb-thumbs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 4px;
}
.safi-lb-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: .65;
    transition: opacity .15s, border-color .15s;
}
.safi-lb-thumb:hover { opacity: .9; }
.safi-lb-thumb.safi-active {
    border-color: #fff;
    opacity: 1;
}

/* ---------- Animations ---------- */
@keyframes safi-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes safi-pop-in {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ---------- Reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .safi-gallery-card,
    .safi-lb-close,
    .safi-lb-prev,
    .safi-lb-next,
    .safi-lb-thumb { transition: none; }
    .safi-lb-inner,
    .safi-lb-backdrop { animation: none; }
}

/* ---------- Empty state ---------- */
.safi-empty {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}
