/* Tickd. One bold idea: a ticked item gets a yellow highlighter stroke
   through it, and the tick itself is drawn by hand. Everything else stays
   quiet so that moment is the one you notice. */

@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #eef1f8;
  --surface: #ffffff;
  --ink: #1a2042;
  --muted: #5f6889;
  --line: #d9deec;
  --accent: #5b3df5;
  --accent-soft: #e6e1ff;
  --on-accent: #ffffff;
  --hi: #ffd84d;
  --hi-ink: #1a2042;
  --danger: #c4314b;
  --display: "Bricolage", "Avenir Next", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-row: 14px;
  --radius-pill: 999px;
  --bar-h: 76px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141833;
    --surface: #1e2347;
    --ink: #edeffa;
    --muted: #a3aad0;
    --line: #2f3561;
    --accent: #a592ff;
    --accent-soft: #2c2b63;
    --on-accent: #141833;
    --hi: #ffd84d;
    --hi-ink: #141833;
    --danger: #ff8197;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-underline-offset: 2px; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--bar-h) + env(safe-area-inset-bottom) + 32px);
  min-height: 100vh;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin: 0;
  line-height: 1;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 12px 0 6px;
  margin-left: -6px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.back svg { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }

.sync {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
}
.sync.offline { color: var(--hi-ink); background: var(--hi); border-color: var(--hi); }

/* ------------------------------------------------------------- titles */

.title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(36px, 10vw, 52px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  margin: 18px 0 6px;
  overflow-wrap: anywhere;
}

.subtitle { color: var(--muted); margin: 0 0 20px; }

.group-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
  margin: 28px 0 8px;
}

/* --------------------------------------------------------- list rows */

.lists { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px 10px 18px;
  border: 0;
  border-radius: var(--radius-row);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.list-row .name {
  flex: 1;
  font-family: var(--display);
  font-weight: 650;
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.count {
  font-weight: 700;
  font-size: 15px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--hi);
  color: var(--hi-ink);
  white-space: nowrap;
}
.count.quiet { background: var(--bg); color: var(--muted); }

.chev { color: var(--muted); display: grid; }
.chev svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-color: transparent; }

.new-list { margin-top: 24px; }

.footer-links { margin-top: 40px; text-align: center; }
.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  cursor: pointer;
}

/* ------------------------------------------------------------ sections */

.section-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  margin: 22px 0 6px 4px;
  color: var(--ink);
}

.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-row); }

.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 4px 6px 8px;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }

.tick {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
.tick .ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  display: grid;
  place-items: center;
  transition: background-color 0.15s;
}
.tick svg { width: 22px; height: 22px; overflow: visible; }
.tick path {
  fill: none;
  stroke: var(--hi);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}
.item.done .tick .ring { background: var(--accent); }
.item.done .tick path { stroke-dashoffset: 0; }
.item.ticking .tick .ring { background: var(--accent); }
.item.ticking .tick path { animation: draw 0.32s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.item-main {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  cursor: pointer;
}
.item-name { overflow-wrap: anywhere; }

/* The highlighter: a translucent yellow band through the words. */
.item.done .item-name,
.item.ticking .item-name {
  background-image: linear-gradient(transparent 52%, color-mix(in srgb, var(--hi) 75%, transparent) 52%, color-mix(in srgb, var(--hi) 75%, transparent) 86%, transparent 86%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: var(--muted);
}
.item.ticking .item-name { animation: swipe 0.32s ease-out; }
@keyframes swipe { from { background-size: 0% 100%; } }

@media (prefers-color-scheme: dark) {
  .item.done .item-name,
  .item.ticking .item-name {
    background-image: linear-gradient(transparent 40%, color-mix(in srgb, var(--hi) 42%, transparent) 40%, color-mix(in srgb, var(--hi) 42%, transparent) 88%, transparent 88%);
    color: var(--ink);
  }
}

.qty {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.note {
  color: var(--muted);
  font-size: 15px;
  white-space: pre-line;
  overflow-wrap: anywhere;
  margin-top: 2px;
}

.edit {
  flex: none;
  width: 44px;
  height: 44px;
  margin-top: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.edit svg { width: 20px; height: 20px; }

.ticked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 30px 0 8px;
}
.ticked-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  background: none;
  padding: 0 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  color: var(--muted);
  cursor: pointer;
}
.ticked-toggle svg { width: 18px; height: 18px; transition: transform 0.2s; }
.ticked-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.empty {
  padding: 28px 20px;
  border-radius: var(--radius-row);
  border: 2px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------- add bar */

.addbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.addbar form { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.addbar .field { flex: 1; }

.suggest {
  list-style: none;
  max-width: 640px;
  margin: 0 auto 8px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-row);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--ink) 18%, transparent);
}
.suggest button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.suggest button:hover, .suggest button:focus-visible { background: var(--accent-soft); }
.suggest .where { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* -------------------------------------------------------------- inputs */

.field { position: relative; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 44px 10px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 17px; /* 16px or more stops iOS zooming on focus */
}
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 90px; resize: vertical; }
select.input { padding-right: 16px; }

.clear {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  display: none;
  place-items: center;
  cursor: pointer;
}
.clear svg { width: 18px; height: 18px; }
.field.has-value .clear { display: grid; }
.field textarea + .clear { top: 6px; }

.label { display: block; font-weight: 700; margin: 16px 0 6px; }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 0; }

.form-error { color: var(--danger); font-weight: 600; }

/* --------------------------------------------------------------- sheets */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: color-mix(in srgb, #000 45%, transparent);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.18s ease-out;
}
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: rise 0.22s ease-out;
}
.sheet h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
}
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 6px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.menu { display: grid; gap: 8px; margin-top: 14px; }
.menu .btn { justify-content: flex-start; border-color: var(--line); color: var(--ink); background: var(--surface); }
.menu .btn.btn-danger { color: var(--danger); }

.kinds { display: grid; gap: 8px; margin-top: 6px; }
.kind {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-row);
  border: 2px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.kind:has(input:checked) { border-color: var(--accent); }
.kind input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; }
.kind strong { display: block; }
.kind span { color: var(--muted); font-size: 15px; }

.section-edit { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.section-edit .field { flex: 1; }
.section-edit .icon-btn { width: 40px; height: 40px; border-width: 1px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0.4; } }

/* --------------------------------------------------------------- toast */

#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 8px);
  z-index: 40;
  display: grid;
  justify-items: center;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 608px;
  padding: 10px 10px 10px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  animation: rise 0.2s ease-out;
}
.toast .btn { border-color: var(--hi); background: var(--hi); color: var(--hi-ink); }

/* --------------------------------------------------------------- login */

.login { display: grid; align-content: center; min-height: 100vh; padding-bottom: 40px; }
.login .wordmark { font-size: 64px; margin-bottom: 18px; }
.login-form .btn { margin-top: 22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .item.ticking .tick path { stroke-dashoffset: 0; }
}
