body, button {
  font-family: Arial;
}
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  background: #357;

  a {
    text-decoration: none;
    color: #44F;
  }
  ul {
    margin: 0;
    padding: 0;
    li { list-style: none; padding: 0; }
  }
}

#app {
  display: flex;
  flex-direction: column;
  margin: 12px 24px;
  gap: 12px;
  flex-grow: 1;
  max-height: 100vh;
}


.menu {
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  list-style: none;
  .expand { flex-grow: 1; }
  .title { text-align: center; button { font-weight: bold; } }
  .user-emblem { cursor: pointer; }
}

.project {
  display: flex;
  width: 100%;
  flex-grow: 1;
  flex-shrink: 1;
  overflow-y: hidden;

  .calendar-board {
    display: flex;
    width: 100%;
    flex-direction: column;
    .calendar-header {
      display: block;
      font-weight: bold;
      text-align: center;
      padding: 12px; 
      background: #fff;
      span { min-width: 120px; display: inline-block; }
    }
    .calendar {
      flex-grow: 1;
      display: grid;
      grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
      grid-template-rows: auto 1fr 1fr 1fr 1fr 1fr;
      width: 100%;
      .day-header, .day {
        background: #fff;
        padding: 4px; 
        border: 1px solid #000;
        &.today { background: #eef; }
        &.other { opacity: 0.5; }
        .day-number { font-weight: bold; font-size: 1.2em; }
        .issue {
          display: block;
          padding: 4px;
          border: 1px solid #aaa;
          cursor: pointer;
        }
      }
    }
  }
}

.project-settings img { max-width: 128px; }
.project-settings .user-listing ul {
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  li {
    display: flex;
    align-items: center;
    gap: 12px;
    list-style: none;
    background: #eee;
    padding: 8px;

    .username { flex-grow: 1; }
    .invite-link { margin-right: 12px; }
  }
}

.menu .tag-field {
  border: 0;
  background: none;
}

.user-filters {
  display: flex;
  position: relative;
  > * {
    position: relative;
    cursor: pointer;
    &.active {
      .user-emblem {
        outline: 4px solid #006;
      }
    }
    &:hover {
      z-index: 2;
    }
  }
}

.choices {
  max-width: 1300px;
  margin: 0 auto;
}
.projects, .views { 
  display: flex;
  gap: 24px;
  flex-wrap: wrap;


  > * {
    padding: 24px;
    font-size: 36px;
    border: 1px solid #aaa;
    background-size: cover;
    background-position: 50% 50%;
    color: white;
    min-width: 300px;
    min-height: 100px;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    background-size: cover;

    &:hover { opacity: 0.5; }
  }

  .add-project {
    background: #cfc;
  }  
}

.projects {
  padding-bottom: 12px;
}

.views {
  border-top: 1px solid #579;
  padding-top: 12px;
}

.loading {
  color: #1c4c5b
}
.loading,
.loading:after {
  box-sizing: border-box;
}
.loading {
  display: inline-block;
  width: 12px;
  height: 12px;
}
.loading:after {
  content: " ";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 6.4px solid currentColor;
  border-color: currentColor transparent currentColor transparent;
  animation: loading 1.2s linear infinite;
}
@keyframes loading {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

button, input, textarea, select, .input {
  background-color: #fefefe;
  &[type='date'], &[type='time'] { height: 36px; }
  &.primary {
    background-color: #115599;
    color: #fff;
  }
  &.danger {
    background-color: #ff4444;
    color: #fff;
  }
  &.plain {
    background: none;
  }
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: Arial;
  &:hover:not(:disabled), &:active:not(:disabled), &:focus:not(button) {
    background-color: #eee;
    &.primary {
      background-color: #003399;
    }
    &.danger {
      background-color: #ff2222;
    }
    &.plain {
      background-color: #fff;
    }
  }
  &:disabled {
    color: #aaa;
    background-color: #ccc;
    cursor: not-allowed;
  }
  border: 1px solid #aaa;
  &.subtle {
    border: 0;
    background: none;
    font-size: 16px;
    padding: 7px 0px;
    padding-right: 12px;
  }
}
button {
  border: 0;
  &:not(:disabled) {
    cursor: pointer;
  }
  &.square { 
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important; 
  }
}

.label-wrapper {
  display: flex;
  gap: 4px;
  flex-direction: column;

  label {
    line-height: 32px;
  }
}

.code-editor textarea {
  min-height: 400px;
}
.code-editor .markdown {
  min-height: 100px;
  background: #eee;
  cursor: pointer;
  padding: 12px;
}
.code-editor.empty .markdown {
  min-height: 24px;
  background: #eee;
  color: #aaa;
}

.markdown {
  .file-link, .mention-link {
    display: inline-block;
    padding: 4px;
    border: 1px solid #999;
    margin: 0 8px;
    border-radius: 4px;
    text-decoration: none;
    background: #333;
    color: #fff;
  }
  .mention-link::before {
    content: "@";
  }
  .code {
    max-width: 100%;
    overflow-x: auto;
  }
  img { max-width: 100%; }
  ul {
    margin-left: 24px;
    padding: auto;
    li { list-style: disc; padding: auto; }
  }
}

.popup-selector {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: 2px;
  z-index: 3;
  background: #fff;
  border: 1px solid #aaa;

  > * {
    padding: 4px;
    cursor: pointer;
    &.active {
      background: #eee;
    }
  }
  &.menu-selector {
    border-radius: 8px;
    > * {
      padding: 12px;
      border-radius: 8px;
    }
  }
}

.modal {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  width: 100%;
  display: flex;
  z-index: 5;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.5);


  .modal-body {
    box-sizing: border-box;
    background: #fff;
    border-radius: 4px;
    padding: 24px 0;    
    > * {
      padding: 0 24px;
    }
    width: 800px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .modal-content {
    flex-grow: 1;
    scrollbar-width: thin;
    max-height: 80vh;
    overflow-y: auto;
  }

  .modal-title {
    display: flex;
    justify-content: space-between;
    align-items: center;

    button {
      font-size: 24px;
    }

    h2 {
      margin: 0;
      font-size: 24px;
    }
  }
  .modal-footer button {
    width: 100%;
  }
}

.card, form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  gap: 12px;
  > * {
    flex-grow: 1;
    flex-shrink: 1;
  }
  select { width: 100%; }
}


.categories {
  display: grid;
  gap: 12px;
  justify-content: stretch;
  align-items: stretch;
  width: 100%;
  grid-template-columns: 1fr 1fr 1fr;
}
.category-header {
  font-weight: bold;
  &:not(.active) { 
    display: none;
  }
}
.categories > * {
  &:nth-child(2):nth-last-child(3) { grid-row: span 2; }
  &:nth-child(3):nth-last-child(2) { grid-row: span 2; }
  &:nth-child(3):nth-last-child(3) { grid-row: span 2; }
  box-sizing: border-box;
  width: 100%;
  padding: 12px;
  display: flex;
  gap: 12px;
  flex-direction: column;
  justify-content: space-between;
  min-height: 200px;

  button {
    width: 100%;
    background: #fefefe;
    border-radius: 4px;
    padding: 12px;
    border: 0;
    font-size: 14px;
    cursor: pointer;
    &:hover {
      background: #eee;
    }
  }
  .category-issues {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 4px;
    --faded: 0.0;
    
    .issue-card {
      font-size: 16px;
      min-height: 80px;
      cursor: move;
      display: flex;
      border: 1px solid #777;
      position: relative;
      text-align: left;
      opacity: calc(1.0 - var(--faded)*0.8);

      .issue-card-issue-id {
        position: absolute;
        left: 8px;
        bottom: 8px;
        opacity: 0.5;
      }

      &:not(.issue-assigned-to-me) {
        opacity: calc(0.5 - var(--faded)*0.4);
        min-height: 36px;
        height: 36px;
        gap: 4px;
        align-items: center;
        > * {
          position: static !important;
        }
        .issue-card-name { 
          flex-grow: 1;
        }
      }
      
      .issue-card-issue-tags {
        position: absolute;
        bottom: 11px;
        right: 48px;
      }

      .issue-card-trash {
        position: absolute;
        right: 4px;
        top: 4px;
        opacity: 0.5;
      }

      .issue-card-date {
        position: absolute;
        left: 12px;
        top: 32px;
        opacity: 0.5;
        color: rgb(calc(80 + 175 * var(--soon)), 40, 40);
        font-weight: calc(400 + 400 *var(--soon));
      }
      
      .issue-card-emblem {
        position: absolute;
        right: 8px;
        bottom: 8px;
        cursor: pointer;
      }
    }
    border: 1px solid transparent;
  }
  &.category-issue-dropping .category-issues {
    border: 1px solid #007;
  }
}


.user-emblem {
  display: inline-flex;
  color: #fff;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 32px;
  text-align: center;
}

.issue {
  .comments {
    display: flex;
    flex-direction: column;
    gap: 12px;
    .comment {
      width: 100%;
      background: #eee;
      padding: 12px;
      box-sizing: border-box;
      border-radius: 2px;
      display: flex;
      flex-direction: column;
      gap: 12px;

      .comment-title {
        display: flex;
        gap: 12px;
        align-items: center;

        .username {
          font-weight: bold;
        }
        .timestamp {
          flex-grow: 1;
        }
      }
      .comment-body {
        img {
          max-width: 100%;
        }
        p {
          margin-bottom: 0;
        }
      }
    }
  }

  .comment-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;

    textarea {
      min-height: 100px;
    }
  }
}
.tag-field {
  display: flex;
  gap: 4px;
  text-transform: uppercase;
  ul {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    li {
      list-style: none;
      margin-left: 8px;
      border-radius: 4px;
      padding: 4px;
      color: #fff;
      &:hover {
        outline: 1px solid #000;
        cursor: pointer;
      }
    }
  }
  padding: 0;
  &:has(input:focus) {
    background: #eee;
  }
  input { 
    border: 0; 
    text-transform: uppercase;
    outline: 0;
    background: none;
    width: auto;
  }
}

.view-all {
  .issue-card::before {
    content: '';
    background-image: var(--projectBackground);
    background-position: 50% 50%;
    background-size: cover;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    opacity: 0.1;
  }
}


@media screen and (max-width: 767px) {
  #app, body {
    max-height: max-content;
  }
  #app {
    margin: 0;
    margin-top: 4px;
  }
  .projects, .views { 
    margin: 12px;
    & > * {
      width: 100%;
    }
  }

  .menu {
    margin: 0 4px;
    .tag-field input {
      display: none;
    }
  }

  .categories >*:nth-child(1), .category-headers >*:nth-child(1) { background-color: rgba(238, 238, 255, 1.0); }
  .categories >*:nth-child(2), .category-headers >*:nth-child(2) { background-color: rgba(238, 255, 238, 1.0); }
  .categories >*:nth-child(3), .category-headers >*:nth-child(3) { background-color: rgba(255, 255, 238, 1.0); }
  .categories >*:nth-child(4), .category-headers >*:nth-child(4) { background-color: rgba(255, 238, 238, 1.0); }

  .modal {
    .modal-body { width: 100%; min-height: 100vh; padding: 24px 2px; } 
  }
  .form-group {
    flex-direction: column;
  }

  .categories {
    width: 100%;
    display: flex;
    & > * { 
      padding: 0;
      opacity: 1;
      &:not(.active) {
        display: none;
      }
      width: 100%;
      .category-headers { 
        display: flex;
        justify-content: stretch;
        width: 100%;

        .category-header {
          flex-grow: 1;
          padding: 8px 0;
          &:not(.active) {
            display: block;
          }
          text-align: center;
        }
      }
      .category-issues {
        .issue-card {
          .issue-card-date {
            left: 58px;
            bottom: 8px;
            top: auto;
          }
        }
      }
    }
    
  }
}
.graph-board {
  cursor: move;
}
.issue-graph {
  width: 100%;
  display: flex;
  justify-content: center;

  .issue-graph-node {
    flex-grow: 1;
    display: flex;
    justify-content: center;    
    flex-direction: column;
    max-width: 600px;
    gap: 12px;
  }
}
.graph-board canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}
.canvas-issue { 
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #000;
  border-radius: 24px;
  border: 1px solid #000;
  padding: 24px;
  cursor: pointer;
  align-items: stretch;
  > * {
    text-align: center;
  }
}
