/* ————————————————————————————————————————————————
   Pigeonhole — a paper sorting desk for a team inbox
   ———————————————————————————————————————————————— */

@font-face {
  font-family: "DM Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f1eadb;
  --surface: #fbf8f0;
  --card: #fffdf7;
  --ink: #262016;
  --muted: #6e6452;
  --faint: #a79c86;
  --line: #d9cfba;
  --line-strong: #b4a88c;
  --accent: #274690;
  --focus: #274690;

  --s-todo: #33567f;
  --s-progress: #96660a;
  --s-blocked: #b3361d;
  --s-done: #38734b;

  --serif: "DM Serif Display", Georgia, serif;
  --sans: "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --shadow-raise: 0 1px 0 rgba(38, 32, 22, 0.06), 0 6px 18px -12px rgba(38, 32, 22, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(255, 253, 245, 0.9), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1380px; margin: 0 auto; padding: 0 clamp(20px, 3vw, 44px); }

/* ——— Top bar ——— */

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0 20px;
  border-bottom: 1.5px solid var(--ink);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 40px; height: 40px; color: var(--ink); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: 0.01em;
}
.brand-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-top: 4px;
}

.topbar-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
  line-height: 1.7;
}

/* ——— Workspace grid ——— */

.workspace {
  display: grid;
  grid-template-columns: 288px 18px minmax(0, 1fr);
  padding: 30px 0 64px;
}

/* perforation divider */
.perf, .detail-perf {
  width: 3px;
  justify-self: center;
  height: 100%;
  min-height: 240px;
  background-image: radial-gradient(circle 1.4px at 1.5px 7px, var(--line-strong) 98%, transparent);
  background-size: 3px 14px;
  background-repeat: repeat-y;
}

/* ——— Sorting rail ——— */

.rail { display: flex; flex-direction: column; gap: 22px; padding-top: 6px; }

.rail-label {
  margin: 0 0 -6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  appearance: none;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  padding: 10px 12px;
  width: 100%;
}
.select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23262016' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
.input::placeholder { color: var(--faint); }
.input:focus-visible, .btn:focus-visible, .item-open:focus-visible,
.detail-close:focus-visible, .tally-row:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
}

/* tally */
.tally { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.tally-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font: inherit;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.tally-row:hover { color: var(--ink); background: rgba(255, 253, 247, 0.7); }
.tally-row[aria-pressed="true"] { color: var(--ink); font-weight: 700; }
.tally-dot { width: 9px; height: 9px; border-radius: 1px; flex: none; }
.tally-name { flex: 1; }
.tally-count { font-variant-numeric: tabular-nums; }
.tally-row[aria-pressed="true"] .tally-count::after { content: " ●"; font-size: 8px; vertical-align: 2px; }

.rail-note {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 16px;
  border-radius: 4px;
}
.rail-note-title {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}
.rail-note-body { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* ——— Board ——— */

.board { min-width: 0; }

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 2px 16px;
}
.board-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.005em;
}
.board-count {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

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

.item {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  transition: background 140ms ease;
  cursor: pointer;
}
.item:hover { background: var(--card); }

.item-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 20px 0;
  border-right: 2px dashed var(--line-strong);
  margin-right: 20px;
}
.item-index {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 140ms ease;
}
.item:hover .item-index { color: var(--ink); }
.item-priority {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.item-priority.p-high { color: var(--s-blocked); border-color: var(--s-blocked); }
.item-priority.p-medium { color: var(--s-progress); border-color: var(--s-progress); }

.item-main { padding: 18px 16px 16px 0; min-width: 0; }
.item-open {
  font: inherit;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.25;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  display: block;
  width: 100%;
  overflow-wrap: break-word;
}
.item-open:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

.item-summary {
  margin: 7px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.item-assignee { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.avatar {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8.5px;
  letter-spacing: 0.04em;
  color: #fdfaf2;
  flex: none;
}
.item-project { text-transform: uppercase; letter-spacing: 0.14em; }
.item-comments { display: inline-flex; align-items: center; gap: 5px; }
.item-comments svg { width: 12px; height: 12px; }

.item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 2px 16px 16px;
}
.item-due { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* status inks — shared by chips, stamps, and tally dots */
.c-todo { color: var(--s-todo); }
.c-in-progress { color: var(--s-progress); }
.c-blocked { color: var(--s-blocked); }
.c-done { color: var(--s-done); }
.dot-todo { background: var(--s-todo); }
.dot-in-progress { background: var(--s-progress); }
.dot-blocked { background: var(--s-blocked); }
.dot-done { background: var(--s-done); }

/* status chips */
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 9px 3px;
  border-radius: 3px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}

/* ——— Empty state ——— */

.empty {
  border: 1.5px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 56px 24px 60px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.empty-mark { width: 44px; height: 44px; color: var(--line-strong); margin-bottom: 8px; }
.empty-title { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 400; }
.empty-body { margin: 0 0 16px; color: var(--muted); font-size: 14.5px; max-width: 34ch; }

.btn {
  font: inherit;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 11px 18px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }

/* ——— Detail dossier ——— */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 32, 22, 0.34);
  z-index: 40;
}

.detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--card);
  border-left: 1.5px solid var(--ink);
  z-index: 50;
  display: flex;
  overflow-y: auto;
  box-shadow: -18px 0 44px -18px rgba(38, 32, 22, 0.4);
}
.detail-perf {
  width: 3px;
  height: auto;
  flex: none;
  min-height: 100%;
  background-image: radial-gradient(circle 1.4px at 1.5px 7px, var(--line-strong) 98%, transparent);
  background-size: 3px 14px;
  background-repeat: repeat-y;
  margin: 0 22px 0 14px;
}
.detail-inner { flex: 1; min-width: 0; padding: 26px clamp(20px, 4vw, 36px) 48px; }

.detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.detail-overline {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-close {
  font: inherit;
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink);
  transition: background 140ms ease, color 140ms ease;
}
.detail-close svg { width: 14px; height: 14px; }
.detail-close:hover { background: var(--ink); color: var(--card); }

.detail-stamp-row { margin: 26px 0 14px; }
.stamp {
  display: inline-block;
  position: relative;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 7px 16px 6px;
  border: 2px solid currentColor;
  border-radius: 4px;
  transform: rotate(-2deg);
  transform-origin: left center;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.55;
}
@media (prefers-reduced-motion: no-preference) {
  .stamp.stamped { animation: stamp-in 260ms ease-out; }
  .detail { animation: slide-in 240ms ease-out; }
  @keyframes stamp-in {
    0% { transform: rotate(-2deg) scale(1.5); opacity: 0; }
    100% { transform: rotate(-2deg) scale(1); opacity: 1; }
  }
  @keyframes slide-in {
    from { transform: translateX(48px); opacity: 0.4; }
    to { transform: translateX(0); opacity: 1; }
  }
}

.detail-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(26px, 5vw, 32px);
  font-weight: 400;
  line-height: 1.14;
  overflow-wrap: break-word;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin: 26px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.detail-meta > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dt-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  order: 1;
  margin: 0;
}
.dt-value { order: 2; margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.dt-value .avatar { width: 22px; height: 22px; }
.dt-tags { flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 3px 7px;
  border-radius: 2px;
}

.detail-section { margin-top: 30px; }
.detail-heading {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.detail-body p { margin: 0 0 14px; font-size: 15.5px; line-height: 1.65; color: #3c352a; }
.detail-body p:last-child { margin-bottom: 0; }

.detail-status .select { max-width: 260px; }
.detail-hint {
  margin: 9px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ——— Toast ——— */

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 60;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 13px 18px;
  border-radius: 4px;
  box-shadow: 0 10px 30px -10px rgba(38, 32, 22, 0.55);
  max-width: min(480px, calc(100vw - 48px));
}
.toast .toast-status { font-weight: 700; }

/* ——— Responsive ——— */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; padding-top: 20px; }
  .perf { display: none; }

  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 0 0 18px;
    border-bottom: 1px solid var(--line);
  }
  .rail-label { display: none; }
  .field { flex: 1 1 160px; min-width: 0; }
  .field:first-of-type { flex: 2 1 200px; }
  .tally {
    flex-direction: row;
    width: 100%;
    border-top: 0;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tally-row {
    border-bottom: 0;
    padding: 6px 12px 6px 2px;
    white-space: nowrap;
  }
  .rail-note { display: none; }

  .item { grid-template-columns: 44px minmax(0, 1fr); }
  .item-stub { padding: 16px 0; margin-right: 12px; border-right-width: 1.5px; }
  .item-index { font-size: 11px; }
  .item-priority { display: none; }
  .item-main { padding: 14px 0 12px; }
  .item-open { font-size: 17.5px; }
  .item-summary { font-size: 13.5px; }
  .item-side {
    grid-column: 2;
    grid-row: 2;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 0 0 14px;
  }
  .board-head { flex-wrap: wrap; gap: 6px 16px; padding-bottom: 12px; }
  .board-count { font-size: 10.5px; }
}

@media (max-width: 480px) {
  .topbar { padding: 18px 0 14px; }
  .brand-name { font-size: 24px; }
  .brand-mark { width: 32px; height: 32px; }
  .topbar-note { display: none; }
  .detail { width: 100vw; border-left: 0; }
  .detail-perf { margin-left: 10px; }
  .detail-meta { grid-template-columns: 1fr; gap: 10px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
