/*
Theme Name: Surreal Gallery
Description: Minimal gallery front page for Surreal Creations: thumbnail grid, hover titles, lightbox with arrows.
Author: Revolweb
Version: 1.5.0
Requires PHP: 8.0
Text Domain: surreal-gallery
*/

:root {
    --bg: #f6f5f2;
    --fg: #1d1d1b;
    --muted: #77756f;
    --overlay: rgba(12, 12, 11, .94);
    --gap: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.site-header {
    max-width: 1320px;
    margin: 0 auto;
    padding: 48px 16px 28px;
}

.site-title {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
    font-weight: 400;
    letter-spacing: -.01em;
}

.site-title a { color: inherit; text-decoration: none; }
.site-title .brand { font-weight: 700; letter-spacing: .08em; }
.site-title .tagline { font-weight: 300; color: var(--muted); }

/* Admin-only buttons on each tile */
.admin-btns {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    gap: 6px;
}
.hide-btn, .regen-btn, .queued-label {
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    font-family: inherit;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    border: 0;
    border-radius: 3px;
    cursor: pointer;
    opacity: .85;
}
.queued-label { cursor: default; background: #1f5fa8; opacity: 1; }
.hide-btn:hover, .hide-btn:focus-visible { opacity: 1; background: #b3261e; }
.regen-btn:hover, .regen-btn:focus-visible { opacity: 1; background: #1f5fa8; }
.item.is-hidden .tile, .item.is-queued .tile { opacity: .3; filter: grayscale(1); }
.item.is-hidden .hide-btn { background: #b3261e; opacity: 1; }

/* Masonry: up to 3 columns, mixed portrait/landscape images keep their own proportions. */
.gallery {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 16px;
    column-count: 3;
    column-gap: var(--gap);
}

@media (max-width: 900px) { .gallery { column-count: 2; } }
@media (max-width: 520px) { .gallery { column-count: 1; } }

.item {
    position: relative;
    margin: 0 0 var(--gap);
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.tile {
    position: relative;
    display: block;
    overflow: hidden;
    background: #ddd;
}

.tile img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .5s ease;
}

.tile-title {
    position: absolute;
    inset: auto 0 0 0;
    padding: 40px 16px 14px;
    color: #fff;
    font-size: 15px;
    line-height: 1.35;
    background: linear-gradient(transparent, rgba(0, 0, 0, .72));
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
}

.tile:hover img, .tile:focus-visible img { transform: scale(1.03); }
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; transform: none; }
.tile:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

@media (hover: none) { .tile-title { opacity: 1; transform: none; } }

.pagination {
    max-width: 1320px;
    margin: 32px auto 0;
    padding: 0 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    color: var(--fg);
    text-decoration: none;
    border: 1px solid #cfccc5;
}

.pagination .current { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.empty { max-width: 1320px; margin: 0 auto; padding: 0 16px; color: var(--muted); }

.site-footer {
    max-width: 1320px;
    margin: 0 auto;
    padding: 56px 16px 40px;
    color: var(--muted);
    font-size: 14px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--overlay);
}

.lightbox.open { display: flex; }

.lightbox figure {
    margin: 0;
    max-width: calc(100vw - 140px);
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 110px);
    object-fit: contain;
    display: block;
}

.lightbox figcaption {
    color: #eee;
    margin-top: 14px;
    font-size: 16px;
    text-align: center;
}

.lb-btn {
    position: absolute;
    background: none;
    border: 0;
    color: #fff;
    font-size: 44px;
    line-height: 1;
    width: 64px;
    height: 64px;
    cursor: pointer;
    opacity: .75;
}

.lb-btn:hover, .lb-btn:focus-visible { opacity: 1; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-close { top: 8px; right: 8px; font-size: 36px; }

@media (max-width: 600px) {
    .lightbox figure { max-width: 100vw; }
    .lb-prev, .lb-next { top: auto; bottom: 8px; transform: none; }
}

/* JS masonry (row order, newest first): columns built by gallery.js; CSS columns above are the no-JS fallback. */
.gallery.js-masonry { column-count: initial; display: flex; gap: var(--gap); align-items: flex-start; }
.gallery.js-masonry .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.gallery.js-masonry .item { margin: 0; }

/* Admin-only: what was mixed, shown in the hover overlay under the title */
.admin-mix { display: block; margin-top: 6px; font-size: 12px; line-height: 1.45; color: rgba(255, 255, 255, .82); }
.admin-mix .mix-line { display: block; }
.admin-mix strong { color: #fff; font-weight: 600; }
.admin-mix .mix-tech { font-size: 11px; opacity: .8; }
