/* ── RESET ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:      #080808;
    --surface: #111;
    --border:  rgba(255,255,255,0.07);
    --text:    #e4dfd6;
    --muted:   #777;
    --dim:     #404040;
    --accent:  #c8a96e;
    --hdr:     54px;
    --gap:     4px;
    --row-h:   300px;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Outfit', -apple-system, sans-serif;
    font-weight: 300;
    min-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 300;
    height: var(--hdr);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.5rem;
    background: rgba(8,8,8,0.95);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    transition: transform 0.3s ease;
}
.site-header.hdr-hidden { transform: translateY(-100%); }

.logo {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.logo span { color: var(--accent); }

nav { display: flex; gap: 1.5rem; }
nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.73rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s;
}
nav a:hover, nav a.nav-active { color: var(--text); }

.photo-count {
    margin-left: auto;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
}

/* ── FILTER BAR ─────────────────────────────────── */
.filter-bar {
    position: sticky;
    top: var(--hdr);
    z-index: 200;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 10px;
    background: rgba(8,8,8,0.97);
    border-bottom: 1px solid var(--border);
    margin-top: var(--hdr);
}

.fbtn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.09);
    color: var(--muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    font-weight: 400;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 4px 13px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.fbtn:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }
.fbtn.fbtn-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #080808;
    font-weight: 500;
}

/* ── JUSTIFIED GALLERY ───────────────────────────── */
.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    padding: var(--gap);
}
/* Ghost prevents last row from stretching */
.gallery::after {
    content: '';
    flex-grow: 99999;
    height: 0;
}

.photo {
    position: relative;          /* CRITICAL: needed for overlay */
    height: var(--row-h);
    overflow: hidden;
    background: var(--surface);
    cursor: zoom-in;
    /* flex-grow + flex-basis set inline */
}

.photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.25,0.46,0.45,0.94),
                filter   0.5s ease;
    filter: brightness(0.88) saturate(1.05);
}
.photo:hover img {
    transform: scale(1.04);
    filter: brightness(1) saturate(1.1);
}

/* ── HOVER OVERLAY ───────────────────────────────── */
/* overlay is a sibling of <img>, both direct children of .photo */
.photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
        rgba(0,0,0,0.82) 0%,
        rgba(0,0,0,0.20) 55%,
        transparent      100%);
    opacity: 0;
    transition: opacity 0.28s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.85rem 0.9rem;
    pointer-events: none;   /* overlay itself doesn't catch clicks */
}
.photo:hover .photo-overlay { opacity: 1; }

/* iNat link is inside the overlay but re-enables pointer events */
.overlay-inat {
    pointer-events: all;
    position: absolute;
    top: 9px; right: 9px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 50%;
    color: rgba(255,255,255,0.55);
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.2s;
}
.overlay-inat:hover {
    border-color: rgba(255,255,255,0.6);
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.overlay-info { pointer-events: none; }

.oi-sci {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 300;
    font-size: 0.95rem;
    color: #fff;
    line-height: 1.25;
    margin-bottom: 1px;
}
.oi-common {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.58);
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}
.oi-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.62rem;
    color: rgba(255,255,255,0.38);
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
.oi-dot {
    width: 2px; height: 2px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ── LIGHTBOX ────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.97);
    align-items: center;
    justify-content: center;
}
.lightbox.lb-open {
    display: flex;
    animation: lbFade 0.2s ease;
}
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }

.lb-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    max-width: 94vw;
}
.lb-body img {
    max-width: 92vw;
    max-height: 78vh;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.lb-cap { text-align: center; }
.lb-sci {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.15rem;
    font-weight: 300;
    color: var(--text);
    margin-bottom: 3px;
}
.lb-common {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 3px;
}
.lb-meta {
    font-size: 0.65rem;
    color: var(--dim);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.lb-link {
    font-size: 0.68rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.75;
    transition: opacity 0.2s;
}
.lb-link:hover { opacity: 1; }

.lb-x {
    position: fixed;
    top: 1rem; right: 1.2rem;
    background: none; border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
    z-index: 1001;
}
.lb-x:hover { color: var(--text); }

.lb-prev, .lb-next {
    position: fixed;
    top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 2.2rem;
    line-height: 1;
    padding: 0.75rem 0.55rem;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1001;
}
.lb-prev:hover, .lb-next:hover {
    background: rgba(255,255,255,0.07);
    color: var(--text);
}
.lb-prev { left: 0.5rem; }
.lb-next { right: 0.5rem; }

/* ── FOOTER ──────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.8rem 2rem;
    text-align: center;
    color: var(--dim);
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.site-footer a { color: var(--accent); text-decoration: none; }

/* ── INDEX PAGE HERO ─────────────────────────────── */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.hero h1 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3rem, 6vw, 5.5rem);
    line-height: 1.05;
    letter-spacing: 0.02em;
    margin-bottom: 1.1rem;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 3rem;
}
.enter {
    display: inline-block;
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.18);
    text-decoration: none;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 0.8rem 2.4rem;
    transition: all 0.25s;
}
.enter:hover { border-color: var(--accent); color: var(--accent); }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 900px)  { :root { --row-h: 240px; } }

@media (max-width: 600px)  {
    nav { gap: 0.9rem; }
    .photo-count { display: none; }
    .lb-prev, .lb-next { display: none; }

    /* Switch justified flex to 2-column grid on mobile */
    .gallery {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 3px;
        padding: 3px;
    }
    /* Reset the inline flex styles that break mobile layout */
    .photo {
        height: 0;
        padding-bottom: 75%; /* 4:3 aspect ratio cells */
        position: relative;
        width: auto !important;
        flex-grow: unset !important;
        flex-basis: unset !important;
    }
    .photo img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    .photo-overlay {
        position: absolute;
        inset: 0;
    }
    /* Hide ghost ::after element that interferes with grid */
    .gallery::after { display: none; }

    /* Tighter filter bar on mobile */
    .filter-bar { gap: 4px; padding: 6px 8px; }
    .fbtn { font-size: 0.62rem; padding: 3px 10px; }

    /* Lightbox full-screen on mobile */
    .lb-body img { max-width: 100vw; max-height: 70vh; }
}

@media (max-width: 420px) {
    nav a { font-size: 0.65rem; }
    .photo { padding-bottom: 85%; } /* slightly taller cells on very small screens */
}