/* ACE 5-a-side 2026 gallery — layout + responsive + lightbox */

:root {
    --bg: #0f1115;
    --panel: #181b22;
    --text: #e8eaed;
    --muted: #9aa0aa;
    --accent: #3a86ff;
    --bar-h: 64px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0));
}

.site-header {
    padding: 20px 16px 8px;
    text-align: center;
}
.site-header h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 4vw, 2rem); }
.hint { margin: 0 auto; max-width: 60ch; color: var(--muted); font-size: 0.95rem; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 18vh 16px;
    font-size: 1.1rem;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 16px;
    margin: 0;
}
@media (max-width: 480px) {
    .grid { grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 8px; }
}

/* Stack the action bar whenever the single-row layout would wrap, so its
   buttons can never overlap the last grid row. Reserve matching space. */
@media (max-width: 600px) {
    :root { --bar-h: 150px; }
    .bar { flex-direction: column; align-items: stretch; gap: 8px; min-height: auto; }
    .bar .count { text-align: center; }
    .bar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .bar #download { grid-column: 1 / -1; }
}

.tile {
    position: relative;
    margin: 0;
    background: var(--panel);
    border-radius: 8px;
    overflow: hidden;
}
.tile .open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    line-height: 0;
}
.tile .thumb {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
    background: #11141a;
}

/* Selection control — generous touch target */
.select {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.45);
}
.select .pick { width: 22px; height: 22px; cursor: pointer; accent-color: var(--accent); }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }

/* Sticky selection/action bar */
.bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    min-height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0));
    background: var(--panel);
    border-top: 1px solid #262a33;
    z-index: 10;
}
.bar .count { color: var(--muted); }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bar button {
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    background: #2a2f3a;
    color: var(--text);
}
.bar #download { background: var(--accent); color: #fff; font-weight: 600; }
.bar #download:disabled { background: #2a2f3a; color: var(--muted); cursor: not-allowed; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    padding: 16px;
}
.lb-image {
    max-width: 92vw;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox button {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
}
.lb-close { top: 14px; right: 14px; width: 48px; height: 48px; font-size: 26px; }
.lb-prev, .lb-next {
    top: 50%; transform: translateY(-50%);
    width: 56px; height: 56px; font-size: 32px;
}
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lightbox button:disabled { opacity: 0.3; cursor: default; }
.lb-actions {
    position: absolute;
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
    left: 0; right: 0;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0 12px;
}
.lb-actions a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
}
.lb-actions a:first-child { background: var(--accent); }

@media (max-width: 480px) {
    .lb-image { max-height: 70vh; }
    .lb-prev, .lb-next { width: 48px; height: 48px; font-size: 26px; }
}
