/* ============================================================
   SleepShop Gallery v2.0 — Tile Grid
   ============================================================ */

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

/* ── Section ──────────────────────────────────────────────── */
.ssg-section {
    padding: 88px 0 104px;
    background: #f9f8f4;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    position: relative;
}

.ssg-container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ── Headings ─────────────────────────────────────────────── */
.ssg-eyebrow {
    font-size: 11px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #b08968;
    font-weight: 500;
    text-align: center;
    margin: 0 0 16px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.ssg-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: 54px;
    color: #1a1a1a;
    text-align: center;
    letter-spacing: 0.01em;
    margin: 0 0 16px;
    line-height: 1.05;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.1s, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s;
}

.ssg-title em {
    font-style: italic;
    color: #b08968;
}

.ssg-sub {
    font-size: 14px;
    color: #888;
    text-align: center;
    font-weight: 300;
    letter-spacing: 0.04em;
    max-width: 440px;
    margin: 0 auto 64px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease 0.2s, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

/* Heading reveal */
.ssg-section.ssg-headers-visible .ssg-eyebrow,
.ssg-section.ssg-headers-visible .ssg-title,
.ssg-section.ssg-headers-visible .ssg-sub {
    opacity: 1;
    transform: translateY(0);
}

/* ── Tile Grid ────────────────────────────────────────────── */
.ssg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

/* ── Individual tile ──────────────────────────────────────── */
.ssg-item {
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
    background: #e8e6e0;

    /* Entrance: hidden by default, revealed via JS */
    opacity: 0;
    transform: translateY(40px) scale(0.96);
    transition:
        opacity  0.8s ease,
        transform 0.8s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.45s ease;
    will-change: transform, opacity;
}

/* Revealed by IntersectionObserver */
.ssg-item.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Hover: whole tile lifts */
.ssg-item.is-visible:hover {
    transform: translateY(-7px) scale(1.005);
    box-shadow:
        0 28px 60px rgba(0, 0, 0, 0.2),
        0 8px 20px rgba(0, 0, 0, 0.09);
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.45s ease;
}

/* ── Image ────────────────────────────────────────────────── */
.ssg-item__inner {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ssg-item__img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.ssg-item:hover .ssg-item__img {
    transform: scale(1.08);
}

/* Loading placeholder shimmer */
.ssg-item__img:not([src]),
.ssg-item__img[src=""] {
    background: linear-gradient(110deg, #e8e6e0 8%, #f3f1eb 18%, #e8e6e0 33%);
    background-size: 200% 100%;
    animation: ssg-shimmer 1.8s linear infinite;
}

@keyframes ssg-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ── Caption overlay ──────────────────────────────────────── */
.ssg-item__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 20px;
    background: linear-gradient(
        180deg,
        transparent 40%,
        rgba(10, 8, 5, 0.52) 72%,
        rgba(10, 8, 5, 0.82) 100%
    );
    opacity: 0;
    transition: opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    margin: 0;
    pointer-events: none;
}

.ssg-item:hover .ssg-item__overlay {
    opacity: 1;
}

.ssg-item__caption {
    color: #fff;
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 500;
    transform: translateY(14px);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    line-height: 1.5;
}

.ssg-item:hover .ssg-item__caption {
    transform: translateY(0);
}

/* ── Zoom icon ────────────────────────────────────────────── */
.ssg-item__zoom {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.55) rotate(-20deg);
    transition:
        opacity 0.3s ease,
        transform 0.48s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.ssg-item:hover .ssg-item__zoom {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.ssg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(8, 7, 5, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s ease, visibility 0.45s ease;
    overflow: hidden;
}

.ssg-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.ssg-lb__stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ssg-lb__track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.ssg-lb__track.is-dragging {
    transition: none;
}

.ssg-lb__slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 48px 96px;
    box-sizing: border-box;
}

.ssg-lb__img-wrap {
    max-width: 100%;
    max-height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
}

.ssg-lb__img-wrap.is-zoomed  { cursor: grab; }
.ssg-lb__img-wrap.is-panning { cursor: grabbing; }

.ssg-lb__img {
    max-width: 100%;
    max-height: 85vh;
    display: block;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
}

.ssg-lb__img.is-panning { transition: none; }

/* Controls */
.ssg-lb__close,
.ssg-lb__prev,
.ssg-lb__next {
    position: absolute;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 2;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ssg-lb__close               { top: 24px; right: 28px; width: 44px; height: 44px; }
.ssg-lb__prev, .ssg-lb__next { top: 50%; transform: translateY(-50%); width: 54px; height: 54px; }
.ssg-lb__prev                { left: 28px; }
.ssg-lb__next                { right: 28px; }

.ssg-lb__close:hover,
.ssg-lb__prev:hover,
.ssg-lb__next:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.22);
}

.ssg-lb__prev:hover { transform: translateY(-50%) translateX(-3px); }
.ssg-lb__next:hover { transform: translateY(-50%) translateX(3px);  }

.ssg-lb__caption {
    position: absolute;
    bottom: 54px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 400;
    padding: 0 80px;
    pointer-events: none;
}

.ssg-lb__counter {
    position: absolute;
    top: 30px;
    left: 28px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    letter-spacing: 0.12em;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.ssg-lb__counter span { color: #fff; }

/* Dots (mobile) */
.ssg-lb__dots {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 6px;
    align-items: center;
}

.ssg-lb__dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.ssg-lb__dots span.is-active {
    background: #fff;
    width: 24px;
    border-radius: 3px;
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 900px) {
    .ssg-section    { padding: 60px 0 72px; }
    .ssg-container  { padding: 0 20px; }
    .ssg-title      { font-size: 38px; }
    .ssg-sub        { font-size: 13px; margin-bottom: 44px; }

    .ssg-grid       { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .ssg-item       { aspect-ratio: 4 / 3; }
    .ssg-item__caption { font-size: 10px; letter-spacing: 0.12em; }
    .ssg-item__zoom { display: none; }

    .ssg-lb__slide  { padding: 72px 16px 88px; }
    .ssg-lb__close  { top: 14px; right: 14px; width: 40px; height: 40px; }
    .ssg-lb__prev,
    .ssg-lb__next   { display: none; }
    .ssg-lb__counter { top: 20px; left: 16px; }
    .ssg-lb__caption { bottom: 60px; font-size: 11px; padding: 0 20px; }
    .ssg-lb__dots   { display: flex; }
}

@media (max-width: 480px) {
    .ssg-title { font-size: 30px; }
    .ssg-grid  { gap: 8px; }
    .ssg-item  { border-radius: 4px; }
}

/* ── Reduce motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ssg-eyebrow,
    .ssg-title,
    .ssg-sub,
    .ssg-item {
        animation: none !important;
        transition: opacity 0.3s ease !important;
        transform: none !important;
        opacity: 0;
    }
    .ssg-section.ssg-headers-visible .ssg-eyebrow,
    .ssg-section.ssg-headers-visible .ssg-title,
    .ssg-section.ssg-headers-visible .ssg-sub,
    .ssg-item.is-visible {
        opacity: 1;
    }
    .ssg-item__img,
    .ssg-item__overlay,
    .ssg-item__zoom,
    .ssg-lb__track {
        transition: none !important;
    }
}
