/* Variables */

:root {
  --backdrop-background: lightgray;
  --gap-1: 10px;
  --font-color: #222;
  --button-text-color: #222;
  --background: #eee;
  --note-background: bisque;
  --highlight-color: beige;
  --shadow-color: rgb(0 0 0 / 0.8);
  --button-background: lightgray;
  --inactive-color: gray;
  --placeholder-text: #999;
}

@media (prefers-color-scheme: dark) {
  :root {
    --backdrop-background: black;
    --font-color: antiquewhite;
    --button-text-color: black;
    --background: #222;
    --note-background: dimgray;
    --highlight-color: gray;
    --shadow-color: rgb(211 211 211 / 0.8);
    --button-background: silver;
    --inactive-color: lightgray;
    --placeholder-text: #999;
  }

  html {
    color-scheme: dark;
  }
}

/* CSS reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

dialog {
  margin: auto;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 90vh;
}

::backdrop {
  background: var(--backdrop-background);
  opacity: 0.75;
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  width: 100vw;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

#root,
#__next {
  isolation: isolate;
}

/* Editable area component */

editable-area {
  display: block;
  position: relative;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  text-indent: inherit;
  letter-spacing: inherit;
  width: 100%;
}

editable-area .display {
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  text-indent: inherit;
  letter-spacing: inherit;
  padding: 0;
  margin: 0;
  border-width: 0;
}

editable-area textarea {
  padding: 0;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-text-fill-color: transparent;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: none;
  resize: none;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  line-break: inherit;
  text-indent: inherit;
  letter-spacing: inherit;
  padding: 0;
  margin: 0;
  border-width: 0;
}

editable-area textarea:focus {
  outline: none;
}

/* Task list */

task-list ul {
  display: flex;
  flex-direction: column;
  wdith: 100%;
  list-style-type: none;
  margin: 0;
  padding: 0;
}

task-list ul {
  padding: 4px 0;
}

task-list-item .remove {
  width: 3em;
}

task-list-item .remove button {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  task-list li:hover {
    background: var(--highlight-color);
  }

  task-list li:hover .remove button {
    display: block;
  }
}

task-list-item .remove button:active {
  display: block;
}

task-list-item:has(textarea:focus) .remove button {
  display: block;
}

task-list-item .checkbox input {
  accent-color: var(--inactive-color);
}

task-list-item:has(.checkbox input:checked) editable-area p.display {
  text-decoration: line-through;
  color: var(--inactive-color);
}

task-list-item {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

task-list-item .handle {
  margin: 2px 0;
  padding: 4px 8px;
  color: var(--button-text-color);
  background: var(--button-background);
  cursor: grab;
}

task-list-item .checkbox {
  padding: 0 4px;
}

task-list-item .checkbox input {
  width: 1.3em;
  height: 1.3em;
}

li.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.drag-placeholder {
  opacity: 0.5;
  background-color: var(--note-background);
}

.draggable,
task-list ul {
  touch-action: none;
}

/* Note form */

note-form:focus-within .title,
note-form .title:has(.non-empty) {
  visibility: visible;
}

note-form .title {
  visibility: hidden;
  font-size: 1.2em;
  font-weight: bold;
}

note-form .title .empty .display::before {
  content: "Title";
  color: var(--placeholder-text);
}

note-form .content {
  min-height: 2.5em;
}

note-form .toolbar {
  display: flex;
  justify-content: space-between;
}

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

/* Styles */

* {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--font-color);
}

body {
  background: var(--background);
}

button {
  color: var(--button-text-color);
  background: var(--button-background);
}

#content {
  display: flex;
  flex-direction: column;
  gap: 1em;
  /* width: 270px; */
  max-width: 1200px;
  margin: var(--gap-1) auto 0 auto;
}

#top-bar {
  position: sticky;
  top: -1px;
  padding-bottom: 0.4em;
  background: var(--background);
  display: flex;
  flex-direction: row-reverse;
  gap: var(--gap-1);
}

#search {
  width: 10em;
  min-width: 0;
}

#notes {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.note {
  background: var(--note-background);
  box-shadow: 2px 2px 4px 0px var(--shadow-color);
  padding: 4px 8px;
}

.note.readonly .title {
  font-size: 1.2em;
  font-weight: bold;
}

.note.readonly ul {
  display: flex;
  flex-direction: column;
  wdith: 100%;
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.note.readonly ul li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 4px;
}

.note.readonly ul li.checked {
  order: 1;
}

.note.readonly ul li.checked .content {
  text-decoration: line-through;
  color: var(--inactive-color);
}

@container (min-width: 700px) {
  #edit-note-dialog {
    width: 100vw;
    margin: 0;
    padding: 0;
  }
}

#edit-note-dialog {
  margin: auto;
  width: 700px;
}

.hidden {
  display: none;
}
