/* To-dos page: the quick-add bar and the list. Builds on /shared/style.css tokens. */

/* ---- Quick-add: a frosted bar at the top of the pane ------------------------------------- */

.quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 7px 7px 16px;
  border: 1px solid var(--edge);
  border-radius: var(--r-bar);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--lift);
  transition: box-shadow 0.2s;
}

.quick-add:focus-within { box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 14%), var(--lift); }

.quick-add-text {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 15px;
  caret-color: var(--accent);
}

.quick-add-text::placeholder { color: var(--muted); opacity: 1; }
.quick-add-text:focus { outline: none; }
.quick-add-due .input { width: auto; min-height: 40px; padding: 7px 10px; color: var(--ink-2); }
.quick-add .btn { min-height: 40px; }

@media (max-width: 520px) {
  .quick-add { flex-wrap: wrap; padding: 8px 8px 8px 14px; }
  .quick-add-text { flex-basis: 100%; }
  .quick-add-due { flex: 1; }
  .quick-add-due .input { width: 100%; }
}

.todo-status:empty { display: none; }
.todo-status { padding: 0 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.todo-status.bad { color: var(--loss); }

/* ---- The list ------------------------------------------------------------------------------ */

.todos { margin: 0; padding: 0; list-style: none; }

.todo {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
}

.todos > .todo:first-child { border-top: 0; }
.todo.pending { opacity: 0.6; }

.todo-body { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; min-width: 0; }

/* The strike-through is a line drawn under the words, so it can sweep across when ticked. */
.todo-text {
  overflow-wrap: anywhere;
  font-weight: 600;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 0 1.5px;
  transition: background-size 0.35s var(--ease), color 0.3s;
}

.todo.done .todo-text { color: var(--muted); background-size: 100% 1.5px; }

/* "Canvas" on to-dos made from Canvas work; sits right after the text. */
.todo-source { flex: none; margin: 0 auto 0 -8px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--fill); color: var(--ink-2); font-size: 12px; font-weight: 650; }
.todo.done .todo-source { color: var(--muted); }

.todo-due { flex: none; color: var(--ink-2); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.todo-due.soon { color: var(--accent); }
.todo-due.overdue { color: var(--loss); }
.todo.done .todo-due { color: var(--muted); }

@media (max-width: 640px) {
  .todo-body { flex-direction: column; align-items: flex-start; gap: 2px; }
  .todo-due { font-size: 13px; }
  /* Text on its own line; the Canvas tag and the due day share the line under it. */
  .todo-body:has(.todo-source) { flex-flow: row wrap; align-items: center; gap: 2px 8px; }
  .todo-body:has(.todo-source)::before { content: ""; flex-basis: 100%; order: 1; }
  .todo-body:has(.todo-source) > :not(.todo-text) { order: 2; }
  .todo-source { margin: 0; }
}

/* Round-cornered checkbox; the tick pops in. */
.todo-check {
  appearance: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1.6px solid var(--line-strong);
  border-radius: 7px;
  background: rgb(255 255 255 / 85%);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.todo-check::after {
  content: "";
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: scale(0);
  transition: transform 0.25s var(--ease);
}

.todo-check:hover { border-color: rgb(var(--accent-rgb) / 60%); }
.todo-check:checked { border-color: var(--accent); background-color: var(--accent); }
.todo-check:checked::after { transform: scale(1); }
.todo-check:disabled { cursor: default; }

/* Edit and delete: quiet until the row is hovered or focused, always there to tap on a phone. */
.todo-acts { display: flex; gap: 2px; }

.todo-act {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}

.todo-act svg { width: 18px; height: 18px; }
.todo-act:hover { background: var(--hover); color: var(--ink); }
.todo-act[data-action="delete"]:hover { color: var(--loss); }
.todo-act:disabled { visibility: hidden; }

@media (hover: hover) {
  .todo-act { opacity: 0.6; }
  .todo:is(:hover, :focus-within) .todo-act { opacity: 1; }
}

/* Editing in place. */
.todo.editing { grid-template-columns: minmax(0, 1fr); }
.todo-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.todo-edit .input[name="text"] { flex: 1 1 240px; }
.todo-edit .input[type="date"] { width: auto; }

.todos-sub {
  margin: 20px 0 4px;
  color: var(--label);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

#empty, #all-done, #loading { padding: 6px 0; }

/* ---- Repeat (repeating to-dos and birthdays) ----------------------------------------------- */

.repeat-opts[hidden], .repeat-opts [hidden] { display: none !important; }

/* The small "Repeat" select: as quiet as the date beside it. */
.repeat-select.input { width: auto; min-height: 40px; padding: 7px 34px 7px 10px; color: var(--ink-2); font-size: 14px; }
.repeat-small.input { width: auto; min-height: 34px; padding: 5px 34px 5px 10px; font-size: 13.5px; }

/* The extra choices some rules need, on one quiet line under the bar or the edit row. */
.repeat-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13.5px; }
.repeat-opts.add-opts { padding: 0 6px; }
.todo-edit .repeat-opts { flex-basis: 100%; }

.repeat-days { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; border: 0; }
.repeat-day { position: relative; }
.repeat-day input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.repeat-day span {
  display: block;
  min-width: 42px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--glass);
  color: var(--ink-2);
  font-weight: 600;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.repeat-day input:hover + span { background: var(--glass-strong); }
/* Picked: filled and ticked, so it isn't colour alone. */
.repeat-day input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.repeat-day input:checked + span::before { content: "✓ "; }
.repeat-day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.repeat-lead { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 600; }
.repeat-hint { font-size: 13px; }

/* The rule in words on a repeating to-do, after the repeat mark. */
.todo-repeat { display: inline-flex; align-items: center; gap: 4px; }
.todo-repeat svg { width: 13px; height: 13px; flex: none; }

.todo-edit .link-btn { padding: 2px; border: 0; background: none; color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.todo-edit .link-btn:hover { color: var(--accent); }

/* One list: on wide screens it stays a readable width (the due date near the to-do) instead of
   stretching across the window. */
body[data-page="todos"] .main { max-width: 1240px; }

@media (max-width: 520px) {
  .quick-add .repeat-select { flex: 1; }
  .todo-edit .repeat-select { flex: 1 1 140px; }
}
