:root {
  --fg: #272420;
  --bg: #d9d9da;
  --border: transparent;
  --item-bg: #f9f9fad9;
  --accent: #ff77aa;
}

body {
  background-color: var(--bg);
  background-image: url(cover.webp);
  background-size: contain;
  color: var(--fg);
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  position: relative;
}

footer {
  align-items: center;
  background-color: var(--bg);
  box-sizing: border-box;
  bottom: 0;
  display: flex;
  height: 40px;
  justify-content: center;
  padding: 16px 0;
  position: fixed;
  width: 100%;
  z-index: 2;
}

h1, h2 {
  text-align: center;
  width: 100%;
}

input[type="checkbox"] {
  display: none;
}

label:has(>input[type="checkbox"]) {
  display: inline-block;
  height: 24px;
  margin: 0 8px;
  position: relative;
  width: 40px;
  &::before {
    content: '';
    display: inline-block;
    border-radius: 8px;
    background: var(--fg);
    height: 16px;
    margin: 4px;
    opacity: .4;
    width: 32px;
  }
  &::after {
    content: '';
    display: inline-block;
    border-radius: 10px;
    background: var(--fg);
    height: 20px;
    position: absolute;
    width: 20px;
    top: 2px;
    transition: .3s;
    left: 2px;
  }
  &:has(input:checked)::after {
    left: 22px;
  }
}
#mode {
  display: inline-block;
  white-space: nowrap;
  &>svg {
    height: 24px;
    opacity: .4;
    transition: .3s;
    width: 24px;
  }
  #asIcon {
    opacity: 1;
  }
  &:has(input:checked) {
    #asIcon{
      opacity: .4;
    }
    #asList {
      opacity: 1;
    }
  }
}

.container {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  left: 50%;
  max-height: calc(100vh - 40px);
  margin-bottom: 8px;
  opacity: 0;
  outline: none;
  overflow: auto;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: scale(.5);
  transition: .3s cubic-bezier(0.18, -0.6, 0.32, 1.6);
  translate: -50% calc(-50% - 20px);
  width: min(calc(100vw - 32px), 384px);
}

.container:target,
body:not(:has(:target))>.container:nth-child(1) {
  opacity: 1;
  pointer-events: unset;
  transform: scale(1)
}

.container:has(.imported) {
  width: unset;
}

.item, .page-title, .imported, .import {
  align-items: center;
  backdrop-filter: blur(2px);
  background: var(--item-bg);
  border-radius: 16px;
  border: 2px solid var(--border);
  box-sizing: border-box;
  display: inline-flex;
  margin: 8px;
  min-height: 64px;
  justify-content: center;
  padding: 16px;
  text-decoration: none;
  min-width: 64px;
}
a.item {
  color: var(--fg) !important;
}
.page-title-container {
  align-items: center;
  display: flex;
  justify-content: center;
  width: 100%;
}
.page-title {
  border: none;
  flex-direction: column;
  min-width: 50%;
  text-align: center;
}
.categoly {
  font-weight: bold;
}
.import::after {
  content: 'Loading...';
}
.imported {
  border: none;
  display: inline-block;
  max-height: calc(100dvh - 80px - 80px);
  overflow: auto;
  h2 {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: center;
  }
  .title-icon {
    width: 32px;
  }
  footer {
    display: none;
  }
  a:link, a:visited {
    color: var(--accent);
  }
  pre {
    background: var(--item-bg);
    border-radius: 8px;
    padding: 16px;
  }
  dt {
    border-bottom: 1px solid;
  }
  dd {
    opacity: .7;
    margin-bottom: 16px;
  }
}

.icon {
  border-radius: 8px;
  width: 24px;
  transition: .3s cubic-bezier(0.18, -0.6, 0.32, 1.6);
}
.card {
  border-radius: 8px;
  transition: .3s cubic-bezier(0.18, -0.6, 0.32, 1.6);
}
.loading {
  opacity: 0;
  transform: scale(.8);
}

body:has(#asListCheckbox:checked) {
  .container {
    margin-bottom: 0;
  }
  .item {
    border: none;
    margin: 16px 0;
    width: 100%;
    &::after {
      content: attr(title);
      padding-left: 16px;
    }
    .icon {
      max-width: 32p;
    }
  }
  .categoly {
    display: none;
  }
}

@media (hover: none) {
  .container {
    bottom: 40px;;
    max-height: calc(100dvh - 40px);
    top: unset;
    translate: -50% 0;
    &:has(.imported) {
      width: calc(100% - 16px);
    }
  }

  @supports (-webkit-appearance: none) {
    body {
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .container {
      bottom: max(40px;, env(safe-area-inset-bottom, 40px;));
      top: unset;
    }
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #efefec;
    --bg: #23232e;
    --border: #ecefef;
    --item-bg: #504540bb;
    --accent: #ccee99;
  }
}
