/* ————————————————————————————————————————————————
   PIGEONHOLE — team sorting desk
   Bento Ledger direction: drawn 2px rules, squared corners,
   one dark inverted masthead band, oversized ledger numbering.
   ———————————————————————————————————————————————— */

@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/space-grotesk.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Work Sans';
  src: url('assets/work-sans.ttf') format('truetype');
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --paper: #F3F1EA;
  --surface: #FBFAF5;
  --ink: #1C1C18;
  --muted: #63625A;
  --rule: #1C1C18;
  --hairline: #DCD9CC;
  --accent: #0E5A46;
  --accent-dark: #0A4636;
  --accent-bright: #3FA184;
  --accent-ink: #F8F6EE;
  --s-todo: #5A5A50;       --s-todo-bg: #E9E7DC;
  --s-prog: #7A520C;       --s-prog-bg: #F1E6C9;
  --s-block: #8F2F1F;      --s-block-bg: #F1DBD4;
  --s-done: #0B4A37;       --s-done-bg: #D9E8DD;
  --dark-muted: #ABA99C;
  --dark-line: rgba(243, 241, 234, 0.28);
  --font-display: 'Space Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
  --font-body: 'Work Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ol { list-style: none; }

.wrap {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 48px);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ————— focus ————— */
:is(button, select, input, a):focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:is(button, select, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.row-hit:focus { outline-offset: -3px; }
.row-hit:focus-visible { outline-offset: -3px; }
#search:focus, #filter:focus, #statusControl:focus { border-color: var(--accent); }
.close-btn:focus-visible, .reset-btn:focus-visible { outline-offset: 3px; }
.btn-primary:focus-visible { outline-offset: 3px; }

/* ————————————————— masthead (the dark wall) ————————————————— */

.masthead {
  background: var(--ink);
  color: var(--paper);
  overflow: clip;
}

.masthead-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: clamp(28px, 4vw, 72px);
  padding-block: clamp(40px, 5vw, 64px) clamp(32px, 4vw, 52px);
}

.masthead-inner > * { animation: rise 0.55s var(--ease) both; }
.masthead-brand { animation-delay: 0.05s; }
.masthead-count { animation-delay: 0.14s; }
.masthead-meter { animation-delay: 0.22s; }

.overline {
  color: var(--accent-bright);
  margin-bottom: 14px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 3.6vw, 46px);
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark { width: 44px; height: 30px; flex: none; }
.mark-cell {
  fill: none;
  stroke: var(--paper);
  stroke-width: 2;
}
.mark-accent { fill: var(--accent-bright); stroke: var(--accent-bright); }

.masthead-tag {
  margin-top: 14px;
  max-width: 44ch;
  color: var(--dark-muted);
  font-size: 16px;
}

.masthead-count { text-align: right; }
.count-label { color: var(--dark-muted); margin-bottom: 2px; }

.big-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(72px, 9vw, 148px);
  line-height: 0.9;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.count-line { color: var(--dark-muted); margin-top: 10px; }

.masthead-meter {
  border: 1.5px solid var(--dark-line);
  padding: 14px;
  min-width: 224px;
}
.meter-head {
  display: flex; align-items: center; gap: 8px;
  color: var(--dark-muted); margin-bottom: 12px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-bright);
  animation: blink 1.6s steps(2, start) infinite;
}
.meter-time { margin-top: 12px; color: var(--dark-muted); }
#clock { color: var(--paper); }

.traywall {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.traywall .cell {
  height: 40px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--paper);
  background: #34332C;
}
.traywall .c-todo  { background: var(--s-todo); }
.traywall .c-in-progress { background: #B58A2E; color: var(--ink); }
.traywall .c-blocked { background: #B44A35; }
.traywall .c-done   { background: var(--accent-bright); color: var(--ink); }

/* ————————————————— controls band ————————————————— */

.controls { border-bottom: 2px solid var(--rule); }

.controls-form {
  display: grid;
  grid-template-columns: minmax(0, 420px) 240px auto 1fr;
  align-items: end;
  gap: 20px 24px;
  padding-block: 26px 22px;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

#search, #filter, #statusControl {
  width: 100%;
  height: 46px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 0 14px;
  font-size: 16px;
}
#search::placeholder { color: #6E6C63; }

.reset-btn {
  height: 46px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  background: transparent;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.readout {
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
  padding-bottom: 14px;
  white-space: nowrap;
}

/* ————————————————— ledger ————————————————— */

.list-head {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 150px 88px 140px 76px 80px;
  gap: 0 16px;
  padding: 12px 20px;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 2px solid var(--rule);
}
.list-head span:nth-child(n+3) { text-align: left; }

.ledger { border-bottom: 2px solid var(--rule); }

.row { border-bottom: 1px solid var(--hairline); }
.row:last-child { border-bottom: none; }

.row-hit {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 150px 88px 140px 76px 80px;
  gap: 0 16px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 14px 20px;
  text-align: left;
  background: transparent;
  transition: background-color 0.18s var(--ease);
}

.row-facts { display: contents; }

.row-no {
  font-size: 13px;
  color: var(--muted);
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1.5px solid var(--ink);
  background: transparent;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.row-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.row-sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}
.row-assignee { font-size: 15px; color: var(--ink); }
.row-due { font-size: 13px; color: var(--muted); }

.chip {
  display: inline-block;
  padding: 5px 10px;
  border: 1.5px solid currentColor;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip.st-todo  { color: var(--s-todo);  background: var(--s-todo-bg); }
.chip.st-in-progress { color: var(--s-prog);  background: var(--s-prog-bg); }
.chip.st-blocked { color: var(--s-block); background: var(--s-block-bg); }
.chip.st-done  { color: var(--s-done);  background: var(--s-done-bg); }

.row-notes { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }

.row-open {
  font-size: 12px;
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
}
.row-open .arr { display: inline-block; transition: transform 0.18s var(--ease); }

/* ledger entrance stagger */
.ledger.enter .row { animation: rise 0.45s var(--ease) both; }
.ledger.enter .row:nth-child(1) { animation-delay: 0.03s; }
.ledger.enter .row:nth-child(2) { animation-delay: 0.07s; }
.ledger.enter .row:nth-child(3) { animation-delay: 0.11s; }
.ledger.enter .row:nth-child(4) { animation-delay: 0.15s; }
.ledger.enter .row:nth-child(5) { animation-delay: 0.19s; }
.ledger.enter .row:nth-child(6) { animation-delay: 0.23s; }
.ledger.enter .row:nth-child(7) { animation-delay: 0.27s; }
.ledger.enter .row:nth-child(8) { animation-delay: 0.31s; }
.ledger.enter .row:nth-child(9) { animation-delay: 0.35s; }
.ledger.enter .row:nth-child(10) { animation-delay: 0.39s; }
.ledger.enter .row:nth-child(11) { animation-delay: 0.43s; }
.ledger.enter .row:nth-child(12) { animation-delay: 0.47s; }

/* ————————————————— empty state ————————————————— */

.empty { padding-block: 72px 88px; text-align: center; }
.empty-overline { color: var(--accent); font-size: 11px; margin-bottom: 12px; }
.empty-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.empty-text {
  margin: 14px auto 26px;
  max-width: 52ch;
  color: var(--muted);
}

.btn-primary {
  min-height: 48px;
  padding: 0 24px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  border: 2px solid var(--accent);
  transition: background-color 0.18s var(--ease), transform 0.12s var(--ease);
}

/* ————————————————— footer ————————————————— */

.foot { padding-block: 36px 48px; }
.foot-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px 32px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
}

/* ————————————————— detail panel ————————————————— */

.scrim {
  position: fixed; inset: 0;
  background: rgba(28, 28, 24, 0.4);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s var(--ease), visibility 0.2s;
}
.scrim.open { opacity: 1; visibility: visible; }

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--paper);
  border-left: 2px solid var(--rule);
  box-shadow: -18px 0 44px rgba(28, 28, 24, 0.22);
  z-index: 50;
  padding: 20px clamp(20px, 4vw, 32px) 48px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateX(24px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), visibility 0.22s;
}
.detail.open { opacity: 1; visibility: visible; transform: none; }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hairline);
}
#detailIndex { color: var(--muted); font-size: 11px; }

.close-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease);
}

.detail-status {
  margin-top: 20px;
  border: 2px solid var(--rule);
  padding: 16px;
}
.detail-status .field-label { color: var(--ink); }
.detail-status select { margin-top: 0; }
.detail-status #statusControl { margin-top: 2px; }

.stamp {
  margin-top: 12px;
  display: inline-block;
  padding: 6px 12px;
  border: 2px solid currentColor;
  font-size: 11px;
  transform: rotate(-2deg);
}
.stamp.st-todo { color: var(--s-todo); }
.stamp.st-in-progress { color: var(--s-prog); }
.stamp.st-blocked { color: var(--s-block); }
.stamp.st-done { color: var(--s-done); }
.stamp.thud { animation: thud 0.26s var(--ease) both; }

.detail-title {
  margin-top: 24px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 34px);
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.detail-body { margin-top: 22px; max-width: 62ch; }
.detail-body p { margin-bottom: 14px; line-height: 1.65; }
.detail-body p:last-child { margin-bottom: 0; }

.detail-meta { margin-top: 28px; border-top: 2px solid var(--rule); }
.detail-meta .mrow {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  padding-block: 11px;
  border-bottom: 1px solid var(--hairline);
}
.detail-meta dt {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-meta dd { font-size: 15px; }

/* ————————————————— hover / active states ————————————————— */

@media (hover: hover) and (pointer: fine) {
  .row-hit:hover { background: var(--surface); }
  .row-hit:hover .row-no { background: var(--ink); color: var(--paper); }
  .row-hit:hover .row-title { color: var(--accent); }
  .row-hit:hover .row-open .arr { transform: translateX(5px); }
  .reset-btn:hover { background: var(--ink); color: var(--paper); }
  .close-btn:hover { background: var(--ink); color: var(--paper); }
  #search:hover, #filter:hover, #statusControl:hover { border-color: var(--accent); }
  .btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
}

.row-hit:active { background: #ECEAE0; }
.reset-btn:active, .close-btn:active { transform: scale(0.97); }
.btn-primary:active { transform: scale(0.97); background: var(--accent-dark); }

.chip.bump { animation: bump 0.24s var(--ease); }
.traywall .cell.flash { animation: cellflash 0.4s var(--ease); }

/* ————————————————— mobile ————————————————— */

@media (max-width: 760px) {
  .masthead-inner {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .masthead-count { text-align: left; }
  .big-num { font-size: clamp(72px, 24vw, 120px); }
  .masthead-meter { min-width: 0; }
  .traywall { grid-template-columns: repeat(6, 1fr); }
  .traywall .cell { height: 32px; font-size: 10px; }

  .controls-form {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-block: 20px;
  }
  .readout { justify-self: start; padding-bottom: 0; }
  .reset-btn { justify-self: start; }

  .list-head { display: none; }

  .row-hit {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "no entry"
      "no facts";
    row-gap: 10px;
    min-height: 0;
    padding: 16px 4px;
  }
  .row-no { grid-area: no; align-self: start; margin-top: 2px; }
  .row-entry { grid-area: entry; }
  .row-facts {
    grid-area: facts;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
  }
  .row-assignee, .row-due, .row-notes { font-size: 12px; }
  .row-open { display: none; }
  .detail { width: 100%; border-left: none; padding-top: 14px; }
  .foot { padding-block: 28px 40px; }
  .foot-inner { flex-direction: column; gap: 8px; }
}

/* ————————————————— motion ————————————————— */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.25; }
}
@keyframes thud {
  0% { transform: scale(1.7) rotate(-9deg); opacity: 0; }
  60% { transform: scale(0.94) rotate(-1.5deg); opacity: 1; }
  100% { transform: scale(1) rotate(-2deg); opacity: 1; }
}
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@keyframes cellflash {
  0% { filter: brightness(1.75); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .live-dot { animation: none; opacity: 1; }
  .detail { transform: none; }
}
