:root {
  font-family: sans-serif;
  height: 100%;
}

body {
  background: #222;
  color: rgba(255, 255, 255, 0.9333333333);
  margin: 0;
  padding: 0;
  height: 100%;
}
body.light {
  background: #eee;
  color: #000;
}

h1, h2 {
  font-size: 1.5em;
  margin: 0.5em;
}

header {
  display: grid;
  grid-template-columns: 1fr min-content;
}
header svg {
  height: 100%;
  width: 100%;
  stroke-width: 1px;
  stroke: rgba(255, 255, 255, 0.9333333333);
  fill: none;
}
header > div {
  display: flex;
  flex-flow: row nowrap;
  white-space: nowrap;
}
header > div .layout {
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0.25rem;
}
header > div .layout--active {
  background: rgba(255, 255, 255, 0.2666666667);
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}
ul svg {
  height: 16px;
  stroke-width: 1px;
  stroke: rgba(255, 255, 255, 0.9333333333);
  fill: none;
  display: inline-block;
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
}
ul > li > a {
  position: relative;
  width: 100%;
  display: inline-block;
  padding: 2px 4px 2px 24px;
  box-sizing: border-box;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.grid {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
}
.grid svg {
  margin: 0 auto;
  height: 100%;
  stroke-width: 1px;
  stroke: rgba(255, 255, 255, 0.9333333333);
  fill: none;
}
.grid img {
  margin: 0 auto;
  height: 100%;
  max-width: 100%;
  min-height: 0;
  object-fit: contain;
}
.grid::after {
  content: "";
  flex: auto;
}
.grid > a {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto min-content;
  gap: 4px;
  width: 320px;
  height: 320px;
  max-height: 320px;
  margin: 10px;
  overflow: hidden;
}
.grid > a > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.grid--small > a {
  width: 160px;
  height: 160px;
  max-height: 160px;
}

a {
  color: #0bf;
}
a:hover {
  background: rgba(255, 255, 255, 0.1333333333);
}

.content {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.content > * {
  max-width: 100%;
}
.content > img {
  aspect-ratio: auto;
  object-fit: contain;
}
.content > img.fit--h {
  max-width: 100%;
}
.content > img.fit--v {
  max-height: 100svh;
}
.content > a {
  padding: 0.5em;
  z-index: 20;
}

.nav-overlay {
  display: grid;
  position: fixed;
  grid-template: repeat(3, 1fr) min-content/repeat(3, 1fr);
  inset: 0 0 0 0;
  pointer-events: none;
  max-width: 100vw;
  max-height: 100vh;
}
.nav-overlay h2 {
  grid-row: 1/2;
  grid-column: 1/-1;
  text-align: center;
  text-shadow: rgba(0, 0, 0, 0.2666666667) 0.1em 0.1em 0.2em;
  animation: forwards 0.5s 2s slide-out-up ease-out;
  z-index: 1;
}
.nav-overlay footer {
  grid-row: 4;
  grid-column: 1/-1;
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  z-index: 15;
  background: #333;
  padding: 0.25em;
  pointer-events: auto;
}
.nav-overlay footer > div {
  width: 100%;
  text-align: center;
}
.nav-overlay footer > div:first-child {
  text-align: left;
}
.nav-overlay footer > div:last-child {
  text-align: right;
}
.nav-overlay .pos {
  grid-row: 1/4;
  grid-column: 1/4;
  z-index: 10;
  pointer-events: auto;
  padding: 0.5em;
  transition: all 100ms ease;
  font-size: 3em;
  text-decoration: none;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-overlay .pos:hover {
  color: #eee;
  text-shadow: #000 1px 2px 4px;
}
.nav-overlay .pos--top {
  grid-row: 1/2;
  align-items: start;
}
.nav-overlay .pos--middle {
  grid-row: 2/3;
  align-items: center;
}
.nav-overlay .pos--bottom {
  grid-row: 3/4;
  align-items: end;
}
.nav-overlay .pos--left {
  grid-column: 1/2;
  justify-content: left;
}
.nav-overlay .pos--center {
  grid-column: 2/3;
  justify-content: center;
}
.nav-overlay .pos--right {
  grid-column: 3/4;
  justify-content: right;
}
.nav-overlay#script-overlay {
  grid-template: min-content 1fr min-content/min-content 1fr min-content;
}
.nav-overlay#script-overlay h2 {
  animation: none;
  margin-top: 0;
  z-index: 15;
  pointer-events: auto;
}
.nav-overlay#script-overlay * {
  transition: transform 200ms ease;
}
.nav-overlay#script-overlay button {
  background: #eee;
  color: #000;
  border: none;
  outline: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5333333333);
}
.nav-overlay#script-overlay button:hover {
  background: #aaa;
}
.nav-overlay#script-overlay.hidden [data-move=up] {
  transform: translateY(-100%);
}
.nav-overlay#script-overlay.hidden [data-move=left] {
  transform: translateX(-100%);
}
.nav-overlay#script-overlay.hidden [data-move=down] {
  transform: translateY(100%);
}
.nav-overlay#script-overlay.hidden [data-move=right] {
  transform: translateX(100%);
}

@keyframes slide-out-up {
  from {
    transform: translateY(0%);
  }
  to {
    transform: translateY(-100%);
  }
}