/* ============================================================
   Small Town 360 — Photo Gallery
   style_grid.css
   ============================================================ */

/* --- Tokens ------------------------------------------------- */
:root {
    --color-bg:         #000000;
    --color-surface:    #111111;
    --color-ink:        #ffffff;
    --color-ink-muted:  #aaaaaa;
    --color-accent:     #2c5f8a;
    --color-accent-lt:  #e8f0f7;
    --color-rule:       #222222;
    --color-overlay:    rgba(0,0,0,.45);

    --font-display: 'Playfair Display', Georgia, serif;
    --font-ui:      'Inter', system-ui, sans-serif;

    --radius:   4px;
    --gap:      3px;                    /* tight grid seam */
    --max-w:    1280px;
    --pad-x:    clamp(1rem, 4vw, 2.5rem);
}

/* --- Reset & base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

::selection { background: var(--color-accent); color: #fff; }

html { scroll-behavior: smooth; }

body {
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
.gallery__img { height: 100% !important; }

a { color: inherit; text-decoration: none; }

/* --- Header ------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-rule);
    padding: .75rem var(--pad-x);
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--color-ink);
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-accent);
    color: #fff;
    font-family: var(--font-display);
    font-size: .8rem;
    font-weight: 600;
    border-radius: var(--radius);
    letter-spacing: .02em;
    flex-shrink: 0;
}

.logo-text {
    font-family: var(--font-ui);
    font-size: .9rem;
    font-weight: 400;
    letter-spacing: .01em;
    color: var(--color-ink-muted);
}

.logo-text strong {
    color: var(--color-ink);
    font-weight: 600;
}

/* --- Gallery wrapper --------------------------------------- */
.gallery-wrapper {
    padding: clamp(2rem, 5vw, 4rem) 0 4rem;
}

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--pad-x);
}

/* --- Gallery header ---------------------------------------- */
.gallery-header {
    margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
    max-width: 640px;
}

.gallery-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -.01em;
    color: var(--color-ink);
    margin-bottom: .5rem;
}

/* Thin accent rule under the title */
.gallery-title::after {
    content: '';
    display: block;
    width: 2.5rem;
    height: 2px;
    background: var(--color-accent);
    margin-top: .6rem;
}

.gallery-intro {
    font-size: .9rem;
    color: var(--color-ink-muted);
    font-weight: 400;
    line-height: 1.65;
    margin-top: .75rem;
}

/* --- Masonry-style CSS grid -------------------------------- */
.pswp-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 180px;
    gap: var(--gap);
    grid-auto-flow: dense;
}

@media (min-width: 600px) {
    .pswp-gallery {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 200px;
        grid-auto-flow: dense;
    }
}

@media (min-width: 900px) {
    .pswp-gallery {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: 220px;
        grid-auto-flow: dense;
    }
}

@media (min-width: 1200px) {
    .pswp-gallery {
        grid-template-columns: repeat(5, 1fr);
        grid-auto-rows: 220px;
        grid-auto-flow: dense;
    }
}

/* Orientation-driven spanning — pattern-based collage layout */

/* Portrait: tall → span 2 rows */
.gallery__item[data-orientation="portrait"] {
    grid-row: span 2;
}

/* Landscape: wide → span 2 columns */
@media (min-width: 600px) {
    .gallery__item[data-orientation="landscape"] {
        grid-column: span 2;
    }
}

/* Feature: hero tile → span 2 cols × 2 rows */
@media (min-width: 600px) {
    .gallery__item[data-orientation="feature"] {
        grid-column: span 2;
        grid-row: span 2;
    }
}

/* Square: 1×1, no spanning needed */

/* --- Gallery item ------------------------------------------ */
.gallery__item {
    position: relative;
    overflow: hidden;
    background: var(--color-rule);
    display: block;
    cursor: zoom-in;
    /* height driven by grid-auto-rows — fills full cell including spanning ones */
    height: 100%;
    min-height: 0;
}

.gallery__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s cubic-bezier(.25,.46,.45,.94),
                filter  .45s ease;
    will-change: transform;
}

/* Hover: subtle zoom + slight desaturate lift */
.gallery__item:hover .gallery__img,
.gallery__item:focus-visible .gallery__img {
    transform: scale(1.04);
    filter: brightness(1.06);
}

/* Caption overlay — slides up on hover */
.gallery__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .5rem .65rem;
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 100%);
    color: #fff;
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* hidden by default, visible on hover */
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
}

.gallery__item:hover .gallery__caption,
.gallery__item:focus-visible .gallery__caption {
    opacity: 1;
    transform: translateY(0);
}

/* Keyboard focus ring */
.gallery__item:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    z-index: 1;
}

/* --- Empty state ------------------------------------------- */
.gallery-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-ink-muted);
    font-size: .9rem;
}

/* --- PhotoSwipe v5 caption bar ----------------------------- */
/* Custom caption element registered in script_grid.js */
.pswp [data-pswp-uid] { /* handled by pswp itself */ }

/* We inject a .pswp__caption-custom via uiRegister */
.pswp__custom-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .6rem 1.25rem;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .8rem;
    font-weight: 400;
    text-align: center;
    pointer-events: none;
}

/* Override PhotoSwipe's default UI tint to match brand */
.pswp__button--arrow {
    --pswp-button-width: 44px;
}

/* --- Footer ------------------------------------------------ */
.site-footer {
    text-align: center;
    padding: 1.5rem var(--pad-x);
    border-top: 1px solid var(--color-rule);
    color: var(--color-ink-muted);
    font-size: .78rem;
}

/* --- Reduced motion ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .gallery__img,
    .gallery__caption {
        transition: none;
    }
}
