/* =============================================
   Smart Gallery — Frontend Styles
   ============================================= */

:root {
    --sg-col-mobile:  2;
    --sg-col-tablet:  3;
    --sg-col-desktop: 5;
    --sg-gap:         10px;
    --sg-radius:      8px;
    --sg-overlay-bg:  rgba(0, 0, 0, .45);
    --sg-accent:      #2563eb;
    --sg-white:       #ffffff;
    --sg-transition:  .22s ease;
}

/* ---- Wrapper ---- */
.sg-gallery-wrap {
    width: 100%;
    margin: 0 0 2em;
}

/* ---- Header ---- */
.sg-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
}

h5.sg-gallery-title {
    font-size: 1.2em;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

/* ---- Masonry Grid ---- */
.sg-gallery-grid {
    columns: var(--sg-col-mobile);
    column-gap: var(--sg-gap);
}

@media (min-width: 600px) {
    .sg-gallery-grid { columns: var(--sg-col-tablet); }
}

@media (min-width: 1024px) {
    .sg-gallery-grid { columns: var(--sg-col-desktop); }
}

/* Custom column overrides via shortcode */
.sg-cols-2 .sg-gallery-grid { columns: 2 !important; }
.sg-cols-3 .sg-gallery-grid { columns: 3 !important; }
.sg-cols-4 .sg-gallery-grid { columns: 4 !important; }
.sg-cols-5 .sg-gallery-grid { columns: 5 !important; }

/* ---- Gallery item ---- */
.sg-gallery-item {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: var(--sg-gap);
    display: block;
}

.sg-item-inner {
    position: relative;
    overflow: hidden;
    border-radius: var(--sg-radius);
    background: #f1f5f9;
    width: 100%;
}

.sg-thumb {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: center;
    transition: transform .35s ease;
}
.sg-item-inner:hover .sg-thumb { transform: scale(1.06); }

/* Overlay — light scrim, buttons centred */
.sg-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--sg-transition);
}
.sg-item-inner:hover .sg-item-overlay { opacity: 1; }

/* Lightbox "View" button — transparent, white border pill */
.sg-lightbox-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 14px !important;
    height: 34px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: 1px solid #ffffff !important;
    border-radius: 25px !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    letter-spacing: .4px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    transition: background var(--sg-transition), transform var(--sg-transition);
}
.sg-lightbox-btn:hover {
    background: rgba(255, 255, 255, .15) !important;
    transform: scale(1.05);
}

/* Download button — pinned to bottom-right corner */
.sg-download-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #ffffff;
    border: none;
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--sg-transition), transform var(--sg-transition), color var(--sg-transition);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.sg-download-btn svg { width: 15px; height: 15px; }
.sg-download-btn:hover { background: #f0f0f0; transform: scale(1.08); color: #111827; }

/* Caption — hidden on frontend */
.sg-caption {
    display: none;
}

/* Misc */
.sg-error, .sg-empty { color: #94a3b8; font-size: 14px; }

/* ===================================================
   LIGHTBOX
   =================================================== */

.sg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}
.sg-lightbox.sg-active { display: flex; }

.sg-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    backdrop-filter: blur(6px);
    animation: sg-fade-in .2s ease;
}

@keyframes sg-fade-in { from { opacity: 0; } to { opacity: 1; } }

.sg-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 60px clamp(40px, 8vw, 100px) 80px;
    background: transparent;
    box-sizing: border-box;
}

/* Close — transparent bg, white SVG X icon */
.sg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: transparent;
    border: none;
    color: #ffffff !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--sg-transition), transform var(--sg-transition);
    opacity: .9;
    padding: 0 !important;
}
.sg-lightbox-close svg {
    width: 24px !important;
    height: 24px !important;
    display: block;
    stroke: #ffffff !important;
}
.sg-lightbox-close:hover { opacity: 1; transform: scale(1.15); }

/* Nav arrows — transparent bg, white icons, pulled away from screen edges */
.sg-lightbox-prev,
.sg-lightbox-next {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: #ffffff !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: opacity var(--sg-transition), transform var(--sg-transition);
    opacity: .85;
    padding: 0 !important;
}
.sg-lightbox-prev { left: 36px !important; }
.sg-lightbox-next { right: 36px !important; }
.sg-lightbox-prev:hover,
.sg-lightbox-next:hover { opacity: 1; transform: translateY(-50%) scale(1.12) !important; }
.sg-lightbox-prev svg,
.sg-lightbox-next svg {
    width: 28px !important;
    height: 28px !important;
    stroke: #ffffff !important;
    stroke-width: 2.5 !important;
    display: block !important;
}
.sg-lightbox-prev svg polyline,
.sg-lightbox-next svg polyline { stroke: #ffffff !important; }

/* Lightbox image */
.sg-lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    flex: 1;
    min-height: 0;
}

.sg-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    animation: sg-img-in .2s ease;
    box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
@keyframes sg-img-in {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}

.sg-lightbox-loader {
    display: none;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: var(--sg-white);
    border-radius: 50%;
    animation: sg-spin .7s linear infinite;
    position: absolute;
}
@keyframes sg-spin { to { transform: rotate(360deg); } }

/* Footer */
.sg-lightbox-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
    flex-wrap: wrap;
    gap: 10px;
}

.sg-lightbox-caption {
    color: rgba(255,255,255,.85);
    font-size: 13.5px;
    line-height: 1.4;
    max-width: 60%;
}

.sg-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sg-lightbox-counter {
    color: rgba(255,255,255,.55);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.sg-lightbox-download {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    color: #ffffff !important;
    background: rgba(255,255,255,.15) !important;
    border: 1px solid rgba(255,255,255,.3) !important;
    border-radius: 5px !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: background var(--sg-transition);
    font-family: inherit !important;
}
.sg-lightbox-download:hover { background: rgba(255,255,255,.28) !important; color: #ffffff !important; }
.sg-lightbox-download svg { width: 14px !important; height: 14px !important; stroke: #ffffff !important; }
.sg-lightbox-download svg path,
.sg-lightbox-download svg polyline,
.sg-lightbox-download svg line { stroke: #ffffff !important; }

/* ---- Responsive lightbox on small screens ---- */
@media (max-width: 599px) {
    .sg-lightbox-container { padding: 52px 60px 70px !important; }
    .sg-lightbox-prev { left: 8px !important; }
    .sg-lightbox-next { right: 8px !important; }
    .sg-lightbox-prev, .sg-lightbox-next { width: 40px !important; height: 40px !important; }
    .sg-lightbox-caption { max-width: 100%; font-size: 12px; }
}
