@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: #f4efe6;
  --surface: #fbf8f2;
  --ink: #1c1b18;
  --ink-2: #2a2824;
  --muted: #5b564b;
  --line: #d6cdbb;
  --signal: #f0b429;
  --focus: #2447b0;

  --s-todo: #3b3830;
  --s-progress: #2447b0;
  --s-blocked: #b8321a;
  --s-done: #2a6a4b;

  --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;

  --rail: 288px;
  --gutter: clamp(20px, 4vw, 56px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
body:has(dialog[open]) { overflow: hidden; }
#detailBody { min-height: 100%; }
.stub::before, .stub::after { pointer-events: none; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--signal); color: var(--ink); padding: 10px 14px; font-weight: 600;
}
.skip:focus { top: 12px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--ink); color: var(--paper);
  padding: 32px 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 36px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark { width: 40px; height: 40px; flex: none; color: var(--paper); }
.brand-name { font: 400 1.75rem/1 var(--serif); letter-spacing: .005em; }
.brand-sub { font: 400 .75rem/1.4 var(--mono); color: #c9c2b2; text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }

.rail-label { font: 400 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: #c9c2b2; margin-bottom: 12px; }

.status-nav ul { display: grid; gap: 2px; }
.nav-btn {
  width: 100%; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  background: none; border: 0; border-left: 4px solid transparent;
  color: var(--paper); text-align: left; padding: 10px 12px 10px 10px; min-height: 44px;
  transition: background-color .15s;
}
.nav-btn:hover { background: #2b2925; }
.nav-btn[aria-pressed="true"] { background: #34312b; border-left-color: var(--signal); }
.nav-btn .n { font: 400 .9rem/1 var(--mono); color: #c9c2b2; }
.nav-btn[aria-pressed="true"] .n { color: var(--paper); }
.nav-btn .glyph { color: var(--paper); }

/* the wall: one pigeonhole per task */
.wall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cell { aspect-ratio: 1.15; border: 2px solid #5b564b; position: relative; transition: opacity .2s, background-color .2s, border-color .2s; }
.cell.on[data-status="todo"] { border-color: var(--paper); }
.cell.on[data-status="in-progress"] { background: #6d8cf0; border-color: #6d8cf0; }
.cell.on[data-status="blocked"] { background: #ec6a4f; border-color: #ec6a4f; }
.cell.on[data-status="done"] { background: var(--signal); border-color: var(--signal); }
.cell.off { opacity: .35; }
.wall-note { font-size: .8125rem; line-height: 1.45; color: #c9c2b2; margin-top: 12px; }
.bar { display: flex; height: 8px; margin-top: 16px; gap: 2px; }
.bar i { display: block; height: 100%; transition: flex-grow .3s; }
.bar i[data-status="todo"] { background: var(--paper); }
.bar i[data-status="in-progress"] { background: #6d8cf0; }
.bar i[data-status="blocked"] { background: #ec6a4f; }
.bar i[data-status="done"] { background: var(--signal); }

.main { padding: 40px var(--gutter) 96px; max-width: 1180px; width: 100%; }

.eyebrow { font: 400 .8125rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.eyebrow .dot { width: 10px; height: 10px; background: var(--signal); border: 2px solid var(--ink); flex: none; }
h1 { font: 400 clamp(3.25rem, 7vw, 6rem)/.95 var(--serif); letter-spacing: -.01em; margin: 18px 0 14px; }
.lede { max-width: 54ch; font-size: 1.125rem; color: var(--muted); }

/* ---------- controls ---------- */
.tools { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 36px; padding-top: 24px; border-top: 3px solid var(--ink); }
.field { display: grid; gap: 6px; min-width: 170px; }
.field.grow { flex: 1 1 280px; }
.field label { font: 400 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.input-wrap { position: relative; }
.input-wrap svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; translate: 0 -50%; color: var(--muted); pointer-events: none; }
input[type="search"], select {
  width: 100%; height: 48px; background: var(--surface); border: 2px solid var(--ink); border-radius: 0;
  padding: 0 14px; font-size: 1rem;
}
input[type="search"] { padding-left: 44px; -webkit-appearance: none; appearance: none; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 40px; 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) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px; background-repeat: no-repeat;
}
input[type="search"]:focus-visible, select:focus-visible { outline-offset: 0; box-shadow: 4px 4px 0 var(--signal); }

.count { margin: 24px 0 12px; font: 400 .8125rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); min-height: 1.4em; }

/* ---------- ticket list ---------- */
.list { display: grid; gap: 14px; }
.ticket {
  position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr) 210px;
  background: var(--surface); border: 2px solid var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.ticket:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.ticket:focus-within { box-shadow: 5px 5px 0 var(--focus); }
.ticket.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 35% { background: #fbe7a8; } 100% { background: var(--surface); } }

.stub {
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  padding: 18px 14px 16px 18px; position: relative;
  border-right: 2px dashed var(--ink);
}
/* punched notches on the perforation */
.stub::before, .stub::after {
  content: ""; position: absolute; right: -11px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink); z-index: 1;
}
.stub::before { top: -12px; clip-path: inset(50% 0 0 0); }
.stub::after { bottom: -12px; clip-path: inset(0 0 50% 0); }
.num { font: 400 2.5rem/1 var(--serif); }
.pri { font: 400 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; }
.pri i { width: 8px; height: 8px; background: var(--ink); display: inline-block; }
.pri i.off { background: none; border: 1.5px solid var(--ink); }

.body { padding: 16px 20px 16px 22px; min-width: 0; }
.ticket h3 { font: 400 1.5rem/1.2 var(--serif); }
.open { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; }
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.ticket:has(.open:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.ticket:hover .open { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.sum { color: var(--muted); margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 70ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font: 400 .75rem/1 var(--mono); padding: 5px 8px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-2); }

.side { padding: 16px 18px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.meta { font-size: .9375rem; display: flex; align-items: center; gap: 8px; }
.meta .mono { font: 400 .8125rem/1.3 var(--mono); }
.side .meta.sub { color: var(--muted); }

/* status badge */
.badge {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font: 500 .875rem/1 var(--sans); padding: 7px 10px 7px 8px; border: 2px solid currentColor;
  text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700;
}
.badge[data-status="todo"] { color: var(--s-todo); }
.badge[data-status="in-progress"] { color: var(--s-progress); background: #e6ebfb; }
.badge[data-status="blocked"] { color: var(--s-blocked); background: #fbe5df; }
.badge[data-status="done"] { color: var(--s-done); background: #e0f0e7; }
.glyph { width: 16px; height: 16px; flex: none; }

/* ---------- empty ---------- */
.empty { margin-top: 12px; border: 2px dashed var(--ink); padding: 48px 24px; text-align: center; background: var(--surface); }
.empty svg { width: 64px; height: 64px; margin-bottom: 8px; }
.empty h2 { font: 400 2rem/1.15 var(--serif); }
.empty p { color: var(--muted); margin: 8px auto 20px; max-width: 44ch; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink); padding: 0 18px; font-weight: 600;
}
.btn:hover { background: var(--ink-2); box-shadow: 3px 3px 0 var(--signal); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper); }

/* ---------- detail sheet ---------- */
dialog.sheet {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0; border-left: 3px solid var(--ink);
  width: min(680px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  background: var(--surface); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
}
dialog.sheet[open] { animation: slide .26s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgba(28, 27, 24, .55); animation: fade .2s; }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.d-top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(20px, 4vw, 36px); background: var(--ink); color: var(--paper);
}
.d-top .id { font: 400 .8125rem/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.d-top .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); min-height: 44px; }
.d-top .btn:hover { background: var(--signal); border-color: var(--signal); box-shadow: none; }
.d-top :focus-visible { outline-color: var(--signal); }

.d-main { padding: clamp(24px, 4vw, 40px) clamp(20px, 4vw, 36px) 48px; }
.d-main h2 { font: 400 clamp(2rem, 4.5vw, 2.75rem)/1.1 var(--serif); margin: 14px 0 0; overflow-wrap: anywhere; }
.d-project { font: 400 .8125rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.d-status { margin-top: 28px; border: 2px solid var(--ink); background: var(--paper); padding: 18px; display: grid; gap: 14px; }
.d-status .row { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.d-status .field { flex: 1 1 220px; }
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-height: 28px; font-weight: 500; }
.feedback .ok { display: inline-flex; align-items: center; gap: 8px; }
.feedback .ok svg { width: 18px; height: 18px; color: var(--s-done); }
.feedback.hint { color: var(--muted); font-weight: 400; }
.link-btn { background: none; border: 0; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; min-height: 32px; }
.feedback.pulse .ok { animation: pop .35s ease-out; }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

.d-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 28px; border-top: 2px solid var(--ink); }
.d-grid > div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.d-grid > div:nth-child(odd) { padding-right: 16px; }
.d-grid dt { font: 400 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.d-grid dd { margin: 0; font-weight: 500; }
dl { margin: 0; }

.d-text { margin-top: 28px; max-width: 62ch; }
.d-text p { font-size: 1.0625rem; line-height: 1.65; }
.d-text p + p { margin-top: 18px; }
.d-text .outcome { border-left: 4px solid var(--signal); background: var(--paper); padding: 14px 16px; }
.d-text .outcome strong { font: 400 .8125rem/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; display: block; margin-bottom: 8px; }

/* ---------- narrow screens ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; overflow: visible; padding: 18px var(--gutter) 14px; gap: 14px; }
  .wall-wrap { display: none; }
  .brand-name { font-size: 1.5rem; }
  .mark { width: 32px; height: 32px; }
  .status-nav .rail-label { display: none; }
  .status-nav ul { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: thin; }
  .nav-btn { width: auto; white-space: nowrap; grid-template-columns: auto auto auto; border: 2px solid #5b564b; padding: 8px 12px; min-height: 44px; }
  .nav-btn[aria-pressed="true"] { border-color: var(--signal); }
  .main { padding-top: 28px; }
}

@media (max-width: 720px) {
  h1 { font-size: clamp(3rem, 16vw, 4rem); }
  .lede { font-size: 1rem; }
  .tools { margin-top: 28px; }
  .field { min-width: 0; flex: 1 1 calc(50% - 8px); }
  .field.grow { flex-basis: 100%; }

  .ticket { grid-template-columns: 1fr; }
  .stub { flex-direction: row; align-items: center; border-right: 0; border-bottom: 2px dashed var(--ink); padding: 12px 16px; }
  .stub::before, .stub::after { top: auto; bottom: -12px; }
  .stub::before { left: -12px; right: auto; clip-path: inset(0 0 0 50%); }
  .stub::after { right: -12px; left: auto; clip-path: inset(0 50% 0 0); }
  .num { font-size: 1.75rem; }
  .body { padding: 14px 16px 6px; }
  .ticket h3 { font-size: 1.375rem; }
  .side { border-left: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 16px 16px; }
  .side .badge { order: -1; flex-basis: auto; }
  .ticket:hover { transform: none; box-shadow: none; }

  dialog.sheet { width: 100vw; border-left: 0; }
  .d-grid { grid-template-columns: 1fr 1fr; }
}

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