/* photos.css — the photo grid and detail.
 *
 * Thumbnails carry the FULL image's width/height attributes, because that is
 * what the row stores and the ratio is the same. The attributes are there to
 * reserve the right aspect ratio before the bytes arrive; the sizing is done
 * here. Without `width: 100%` the browser would honour the attribute literally
 * and lay out a 2048px image.
 */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3, 12px);
    list-style: none;
    margin: 0 0 var(--space-5, 24px);
    padding: 0;
}

.photo-cell {
    position: relative;
    margin: 0;
}

.photo-cell img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm, 3px);
    background: var(--color-surface-2, #eee);
}

/* Reads as a state, not a warning: an untagged photo is ordinary until someone
 * gets to it, and thirty amber pills would say something is wrong. */
.photo-flag {
    position: absolute;
    left: 4px;
    bottom: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-inverse, #fff);
    background: rgba(0, 0, 0, .62);
    border-radius: var(--radius-sm, 2px);
}

.photo-detail {
    margin-bottom: var(--space-5, 24px);
}

.photo-detail img {
    display: block;
    width: 100%;
    max-width: 720px;
    height: auto;
    border-radius: var(--radius-sm, 3px);
}

/* ── Lightbox ────────────────────────────────────────────────────────────────
 * Hidden until app.js opens it, so a JS-off browser follows the link to the
 * image instead and still sees the photo.
 */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: rgba(10, 10, 9, .92);
}

.lightbox.is-open {
    display: flex;
}

.lightbox img {
    max-width: 100%;
    /* Not 100vh: on iOS the toolbar makes vh taller than what is on screen, so
     * the bottom of the photo sits under the browser chrome. */
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    width: 44px;              /* a real touch target, not a 24px × */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, .4);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

/* Stops the page behind scrolling under the overlay on touch. */
body.has-lightbox {
    overflow: hidden;
}

.photo-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3, 12px);
    margin-bottom: var(--space-5, 24px);
}

.tag-list {
    list-style: none;
    margin: 0 0 var(--space-4, 16px);
    padding: 0;
}

.tag-list li {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border, #e3e3df);
}

.tag-add {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3, 12px);
}

form.inline {
    display: inline;
    margin: 0;
}
