/* Patrick Hand in two slices, each declaring exactly the code points it maps: a browser fetches a slice only for text
   that uses one of them, so Latin text never fetches the second, and a character neither maps falls to the next family. */
@font-face {
  font-family: "Patrick Hand";
  src: url("/vendor/patrick_hand/patrick_hand_latin.woff2") format("woff2");
  font-display: fallback;
  unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00B4, U+00B6-00FF, U+0131, U+0152-0153, U+02BC, U+02C6, U+02DA, U+02DC,
    U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: "Patrick Hand";
  src: url("/vendor/patrick_hand/patrick_hand_latin_ext.woff2") format("woff2");
  font-display: fallback;
  unicode-range: U+0100-0130, U+0132-0151, U+0154-017F, U+0192, U+01A0-01A1, U+01AF-01B0, U+01CD-01D4, U+01F0, U+01FA-01FF,
    U+0218-021B, U+0237, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+02F3, U+0300-0301, U+0303, U+0309, U+030F, U+031B, U+0323,
    U+0325-0326, U+03A9, U+03BB-03BC, U+03C0, U+1E00-1E01, U+1E3E-1E3F, U+1E80-1E85, U+1EA0-1EF9, U+2070, U+2074-2079, U+207F,
    U+20A3-20A4, U+20A7, U+20AB, U+2211, U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA, U+2665, U+275B-275E,
    U+2766-2767;
}


:root {
  color-scheme: light dark;
  --paper: #f5efe3;
  --texture: url("/paper.avif");
  --surface: #fffbf2;
  --ink: #34342d;
  --muted: #8a8577;
  --line: #ddd4c2;
  --error: #9e3229;
  font: 16px/1.5 system-ui, sans-serif;
  background: var(--paper) var(--texture) 0 0 / 128px 128px;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

main {
  max-width: 640px;
  margin: auto;
  padding: 8px 20px calc(120px + env(safe-area-inset-bottom));
}

svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

header {
  display: flex;
  align-items: center;
  min-height: 48px;
  margin-bottom: 8px;
}

#status, #alert {
  display: grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
}

#status {
  color: var(--muted);
}

#alert {
  color: var(--error);
}

#clear {
  margin-left: auto;
}

#empty_list, noscript {
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 48px 0;
  margin: 0;
}

#empty_list svg, noscript svg {
  width: 48px;
  height: 48px;
}

#list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.task {
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) 48px;
  align-items: center;
  border-top: 1px solid var(--line);
  gap: 4px;
  padding: 4px 0;
}

button, input {
  font: inherit;
}

button {
  display: grid;
  place-items: center;
  min-height: 48px;
  min-width: 48px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}

button:hover {
  background: var(--line);
}

button:disabled, input:disabled, input:disabled ~ svg {
  opacity: .55;
  cursor: default;
}

input {
  min-width: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.check {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
}

.check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.check .checked, .check input:checked ~ .unchecked {
  display: none;
}

.check input:checked ~ .checked {
  display: block;
}

.check input:focus-visible ~ svg {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 4px;
}

.edit, #text {
  font: 1.25rem/1.3 "Patrick Hand", system-ui, sans-serif;
}

.edit {
  width: 100%;
  min-height: 48px;
  padding: 8px;
  border-radius: 8px;
}

.done .edit:not(:focus) {
  text-decoration: line-through;
  color: var(--muted);
}

.edit:focus {
  background: var(--surface);
}

.delete {
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#add_task {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%,640px);
  display: flex;
  gap: 8px;
  background: var(--paper) var(--texture) 0 0 / 128px 128px;
  border-top: 1px solid var(--line);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}

#text {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  main {
    padding-top: 40px;
  }
}

/* Multiplied over the dark paper the tile varies by under one level of 255, so the dark page keeps the flat color and
   never fetches it. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #23221d;
    --surface: #2d2c26;
    --ink: #ebe5d6;
    --muted: #a8a293;
    --line: #403d35;
    --error: #ffaca1;
    --texture: none;
  }
}
