:root {
  --color-background: #333;
  --color-foreground: #fefefe;
  --color-header-bg: darkslategray;
  --color-header-fg: #fefefe;
  --color-hr: #ccc;
  --color-link: darkblue;
  --color-link-active: orangered;
  --color-final-value: darkorange;
  --color-collection-value: deepskyblue;
  --color-multiplicity: hotpink;
  --color-regex: aquamarine;
  --color-number-variable: khaki;
  --color-id: silver;
  --color-json-key: plum;
  --color-popover-bg: #ddd;
  --color-popover-fg: #333;
  --color-element-expand: #aaa;
  --color-button-bg: rgb(255 255 255 / 6%);
  --color-button-hover: rgb(255 255 255 / 20%);
  --color-button-active: rgb(255 255 255 / 30%);
  --color-xml-declaration: silver;
}

body {
  font-size: 16px;
  font-family: sans-serif;
  display: grid;
  padding: 0;
  margin: 0;
  padding-top: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

header {
  background: var(--color-header-bg);
  color: var(--color-header-fg);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;

  label {
    display: inline-flex;
    flex-direction: column;
  }

  .logo-link {
    margin: 0;
    margin-right: auto;
    color: var(--color-header-fg);
    text-decoration: none;
  }
}

hr {
  height: 1px;
  background: var(--color-hr);
  border: none;
}

.radio-button {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: 0.5rem;
}

#api-url {
  width: 35ch;
}

#app {
  display: grid;
  grid-template-columns: minmax(15rem, max-content) 1fr;
  gap: 1rem;
  padding: 1rem;
}

button {
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

p {
  max-width: 100ch;
  line-height: 1.5;
}

select {
  margin-bottom: 1rem;
}

.record-type {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  fieldset {
    align-self: flex-start;
    border-radius: 0.5rem;
  }
}

.validation-type-select {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
}

.filterable-select {
  position: relative;
  display: inline-block;
  min-width: 30rem;
}

.filterable-select input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 1.5rem;
}

.filterable-select::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-25%);
  border: 0.3rem solid transparent;
  border-top-color: currentColor;
  pointer-events: none;
}

.filterable-select-listbox {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  max-height: 20rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: white;
  color: black;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: 0 4px 8px rgb(0 0 0 / 20%);

  li {
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    background: white;
    font-size: 0.9rem;

    &:hover {
      background: #d0e8ff;
    }

    &.active {
      background: #b0d4ff;
    }
  }
}

.code-block {
  position: relative;
  padding: 1rem;
  padding-left: 2rem;
  font-size: 0.9rem;
  font-family: monospace;
  color: var(--color-foreground);
  background-color: var(--color-background);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.highlight {
  background-color: rgba(255, 255, 0, 0.3);
  border-radius: 2px;
  padding: 0 2px;
}

.data-format {
  display: grid;
  grid-template-columns: 1fr max-content;
}

.legend {
  font-size: 0.9rem;

  line-height: 1.5;

  dl {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 0.5rem;
  }
  dt {
    text-align: right;
  }
  dd {
    margin: 0;
    font-family: sans-serif;
    cursor: help;
  }
}

.collection-variable-expand {
  cursor: pointer;
  background: var(--color-button-bg);
  border-radius: 2px;
  margin-left: 1ch;

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

  &:active {
    background: var(--color-button-active);
  }
}

.data-name {
  position: relative;

  button {
    user-select: text;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    background: var(--color-button-bg);
    font-size: inherit;
    &:hover {
      background: var(--color-button-hover);
    }

    &:active {
      background: var(--color-button-active);
    }
  }
}

.popover {
  margin: 0;
  inset: unset;
  position-area: bottom span-right;
  position-try-fallbacks: flip-block;
  font-family: sans-serif;
  margin-top: 0.5rem;
  min-width: max-content;
  background: var(--color-popover-bg);
  color: var(--color-popover-fg);
  border-radius: 0.5rem;
  padding: 0.5rem;
  border: none;

  h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    margin-top: 0;
    max-width: 30rem;
  }

  p {
    margin: 0;
    max-width: 30rem;
  }
}

.id {
  color: var(--color-id);
}

.element,
.json-element {
  position: relative;
}

.element.collapsed {
  .closing-bracket::before {
    content: " ...";
  }

  .repead-id-attribute,
  .multiplicity,
  .indent,
  .closing-tag {
    display: none;
  }
}

.indent {
  padding-left: 3ch;
}

.json-key {
  color: var(--color-json-key);
}

.json-element {
  .regex,
  .collection-value,
  .number-variable {
    display: inline;
  }

  .indent {
    padding-left: 2ch;
  }

  &.collapsed {
    color: var(--color-element-expand);

    .json-key {
      color: var(--color-element-expand);
    }

    & .indent {
      display: none;
    }
    .multiplicity {
      display: none;
    }

    & > .name-in-data {
      display: inline;
      padding: 0;
    }

    & > div {
      display: inline;
      &:last-child::before {
        content: " ... ";
      }
    }
  }
}

.element-expand-button {
  color: var(--color-element-expand);
  position: absolute;
  left: -1rem;
  top: -1px;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  background: none;
  border-radius: 50%;

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

  &:active {
    background: var(--color-button-active);
  }
}

.final-value {
  color: var(--color-final-value);
}

.collection-value {
  color: var(--color-collection-value);
}

.multiplicity {
  color: var(--color-multiplicity);
  user-select: none;
}

.regex {
  color: var(--color-regex);
}

summary {
  cursor: pointer;
}
.number-variable {
  color: var(--color-number-variable);
}

.main-nav {
  .main-nav-item {
    margin-bottom: 1.5rem;
  }
  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1rem;
    margin-top: 0.5rem;
  }
  ul {
    list-style: none;
    padding-left: 1rem;
  }
  li {
    margin-top: 0.25rem;
  }
  a {
    text-decoration: none;
    color: var(--color-link);
    border-radius: 4px;
    &[aria-current="page"] {
      color: var(--color-link-active);
      font-weight: bold;
      position: relative;
    }
  }
}

.xml-declaration {
  color: var(--color-xml-declaration);
}
