/* ============================================================
   Custom Gallery Plugin v2 — Frontend Styles
   ============================================================ */

/* ---- Wrapper ---- */
.cg-gallery-wrap {
    width: 100%;
    margin: 0 0 36px;
}

/* ---- Grid ---- */
.cg-grid {
    display: grid;
    gap: 14px;
    width: 100%;
}

.cg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cg-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cg-cols-5 { grid-template-columns: repeat(5, 1fr); }
.cg-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Responsive collapse */
@media (max-width: 1100px) {
    .cg-cols-5,
    .cg-cols-6 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 820px) {
    .cg-cols-4,
    .cg-cols-5,
    .cg-cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 580px) {
    .cg-cols-3,
    .cg-cols-4,
    .cg-cols-5,
    .cg-cols-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
    .cg-grid { grid-template-columns: 1fr; }
}

/* ---- Item ---- */
.cg-item {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 7px;
    background: #f4f4f4;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.cg-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cg-item:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* ---- Image wrapper (4:3) ---- */
.cg-img-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    background: #e4e4e4;
    border-radius: 7px 7px 0 0;
}

/* Inner clip — overflow:hidden here only, so badge is NOT clipped */
.cg-img-clip {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 7px 7px 0 0;
}

.cg-img-clip img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    transition: transform 0.35s ease, opacity 0.3s ease;
    opacity: 0;
}

.cg-img-wrap img.cg-loaded {
    opacity: 1;
}

.cg-item:hover .cg-img-clip img {
    transform: scale(1.07);
}

/* ---- Featured badge — sits over the image, outside overflow:hidden ---- */
.cg-feat-badge {
    position: relative;
    top: 10px;
    left: 10px;
    z-index: 999;
    pointer-events: none;
    line-height: 0;
   
}

/* Custom image badge */
.cg-feat-badge img {
    max-width: 26px;
    max-height: 26px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    display: block;
}

/* Default text badge (when no custom image set) */
.cg-feat-badge-text {
    display: inline-block;
    background: rgba(240, 165, 0, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ---- Hover overlay ---- */
.cg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.22s ease;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px 7px 0 0;
}

.cg-item:hover .cg-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.cg-overlay-icon {
    display: block;
    width: 36px;
    height: 36px;
    opacity: 0;
    transform: scale(0.65);
    transition: opacity 0.22s ease, transform 0.22s ease;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='22' y2='22'/%3E%3C/svg%3E") center/contain no-repeat;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

.cg-item:hover .cg-overlay-icon {
    opacity: 1;
    transform: scale(1);
}

/* ---- Image title ---- */
.cg-item-title {
    padding: 9px 11px 11px;
    font-size: 13px;
    font-weight: 500;
    color: #2c2c2c;
    text-align: center;
    line-height: 1.4;
    background: #fff;
    border-top: 1px solid #ebebeb;
    flex-shrink: 0;
    word-break: break-word;
    transition: color 0.18s ease;
}

.cg-item:hover .cg-item-title {
    color: #0073aa;
}

/* ---- Load More ---- */
.cg-load-more-wrap {
    text-align: center;
    margin-top: 30px;
}

.cg-load-more-btn {
    display: inline-block;
    padding: 12px 40px;
    background: #111;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border: 2px solid #111;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.cg-load-more-btn:hover {
    background: transparent;
    color: #111;
    transform: translateY(-2px);
}

.cg-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.cg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cg-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.cg-lb-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 92vw;
    max-height: 92vh;
    width: 100%;
}

/* Main image */
.cg-lb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 86vw;
    max-height: 74vh;
    min-width: 200px;
    min-height: 140px;
}

.cg-lb-img {
    display: block;
    max-width: 86vw;
    max-height: 74vh;
    border-radius: 5px;
    object-fit: contain;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.6);
    transition: opacity 0.22s ease;
}

.cg-lb-img.cg-lb-loading { opacity: 0.08; }

/* Spinner */
.cg-lb-spinner {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.cg-lb-spinner::after {
    content: '';
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cg-spin 0.65s linear infinite;
}

@keyframes cg-spin { to { transform: rotate(360deg); } }

.cg-lightbox.cg-lb-busy .cg-lb-spinner { display: flex; }

/* Title & counter */
.cg-lb-title {
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    margin-top: 14px;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
    max-width: 80vw;
    word-break: break-word;
    min-height: 22px;
}

.cg-lb-counter {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    margin-top: 4px;
    letter-spacing: 0.04em;
}

/* Prev / Next arrows */
.cg-lb-prev,
.cg-lb-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 46px;
    line-height: 1;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.18s ease;
    z-index: 2;
    user-select: none;
}

.cg-lb-prev:hover,
.cg-lb-next:hover { background: rgba(255, 255, 255, 0.22); }

.cg-lb-prev { left: 14px; }
.cg-lb-next { right: 14px; }

.cg-lb-prev:disabled,
.cg-lb-next:disabled { opacity: 0.18; cursor: default; }

/* Close */
.cg-lb-close {
    position: fixed;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
    padding: 4px 10px;
    transition: transform 0.2s ease, color 0.18s ease;
}

.cg-lb-close:hover {
    transform: rotate(90deg);
    color: #f0a500;
}

/* Fade-in */
@keyframes cg-lb-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
.cg-lightbox.cg-lb-open { animation: cg-lb-in 0.2s ease forwards; }

/* ---- Thumbnail strip ---- */
.cg-lb-thumbs {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    max-width: 86vw;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.cg-lb-thumbs::-webkit-scrollbar { height: 3px; }
.cg-lb-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 2px; }

.cg-lb-thumb-item {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.45;
    border: 2px solid transparent;
    transition: opacity 0.18s ease, border-color 0.18s ease;
    position: relative;
}

.cg-lb-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cg-lb-thumb-item.cg-lb-thumb-active {
    opacity: 1;
    border-color: #f0a500;
}

.cg-lb-thumb-item:hover { opacity: 0.8; }

/* Featured dot on lightbox thumbnail */
.cg-lb-thumb-item.cg-lb-thumb-featured::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    background: #f0a500;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.3);
}

/* ---- Mobile ---- */
@media (max-width: 500px) {
    .cg-lb-prev,
    .cg-lb-next { font-size: 30px; padding: 8px 12px; }
    .cg-lb-prev { left: 4px; }
    .cg-lb-next { right: 4px; }
    .cg-lb-close { top: 8px; right: 8px; font-size: 34px; }
    .cg-lb-thumbs { display: none; }
    .cg-feat-badge img { max-width: 36px; max-height: 36px; }
}