/* ===== PAGES/PHOTO.CSS ===== */
/* Photo presentation: the album tile, the paper-mounted print, the detail
   stage, and the EXIF table. Kept out of the kit deliberately — the white
   mount is a darkroom decision, not a theme one, so it holds in both modes. */

:root {
    /* The paper a print is mounted on, and the ink of its caption. Fixed,
       not theme-derived: a print does not change colour with the page. */
    --photo-paper: #fff;
    --photo-paper-ink: #222;
}

/* --- Album tile --- */

.gallery-photo {
    position: relative;
    overflow: hidden;
}

.gallery-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border: none;
    cursor: pointer;
}

.gallery-photo img:hover {
    opacity: 0.9;
}

.gallery-photo-placeholder {
    background: linear-gradient(
        135deg,
        var(--bg-primary) 0%,
        color-mix(in srgb, var(--accent) 4%, var(--bg-primary)) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    padding: var(--space-2);
    word-break: break-all;
    text-align: center;
}

/* --- Mounted prints (daily entries) --- */
/* Rows break the reading column: a photograph gets the full width the
   viewport allows, and the caption stays with the print it belongs to. */

.photo-rows {
    display: grid;
    gap: var(--space-8);
}

/* Centred on the reading column rather than hung off its left edge, so a
   row wider than the column stays inside the viewport at every width. */
.photo-row {
    display: grid;
    gap: var(--space-8);
    width: min(150%, calc(100vw - 2 * var(--page-pad)));
    margin-left: 50%;
    transform: translateX(-50%);
}

.photo-row-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* A single portrait keeps the pair's column width rather than stretching
   across the row, so a run of them reads at one size. */
.photo-row-single {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.photo-row-single .photo-print {
    grid-column: 1;
}

.photo-print {
    margin: 0;
    display: grid;
    gap: 0;
    padding: clamp(10px, 1vw, 16px);
    background: var(--photo-paper);
}

.photo-print a {
    display: block;
    background: var(--photo-paper);
}

.photo-print img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border: none;
}

.photo-print figcaption {
    max-width: 78ch;
    margin: clamp(10px, 1vw, 16px) 0 0;
    padding-bottom: clamp(8px, 1vw, 16px);
    font-size: 13px;
    line-height: 1.6;
    color: var(--photo-paper-ink);
}

.photo-print.has-caption {
    padding-bottom: clamp(18px, 2vw, 32px);
}

/* --- Detail stage --- */

/* The stage is wider than the reading column and centred on it, so a large
   print gets the viewport without pushing the page sideways. */
.photo-detail {
    width: min(96vw, 1480px);
    position: relative;
    margin-left: 50%;
    transform: translateX(-50%);
}

.photo-shell {
    display: grid;
    gap: 18px;
}

.photo-stage {
    margin: 0;
    display: grid;
    gap: var(--space-3);
    justify-items: center;
}

.photo-stage #img {
    scroll-margin-top: clamp(72px, 10vh, 128px);
}

/* Sized from the photo's own aspect so the print fits the viewport height
   without the layout jumping once the image decodes. */
.photo-detail-link {
    display: inline-block;
    width: min(100%, calc((100dvh - 240px) * var(--photo-aspect, 1)));
    max-width: 100%;
    aspect-ratio: var(--photo-width, 1) / var(--photo-height, 1);
}

.photo-detail-img {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    border: clamp(10px, 1vw, 16px) solid var(--photo-paper);
    margin: 0;
    image-orientation: from-image;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--photo-paper);
    box-sizing: border-box;
}

.photo-stage-caption {
    max-width: min(72ch, 100%);
    margin: 0;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.6;
}

.photo-stage-placeholder {
    width: min(100%, 1200px);
}

/* --- EXIF --- */

.photo-exif {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--space-8);
    margin: 0;
    padding: 0;
}

.photo-exif-row {
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.photo-exif dt {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    min-width: 60px;
    margin: 0;
}

.photo-exif dd {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

/* --- Responsive --- */

@media (max-width: 600px) {
    .photo-row,
    .photo-row-pair,
    .photo-row-single {
        width: 100%;
        margin-left: 0;
        transform: none;
        grid-template-columns: 1fr;
    }

    .photo-row-single .photo-print {
        grid-column: auto;
    }

    /* At this width the stage and the column are the same thing. */
    .photo-detail {
        width: min(100%, calc(100vw - 16px));
        margin-left: 0;
        transform: none;
    }

    .photo-shell {
        gap: 14px;
    }

    .photo-exif {
        grid-template-columns: 1fr;
    }

    .photo-detail-link {
        width: min(100%, calc((100dvh - 280px) * var(--photo-aspect, 1)));
    }
}
