@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200");

.material-symbols-outlined,
.material-symbols-filled {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24
}

.material-symbols-filled {
  font-variation-settings:
    'FILL' 1,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24
}

* {
  box-sizing: inherit;
}

body {
  box-sizing: border-box;
  margin: 0;
  padding: 0;

  --background: #2e2e2e;
  --foreground: #FFF;

  --font-monospace: monospace;

  font-family: var(--font-monospace);

  background-color: var(--background);
  color: var(--foreground);
}

/* Layout */
.swipe-root {
  height: 100svh;
  width: 100vw;
  overflow: hidden;
}

body {
  overflow: hidden;
}

main {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-areas: "main right";
}

.layout-main {
  grid-area: main;
  align-self: center;

  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.15em;
}

.layout-right {
  grid-area: right;
  position: sticky;
  bottom: 0;
  align-self: end;
  min-height: 100svh;

  display: flex;
  flex-direction: column;
}

.layout-nav {
  background: rgba(0, 0, 0, 0.2);
  display: grid;
  grid-template-columns: 80px 80px 80px;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(from var(--foreground) r g b / 0.1);
}

.layout-nav-prev {
  grid-column: 1;
}

.layout-nav-cfg {
  grid-column: 2;
}

.layout-nav-next {
  grid-column: 3;
}

.layout-metadata {
  background: rgba(0, 0, 0, 0.2);
  padding: 20px;
  align-self: start;
  flex: 1;
  width: 100%;
}

.panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;

  overflow-y: auto;
  touch-action: pan-y;
}

.panel-current {
  transform: translateX(var(--swipe-offset));
}
.panel-prev {
  transform: translateX(calc(-100vw + var(--swipe-offset)));
}
.panel-next {
  transform: translateX(calc(100vw + var(--swipe-offset)));
}

.panel-error, .panel-loading {
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.panel-loading {
  opacity: 0.5;
}

.panel-error-settings {
  margin-top: 20px;
}

main > .layout-nav {
  display: none;
}

@media (max-width: 800px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: min-content 1fr min-content;
    grid-template-areas: "nav" "main" "right";
    min-height: 100svh;
  }

  .layout-right {
    bottom: unset;
    min-height: unset;
  }

  main > .layout-nav {
    grid-area: nav;
    display: grid;
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(2px);
  }

  .layout-right .layout-nav {
    display: none;
  }
}

/* Gallery */
.rendered-gallery {
  font-family: var(--font-monospace);
  width: 100%;
  padding: 20px;
}

.rendered-gallery-header {
  display: block;
}

.rendered-gallery-header input {
  display: none;
}

.rendered-gallery-header label {
  cursor: pointer;
  opacity: 0.5;
}

.rendered-gallery-header label:hover {
  opacity: .7;
}

.rendered-gallery-header label:has(:checked) {
  opacity: 1;
}

.rendered-gallery-items {
  --item-dim: 150px;

  display: grid;
  grid-template-columns: repeat(auto-fit, var(--item-dim));
  justify-content: center;
  gap: 10px;

  width: 100%;
}

.rendered-gallery-img {
  height: calc(2px + var(--item-dim));
  width: calc(2px + var(--item-dim));
  border: 1px solid rgba(from var(--foreground) r g b / 0.1);
  cursor: pointer;
}

.rendered-gallery-thumbnail,
.rendered-gallery-thumbnail-placeholder {
  height: var(--item-dim);
  width: var(--item-dim);
}

.rendered-gallery-thumbnail {
  object-fit: contain;
  pointer-events: none;
  background: #000;
}

.rendered-gallery-img {
  position: relative;
}

.rendered-gallery-img:hover {
  border: 1px solid rgba(from var(--foreground) r g b / 0.2);
}

.rendered-gallery-img::after {
  content: attr(data-name);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20px;
  box-sizing: border-box;
  line-height: 20px;
  background: rgba(from var(--background) r g b / 0.5);
  font-size: 12px;
  padding: 0 5px 20px 5px;
  text-align: center;
  text-wrap: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.rendered-gallery-thumbnail-placeholder {
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rendered-gallery-thumbnail-placeholder .material-symbols-filled {
  font-size: calc(var(--item-dim) / 150 * 48);
}

.rendered-gallery-header:has(input[value="list"]:checked) +
.rendered-gallery-items {
  --item-dim: 50px;
  grid-template-columns: minmax(0, 1fr);
}

.rendered-gallery-header:has(input[value="list"]:checked) +
.rendered-gallery-items
.rendered-gallery-img {
  width: 100%;
  display: flex;
  align-items: center;
  height: min-content;
}

.rendered-gallery-header:has(input[value="list"]:checked) +
.rendered-gallery-items
.rendered-gallery-img img {
  width: 50px;
  height: 50px;
}

.rendered-gallery-header:has(input[value="list"]:checked) +
.rendered-gallery-items
.rendered-gallery-img::after {
  position: relative;
  flex: 1;
  min-height: 50px;
  height: min-content;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 10px;
  text-wrap: wrap;
  text-align: left;
  word-break: break-word;
}


/* Image */
.rendered-img,
.rendered-video {
  width: 100%;
  height: auto;
  max-height: 100lvh;
  object-fit: contain;
  display: block;
}

/* Text */
.rendered-text {
  word-break: break-word;
}

.rendered-text-title {
  font-size: 1.6em;
  font-weight: bold;
}

.rendered-text-hint {
  opacity: .3;
  font-size: 0.7em;
  margin-top: 20px;
}

.rendered-text-link {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: rgba(from var(--foreground) r g b / 0.5);
  cursor: pointer;
}

button,
.rendered-button {
  padding: 5px 15px;
  height: 30px;
  line-height: 20px;
  outline: none;
  border: none;
  background: rgba(from var(--foreground) r g b / 0.1);
  color: var(--foreground);
  cursor: pointer;
  border-radius: 4px;

  &:hover {
    background: rgba(from var(--foreground) r g b / 0.2);
  }
}

.rendered-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.rendered-button-icon {
  font-size: 18px;
}

.rendered-text + .rendered-button {
  margin-top: 20px
}

.layout-main > .rendered-text {
  padding: 20px;
  max-width: 600px;
  width: 100%;
}

.rendered-box {
  border: 1px solid rgba(from var(--foreground) r g b / 0.1);
  padding: 10px 20px;
  margin: 20px;
  width: calc(100% - 40px)
}

.rendered-box-link {
  cursor: pointer;
}

.rendered-box-link:hover {
  border-color: rgba(from var(--foreground) r g b / 0.2);
}

/* Settigns & Input */
.input-row {
  display: flex;
  background: rgba(from var(--foreground) r g b / 0.1);
  border-radius: 4px;
}

.input-row input {
  flex: 1;
  outline: none;
  border: none;
  background: transparent;
  color: var(--foreground);
  padding: 0 10px;
}

.input-row input::placeholder {
  color: rgba(from var(--foreground) r g b / 0.5);
}

.backend-row {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.backend-url {
  flex: 1;
  font-family: var(--font-monospace);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: rgba(from var(--foreground) r g b / 0.5);
  margin-bottom: 5px;
}

.backend-init {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100vh;
  width: 100%;
  max-width: 480px;
  padding: 40px;
  margin: 0 auto;
}

/* Dialog */
dialog {
  background: var(--background);
  width: 100%;
  max-width: min(500px, calc(100vw - 80px));
  max-height: calc(100svh - 40px);
  padding: 20px;
  border: none;
  color: inherit;
}

dialog > :first-child {
  margin-top: 0;
}

dialog::backdrop {
  backdrop-filter: blur(2px);
}
