:root {
  --bg: #e9d9b8;
  --surface: #f6eedc;
  --ink: #241c14;
  --muted: #5c4d3c;
  --accent: #b3361e;
  --accent-ink: #f6eedc;
  --todo: #5c4d3c;
  --in-progress: #1f4e79;
  --blocked: #b3361e;
  --done: #2f6b3a;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(0deg, rgba(36, 28, 20, 0.035) 0 1px, transparent 1px 7px);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  overflow-x: clip;
}

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }

.wrap,
.masthead,
main,
.colophon {
  width: min(100% - 40px, 1120px);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  padding: 12px 20px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus-visible { top: 12px; outline: 2px solid var(--accent); outline-offset: 2px; }

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

.kicker {
  font: 600 12px/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Masthead */

.masthead { padding-block: 64px 48px; }

.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 24px 40px;
  margin-top: 24px;
}

.open-count { line-height: 0.78; }

.numeral {
  display: block;
  font: 700 clamp(7rem, 20vw, 17rem)/0.78 var(--display);
  letter-spacing: -0.04em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
  animation: settle 900ms var(--ease) both;
}

.hero-copy { padding-bottom: 12px; }

h1 {
  font: 700 clamp(2.4rem, 5vw, 4.2rem)/0.98 var(--display);
  letter-spacing: -0.03em;
}

.lede {
  margin-top: 16px;
  max-width: 44ch;
  color: var(--muted);
  font-size: 18px;
}

/* Panel and controls */

.rail-panel {
  padding-block: 48px 96px;
  border-top: 3px solid var(--ink);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 24px;
}

h2 {
  font: 600 clamp(1.5rem, 3vw, 2rem)/1.1 var(--display);
  letter-spacing: -0.01em;
}

.count { font: 500 13px/1.4 var(--mono); color: var(--muted); }

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 16px 24px;
  margin-bottom: 40px;
}

.field { display: grid; gap: 8px; }

.field label,
.status-row label {
  font: 600 12px/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.3 var(--body);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

@media (hover: hover) and (pointer: fine) {
  input[type="search"]:hover,
  select:hover { border-color: var(--accent); }
}

input[type="search"]:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="search"]:focus-visible,
select:focus-visible { border-color: var(--accent); }

/* Rail of tags */

.rail {
  position: relative;
  display: grid;
  gap: 28px;
  padding-left: 56px;
  max-width: 820px;
}

.rail::before {
  content: "";
  position: absolute;
  top: -40px;
  bottom: 24px;
  left: 22px;
  width: 2px;
  background: var(--ink);
}

.tag {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px 20px 20px 28px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 4px 18px 4px 4px;
  transform-origin: 50% -20px;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease);
  animation: hang 600ms var(--ease) backwards;
}

.tag:nth-child(2) { animation-delay: 70ms; }
.tag:nth-child(3) { animation-delay: 140ms; }
.tag:nth-child(n + 4) { animation-delay: 200ms; }

.tag::before {
  content: "";
  position: absolute;
  left: -40px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
}

.tag::after {
  content: "";
  position: absolute;
  left: -26px;
  top: 50%;
  width: 26px;
  height: 2px;
  background: var(--ink);
}

.tag-body { display: grid; gap: 6px; min-width: 0; }

.tag-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

.tag-id { font: 500 12px/1.2 var(--mono); color: var(--muted); }

.tag-title {
  font: 600 19px/1.3 var(--body);
  overflow-wrap: anywhere;
}

.tag-line { font-size: 14px; color: var(--muted); }

.stamp {
  display: inline-block;
  padding: 3px 9px;
  border: 2px solid currentColor;
  border-radius: 2px;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--todo);
}

.stamp[data-status="in-progress"] { color: var(--in-progress); }
.stamp[data-status="blocked"] { color: var(--blocked); }
.stamp[data-status="done"] { color: var(--done); }

.stamp.stamped { animation: stamp 320ms var(--ease) both; }

.open-item {
  min-height: 44px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--surface);
  font: 600 14px/1.2 var(--body);
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 150ms var(--ease);
}

.open-item:active { transform: scale(0.97); }

@media (hover: hover) and (pointer: fine) {
  .tag:hover {
    transform: rotate(-0.8deg) translateY(-2px);
    border-color: var(--accent);
  }
  .open-item:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
}

.tag:focus-within {
  transform: rotate(-0.8deg) translateY(-2px);
  border-color: var(--accent);
}

/* Buttons */

.btn {
  min-height: 44px;
  padding: 12px 20px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--surface);
  font: 600 15px/1.2 var(--body);
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 150ms var(--ease);
}

.btn:active { transform: scale(0.97); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .btn.ghost:hover { background: var(--ink); color: var(--surface); border-color: var(--ink); }
}

/* Empty state */

.empty {
  display: grid;
  justify-items: start;
  gap: 12px;
  max-width: 560px;
  padding: 32px;
  border: 2px dashed var(--ink);
}

.empty-title {
  font: 600 22px/1.25 var(--display);
}

#empty-query { font-weight: 600; overflow-wrap: anywhere; }

/* Slip dialog */

.slip {
  width: min(640px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 4px 22px 4px 4px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}

.slip[open] { animation: slip-in 260ms var(--ease) backwards; }

.slip::backdrop { background: rgba(36, 28, 20, 0.55); }

.slip-inner {
  display: grid;
  gap: 20px;
  padding: 28px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.slip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slip h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  overflow-wrap: anywhere;
}

.slip-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  padding-block: 16px;
  border-block: 1px solid var(--ink);
}

.slip-meta dt { font: 600 11px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.slip-meta dd { font-size: 16px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list li {
  padding: 4px 10px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font: 500 13px/1.3 var(--mono);
}

.slip-body { display: grid; gap: 12px; color: var(--ink); max-width: 62ch; }

.status-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px 16px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
}

.status-row .feedback {
  grid-column: 1 / -1;
  min-height: 1.6em;
  font: 500 14px/1.4 var(--body);
  color: var(--muted);
}

.feedback.is-error { color: var(--accent); }

/* Colophon */

.colophon {
  padding-block: 32px 48px;
  border-top: 1px solid var(--ink);
  font-size: 14px;
  color: var(--muted);
}

/* Motion */

@keyframes settle {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes hang {
  from { opacity: 0; transform: translateY(-14px) rotate(-2deg); }
  to { opacity: 1; transform: none; }
}

@keyframes stamp {
  0% { opacity: 0; transform: scale(1.35); }
  60% { opacity: 1; transform: scale(0.94); }
  100% { transform: scale(1); }
}

@keyframes slip-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 900px) {
  .masthead { padding-block: 96px 64px; }
  .rail-panel { padding-block: 64px 128px; }
}

@media (max-width: 640px) {
  .masthead { padding-block: 40px 32px; }
  .hero { grid-template-columns: 1fr; gap: 8px; }
  .numeral { font-size: clamp(6rem, 36vw, 9rem); }
  .controls { grid-template-columns: 1fr; }
  .rail { gap: 24px; padding-left: 48px; }
  .rail::before { left: 18px; }
  .tag { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 16px 22px; }
  .tag::before { left: -36px; }
  .tag::after { left: -22px; width: 22px; }
  .open-item { justify-self: start; }
  .slip-inner { padding: 22px 20px; }
  .slip-meta { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .tag:hover,
  .tag:focus-within,
  .btn:active,
  .open-item:active { transform: none; }
  .stamp.stamped { animation: none; }
  .numeral, .tag, .slip[open] { animation-name: fade-only; }
}

@keyframes fade-only {
  from { opacity: 0; }
  to { opacity: 1; }
}
