/* Tasks — stark minimal white.
   Monochrome by discipline: one accent (overdue), everything else is
   type, space and hairlines. */

:root {
  --paper:      #ffffff;
  --hover:      #fafafa;
  --sunken:     #f4f4f4;

  --ink:        #111111;   /* primary text            */
  --ink-2:      #5c5c5c;   /* secondary text  7.0:1   */
  --ink-3:      #6e6e6e;   /* meta text       5.3:1   */
  --ink-4:      #a5a5a5;   /* placeholder / disabled  */

  --rule:       #ebebeb;
  --rule-2:     #dcdcdc;

  --alert:      #b3261e;   /* the one accent. overdue only. 6.0:1 */

  --gap:        16px;
  --measure:    640px;

  --ease:       cubic-bezier(.2, .7, .3, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 56px 24px calc(64px + env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:where(a, button, input):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── masthead ─────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.masthead h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -.022em;
}

.tally {
  margin: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ── compose ──────────────────────────────────────────────── */

.compose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 40px;
}

.compose__field { flex: 1 1 100%; }

.compose__row {
  display: flex;
  gap: 8px;
  flex: 1 1 100%;
}

.compose input {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s var(--ease);
}

.compose input::placeholder { color: var(--ink-4); }

.compose input:hover { border-color: #cacaca; }

.compose input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

#due {
  flex: 1 1 auto;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.btn {
  font: inherit;
  font-weight: 500;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 11px 22px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: opacity .15s var(--ease);
}

.btn:hover { opacity: .82; }
.btn:active { opacity: .7; }

@media (min-width: 560px) {
  .compose__field { flex: 1 1 auto; }
  .compose__row   { flex: 0 0 auto; }
  #due { flex: 0 0 auto; width: 150px; }
}

.error {
  margin: -28px 0 32px;
  font-size: 13px;
  color: var(--alert);
}

/* ── groups ───────────────────────────────────────────────── */

.group { margin-bottom: 36px; }
.group:last-child { margin-bottom: 0; }

.group__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* the hairline that runs out to the measure — an editorial habit */
.group__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.group--overdue .group__head { color: var(--alert); }

.group__count {
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  letter-spacing: 0;
}

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

/* ── task row ─────────────────────────────────────────────── */

.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 8px 11px 2px;
  margin: 0 -8px 0 -2px;
  border-bottom: 1px solid var(--rule);
  border-radius: 6px;
  transition: background-color .12s var(--ease);
}

.task:hover { background: var(--hover); }

.task__box {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  border: 1.5px solid var(--rule-2);
  border-radius: 5px;
  background: var(--paper);
  cursor: pointer;
  position: relative;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}

.task__box:hover { border-color: var(--ink-3); }

.task__box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: no-repeat center/11px 11px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 6.4 4.3 9.2 10.5 3'/%3E%3C/svg%3E");
  opacity: 0;
  transform: scale(.6);
  transition: opacity .12s var(--ease), transform .18s var(--ease);
}

.task__box:checked {
  background: var(--ink);
  border-color: var(--ink);
}

.task__box:checked::after {
  opacity: 1;
  transform: scale(1);
}

.task__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}

/* description and date are buttons so they're click-to-edit and keyboard reachable */
.task__desc,
.task__date {
  font: inherit;
  text-align: start;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: text;
  border-radius: 3px;
}

.task__desc {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  position: relative;
}

/* strike-through drawn, not declared — so it sweeps in */
.task__desc::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 51%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .22s var(--ease);
}

.task__date {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  white-space: nowrap;
  cursor: pointer;
}

.task__date--none { color: var(--ink-4); }
.task__date--alert { color: var(--alert); }

/* Narrow: the date always sits under the description. Letting it wrap only
   sometimes made rows disagree with each other. */
@media (max-width: 559px) {
  .task__body {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
  .task__desc { flex: 0 0 auto; width: 100%; }
}

.task__desc:hover,
.task__date:hover { text-decoration: underline; text-underline-offset: 2px; }

.task--done .task__desc { color: var(--ink-4); }
.task--done .task__desc::after { transform: scaleX(1); }
.task--done .task__date { color: var(--ink-4); }

/* delete — quiet until you're on the row */
.task__del {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--ink-4);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s var(--ease), color .12s var(--ease), background-color .12s var(--ease);
}

.task__del svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  fill: none;
}

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

.task__del:hover {
  color: var(--alert);
  background: var(--sunken);
}

/* touch devices have no hover — keep it permanently visible */
@media (hover: none) {
  .task__del { opacity: 1; }
}

/* ── inline edit ──────────────────────────────────────────── */

.edit {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 0 1px;
  width: 100%;
  min-width: 0;
}

.edit:focus { outline: none; }

.edit--date {
  width: auto;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ── empty + footer ───────────────────────────────────────── */

.empty {
  margin: 8px 0 0;
  padding: 40px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

.footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.linkbtn {
  font: inherit;
  font-size: 13px;
  color: var(--ink-3);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule-2);
}

.linkbtn:hover { color: var(--ink); text-decoration-color: currentColor; }

.note {
  margin: 0;
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--ink-4);
}

@media (max-width: 420px) {
  .wrap { padding-top: 40px; }
  .masthead h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
