* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: #d7d7d7;
    color: #171717;
    font-family: Arial, Helvetica, sans-serif;
}

.page {
    width: 210mm;
    height: 297mm;
    margin: 12mm auto;
    padding: 15mm;
    background: #ffffff;
    overflow: hidden;
    page-break-after: always;
    break-after: page;
}

/* First-page document title */

.first-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.document-title {
    width: 100%;
    text-align: center;
    margin-bottom: 10mm;
}

.document-title h1 {
    margin: 5mm 0 3mm;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 30px;
    font-weight: bold;
    letter-spacing: 2px;
}

.title-subtitle {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 10px;
    letter-spacing: 4px;
    color: #555;
}

.title-rule {
    width: 100%;
    height: 2px;
    background: #171717;
}

.first-image {
    height: 245mm !important;
}

/* Page headings */

.gallery-page h2 {
    margin: 0 0 8mm;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px;
    font-weight: bold;
}

.gallery-page:has(h2) .gallery {
    height: 247mm;
}

/* Four-image pages */

.gallery {
    width: 100%;
    height: 267mm;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8mm;
}

.gallery figure {
    min-width: 0;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.gallery img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
}

.gallery figcaption {
    margin-top: 3mm;
    font-size: 14px;
    line-height: 1.2;
}

/* Single-image pages */

.single-image-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.single-image {
    width: 100%;
    height: 267mm;
    display: flex;
    align-items: center;
    justify-content: center;
}

.single-image figure {
    width: 100%;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.single-image img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.single-image figcaption {
    margin-top: 5mm;
    font-size: 18px;
    text-align: center;
}

/* Missing-file warning */

.missing {
    padding: 20px;
    border: 2px dashed #b00000;
    color: #b00000;
    text-align: center;
}

/* Screen display */

@media screen {
    .page {
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    }
}

@media screen and (max-width: 850px) {
    .page {
        width: 100%;
        height: auto;
        min-height: 297mm;
        margin: 0 0 15px;
    }
}

/* A4 printing */

@media print {
    body {
        background: white;
    }

    .page {
        margin: 0;
        box-shadow: none;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }
}
