/* The dripping list: a white card on a white page; the chores done lie in a pool of ultramarine ink at its bottom. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --edge: #e4e6ed;          /* the card's edge */
  --ink: #15171d;           /* the words */
  --muted: #7d8293;
  --faint: #c3c7d1;         /* an empty box, the handle */
  --rule: #eef0f4;          /* the lines between chores */
  --hover: #f5f6f9;         /* a chore under the pointer */
  --field: #f3f4f7;         /* the field to add a chore */
  --liquid: #2944f0;        /* the ink: the chores done, a box ticked */
  --liquid-deep: #1a2bb4;   /* the ink at the bottom of the pool */
  --danger: #e5484d;        /* deleting */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Rethink Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* held from the top: chores added or deleted change the height, and a card kept in the middle would jump */
.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  padding: clamp(28px, 12vh, 120px) 16px 48px;
}

.todo {
  position: relative;
  isolation: isolate;
  width: min(390px, 100%);
  overflow: hidden;
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--edge), 0 1px 2px rgba(21, 23, 29, 0.04), 0 22px 44px -26px rgba(21, 23, 29, 0.26);
}

/* ---------------------------------------------------------------- the head */
.todo__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 0;
}

.todo__title {
  margin: 0;
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.todo__count {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 540;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the count: its number rolls over to the next one (and the whole line, to say All done) */
.todo__roll {
  position: relative;
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}

.todo__roll > span {
  display: inline-block;
}

.todo__roll > .is-old {
  position: absolute;
  right: 0;
  top: 0;
}

.todo__n {
  color: var(--ink);
}

/* ---------------------------------------------------------------- adding */
.add {
  position: relative;
  display: flex;
  align-items: center;
  height: 46px;
  margin: 14px 12px 2px;
  padding: 0 6px 0 0;
  border-radius: 14px;
  background: var(--field);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.add:focus-within {
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--liquid);
}

.add__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 100%;
  color: var(--liquid);
}

.add__icon svg,
.add__go svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.add__field {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
}

.add__field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.add__go {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--liquid);
  color: #fff;
  cursor: pointer;
  visibility: hidden;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1), visibility 0s linear 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.add.has-text .add__go {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 0.18s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1), visibility 0s;
}

.add__go:active {
  transform: scale(0.92);
  transition: transform 0.1s ease-out;
}

.add__go:focus-visible {
  outline: 2px solid var(--liquid);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- the chores */
/* every chore sits in its place by the script (on a spring); the ink is a copy of them all on top */
.board {
  position: relative;
  margin-top: 4px;
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.task {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 100%;
  height: var(--row, 54px);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.task.is-lifted {
  z-index: 4;
}

/* the line under a chore */
.task::after {
  content: '';
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 0;
  height: 1px;
  background: var(--rule);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.task.has-rule::after {
  opacity: 1;
}

/* under the pointer, and lifted to be moved */
.task__plate {
  position: absolute;
  inset: 4px 8px;
  border-radius: 15px;
  background: var(--hover);
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, box-shadow 0.25s ease;
}

.task.is-hover .task__plate {
  opacity: 1;
}

.task.is-lifted .task__plate {
  opacity: 1;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--edge), 0 2px 4px rgba(21, 23, 29, 0.05), 0 18px 34px -14px rgba(21, 23, 29, 0.34);
}

/* carried over the ink: let go, it goes in */
.task.is-dipping .task__plate {
  box-shadow: 0 0 0 2px var(--liquid), 0 2px 4px rgba(21, 23, 29, 0.05), 0 18px 34px -14px rgba(21, 23, 29, 0.34);
}

.task.is-dipping .task__box {
  border-color: var(--liquid);
}

/* and its box shows the tick it will get */
.task.is-dipping .task__tick {
  stroke: var(--liquid);
  stroke-dashoffset: 0 !important;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

/* swiped to the left: the red behind, with the bin */
.task__bin {
  position: absolute;
  inset: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 16px;
  border-radius: 15px;
  background: var(--danger);
  color: #fff;
  visibility: hidden;
}

.task__bin svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task__body {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 6px 0 22px;
}

.task__hit {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 14px;
  min-width: 0;
  height: 100%;
  cursor: pointer;
}

/* the real checkbox, over the drawn box */
.task__input {
  position: absolute;
  left: 0;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0;
  opacity: 0;
  cursor: pointer;
}

.task__box {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--faint);
  border-radius: 7px;
  pointer-events: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.task__box svg {
  width: 16px;
  height: 16px;
  overflow: visible;
  fill: none;
  stroke: #fff;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task__tick {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.task.is-checked .task__box {
  border-color: var(--liquid);
  background: var(--liquid);
}

.task__text {
  min-width: 0;
  overflow: hidden;
  padding: 2px 0;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task__del,
.task__grip {
  display: grid;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.task__del {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.task__grip {
  width: 40px;
  height: 100%;
  cursor: grab;
  touch-action: none;
  transition: color 0.18s ease;
}

.task.is-lifted .task__grip {
  color: var(--muted);
  cursor: grabbing;
}

.task.is-done .task__grip {
  visibility: hidden;
}

.task__del svg,
.task__grip svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.task.is-hover .task__del,
.task.is-ring-del .task__del,
.task__del:focus-visible {
  opacity: 1;
}

.task.is-lifted .task__del {
  opacity: 0;
}

@media (hover: hover) {
  .task__del:hover {
    background: var(--rule);
    color: var(--danger);
  }

  .task__grip:hover,
  .task.is-hover .task__grip {
    color: var(--muted);
  }
}

.task__input:focus-visible + .task__box,
.task.is-ring-box .task__box {
  outline: 2px solid var(--liquid);
  outline-offset: 3px;
}

.task__del:focus-visible,
.task.is-ring-del .task__del,
.task__grip:focus-visible,
.task.is-ring-grip .task__grip {
  outline: 2px solid var(--liquid);
  outline-offset: -5px;
  border-radius: 12px;
}

/* ---------------------------------------------------------------- the ink */
/* the same chores in white on the ink, cut out by the shape of the ink (the script writes its clip-path) */
.ink {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--liquid);
  pointer-events: none;
  clip-path: inset(100% 0 0 0);
}

.ink__art {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ink__stop {
  stop-color: var(--liquid);
}

.ink__stop--deep {
  stop-color: var(--liquid-deep);
}

.ink__shine {
  fill: none;
  stroke: #fff;
  stroke-opacity: 0.38;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.ink__rows {
  position: absolute;
  inset: 0;
}

.task--wet {
  color: #fff;
}

.task--wet::after {
  background: rgba(255, 255, 255, 0.16);
}

.task--wet .task__plate {
  background: rgba(255, 255, 255, 0.09);
}

.task--wet.is-lifted .task__plate {
  transition: none;
  background: var(--liquid);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 16px 30px -14px rgba(4, 8, 60, 0.75);
}

.task--wet .task__box {
  border-color: rgba(255, 255, 255, 0.74);
}

.task--wet.is-checked .task__box {
  border-color: #fff;
  background: transparent;
}

.task--wet .task__del,
.task--wet .task__grip {
  color: rgba(255, 255, 255, 0.58);
}

.task--wet.is-hover .task__grip {
  color: rgba(255, 255, 255, 0.85);
}

.task--wet.is-ring-box .task__box,
.task--wet.is-ring-del .task__del,
.task--wet.is-ring-grip .task__grip {
  outline-color: #fff;
}

/* a chore on its way into the ink is not seen until the ink has it */
.task.is-veiled {
  opacity: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- with a finger */
/* no pointer to rest on a chore: the cross gives way to swiping, and stays for screen readers */
@media (hover: none) {
  .task__del {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}
