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

:root {
  --paper: #f1ebdf;
  --surface: #fbf8f1;
  --ink: #1f1d19;
  --muted: #5b5548;
  --rule: #cdc3ae;
  --accent: #2036b8;
  --accent-ink: #fff;

  --todo: #3d4a63;       --todo-bg: #dde2ec;
  --progress: #7d5200;   --progress-bg: #f5e1ae;
  --blocked: #a32913;    --blocked-bg: #f6d3c9;
  --done: #276336;       --done-bg: #d2e7d1;

  --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  background-image: radial-gradient(rgba(31,29,25,.07) 1px, transparent 1px);
  background-size: 22px 22px;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.skip { position: absolute; left: .5rem; top: -4rem; background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 100; border-radius: 4px; }
.skip:focus { top: .5rem; }

/* ---------- masthead ---------- */
.masthead {
  max-width: 1180px; margin: 0 auto; padding: 1.25rem 2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font: 400 1.6rem/1 var(--serif); letter-spacing: .01em; }
.masthead-note { margin: 0; font: 400 .78rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 2rem 4rem; }

/* ---------- title ---------- */
.titleblock { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: end; gap: 2rem; padding: 2.5rem 0 1.75rem; }
h1 { margin: 0; font: 400 clamp(3.4rem, 7vw, 5.6rem)/.92 var(--serif); letter-spacing: -.01em; }
.lede { margin: 0; max-width: 34rem; color: var(--muted); font-size: 1.05rem; }

/* ---------- pigeonholes (status compartments) ---------- */
.holes-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 2px solid var(--ink); border-radius: 6px; background: var(--ink); gap: 2px; overflow: visible; }
.hole { display: block; }
.hole button {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "glyph count" "label label"; align-items: center; column-gap: .75rem; row-gap: .25rem;
  padding: 1rem 1.1rem .95rem; border: 0; background: var(--surface); position: relative;
  transition: transform .18s ease, box-shadow .18s ease, background .18s;
}
.hole:first-child button { border-radius: 4px 0 0 4px; }
.hole:last-child button { border-radius: 0 4px 4px 0; }
.hole button:hover { background: #fff; }
.hole .glyph { grid-area: glyph; }
.hole .num { grid-area: count; justify-self: end; font: 400 2.6rem/1 var(--serif); font-variant-numeric: tabular-nums; }
.hole .lab { grid-area: label; font: 400 .8rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hole button[aria-pressed="true"] { background: var(--hb); transform: translateY(-8px); box-shadow: 0 8px 0 -2px var(--ink); border-radius: 4px; z-index: 1; }
.hole button[aria-pressed="true"] .lab { color: var(--hc); font-weight: 400; }
.hole button[aria-pressed="true"] .lab::after { content: " · showing"; }
.hole[data-s="todo"] { --hc: var(--todo); --hb: var(--todo-bg); }
.hole[data-s="in-progress"] { --hc: var(--progress); --hb: var(--progress-bg); }
.hole[data-s="blocked"] { --hc: var(--blocked); --hb: var(--blocked-bg); }
.hole[data-s="done"] { --hc: var(--done); --hb: var(--done-bg); }
.hole .glyph { color: var(--hc); }

/* ---------- glyphs ---------- */
.glyph { display: inline-block; width: 22px; height: 22px; flex: none; }
.glyph svg { width: 100%; height: 100%; display: block; }
.glyph-lg { display: inline-block; width: 26px; height: 26px; flex: none; }
.glyph-lg svg { width: 100%; height: 100%; display: block; }

/* ---------- toolbar ---------- */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 14rem 14rem; gap: 1rem; margin-top: 2.1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font: 400 .75rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
input[type="search"], select {
  width: 100%; min-height: 48px; padding: .6rem .85rem; background: var(--surface);
  border: 2px solid var(--ink); border-radius: 6px; appearance: none; -webkit-appearance: none;
}
input[type="search"]::placeholder { color: #7a7364; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
select {
  padding-right: 2.4rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px; background-repeat: no-repeat;
}

.count { margin: 1.1rem 0 .5rem; font: 400 .82rem/1.3 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- list ---------- */
.listhead, .row { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) 9.5rem 5.5rem 9.5rem; column-gap: 1.25rem; align-items: center; }
.listhead { padding: .5rem 1rem; font: 400 .72rem/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border-bottom: 2px solid var(--ink); }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative; padding: 1rem; background: transparent; border-bottom: 1px dashed var(--rule);
  transition: background .15s;
}
.row:hover { background: rgba(251,248,241,.9); }
.row:focus-within { background: var(--surface); }
.row-no { font: 400 .9rem/1 var(--mono); color: var(--muted); }
.row-no b { font-weight: 400; color: var(--ink); font-size: 1.15rem; }
.row-main { min-width: 0; }
.open-item {
  display: block; text-align: left; background: none; border: 0; padding: 0; cursor: pointer;
  font: 500 1.08rem/1.3 var(--sans); letter-spacing: -.005em;
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.open-item:focus-visible { outline: none; }
.row:has(.open-item:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: 4px; }
.row-sum { margin: .2rem 0 0; color: var(--muted); font-size: .92rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-tags { margin-top: .45rem; display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center; font: 400 .72rem/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.row-tags .prio { color: var(--ink); }
.prio[data-p="high"]::before { content: "▲▲▲ "; letter-spacing: -.15em; }
.prio[data-p="medium"]::before { content: "▲▲△ "; letter-spacing: -.15em; }
.prio[data-p="low"]::before { content: "▲△△ "; letter-spacing: -.15em; }
.row-owner { font-size: .95rem; line-height: 1.3; }
.row-due { font: 400 .85rem/1.3 var(--mono); }
.row-status { justify-self: start; }

.pill {
  display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .7rem .3rem .5rem;
  border-radius: 999px; font: 500 .85rem/1.2 var(--sans); background: var(--pb); color: var(--pc); white-space: nowrap;
  border: 1.5px solid var(--pc);
}
.pill .glyph { width: 16px; height: 16px; }
.pill[data-s="todo"] { --pc: var(--todo); --pb: var(--todo-bg); }
.pill[data-s="in-progress"] { --pc: var(--progress); --pb: var(--progress-bg); }
.pill[data-s="blocked"] { --pc: var(--blocked); --pb: var(--blocked-bg); }
.pill[data-s="done"] { --pc: var(--done); --pb: var(--done-bg); }
.row[data-s="done"] .open-item { text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: var(--muted); }
.row[data-s="done"] .row-sum { opacity: .8; }

@keyframes flash { from { background: #fff3b8; } to { background: transparent; } }
.row.flash { animation: flash 1.4s ease-out; }

/* ---------- empty ---------- */
.empty { margin-top: 1rem; padding: 3rem 1.5rem; text-align: center; border: 2px dashed var(--ink); border-radius: 8px; background: var(--surface); color: var(--ink); }
.empty h2 { margin: .5rem 0 .25rem; font: 400 2rem/1.1 var(--serif); }
.empty p { margin: 0 0 1.25rem; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: .5rem 1.1rem; cursor: pointer;
  background: var(--ink); color: #fff; border: 2px solid var(--ink); border-radius: 6px; font-weight: 500;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn-close { background: var(--surface); color: var(--ink); }
.btn-close:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- detail drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(31,29,25,.45); z-index: 20; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); z-index: 30;
  background: var(--surface); border-left: 2px solid var(--ink);
  display: flex; flex-direction: column; box-shadow: -18px 0 0 rgba(31,29,25,.08);
}
.detail:focus { outline: none; }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.detail.enter { animation: slide .22s ease-out; }
.detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; border-bottom: 2px solid var(--ink); background: var(--paper); }
.kicker { margin: 0; font: 400 .8rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.detail-scroll { overflow-y: auto; padding: 1.75rem 1.5rem 2.5rem; flex: 1; overscroll-behavior: contain; }
.detail-title { margin: 0 0 1.5rem; font: 400 clamp(2rem, 4vw, 2.6rem)/1.08 var(--serif); text-wrap: balance; }

.statusbox { padding: 1rem; border: 2px solid var(--ink); border-radius: 8px; background: var(--sb, var(--paper)); transition: background .2s; }
.statusbox[data-s="todo"] { --sb: var(--todo-bg); }
.statusbox[data-s="in-progress"] { --sb: var(--progress-bg); }
.statusbox[data-s="blocked"] { --sb: var(--blocked-bg); }
.statusbox[data-s="done"] { --sb: var(--done-bg); }
.statusbox .field label { color: var(--ink); }
.select-wrap { display: flex; align-items: center; gap: .75rem; }
.select-wrap .glyph-lg { color: var(--ink); }
.feedback { margin: .7rem 0 0; min-height: 1.4em; font-size: .92rem; font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.feedback:empty { display: none; }

.detail-body { margin: 1.75rem 0 0; white-space: pre-line; font-size: 1.05rem; line-height: 1.65; max-width: 38rem; padding-left: 1rem; border-left: 4px solid var(--ink); }

.facts { margin: 2rem 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 2px solid var(--ink); }
.facts > div { padding: .8rem 0; border-bottom: 1px dashed var(--rule); }
.facts > div:nth-child(odd) { padding-right: 1rem; }
.facts dt { font: 400 .72rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .2rem; }
.facts dd { margin: 0; font-weight: 500; }
.facts .tag { display: inline-block; margin: 0 .3rem .3rem 0; padding: .1rem .5rem; border: 1.5px solid var(--ink); border-radius: 4px; font: 400 .8rem/1.5 var(--mono); }

/* ---------- toast ---------- */
.toast-region { position: fixed; left: 0; right: 0; bottom: 1.25rem; display: flex; justify-content: center; pointer-events: none; z-index: 50; padding: 0 1rem; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 1rem; max-width: 36rem;
  background: var(--ink); color: #fff; padding: .7rem .8rem .7rem 1.1rem; border-radius: 8px; box-shadow: 0 8px 0 rgba(31,29,25,.2);
  font-size: .95rem;
}
.toast-undo { min-height: 40px; padding: .3rem .9rem; border-radius: 5px; border: 2px solid #fff; background: transparent; color: #fff; cursor: pointer; font-weight: 600; }
.toast-undo:hover { background: #fff; color: var(--ink); }
.toast-undo:focus-visible { outline-color: #ffd84d; }
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.show { animation: pop .2s ease-out; }
body.drawer-open { overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .titleblock { grid-template-columns: 1fr; gap: 1rem; padding-top: 2rem; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .masthead { padding: .9rem 1rem; }
  .masthead-note { display: none; }
  .wrap { padding: 0 1rem 5rem; }
  .titleblock { padding: 1.5rem 0 1.25rem; }
  h1 { font-size: 3.2rem; }
  .lede { font-size: 1rem; }

  .holes-list { grid-template-columns: 1fr 1fr; margin-top: .25rem; }
  .hole button { padding: .8rem .85rem; }
  .hole button, .hole:first-child button, .hole:last-child button { border-radius: 0; }
  .hole:nth-child(1) button { border-top-left-radius: 4px; }
  .hole:nth-child(2) button { border-top-right-radius: 4px; }
  .hole:nth-child(3) button { border-bottom-left-radius: 4px; }
  .hole:nth-child(4) button { border-bottom-right-radius: 4px; }
  .hole .num { font-size: 2.2rem; }
  .hole .lab { font-size: .72rem; }
  .hole button[aria-pressed="true"] { transform: none; box-shadow: inset 0 0 0 3px var(--hc); border-radius: 0; }
  .hole .lab::after { content: "" !important; }
  .hole button[aria-pressed="true"] .lab::after { content: " ✓" !important; }

  .toolbar { margin-top: 1.5rem; gap: .75rem; }

  .listhead { display: none; }
  .row {
    grid-template-columns: 1fr auto; grid-template-areas: "no status" "main main" "owner due";
    row-gap: .55rem; padding: 1rem .25rem;
  }
  .row-no { grid-area: no; }
  .row-status { grid-area: status; }
  .row-main { grid-area: main; }
  .row-owner { grid-area: owner; font-size: .9rem; color: var(--muted); }
  .row-due { grid-area: due; justify-self: end; color: var(--muted); }
  .row-owner::before { content: "Owner · "; font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }

  .detail { width: 100%; border-left: 0; box-shadow: none; }
  .detail-bar { padding: .7rem 1rem; }
  .detail-scroll { padding: 1.25rem 1rem 3rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  .toast { width: 100%; justify-content: space-between; }
  .toast-region { bottom: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
