@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ink: #1e1634;
  --muted: #564e6e;
  --ground: #e4def2;
  --paper: #fcfbfe;
  --line: #cfc7e4;
  --focus: #4a2fe0;

  --c-todo: #5b47d6;
  --c-todo-ink: #fff;
  --c-todo-tint: #e9e6fa;
  --c-in-progress: #f2a900;
  --c-in-progress-ink: #1e1634;
  --c-in-progress-tint: #fdf0cc;
  --c-blocked: #c91d58;
  --c-blocked-ink: #fff;
  --c-blocked-tint: #fbe1ea;
  --c-done: #0f7a55;
  --c-done-ink: #fff;
  --c-done-tint: #d9f0e6;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
}

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

html { background: var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

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

[data-status="todo"] { --c: var(--c-todo); --c-ink: var(--c-todo-ink); --c-tint: var(--c-todo-tint); }
[data-status="in-progress"] { --c: var(--c-in-progress); --c-ink: var(--c-in-progress-ink); --c-tint: var(--c-in-progress-tint); }
[data-status="blocked"] { --c: var(--c-blocked); --c-ink: var(--c-blocked-ink); --c-tint: var(--c-blocked-tint); }
[data-status="done"] { --c: var(--c-done); --c-ink: var(--c-done-ink); --c-tint: var(--c-done-tint); }

/* ---------- header ---------- */

.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  grid-template-areas:
    "brand controls"
    "tag controls"
    "rack rack";
  column-gap: 48px;
  align-items: end;
  padding: 32px 48px 28px;
}

.brand {
  grid-area: brand;
  margin: 0;
  font: 800 44px/1 var(--serif);
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72;
}

.tagline {
  grid-area: tag;
  margin: 8px 0 24px;
  color: var(--muted);
  max-width: 44ch;
}

.controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  margin-bottom: 24px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 13px;
}

.field input,
.field select,
.detail select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
}

.field select,
.detail select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231e1634' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ---------- the rack: one open-topped slot per status ---------- */

.rack {
  grid-area: rack;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.slot {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  align-items: start;
  min-height: 132px;
  padding: 12px 16px 0;
  text-align: left;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}

.slot::before { /* the inner shadow where the slot meets the shelf */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(var(--line), transparent);
}

.slot-name { font-weight: 600; font-size: 15px; z-index: 1; }

.slot-count {
  font: 800 38px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  z-index: 1;
}

.slips {
  grid-column: 1 / -1;
  align-self: end;
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  margin: 0 -16px;
  padding: 0 16px 10px;
}

.slip {
  display: block;
  height: 7px;
  background: var(--c);
  border-radius: 2px;
}
.slip:nth-child(even) { margin-left: 10px; margin-right: 0; }
.slip:nth-child(odd) { margin-right: 10px; }

.slot[aria-pressed="true"] {
  background: var(--c-tint);
  box-shadow: inset 0 -6px 0 var(--c);
}
.slot[aria-pressed="true"] .slips { padding-bottom: 16px; }
.slot:hover { background: var(--c-tint); }

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 0 48px 64px;
}
.workspace.has-detail { grid-template-columns: minmax(0, 1fr) minmax(380px, 460px); }

.listing-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0 0 12px;
}
.listing-head h2 {
  margin: 0;
  font: 700 22px/1.2 var(--serif);
}
.count { margin: 0; color: var(--muted); font-size: 14px; }

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

.items[hidden] { display: none; }

.item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 72px 120px;
  align-items: center;
  column-gap: 20px;
  padding: 14px 18px 14px 26px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
}
.has-detail .item { grid-template-columns: minmax(0, 1fr) 120px; }
.has-detail .item .when,
.has-detail .item .who { display: none; }

.item::before { /* the slip's colored edge */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 10px;
  background: var(--c);
}
.item:hover { background: var(--c-tint); }
.item.is-open { background: var(--c-tint); box-shadow: 0 0 0 3px var(--ink); }
.item.just-moved { animation: landed 900ms ease-out; }

@keyframes landed {
  0% { background: var(--c); }
  100% { background: var(--paper); }
}

.item h3 { margin: 0; font: 600 17px/1.35 var(--serif); }

.open-item {
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
  letter-spacing: inherit;
}
.open-item::after { /* the whole row is the hit area */
  content: "";
  position: absolute;
  inset: 0;
}
.open-item:focus-visible { outline: none; }
.item:has(.open-item:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.item .sum {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item .who { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
}
.item .when { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chip {
  justify-self: end;
  display: inline-block;
  padding: 2px 10px;
  background: var(--c);
  color: var(--c-ink);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.empty {
  padding: 40px 28px;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: 12px;
}
.empty[hidden] { display: none; }
.empty-title { margin: 0; font: 700 24px/1.2 var(--serif); }
.empty-text { margin: 6px 0 18px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  font-weight: 600;
}
.btn:hover { background: #3a2c63; }
.btn-quiet { background: transparent; color: var(--ink); }
.btn-quiet:hover { background: var(--c-tint, var(--ground)); }

/* ---------- detail ---------- */

.detail {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-top: 12px solid var(--c);
  border-radius: 14px;
  overflow: hidden;
}
.detail[hidden] { display: none; }

.detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}
.detail-id { color: var(--muted); font-size: 13px; }

.detail-scroll { overflow-y: auto; padding: 4px 22px 26px; }

.detail-title {
  margin: 4px 0 18px;
  font: 700 28px/1.2 var(--serif);
  font-variation-settings: "opsz" 48;
  overflow-wrap: anywhere;
}
.detail-title:focus { outline: none; }
.detail-title:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.status-box {
  padding: 14px;
  background: var(--c-tint);
  border: 2px solid var(--ink);
  border-radius: 12px;
}
.status-box label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }
.status-box select { border-left: 10px solid var(--c); }
.feedback { margin: 10px 0 0; min-height: 22px; font-weight: 600; font-size: 14px; }
.feedback:empty { display: none; }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  margin: 22px 0;
  padding: 0 0 18px;
  border-bottom: 2px solid var(--line);
}
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 500; }

.body { font: 400 16px/1.7 var(--serif); max-width: 60ch; }
.body p { margin: 0 0 14px; }
.body p:last-child { padding-left: 14px; border-left: 4px solid var(--c); }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; }
.tags li { padding: 2px 12px; border: 2px solid var(--ink); border-radius: 999px; font-size: 13px; font-weight: 500; }

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

.toast {
  position: fixed;
  left: 48px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(480px, calc(100vw - 32px));
  padding: 10px 10px 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(30, 22, 52, 0.35);
  animation: toast-in 220ms ease-out;
}
.toast[hidden] { display: none; }
.toast-undo {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  color: #ffd76a;
  border: 2px solid #ffd76a;
  border-radius: 8px;
  font-weight: 700;
}
.toast-undo:focus-visible { outline-color: #fff; }

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

/* ---------- narrower screens ---------- */

@media (max-width: 1100px) {
  .top { column-gap: 24px; padding-inline: 28px; }
  .workspace { padding-inline: 28px; }
  .workspace.has-detail { grid-template-columns: minmax(0, 1fr) 380px; }
  .toast { left: 28px; }
}

@media (max-width: 860px) {
  .top {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "tag" "controls" "rack";
    padding: 22px 16px 20px;
  }
  .brand { font-size: 36px; }
  .tagline { margin-bottom: 18px; }
  .controls { grid-template-columns: minmax(0, 1fr); margin-bottom: 18px; gap: 10px; }
  .rack { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .slot { min-height: 104px; padding: 10px 12px 0; }
  .slot-count { font-size: 30px; }
  .slips { margin: 0 -12px; padding: 0 12px 8px; }

  .workspace, .workspace.has-detail { grid-template-columns: minmax(0, 1fr); padding: 0 16px 56px; }

  .item,
  .has-detail .item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main chip" "who when";
    row-gap: 10px;
    padding: 14px 14px 12px 24px;
  }
  .has-detail .item .when,
  .has-detail .item .who { display: flex; }
  .item .main { grid-area: main; }
  .item .chip { grid-area: chip; align-self: start; }
  .item .who { grid-area: who; }
  .item .when { grid-area: when; justify-self: end; }
  .item .sum { -webkit-line-clamp: 2; }

  .detail {
    position: fixed;
    inset: 0;
    z-index: 50;
    max-height: none;
    border-width: 0;
    border-top: 12px solid var(--c);
    border-radius: 0;
  }
  .detail-title { font-size: 24px; }
  .toast { left: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .item.just-moved, .toast { animation: none; }
}
