@import url('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/panda-syntax-dark.min.css') (prefers-color-scheme: dark);
@import url('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/panda-syntax-light.min.css') (prefers-color-scheme: light);

:root {
  --primary-hue: 200;

  --color-primary: hsl(var(--primary-hue), 90%, 50%);

  --bg-lightness: 95%;

  --color-bg: #eee;
  --color-bg-muted: #ddd;
  --color-bg-hover: rgba(0, 0, 0, 0.25);
  --color-text: #111;
  --color-text-hover: #000;
  --color-text-muted: #aaa;
  --color-text-disabled: #444;
  --color-text-danger: #d00;
  --color-shadow: #aaa;

  @media (prefers-color-scheme: dark) {
    --bg-lightness: 5%;

    --color-bg: #111;
    --color-bg-muted: #222;
    --color-bg-hover: rgba(255, 255, 255, 0.125);
    --color-text: #eee;
    --color-text-hover: #fff;
    --color-text-muted: #aaa;
    --color-text-disabled: #666;
    --color-text-danger: #d44;
    --color-shadow: #000;
  }
}

[x-cloak] { display: none !important; }

* {
  box-sizing: border-box;
  font-family: sans-serif;
}

html,
body,
#pages-container {
  height: 100vh;
  background-color: var(--color-bg);
}

body,
ul {
  margin: 0;
  padding: 0;
}

h1 {
  font-size: x-large;
  cursor: default;
}

li {
  list-style: none;
}

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

button {
  &:disabled {
    color: var(--color-text-disabled);
    cursor: default;

    svg {
      fill: var(--color-text-disabled) !important;
    }
  }

  &:hover:not(:disabled) {
    color: var(--color-text-hover);

    svg {
      fill: var(--color-text-hover);
    }
  }

  &.danger {
    opacity: 0.5;
    color: var(--color-text-danger);
    svg {
      fill: var(--color-text-danger);
    }

    &:hover {
      opacity: 1;
    }
  }
}

.btn {
  &.active {
    color: var(--color-primary) !important;
  
    svg {
      fill: var(--color-primary) !important;
    }
  }
}

.task-progress {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;

  progress {
    height: 0.5rem;
    width: 100%;
    border-radius: 0.25rem;

    flex-grow: 1;

    &::-webkit-progress-value,
    &::-moz-progress-bar {
      background-color: var(--color-primary);
    }
  }
}

textarea, pre {
  margin: 0;
  padding: 0.5rem;
}

.markdown-toggle {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 3;
  cursor: pointer;

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

  svg {
    fill: var(--color-text-muted);
  }
}

code.id {
  font-family: monospace;
  font-size: small;
  color: var(--color-text);
  background-color: var(--color-bg-muted);
}

pre code.hljs {
  padding: 0;
  background: transparent;
  text-wrap: auto;
}

pre code.hljs, pre code.hljs * {
  font-family: monospace;
  font-size: 1rem;
}

textarea {
  scrollbar-color: auto;
  scrollbar-width: thin;
  color: transparent !important;
  caret-color: var(--color-text);
  position: relative;
  z-index: 2;
}

#pages-container {
  padding-top: 40px; /* for topbar. TODO: flex or grid */
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;

  scrollbar-color: var(--color-primary) transparent;
  scroll-snap-type: x mandatory;
  overflow-x: auto;
  overflow-y: hidden;

  .page {
    position: relative;
    background-color: transparent;

    scroll-snap-align: start;

    width: 100%;

    @media (min-width: 800px) {
      &.split {
        width: 50%;
        &:only-of-type {
          width: 100vw;
        }
      }
    }

    &:focus {
      /* box-shadow: 0 0 0 2px var(--color-primary) inset; */
      outline: none;
    }

    flex-shrink: 0;
    padding: 0.5rem;

    display: flex;
    flex-direction: column;

    .text-container {
      position: relative;
      flex-grow: 1;

      textarea, pre {
        height: 100%;
      }

      pre {
        position: absolute;
        top: 0;

        > code {
          height: 100%;
          overflow: hidden
        }
      };
    }

    textarea {
      resize: none;
      width: 100%;
      padding: 0.5rem;

      &:focus {
        max-height: calc(100% - env(keyboard-inset-height, 0));
      }
    }

    &:not(:last-child) {
      border-right: 1px solid var(--color-bg-muted);
    }
  }
}

input[type="checkbox"] {
  transform: scale(1.5);
  margin: 0.25rem;
}

textarea,
input[type="text"],
button,
.btn {
  background: transparent;
  color: var(--color-text);
  border: none;
  border-radius: 1px;

  &:focus {
    outline: 2px solid var(--color-primary);
  }
}

textarea,
input[type="text"] {
  font-family: monospace;
  font-size: 1rem;
}

h1,
label,
span,
time {
  color: var(--color-text);
}

svg {
  fill: var(--color-text);
}

.tasks-container {
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);

  &:focus-within {
    transform: translateY(calc(-1 * env(keyboard-inset-height, 0)));
  }


  .tasks {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    hr {
      flex-grow: 1;
      height: 3px;
      border-radius: 1px;
      border: none;
      margin: 0 1rem;
      color: transparent;
      background-color: var(--color-bg-muted);
    }
  }

  .snoozed-toggle {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: start;
  }
}

.task {
  display: flex;
  flex-direction: row;
  gap: 0.125rem;
  align-items: center;
  border-radius: 2px;
  padding: 0 0.5rem;
  min-height: 2rem;

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

  a, label {
    font-family: monospace;
    font-size: 1rem;
  }

  label {
    cursor: pointer;
    flex-grow: 1;
  }
}

input[type="text"].new {
  padding: 0.75rem;
  margin: 0.5rem 0;
  flex-grow: 3;
  background-color: var(--color-bg-muted);
}

nav.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.bottom-right {
  position: fixed;
  bottom: 0;
  right: 0;
  margin: 0.125rem;
}

.btn {
  padding: 0.25rem;
  margin: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.25s ease-in-out;

  &:not(:disabled):hover {
    background-color: var(--color-bg-hover);
  }

  font-size: small;
  font-weight: bold;
}

.contextmenu, .menu {
  background-color: var(--color-bg-muted);
  border-radius: 0.25rem;
}

.contextmenu {
  z-index: 2;
  box-shadow: 0 0 5px var(--color-shadow);
  min-width: 10rem;

  .btn {
    padding: 1rem 3rem;
    margin: 0;
    border-radius: 0;
  }

  .snooze-time-select {
    display: flex;

    .btn {
      padding: 1rem 0.5rem;
      flex-grow: 1;
    }
  }
}

.menu {
  z-index: 11;
  box-shadow: 0 0 10px var(--color-shadow);

  select {
    width: 100%;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--color-text);
  }

  ul {
    max-height: 70vh;
    overflow-y: auto;

    li {
      border-left: 3px solid transparent;
      padding: 0.75rem 1rem;

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

      &.active {
        border-color: var(--color-primary);
      }
    }

    .preview {
      display: flex;
      flex-direction: row;
      align-items: stretch;
      justify-content: space-between;

      &.hidden span.grow {
        filter: blur(1px);
      }

      button, label {
        cursor: pointer;
        text-align: left;
        font-family: monospace;
      }
    }
  }

  label {
    font-size: x-small;
  }

  p {
    color: var(--color-text);
    font-family: monospace;
    font-size: 1rem;

    margin: 0;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  time {
    font-size: smaller;
    color: var(--color-text-muted);
  }

  footer {
    font-size: smaller;
    color: var(--color-text-muted);
    text-align: center;
    padding: 0.75rem;

    a {
      color: var(--color-text);
    }
  }
}

nav {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

.btn-spot {
  display: flex;
  justify-content: end;
  width: 4rem;
  flex-grow: 1;
  flex-shrink: 1;
}

/* Flex utilities */

.flex { display: flex; }
.gap { gap: 1rem; }
.grow { flex-grow: 1; }
.col { flex-direction: column; }
.centered { align-items: center; }
.justified { justify-content: center; }
.between { justify-content: space-between; }

/* Tag-based utilities */

span.small {
  font-size: small;
}

span.mono {
  font-family: monospace;
}

/* Grab handle */

.grab {
  cursor: grab;
  svg { fill: rgba(255, 255, 255, 0.25); } /* FIXME: Light mode */
}


/* Progress bar */

.progressbar {
  width: 100%;
  height: 0.5rem;
  background-color: var(--color-bg-muted);
  border-radius: 1rem;
  /* box-shadow: inset 5px 5px 5px var(--color-bg); */

  .progress {
    border-radius: 1rem;
    height: 100%;

    transition: width;
    transition-duration: 0.25s;
    transition-timing-function: ease-out;
    background-color: var(--color-primary);
  }
}


.overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 5;

  background-color: hsl(0, 0%, var(--bg-lightness), 80%);
  color: var(--color-text);
}


.input {
  display: flex;
  flex-direction: column;
  justify-content: start;

  label {
    font-size: small;
    color: var(--color-text-muted);
  }
}


p.error {
  color: var(--color-text-danger);
  font-size: small;
}