.collection-home {
  grid-template-columns: minmax(0, 88rem);
  padding-top: 8vh;
}

.collection-home main {
  min-width: 0;
}

.collection-home .identity,
.collection-heading {
  max-width: 64ch;
}

.collection-home .collection-logo {
  display: block;
  width: max-content;
  margin: 0 0 calc(var(--lh) / 2);
  padding: 0;
}

.collection-home .collection-logo:focus-visible,
.collection-home .collection-entry button:focus-visible,
.collection-home .collection-dialog > button:focus-visible {
  outline: 1px dotted currentColor;
  outline-offset: 4px;
}

.collection-heading,
.collection-browser {
  margin-bottom: calc(var(--lh) * 2);
}

.collection-heading h2,
.collection-heading > p,
.collection-browser > p {
  margin-bottom: var(--lh);
}

.collection-toolbar {
  display: block;
}

.collection-controls {
  display: grid;
  grid-template-columns: 1fr auto minmax(12ch, 22ch);
  gap: 1ch;
  align-items: baseline;
  margin-bottom: var(--lh);
}

.collection-controls .collection-count {
  margin: 0;
}

.collection-controls input {
  min-width: 0;
  border: 0;
  border-bottom: 1px dotted var(--muted);
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.collection-controls input:focus {
  border-bottom-style: solid;
}

.collection-controls input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.collection-count {
  color: var(--muted);
}

.collection-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5em;
}

.collection-load-more {
  width: 100%;
  height: 1px;
}

.collection-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.collection-entry {
  width: 100%;
  margin-bottom: calc(var(--lh) * 2);
}

.collection-entry.is-revealing {
  animation: collection-entry-reveal 220ms ease-out both;
}

@keyframes collection-entry-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.collection-entry:last-child {
  margin-bottom: 0;
}

.collection-entry h3,
.collection-entry p {
  margin: 0 0 var(--lh);
}

.collection-entry h3 {
  margin-top: calc(var(--lh) / 2);
  margin-bottom: 0;
  font-weight: inherit;
}

.collection-entry button {
  display: block;
  width: 100%;
  cursor: zoom-in;
  border: 0;
  background: transparent;
  padding: 0;
}

.collection-entry img,
.collection-entry video {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
}

.collection-entry video {
  background: transparent;
  pointer-events: none;
}

.collection-entry .entry-meta {
  margin-top: 0;
  margin-bottom: 0;
  color: var(--muted);
}

.collection-dialog {
  position: fixed;
  inset: 0;
  width: min(88vw, 1000px);
  max-width: none;
  height: min(88vh, 800px);
  max-height: none;
  margin: auto;
  border: 1px solid var(--code-border);
  border-radius: 0;
  color: var(--ink);
  background: var(--page);
  padding: var(--lh);
}

.collection-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.collection-dialog[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--lh);
}

.dialog-caption p {
  margin: 0;
}

.dialog-caption .dialog-meta {
  margin-bottom: calc(var(--lh) / 2);
}

.collection-dialog > button {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  cursor: pointer;
  place-items: center;
  border: 0;
  color: inherit;
  background: var(--page);
  padding: 0;
  font-size: 48px;
  line-height: 1;
}

.collection-dialog > img,
.collection-dialog > video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: var(--code);
}

.dialog-meta {
  color: var(--muted);
}

@media (min-width: 1000px) {
  .collection-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 650px) and (max-width: 999px) {
  .collection-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-device-width: 600px), (max-width: 600px) {
  .collection-home {
    padding-top: 2em;
  }

  .collection-controls {
    grid-template-columns: 1fr auto minmax(10ch, 1fr);
  }

  .collection-list {
    display: block;
  }

  .collection-dialog {
    width: calc(100vw - 2em);
    height: calc(100vh - 2em);
    padding: calc(var(--lh) / 2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .collection-entry.is-revealing {
    animation: none;
  }
}
