﻿.sgx {
    --pos: 50%;
    --bar: 3px;
    --accent: #c9a227;
    --ink: #111;
    --paper: #fff;
    max-width: 1100px;
    margin: 2rem auto;
    font: 16px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;
    color: var(--ink)
}

    .sgx * {
        box-sizing: border-box
    }

/* --- stage --- */
.sgx__stage {
    position: relative;
    overflow: hidden;
    background: #e8e8e8;
    border: 1px solid #cfcfcf;
    border-radius: 6px;
    touch-action: pan-y;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none
}

    .sgx__stage img {
        display: block;
        width: 100%;
        height: auto
    }

.sgx__layer {
    position: absolute;
    inset: 0
}

    .sgx__layer img {
        width: 100%;
        height: 100%;
        object-fit: cover
    }
/* base layer = degraded/after ; top layer = original/before */
.sgx__base {
    position: relative
}
/* sets intrinsic height */
.sgx__top {
    will-change: clip-path,opacity
}

/* mode: wipe */
.sgx[data-mode="wipe"] .sgx__top {
    clip-path: inset(0 calc(100% - var(--pos)) 0 0)
}

.sgx[data-mode="wipe"] .sgx__handle {
    display: flex
}
/* mode: fade */
.sgx[data-mode="fade"] .sgx__top {
    opacity: calc(var(--pos)/100%)
}
/* mode: peek (hold) */
.sgx[data-mode="peek"] .sgx__top {
    opacity: 0;
    transition: opacity .18s ease
}

.sgx[data-mode="peek"][data-peeking="true"] .sgx__top {
    opacity: 1
}

.sgx[data-mode="peek"] .sgx__stage {
    cursor: pointer
}

/* --- wipe handle --- */
.sgx__handle {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos);
    width: var(--bar);
    margin-left: calc(var(--bar)/-2);
    background: var(--accent);
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0,0,0,.35)
}

.sgx__grip {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 6px rgba(0,0,0,.45);
    display: grid;
    place-items: center;
    color: #1a1a1a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -1px
}

/* --- corner labels --- */
.sgx__tag {
    position: absolute;
    bottom: 8px;
    padding: .28rem .6rem;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    background: rgba(17,17,17,.82);
    color: #fff;
    border-radius: 3px;
    pointer-events: none
}

.sgx__tag--l {
    left: 8px
}

.sgx__tag--r {
    right: 8px
}

/* --- controls --- */
.sgx__ctl {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-top: .75rem
}

.sgx__modes {
    display: flex;
    gap: 2px;
    background: #ddd;
    padding: 2px;
    border-radius: 5px
}

    .sgx__modes button {
        border: 0;
        background: transparent;
        padding: .4rem .7rem;
        border-radius: 4px;
        font: inherit;
        font-size: .85rem;
        cursor: pointer;
        color: #333
    }

        .sgx__modes button[aria-pressed="true"] {
            background: var(--paper);
            color: #000;
            box-shadow: 0 1px 3px rgba(0,0,0,.2);
            font-weight: 600
        }

.sgx__range {
    flex: 1 1 180px;
    min-width: 140px;
    accent-color: var(--accent);
    height: 28px
}

.sgx__zoom {
    border: 1px solid #bbb;
    background: var(--paper);
    padding: .4rem .7rem;
    border-radius: 4px;
    font: inherit;
    font-size: .85rem;
    cursor: pointer
}

    .sgx__zoom[aria-pressed="true"] {
        background: var(--accent);
        border-color: var(--accent);
        font-weight: 600
    }

.sgx__cap {
    margin: .6rem 0 0;
    font-size: .83rem;
    color: #4a4a4a
}

    .sgx__cap strong {
        color: #111
    }

/* --- magnifier --- */
.sgx__loupe {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 3px 14px rgba(0,0,0,.5);
    overflow: hidden;
    pointer-events: none;
    display: none;
    background: #fff
}

.sgx[data-zoom="true"] .sgx__loupe {
    display: block
}

.sgx__loupe > div {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat
}

.sgx__loupeTop {
    clip-path: inset(0 50% 0 0)
}

.sgx__loupeSplit {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: var(--accent)
}

/* --- no-JS / fallback --- */
.sgx:not([data-ready]) .sgx__ctl {
    display: none
}

.sgx:not([data-ready]) .sgx__top {
    position: static;
    clip-path: none;
    opacity: 1;
    border-top: 2px solid var(--accent)
}

.sgx:not([data-ready]) .sgx__stage {
    cursor: auto
}

@media (max-width:520px) {
    .sgx__loupe {
        width: 130px;
        height: 130px
    }

    .sgx__tag {
        font-size: .66rem;
        padding: .22rem .45rem
    }

    .sgx__modes button {
        padding: .4rem .55rem;
        font-size: .8rem
    }
}

@media (prefers-reduced-motion:reduce) {
    .sgx[data-mode="peek"] .sgx__top {
        transition: none
    }
}
