:root {
  font-family: Geist, sans-serif;
  font-size: 16;

  --color-1: #817;
  --color-2: #a35;
  --color-3: #c66;
  --color-4: #e94;
  --color-5: #ed0;
  --color-6: #9d5;
  --color-7: #4d8;
  --color-8: #2cb;
  --color-9: #0bc;
  --color-10: #09c;
  --color-11: #36b;
  --color-12: #639;
  --color-w: #eee;
  --color-w2: #ccc;
  --color-b: #111;
  --color-b2: #333;

  @media (prefers-color-scheme: light) {
    --theme-bg: var(--color-w);
    --theme-bg2: var(--color-w2);
    --theme-fg: var(--color-b);
  }
  @media (prefers-color-scheme: dark) {
    --theme-bg: var(--color-b);
    --theme-bg2: var(--color-b2);
    --theme-fg: var(--color-w);
  }
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--theme-bg);
  color: var(--theme-fg);
  margin: 0;
  position: relative;

  &:has(.sidebar) {
    padding-left: 48px;
  }
}

nav.topbar {
  align-items: center;
  backdrop-filter: blur(10px);
  display: flex;
  height: 48px;
  padding: 0 max(0px, 100vw / 2 - 400px + 8px);
  position: sticky;
  width: 100vw;
}

nav.sidebar {
  align-items: center;
  border-right: 1px solid var(--theme-bg2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  left: 0;
  padding: 24px 0;
  position: fixed;
  top: 0;
  width: 48px;

  &::before {
    background-color: var(--color-5);
    color: var(--color-b);
    border-radius: 4px;
    content: "beta";
    font-size: 0.8em;
    font-weight: bold;
    padding: 2px 4px;
    rotate: 5deg;
  }

  a {
    border-radius: 4px;
    padding: 4px;
    position: relative;
    line-height: 1;

    &:hover {
      background-color: var(--theme-bg2);
    }
  }

  [tooltip]:hover::after {
    background-color: var(--theme-bg2);
    border-radius: 4px;
    content: attr(tooltip);
    font-size: 0.9em;
    font-weight: 500;
    left: calc(100% + 16px);
    padding: 4px 8px;
    position: absolute;
  }
}

main {
  margin: 0 auto;
  max-width: 800px;
  width: 100%;
  padding: 24px 8px;
}

footer {
  font-size: 0.8em;
  width: 100%;
  max-width: 800px;
  margin: auto;
  padding: 24px 8px;
}

/* GENERAL STYLING */

::selection {
  background-color: var(--color-1);
  color: var(--color-w);
}

h1,
h2 {
  align-items: baseline;
  display: flex;
  gap: 8px;

  > svg {
    align-self: center;
  }
}

a {
  color: currentColor;
  text-decoration: underline;

  &:hover {
    text-decoration: none;
  }
}

hr {
  display: block;
  border: none;
  height: 1px;
  background-color: var(--theme-bg2);
  margin: 16px 0;
}

dl {
  gap: 8px 32px;
  display: grid;
  grid-template-columns: auto 1fr;

  dh {
    font-weight: bold;
  }

  dd {
    margin: 0;
  }
}

/* FORM STYLING */

label {
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;

  &:not(:last-child) {
    margin-bottom: 16px;
  }
}

input,
select {
  background-color: unset;
  color: currentColor;
  font-family: inherit;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--theme-bg2);

  &:active,
  &:focus {
    outline: 2px solid var(--color-1);
    outline-offset: 2px;
  }
}

button,
.button {
  align-items: center;
  background-color: unset;
  border-radius: 4px;
  border: 1px solid var(--theme-bg2);
  color: currentColor;
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  gap: 8px;
  padding: 6px 12px;
  text-decoration: none;
  user-select: none;

  &:hover {
    background-color: var(--theme-bg2);
  }

  &.subtle {
    border-color: transparent;
  }
}

.buttonbar {
  display: flex;
  gap: 8px;
  margin: 4px 0;
}

/* APP-SPECIFIC STYLING */

.id {
  font-family: "Geist Mono", monospace;
}

.entity-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon title"
    "icon subtitle";
  column-gap: 16px;

  > .icon {
    grid-area: icon;
    align-self: center;
    height: 48px;
  }
  > .title {
    grid-area: title;
    margin: 0;
  }
  > .subtitle {
    grid-area: subtitle;
    font-size: 1.2em;
    font-weight: 500;
    font-style: italic;
  }
}

.beta-tag {
  background-color: var(--color-5);
  border-radius: 4px;
  color: var(--color-b);
  display: inline-block;
  font-size: 0.8em;
  font-weight: bold;
  padding: 2px 4px;
  rotate: 5deg;
}

/* ENTITY LISTS */

.entities {
  display: block;
  padding: 0;
  margin: 24px 0;

  > * {
    align-items: center;
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 8px;
    padding: 6px 12px;
    text-decoration: none;

    &:hover {
      background-color: var(--theme-bg2);
    }

    &:first-child {
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
    }
    &:last-child {
      border-bottom-left-radius: 4px;
      border-bottom-right-radius: 4px;
    }
    &:not(:first-child) {
      border-top: 1px solid var(--theme-bg2);
    }
  }
}
