/* Emlak Tez Tezel Digital Tarafından Yapılmıştır */
/* Galeri görüntüleyici (tam ekran) — assets/js/gallery-lightbox.js ile birlikte.
   Renkler tema rollerinden gelir (--tc-overlay-rgb, --tc-on-dark-rgb, --secondary); rol yoksa koyu/beyaz varsayılan. */

html.wgl-lock,
html.wgl-lock body {
    overflow: hidden;
}

/* Sitenin html { scrollbar-gutter: stable } kuralı sağda fixed öğenin boyayamadığı boş şerit bırakır; kilit süresince kapat */
html.wgl-lock {
    scrollbar-gutter: auto;
}

.wgl {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    max-width: none;
    z-index: 2000000;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: rgb(var(--tc-overlay-rgb, 0, 0, 0)); /* opak: arkadaki sayfa sızmaz */
    color: var(--tc-on-dark, #fff);
    opacity: 0;
    transition: opacity 0.2s ease;
    overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    font-family: inherit;
    -webkit-user-select: none;
    user-select: none;
}

.wgl.is-in {
    opacity: 1;
}

.wgl *,
.wgl *::before,
.wgl *::after {
    box-sizing: border-box;
}

/* ---- Üst çubuk ---- */
.wgl-top {
    position: relative;
    z-index: 4;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: env(safe-area-inset-top, 0) max(8px, env(safe-area-inset-right, 0)) 0 max(16px, env(safe-area-inset-left, 0));
}

.wgl-count {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.wgl-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.wgl .wgl-btn {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.wgl .wgl-btn:hover {
    background: rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.16);
}

.wgl .wgl-btn[aria-disabled="true"] {
    opacity: 0.35;
    cursor: default;
}

.wgl .wgl-btn[aria-disabled="true"]:hover {
    background: transparent;
}

.wgl button:focus-visible {
    outline: 2px solid var(--tc-focus, var(--tc-on-dark, #fff));
    outline-offset: 2px;
}

.wgl.is-grid [data-act="zin"],
.wgl.is-grid [data-act="zout"] {
    visibility: hidden;
}

/* ---- Sahne ---- */
.wgl-main {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.wgl-stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}

.wgl.is-zoomed .wgl-stage {
    cursor: move;
}

.wgl-stage:active {
    cursor: grabbing;
}

.wgl .wgl-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    transform-origin: 50% 50%;
    will-change: transform;
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

.wgl .wgl-img.is-anim {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.wgl-spin {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border-radius: 50%;
    border: 3px solid rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.25);
    border-top-color: var(--tc-on-dark, #fff);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease 0.25s;
    animation: wgl-rotate 0.8s linear infinite;
}

.wgl.is-loading .wgl-spin {
    opacity: 1;
}

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

/* ---- Önceki / sonraki ---- */
.wgl .wgl-nav {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 48px;
    height: 48px;
    margin: -24px 0 0;
    padding: 0;
    border: 1px solid rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.22);
    border-radius: 50%;
    background: rgba(var(--tc-overlay-rgb, 0, 0, 0), 0.55);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.wgl .wgl-nav:hover {
    background: rgba(var(--tc-overlay-rgb, 0, 0, 0), 0.85);
}

.wgl-prev {
    left: max(12px, env(safe-area-inset-left, 0));
}

.wgl-next {
    right: max(12px, env(safe-area-inset-right, 0));
}

.wgl.is-grid .wgl-nav,
.wgl.is-zoomed .wgl-nav {
    display: none;
}

/* ---- Alt şerit ---- */
.wgl-bottom {
    position: relative;
    z-index: 4;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px max(8px, env(safe-area-inset-right, 0)) calc(8px + env(safe-area-inset-bottom, 0)) max(8px, env(safe-area-inset-left, 0));
}

.wgl.is-single .wgl-bottom {
    display: none;
}

.wgl-strip {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px;
    touch-action: pan-x;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.wgl-strip::-webkit-scrollbar {
    display: none;
}

.wgl .wgl-thumb {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 88px;
    height: 62px;
    margin: 0;
    padding: 0;
    border: 3px solid transparent;
    border-radius: 6px;
    background: rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.1);
    overflow: hidden;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.wgl .wgl-thumb:hover {
    opacity: 0.9;
}

.wgl .wgl-thumb.is-active {
    opacity: 1;
    border-color: var(--secondary, #c1272d);
}

.wgl .wgl-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    pointer-events: none;
}

.wgl .wgl-gridbtn[aria-expanded="true"] {
    background: rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.22);
}

/* Izgara açıkken şerit gizlenir; yalnız ızgara düğmesi sağ altta yüzer (ızgara hücreleriyle çakışmaz) */
.wgl.is-grid .wgl-bottom {
    position: absolute;
    right: 0;
    bottom: 0;
    padding-top: 0;
}

.wgl.is-grid .wgl-strip {
    display: none;
}

.wgl.is-grid .wgl-gridbtn {
    background: rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.22);
    box-shadow: 0 0 0 1px rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.3);
}

/* ---- Tüm fotoğraflar ızgarası ---- */
.wgl-grid {
    position: absolute;
    top: calc(56px + env(safe-area-inset-top, 0));
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    overflow-y: auto;
    padding: 8px max(16px, env(safe-area-inset-right, 0)) calc(76px + env(safe-area-inset-bottom, 0)) max(16px, env(safe-area-inset-left, 0));
    background: rgb(var(--tc-overlay-rgb, 0, 0, 0));
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.wgl-grid:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    align-content: start;
}

.wgl .wgl-cell {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    display: block;
    width: 100%;
    height: 0;
    padding: 75% 0 0; /* 4:3 oran; aspect-ratio eski iOS'ta yok ve grid satır yüksekliğine katılmıyor */
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: rgba(var(--tc-on-dark-rgb, 255, 255, 255), 0.1);
    overflow: hidden;
    cursor: pointer;
}

.wgl .wgl-cell img {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.wgl .wgl-cell:hover img {
    transform: scale(1.04);
}

/* ---- Küçük ekranlar ---- */
@media (max-width: 575.98px) {
    .wgl .wgl-nav {
        width: 44px;
        height: 44px;
        margin-top: -22px;
    }

    .wgl .wgl-thumb {
        width: 68px;
        height: 50px;
    }

    .wgl-grid:not([hidden]) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Yatay telefon: yer çok az, şerit gizlenir (ızgara düğmesi kalır) */
@media (max-height: 480px) {
    .wgl-top {
        min-height: 48px;
    }

    .wgl-strip {
        display: none;
    }

    .wgl-bottom {
        position: absolute;
        right: 0;
        bottom: 0;
        padding-top: 0;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0));
    }

    .wgl-grid {
        top: calc(48px + env(safe-area-inset-top, 0));
    }
}

@media (prefers-reduced-motion: reduce) {
    .wgl,
    .wgl *,
    .wgl *::before,
    .wgl *::after {
        transition: none !important;
    }

    .wgl-spin {
        animation-duration: 2s;
    }
}
