:root {
  --primary-color: rgb(0, 0, 192);
  --surface-color: #e0e0e0;
  --surface-dark-color: #c0c0c0;
  --background-color: white;
  --space-lg: 2rem;
  --space-md: 1rem;
  --space-sm: 0.5rem;
  --space-xs: 0.2rem;
  --number-of-cantons: 7;
  --radius: 0.25rem;
  --min-col-width: min(50vw, 20rem);
  font-size: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

a {
  text-decoration: none;
  /* text-decoration: underline; */
  color: var(--primary-color);
}

input,
select {
  padding: var(--space-sm);
  border: 1px solid;
  border-radius: var(--radius);
  color: black;
}

#app-header {
  display: grid;
  align-items: center;
  border-bottom: 1px solid var(--surface-color);
  padding: var(--space-md);
  gap: var(--space-md);
  grid-template-columns: auto 6rem;
  grid-template-rows: auto auto;
  grid-template-areas: "title title" "toggle language";


  #toggle-app-nav {
    grid-area: toggle;
    text-align: left;
  }

  #language-select {
    list-style: none;
    display: flex;
    gap: var(--space-sm);
    grid-area: language;
    justify-content: flex-end;
  }

  #title {
    grid-area: title;

    h1 {
      color: var(--primary-color);
    }
  }
}

@media screen and (min-width: 480px) {
  #app-header {
    grid-template-rows: auto 0;
    grid-template-areas: "title language" ". .";
  }

  .hidden-desktop {
    display: none;
  }
}

@media screen and (max-width: 480px) {
  .hidden-mobile {
    display: none;
  }
}

#app-footer {
  display: grid;
  border-top: 1px solid var(--surface-color);
  gap: var(--space-md);
  padding: var(--space-md);
}

#app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 20rem;
}

#app-nav {
  background-color: #e0ffe0;

  form {
    padding: var(--space-md);
  }

  &.show {
    display: block;
  }
}

#canton-select {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.toggle-canton-button {
  position: relative;
  cursor: pointer;
  text-align: center;
  border: none;
  opacity: 0.5;
  border-radius: var(--radius);

  img {
    height: 100%;
    border-radius: var(--radius);
    width: 3rem;
    height: 3rem;
    display: block;
  }

  span {
    display: block;
    padding: var(--space-sm) 0 0 0;
    text-align: center;
  }

  input {
    display: none;
  }


  &:has(input:checked),
  &.checked {
    opacity: 1;
  }

  &:has(input:checked) img,
  &.checked img {
    outline: 3px solid var(--primary-color);
  }

  &:hover {
    opacity: 1;
  }
}

#selected-aspect {
  font-weight: bold;
}

#compare-table {
  display: grid;
  gap: 0;
  grid-auto-columns: var(--min-col-width);
  grid-auto-flow: column;
  grid-auto-rows: auto;
  overflow: scroll;
  transition: opacity 300ms;
  transition-delay: 100ms;
  height: 100%;

  &.loading {
    opacity: 0.2;
  }

}

.column {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 999;
  margin: calc(var(--space-sm) / 2);
}

.column-header {
  border-bottom: var(--space-sm) solid var(--background-color);
  position: sticky;
  top: 0;
  z-index: 1;
}

.canton-column,
.legal-column,
.aspect-column {
  .column-header {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    background-color: var(--surface-color);
    padding: var(--space-sm);

    .drag,
    .remove {
      background-color: transparent;
      padding: var(--space-sm);
      aspect-ratio: 1;
      height: 2rem;
      font-size: 2rem;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      cursor: pointer;
      border-radius: var(--radius);

      &:last-child {
        margin-left: auto;
      }
    }
  }
}

.legal-column {
  .column-header {
    display: flex;
    align-items: flex-end;
    background-color: var(--surface-dark-color);
  }

  .legal {
    height: 100%;
  }
}

.canton-name {
  padding: 0 var(--space-sm);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  line-height: 2rem;

  img {
    height: 2rem;
  }
}

.header-column {
  position: sticky;
  z-index: 1;
  left: 0;
  background-color: var(--background-color);
  box-shadow: 0 0 -1rem;

  h2 {
    font-size: 1rem;
    font-weight: bold;
  }

  h3 {
    font-size: 1rem;
    font-weight: normal;
  }

  >data {
    padding: var(--space-sm);
  }
}


data.title {
  background-color: var(--background-color);
}

data.data {
  background-color: var(--surface-color);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-height: 17.5em;
  margin-bottom: var(--space-sm);

  main {
    padding: var(--space-sm);
    flex: 1;
    overflow: hidden;
    line-height: 1.5em;
    position: relative;
    padding-bottom: 1em;
  }

  main::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2em;
    background: linear-gradient(to bottom, #e0e0e000 0%, var(--surface-color) 100%);
  }

  &:has(main.expanded) {
    max-height: none;

    button.more {
      >span.variant-more {
        display: none;
      }

      >span.variant-less {
        display: inline;
      }
    }

  }
}

.legal {
  padding: var(--space-sm);
  background-color: var(--surface-dark-color) !important;
  min-height: 2rem;
  overflow: hidden;

  &footer {
    height: 100%;
    font-size: 0.8rem;
  }
}

button.more {
  text-align: left;
  padding: var(--space-sm);
  border: none;
  background-color: var(--surface-color);
  cursor: pointer;

  ::before {
    content: '[';
    color: black;
  }

  ::after {
    content: ']';
    color: black;
  }

  >span {
    color: var(--primary-color);
  }

  >span.variant-more {
    display: inline;
  }

  >span.variant-less {
    display: none;
  }
}

.drag {
  background: url(./assets/icons/drag-icon.png);
  background-position: center center;
  background-size: contain;
  width: 2rem;
  cursor: grab
}

.hidden {
  display: none;
}

.block {
  display: block;
}

.sortable-ghost {
  opacity: 0.5;
}

.sortable-drag {
  opacity: 0;
}

.wrap {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

button.link {
  padding: 0;
  color: var(--primary-color);
  background: none;
  cursor: pointer;
  border: none;

  &:hover {
    opacity: 0.5;
  }
}

#toggle-search-button {
  display: flex;
  width: 100%;
  text-align: left;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  height: 100%;

  >div:first-child {
    flex: 1;
  }
}

#table-select {
  width: 19rem;
}

#search-modal {
  margin: auto auto;
  border: none;
  border-radius: var(--space-md);
  box-shadow: 0 0 5rem rgb(0, 0, 0, 0.25);

  .container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 90vw;
    max-width: 56rem;
    height: 90vh;
    max-height: 50rem;

    >main {
      padding: var(--space-lg);
      overflow-y: scroll;
      flex: 1;
    }

    >header {
      padding: var(--space-lg);
      border-bottom: 1px solid var(--surface-color);
    }

    h2 {
      margin-bottom: var(--space-md);
    }

    .search-form {
      margin-bottom: var(--space-md);
    }

    .search-form:not(:has(.show)) {
      display: none;
    }
  }
}

#search {
  display: block;
  /* border-radius: var(--space-sm);
  padding: var(--space-md); */
  font-size: 1.2rem;
  width: 100%;
}

.search-results {
  column-count: auto;
  column-width: 14rem;
  column-gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;

  li {
    display: none;
  }

  li.show {
    display: block;
  }
}
