@import url('https://fonts.googleapis.com/css2?family=Playwrite+NO&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  font: inherit;
}
body {
  padding: 1.5rem .5rem;
  font-family: sans-serif;
  font-weight: 400;
  color: #232323;
  max-width: 935px;
  margin-inline: auto;
  line-height: 1.375;
}
h1 {
  font-family: "Playwrite NO", sans-serif;
  font-size: 2rem;
  a {
    color: inherit;
    text-decoration: none;
  }
}
input, textarea {
  display: block;
  width: 100%;
}
header {
  margin-block-end: 1.5rem;
}
.flow > :not(:last-child) {
  margin-block-end: 1rem;
}
input, textarea, button {
  padding: .25rem .5rem;
  border: 1px solid black;
  border-radius: 2px;
}
img, video {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  display: block;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  .dialog-button {
    width: 100%;
    :is(img, video) {
      aspect-ratio: 1;
      object-fit: cover;
    }
  }
  > figure figcaption {
    display: none;
  }
}
body:has([id="list"]:checked) .grid {
  grid-template-columns: 1fr;
  gap: 1rem;
  img, video {
    aspect-ratio: revert;
    object-fit: revert;
  }
  video {
    width: 100%;
    height: auto;
  }
  figcaption {
    display: block;
  }
}
figcaption {
  background-color: white;
  padding-inline: 0;
  padding-block: .5rem;
  time {
    font-size: .875rem;
    opacity: .6;
  }
}
.icon-label {
  cursor: pointer;
  padding: .5rem;
  border-bottom: 3px solid transparent;
  input {
    display: none;
  }
  svg {
    width: 24px;
    display: block;
    aspect-ratio: 1;
    fill: currentColor;
    opacity: .4;
  }
  input:checked + svg {
    opacity: 1;
  }
  &:has(input:checked) {
    border-color: currentColor;
  }
  &:hover svg {
    opacity: 1;
  }
}
.flex, .space-between {
  display: flex;
  gap: .25rem;
  align-items: center;
}
.space-between {
  justify-content: space-between;
}
strong {
  font-weight: 600;
}
.dialog-button {
  border: 0;
  padding: 0;
  background-color: transparent;
  cursor: pointer;
  display: block;
  outline: none;
}
::backdrop {
  background-color: #000;
  opacity: 0.85;
}
dialog[open] {
  border: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  display: grid;
  place-items: center;
  background-color: transparent;
  pointer-events: auto;
}
figure {
  position: relative;
}
dialog > figure {
  display: grid;
  margin-inline: 1.5rem;
  grid-template-columns: auto 300px;
  max-height: calc(100vh - 3rem);
  max-width: calc(100vw - 3rem);
  button {
    cursor: pointer;
    display: inline-block;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 50%;
    width: 2rem;
    aspect-ratio: 1;
    text-align: center;
    background-color: rgb(255 255 255 / .2);
    border: 0;
    box-shadow: 0px 3px 4px 0px rgba(0, 0, 0, 0.10);
    background-repeat: no-repeat;
    background-size: 1rem 1rem;
    background-position: center center;
  }
  .prev {
    left: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z' fill='rgb(0 0 0 / .8)'/%3E%3C/svg%3E");
  }
  .next {
    right: calc(300px + 1rem);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z' fill='rgb(0 0 0 / .8)'/%3E%3C/svg%3E");
  }
  div {
    display: flex;
    overflow-x: auto;
    overflow-y: clip;
    align-items: center;
    background-color: black;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    outline: 0;
    max-width: 600px;
    scrollbar-width: none;
    picture {
      scroll-snap-align: start;
      flex: 0 0 100%;
      max-width: 100%;
      max-height: 100%;
      object-fit: cover;
      height: auto; 
    }
    img {
      display: block;
      max-width: 100%;
      max-height: 100%;
      object-fit: cover;
      height: auto; 
    }
  }
  figcaption {
    padding: 1rem;
  }
}
dialog .prev,
dialog .next {
  display: none;
}
dialog:has(.image-container picture:nth-child(2)) .prev,
dialog:has(.image-container picture:nth-child(2)) .next {
  z-index: 100;
  display: block;
}
@media (width < 760px) {
  dialog > figure {
    max-height: 90svh;
    grid-template-columns: 1fr;
    .next {
      right: 1rem;
    }  
  }
}
.icon-multiple,
.video-icon {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 2rem;
  aspect-ratio: 1;
  background-color: rgb(0 0 0 / .4);
  border-radius: 50%;
  display: grid;
  place-items: center;
  svg {
    fill: white;
    opacity: .9;
    width: 1rem;
    aspect-ratio: 1;
  }
}
.dialog-button video:before {
  content: "";
  display: block;
  position: absolute;
  inset: 0;
}
.pagination ol {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .5rem 0;
  font-size: .875rem;
  li {
    flex: 1;
  }
  li:not(:has(a)) {
    text-align: center;
    flex: 1;
  }
  li:last-of-type {
    text-align: right;
  }
  a {
    display: inline-block;
    text-align: center;
    border-radius: 2px;
    text-decoration: none;
    color: inherit;
    line-height: 1.5rem;
    cursor: pointer;
    padding: .125rem .75rem;
    border: 1px solid midnightblue;
    &:hover {
      background-color: midnightblue;
      color: white;
    }
  }
}
footer {
  text-align: center;
  font-size: .875rem;
  opacity: .7;
  a {
    color: inherit;
    &:hover {
      color: midnightblue;
    }
  }
}
dialog::backdrop {
  backdrop-filter: blur(25px);
}