.gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-gap: 20px;
    max-width: 100vw;
    margin: 0 auto;
    overflow: hidden;
    font-size: small;
    text-align: center;
}

@media (min-width: 400px) and (max-width: 600px) {
    .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .gallery > div:has(> div) {
        grid-column: span 2;
    }
}

@media (max-width: 400px) {
    .gallery {
        grid-template-columns: 1fr;
    }
}

.gallery div,
.gallery img {
    max-width: 100%;
    margin: 0 auto;
}

.gallery > div {
    padding: 0 10px;
}

.gallery > div > div {
    display: flex;
}

.gallery > div > div img {
    width: 100%;
}

.gallery img {
    max-height: 180px;
    padding: 10px;
    object-fit: contain;
    cursor: pointer;
    display: block;
}

.gallery img:not(.full) {
    padding: 10px;
    border: 1px solid currentcolor;
    cursor: zoom-in;
}

.gallery img.full {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    max-height: unset;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: zoom-out;
}

.gallery div:has(img.full)::before,
.gallery div:has(img.full)::after {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  font-size: 2.5rem;
  color: grey;
  cursor: pointer;
}

.gallery div:has(img.full)::before {
  content: "〈";
  left: 0;
}
.gallery div:has(img.full)::after {
  content: "〉";
  right: 0;
}

img.loading.full {
    filter: blur(2px);
}

body:has(.gallery img.full) {
    overflow: hidden;
}

#name-composition {
    display: inline-block;
}
#name-composition .upper-lower {
    display: inline-flex;
    flex-flow: column;
    vertical-align: middle;
}

#name-composition .green {
    color: darkgreen;
}
#name-composition .red {
    color: red;
}
#name-composition .blue {
    color: blueviolet;
}
#name-composition .magenta {
    color: mediumaquamarine !important;
}

#name-composition .flipping::after {
    content: '↭'; /* TODO! */
    position: absolute;
    height: 1ch;
    transform: translate(-100%, 100%);
    width: 2ch; /* TODO! */
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    @layer {
        #name-composition .green {
            color: limegreen !important;
        }
        #name-composition .red {
            color: red !important;
        }
        #name-composition .blue {
            color: cyan !important;
        }
        #name-composition .magenta {
            color: magenta !important;
        }
    }
}
