/* ============================================================
   Landscaping Gallery — Frontend Styles
   Mobile-first. Uses CSS custom properties for easy theming.
   ============================================================ */

/* ── Scrollbar gutter — reserves scrollbar space at all times so the
      page never shifts when the lightbox opens/closes ───────────── */
html {
    scrollbar-gutter: stable;
}

/* ── Design tokens ──────────────────────────────────────────── */
:root {
    --gsc-accent:          #1a6ef5;
    --gsc-accent-hover:    #1458cc;
    --gsc-radius:          8px;
    --gsc-gap:             16px;
    --gsc-caption-bg:      rgba(0, 0, 0, 0.55);
    --gsc-transition:      0.25s ease;
    --gsc-overlay-bg:      rgba(10, 10, 10, 0.92);
    --gsc-filter-bg:       #f4f4f5;
    --gsc-filter-active:   var(--gsc-accent);
    --gsc-filter-radius:   100px;
    --gsc-shadow:          0 4px 24px rgba(0, 0, 0, 0.18);
}

/* ── Gallery wrapper ────────────────────────────────────────── */
.gsc-gallery {
    --cols: 1;
    width: 100%;
    font-family: inherit;
}

/* ── Category filter bar ────────────────────────────────────── */
.gsc-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.gsc-filter-btn {
    appearance: none;
    cursor: pointer;
    background: var(--gsc-filter-bg);
    border: 1.5px solid transparent;
    border-radius: var(--gsc-filter-radius);
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    padding: 7px 18px;
    transition:
        background var(--gsc-transition),
        color var(--gsc-transition),
        border-color var(--gsc-transition),
        transform var(--gsc-transition);
}

.gsc-filter-btn:hover {
    background: #e8e9eb;
    transform: translateY(-1px);
}

.gsc-filter-btn.is-active {
    background: var(--gsc-filter-active);
    border-color: var(--gsc-filter-active);
    color: #fff;
}

.gsc-filter-btn:focus-visible {
    outline: 2px solid var(--gsc-accent);
    outline-offset: 3px;
}

/* ── Grid layout ────────────────────────────────────────────── */
.gsc-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: var(--gsc-gap);
    width: 100%;
}

/* Column breakpoints */
@media (min-width: 480px) {
    .gsc-cols-2 { --cols: 2; }
    .gsc-cols-3 { --cols: 2; }
    .gsc-cols-4 { --cols: 2; }
}
@media (min-width: 768px) {
    .gsc-cols-2 { --cols: 2; }
    .gsc-cols-3 { --cols: 3; }
    .gsc-cols-4 { --cols: 3; }
}
@media (min-width: 1024px) {
    .gsc-cols-2 { --cols: 2; }
    .gsc-cols-3 { --cols: 3; }
    .gsc-cols-4 { --cols: 4; }
}

/* ── Individual gallery item ────────────────────────────────── */
.gsc-item {
    margin: 0;
}

/* Hidden during filter transition */
.gsc-item.is-hidden {
    display: none;
}

/* Subtle "appear" animation when filter reveals items */
.gsc-item.is-visible {
    animation: gscFadeIn 0.3s ease forwards;
}

@keyframes gscFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1);    }
}

/* ── Trigger button (the whole card is the button) ──────────── */
.gsc-item__trigger {
    appearance: none;
    background: none;
    border: none;
    border-radius: var(--gsc-radius);
    cursor: pointer;
    display: block;
    padding: 0;
    width: 100%;
    text-align: left;
    position: relative;       /* needed for the shadow pseudo-element */

    /* Promote to its own GPU layer so transform doesn't trigger repaint */
    will-change: transform;

    /* Spring-like cubic-bezier: slight overshoot on the way up,
       smooth settle on the way down — no more jerkiness */
    transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* Resting shadow — always present at low opacity */
.gsc-item__trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--gsc-radius);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.10);
    opacity: 1;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 1;
}

/* Hover shadow — fades in on hover. Animating opacity (not box-shadow)
   means the browser composites on the GPU and never triggers a repaint. */
.gsc-item__trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--gsc-radius);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.20);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 1;
}

.gsc-item__trigger:hover {
    transform: translateY(-5px);
}

.gsc-item__trigger:hover::before { opacity: 0; }
.gsc-item__trigger:hover::after  { opacity: 1; }

.gsc-item__trigger:focus-visible {
    outline: 2px solid var(--gsc-accent);
    outline-offset: 3px;
}

/* ── Image wrapper (enforces aspect ratio) ──────────────────── */
.gsc-item__img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;           /* clip the image scale — kept here, not on trigger */
    background: #e5e7eb;
    border-radius: var(--gsc-radius);
    /* Own GPU layer so the scale transform doesn't repaint the card */
    transform: translateZ(0);
}

/* Fallback for browsers without aspect-ratio */
@supports not (aspect-ratio: 1) {
    .gsc-item__img-wrap::before {
        content: '';
        display: block;
        padding-top: 75%; /* 4:3 */
    }
    .gsc-item__img-wrap img {
        position: absolute;
        inset: 0;
    }
}

.gsc-item__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    will-change: transform;
    /* Smooth deceleration easing feels more natural than linear ease */
    transition: transform 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gsc-item__trigger:hover .gsc-item__img-wrap img {
    transform: scale(1.07);
}

/* ── Zoom icon overlay ──────────────────────────────────────── */
.gsc-item__zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    color: #fff;
    opacity: 0;
    transition:
        opacity var(--gsc-transition),
        background var(--gsc-transition);
}

.gsc-item__trigger:hover .gsc-item__zoom,
.gsc-item__trigger:focus-visible .gsc-item__zoom {
    opacity: 1;
    background: rgba(0, 0, 0, 0.28);
}

.gsc-item__zoom svg {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ── Optional caption below image ──────────────────────────── */
.gsc-item__caption {
    margin: 0;
    padding: 8px 12px 10px;
    font-size: 0.8125rem;
    color: #4b5563;
    line-height: 1.4;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

/* ── Empty state ────────────────────────────────────────────── */
.gsc-empty {
    color: #6b7280;
    font-style: italic;
    padding: 24px 0;
}

/* ── Lightbox backdrop & dialog ─────────────────────────────── */
.gsc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none; /* JS sets display:flex to open, display:none to close */
    align-items: center;
    justify-content: center;
}

.gsc-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: var(--gsc-overlay-bg);
    cursor: pointer;
    /* subtle fade-in driven by JS adding .is-open */
    opacity: 0;
    transition: opacity 0.25s ease;
}

.gsc-lightbox.is-open .gsc-lightbox__backdrop {
    opacity: 1;
}

/* ── Lightbox inner panel ───────────────────────────────────── */
.gsc-lightbox__inner {
    position: relative;
    z-index: 1;
    width: calc(100% - 32px);
    max-width: 960px;
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    border-radius: var(--gsc-radius);
    overflow: hidden;
    background: #111;
    box-shadow: var(--gsc-shadow);
    transform: scale(0.96);
    opacity: 0;
    transition:
        transform 0.25s ease,
        opacity 0.25s ease;
}

.gsc-lightbox.is-open .gsc-lightbox__inner {
    transform: scale(1);
    opacity: 1;
}

/* ── Close button ───────────────────────────────────────────── */
.gsc-lightbox__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    appearance: none;
    background: rgba(0,0,0,0.55);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: background var(--gsc-transition);
}

.gsc-lightbox__close:hover {
    background: rgba(255,255,255,0.2);
}

.gsc-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* ── Stage (image + nav arrows) ─────────────────────────────── */
.gsc-lightbox__stage {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Prev / Next nav buttons ────────────────────────────────── */
.gsc-lightbox__nav {
    appearance: none;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    padding: 0;
    transition: color var(--gsc-transition), background var(--gsc-transition);
    z-index: 2;
}

.gsc-lightbox__nav:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.gsc-lightbox__nav:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
}

.gsc-lightbox__nav[hidden],
.gsc-lightbox__nav.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

/* ── Figure (image + caption) ───────────────────────────────── */
.gsc-lightbox__figure {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
}

.gsc-lightbox__img {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
    background: #000;
    transition: opacity 0.2s ease;
}

.gsc-lightbox__img.is-loading {
    opacity: 0;
}

/* ── Lightbox meta section (title + caption + description) ──── */
.gsc-lightbox__meta {
    background: #1a1a1a;
    padding: 14px 20px;
    max-height: 30%;
    overflow-y: auto;
    flex-shrink: 0;
}

.gsc-lightbox__title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
    color: #f9fafb;
    line-height: 1.3;
}

.gsc-lightbox__title:empty { display: none; }

.gsc-lightbox__caption {
    margin: 0 0 4px;
    font-size: 0.875rem;
    color: #9ca3af;
    line-height: 1.5;
}

.gsc-lightbox__caption:empty { display: none; }

.gsc-lightbox__desc {
    margin: 6px 0 0;
    font-size: 0.875rem;
    color: #d1d5db;
    line-height: 1.65;
    white-space: pre-wrap;
    padding-top: 8px;
    border-top: 1px solid #2d2d2d;
}

.gsc-lightbox__desc:empty {
    display: none;
}

/* ── Mobile overrides ───────────────────────────────────────── */
@media (max-width: 480px) {
    .gsc-lightbox__nav {
        width: 36px;
    }
    .gsc-lightbox__meta {
        padding: 10px 14px;
        max-height: 35%;
    }
    .gsc-filters {
        gap: 6px;
    }
    .gsc-filter-btn {
        font-size: 0.8125rem;
        padding: 6px 14px;
    }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .gsc-item__trigger,
    .gsc-item__img-wrap img,
    .gsc-item__zoom,
    .gsc-filter-btn,
    .gsc-lightbox__backdrop,
    .gsc-lightbox__inner,
    .gsc-lightbox__img {
        transition: none !important;
        animation: none !important;
    }
}
