/* ================================================================
   STELLAR GALLERY — Frontend 3D Carousel + Lightbox
   Aesthetic: cinematic dark luxury with warm amber glow
================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap');

/* ---- Variables ---- */
.stellar-gallery-wrap {
    --sg-bg:         transparent;
    --sg-gold:       #c9a84c;
    --sg-gold-glow:  rgba(201,168,76,.35);
    --sg-white:      #f0ede8;
    --sg-muted:      rgba(240,237,232,.45);
    --sg-shadow:     0 4px 16px rgba(0,0,0,.12);
    --sg-radius:     12px;
    --sg-duration:   0.55s;
    --sg-ease:       cubic-bezier(0.4, 0, 0.2, 1);

    /* Color overrides — set per-gallery via inline style */
    --sg-dot-color:    #c9a84c;
    --sg-arrow-color:  #ffffff;
    --sg-arrow-bg:     rgba(0,0,0,.08);

    /* Carousel dimensions */
    --sg-slide-w:    520px;
    --sg-slide-h:    360px;
    --sg-side-scale: 0.72;
    --sg-side-x:     400px;
    --sg-side-z:    -160px;

    /* Arrow gutter — arrows live here, never over photos */
    --sg-arrow-gutter: 72px;

    position: relative;
    width: 100%;
    background: transparent;
    padding: 56px var(--sg-arrow-gutter) 40px;
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
    color: var(--sg-white);
    border-radius: var(--sg-radius);
}

/* ---- Ambient background glow — subtle, works on any bg ---- */
.stellar-gallery-wrap::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: radial-gradient(ellipse at center, rgba(0,0,0,.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ================================================================
   STAGE & TRACK
================================================================ */
.stellar-stage {
    position: relative;
    width: 100%;
    height: calc(var(--sg-slide-h) + 60px);
    perspective: 1200px;
    perspective-origin: 50% 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: visible;
}

/* Arrows are pulled OUT of the track into the gutters via negative margin */
.stellar-arrow {
    position: absolute;
    top: 50%;
    z-index: 20;
    background: var(--sg-arrow-bg);
    border: 1px solid rgba(0,0,0,.12);
    color: var(--sg-arrow-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
    transform: translateY(-50%);
}
.stellar-arrow:hover {
    background: rgba(0,0,0,.16);
    border-color: var(--sg-arrow-color);
}
.stellar-arrow:active { transform: translateY(-50%) scale(.92); }
.stellar-arrow svg { width: 20px; height: 20px; }

/* Position arrows inside the gutter — outside the track width */
.stellar-arrow-prev {
    left: calc(var(--sg-arrow-gutter) / 2 - 22px);
}
.stellar-arrow-next {
    right: calc(var(--sg-arrow-gutter) / 2 - 22px);
}

.stellar-track {
    position: relative;
    width: var(--sg-slide-w);
    height: var(--sg-slide-h);
    transform-style: preserve-3d;
}

/* ================================================================
   SLIDES
================================================================ */
.stellar-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--sg-slide-w);
    height: var(--sg-slide-h);
    transition:
        transform   var(--sg-duration) var(--sg-ease),
        opacity     var(--sg-duration) var(--sg-ease),
        filter      var(--sg-duration) var(--sg-ease),
        z-index     0s;
    cursor: pointer;
    transform-style: preserve-3d;
    will-change: transform, opacity;

    /* Default: hidden far side */
    opacity: 0;
    transform: translateX(calc(var(--sg-side-x) * 2)) translateZ(calc(var(--sg-side-z) * 2)) scale(0.5);
    pointer-events: none;
}

/* ACTIVE — center, full spotlight */
.stellar-slide.pos-active {
    opacity: 1;
    transform: translateX(0) translateZ(0) scale(1);
    z-index: 10;
    pointer-events: all;
    filter: none;
}

/* PREV — left side */
.stellar-slide.pos-prev {
    opacity: 1;
    transform: translateX(calc(-1 * var(--sg-side-x))) translateZ(var(--sg-side-z)) scale(var(--sg-side-scale)) rotateY(12deg);
    z-index: 5;
    pointer-events: all;
    filter: none;
}

/* NEXT — right side */
.stellar-slide.pos-next {
    opacity: 1;
    transform: translateX(var(--sg-side-x)) translateZ(var(--sg-side-z)) scale(var(--sg-side-scale)) rotateY(-12deg);
    z-index: 5;
    pointer-events: all;
    filter: none;
}

/* PREV-FAR — two left */
.stellar-slide.pos-prev-far {
    opacity: 1;
    transform: translateX(calc(-1 * var(--sg-side-x) * 1.72)) translateZ(calc(var(--sg-side-z) * 2)) scale(0.52) rotateY(18deg);
    z-index: 2;
    pointer-events: none;
    filter: none;
}

/* NEXT-FAR — two right */
.stellar-slide.pos-next-far {
    opacity: 1;
    transform: translateX(calc(var(--sg-side-x) * 1.72)) translateZ(calc(var(--sg-side-z) * 2)) scale(0.52) rotateY(-18deg);
    z-index: 2;
    pointer-events: none;
    filter: none;
}

/* ================================================================
   CARD
================================================================ */
.stellar-card {
    width: 100%;
    height: 100%;
    border-radius: var(--sg-radius);
    overflow: hidden;
    position: relative;
    background: #0d0d17;
    box-shadow: var(--sg-shadow);
    transition: box-shadow var(--sg-duration) var(--sg-ease);
}

.pos-active .stellar-card {
    box-shadow:
        0 0 0 1px rgba(201,168,76,.15),
        0 8px 30px rgba(0,0,0,.18),
        0 0 20px rgba(201,168,76,.08);
}

.pos-prev .stellar-card,
.pos-next .stellar-card {
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

.stellar-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .6s var(--sg-ease);
}
.pos-active .stellar-card:hover .stellar-card-img {
    transform: scale(1.03);
}

/* Card overlay (expand button) */
.stellar-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.5) 0%, transparent 50%);
    opacity: 0;
    transition: opacity .3s;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 14px;
}
.pos-active .stellar-card:hover .stellar-card-overlay { opacity: 1; }

.stellar-open-lb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(201,168,76,.85);
    color: #080810;
    font-size: 18px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform .2s, background .2s;
    line-height: 1;
    backdrop-filter: blur(4px);
}
.stellar-open-lb:hover { background: var(--sg-gold); transform: scale(1.08); }

/* Active slide — gold frame line top */
.pos-active .stellar-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--sg-gold), transparent);
    opacity: .8;
}

/* ================================================================
   DOTS
================================================================ */
.stellar-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
    position: relative;
    z-index: 1;
}
.stellar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sg-dot-color);
    opacity: 0.3;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all .3s var(--sg-ease);
}
.stellar-dot.active {
    width: 24px;
    border-radius: 3px;
    opacity: 1;
    background: var(--sg-dot-color);
}
.stellar-dot:hover:not(.active) { opacity: 0.6; }

/* ================================================================
   COUNTER (replaces caption — no filename shown)
================================================================ */
.stellar-counter {
    text-align: center;
    margin-top: 16px;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(0,0,0,.35);
    position: relative;
    z-index: 1;
}
.stellar-counter-sep { opacity: .5; }

/* ================================================================
   LIGHTBOX
================================================================ */
.stellar-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
.stellar-lightbox.is-open {
    opacity: 1;
    pointer-events: all;
}

.stellar-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5,5,10,.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
}

.stellar-lb-inner {
    position: relative;
    z-index: 2;
    width: 90vw;
    max-width: 1200px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 10px;
}

/* Lightbox close */
.stellar-lb-close {
    position: absolute;
    top: -56px;
    right: 0;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    color: rgba(255,255,255,.7);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stellar-lb-close:hover { background: rgba(224,85,85,.2); border-color: rgba(224,85,85,.5); color: #fff; }

/* Lightbox arrows */
.stellar-lb-arrow {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.7);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    backdrop-filter: blur(6px);
}
.stellar-lb-arrow:hover {
    background: rgba(201,168,76,.15);
    border-color: rgba(201,168,76,.4);
    color: var(--sg-gold);
}
.stellar-lb-arrow svg { width: 22px; height: 22px; }

/* Lightbox image stage */
.stellar-lb-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.stellar-lb-img {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 40px 100px rgba(0,0,0,.9);
    display: block;
    transition: opacity .25s ease, transform .25s ease;
}
.stellar-lb-img.is-loading { opacity: 0; }

/* Spinner */
.stellar-lb-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 2px solid rgba(201,168,76,.2);
    border-top-color: var(--sg-gold);
    border-radius: 50%;
    animation: stellar-spin 0.7s linear infinite;
    display: none;
}
.stellar-lb-stage.is-loading .stellar-lb-spinner { display: block; }
.stellar-lb-stage.is-loading .stellar-lb-img { opacity: 0; }

@keyframes stellar-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Lightbox caption */
.stellar-lb-caption {
    position: absolute;
    bottom: -44px;
    left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}
.stellar-lb-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    font-style: italic;
    color: rgba(240,237,232,.55);
}
.stellar-lb-counter {
    font-size: 11px;
    letter-spacing: .1em;
    color: rgba(240,237,232,.25);
    text-transform: uppercase;
}

/* ================================================================
   TOUCH / SWIPE HINT
================================================================ */
@media (pointer: coarse) {
    .stellar-arrow { display: none; }
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 900px) {
    .stellar-gallery-wrap {
        --sg-slide-w:      320px;
        --sg-slide-h:      220px;
        --sg-side-x:       240px;
        --sg-side-z:      -100px;
        --sg-arrow-gutter: 60px;
    }
}
@media (max-width: 600px) {
    .stellar-gallery-wrap {
        --sg-slide-w:      260px;
        --sg-slide-h:      180px;
        --sg-side-x:       190px;
        --sg-side-z:       -80px;
        --sg-side-scale:   0.65;
        --sg-arrow-gutter: 52px;
    }
    .stellar-stage { height: calc(var(--sg-slide-h) + 40px); }
    .stellar-lb-inner { width: 98vw; gap: 6px; }
    .stellar-lb-arrow { width: 36px; height: 36px; }
    .stellar-lb-arrow svg { width: 16px; height: 16px; }
}

/* ================================================================
   ENTRY ANIMATION
================================================================ */
@keyframes stellar-fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stellar-gallery-wrap { animation: stellar-fade-up .6s ease both; }

/* Error text */
.stellar-error {
    text-align: center;
    color: rgba(224,85,85,.8);
    font-style: italic;
    padding: 16px;
}
