/* ============================================================
   Pigeonhole — team inbox
   World: print-room job board. Ink rail, paper ledger, stamp inks.
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  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 + ink */
  --paper: #F4F3ED;
  --paper-2: #ECEBE2;
  --paper-3: #E3E2D8;
  --ink: #22251F;
  --ink-2: #4C5049;
  --ink-3: #666A60;
  --line: #D8D7CC;
  --line-2: #C3C2B5;

  /* ink rail */
  --rail: #20231D;
  --rail-2: #2B2E27;
  --rail-line: #3B3E36;
  --rail-text: #EFEDE4;
  --rail-dim: #A9ADA2;

  /* interactive accent */
  --accent: #1E56A8;
  --accent-deep: #173F7D;
  --accent-light: #A9C6EC;

  /* stamp inks (on paper) */
  --c-todo: #54594F;
  --c-progress: #1E56A8;
  --c-blocked: #B23A1E;
  --c-done: #27694A;
  /* stamp inks (light, on rail) */
  --cl-todo: #C8CCC3;
  --cl-progress: #A9C6EC;
  --cl-blocked: #F2A58D;
  --cl-done: #A2D0B6;

  --font-ui: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  height: 100dvh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  caret-color: var(--ink);
  overflow: hidden;
}

/* paper grain sits over the surface, never behind it */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--ink); color: var(--paper); }

.mono { font-family: var(--font-mono); }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.rail :focus-visible, .detail :focus-visible { outline-color: var(--accent-light); }

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

/* ------------------------------------------------------------
   Shell
   ------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100dvh;
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------
   Ink rail
   ------------------------------------------------------------ */
.rail {
  background: var(--rail);
  color: var(--rail-text);
  padding: 30px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rail-line) transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand-mark rect {
  fill: none;
  stroke: var(--rail-dim);
  stroke-width: 1.6;
}
.brand-mark rect.filled {
  fill: var(--accent-light);
  stroke: var(--accent-light);
}
.brand-name {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rail-dim);
  margin-top: 3px;
}

.rail-block { display: flex; flex-direction: column; gap: 8px; }

.rail-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rail-dim);
}

.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic {
  position: absolute;
  left: 11px;
  stroke: var(--rail-dim);
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  pointer-events: none;
}
#search {
  width: 100%;
  background: var(--rail-2);
  border: 1px solid var(--rail-line);
  color: var(--rail-text);
  caret-color: var(--accent-light);
  border-radius: 7px;
  padding: 10px 32px 10px 33px;
  font: inherit;
  font-size: 14px;
}
#search::placeholder { color: #979B90; }
#search:focus-visible { outline-color: var(--accent-light); border-color: var(--accent-light); }
#search::-webkit-search-cancel-button { display: none; }

.clear-search {
  position: absolute;
  right: 5px;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--rail-dim);
}
.clear-search:hover { color: var(--rail-text); background: var(--rail-line); }
.clear-search svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.rail-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--rail-2) 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.5 6 6.5 11 1.5' fill='none' stroke='%23A9ADA2' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--rail-line);
  color: var(--rail-text);
  border-radius: 7px;
  padding: 10px 34px 10px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.rail-select:hover { border-color: var(--rail-dim); }

/* status tally slots */
.slots { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }

.slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.slot:hover { background: var(--rail-2); }
.slot[aria-pressed="true"] {
  background: var(--rail-2);
  box-shadow: inset 2px 0 0 var(--accent-light);
}
.slot-label { font-size: 13.5px; font-weight: 500; color: var(--rail-text); }
.slot[data-status="todo"] .slot-label { color: var(--cl-todo); }
.slot[data-status="in-progress"] .slot-label { color: var(--cl-progress); }
.slot[data-status="blocked"] .slot-label { color: var(--cl-blocked); }
.slot[data-status="done"] .slot-label { color: var(--cl-done); }
.slot[data-status="all"] .slot-label { color: var(--rail-text); }

.tally { display: block; color: inherit; margin-left: 2px; }
.slot .tally line { stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.slot[data-status="todo"] .tally { color: var(--cl-todo); }
.slot[data-status="in-progress"] .tally { color: var(--cl-progress); }
.slot[data-status="blocked"] .tally { color: var(--cl-blocked); }
.slot[data-status="done"] .tally { color: var(--cl-done); }
.slot[data-status="all"] .tally { color: var(--rail-dim); }

.slot-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--rail-dim);
  min-width: 2ch;
  text-align: right;
}
.slot[aria-pressed="true"] .slot-count { color: var(--rail-text); }

.rail-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--rail-line);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: #8E9288;
}

/* ------------------------------------------------------------
   Board — the ticket ledger
   ------------------------------------------------------------ */
.board {
  position: relative;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  background: var(--paper);
}

.board-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 30px 36px 16px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.board-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.board-count {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.ticket-list { list-style: none; }

.ticket {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  width: 100%;
  padding: 15px 36px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}
.ticket:hover { background: var(--paper-2); }
.ticket:focus-visible { background: var(--paper-2); }
.ticket:active { background: var(--paper-3); }

/* status stamp chip */
.chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3.5px 8px 3px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  white-space: nowrap;
  justify-self: start;
}
.chip.todo { color: var(--c-todo); }
.chip.in-progress { color: var(--c-progress); }
.chip.blocked { color: var(--c-blocked); }
.chip.done { color: var(--c-done); }

.t-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.t-title {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
  line-height: 1.3;
  color: var(--ink);
}
.t-meta {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}
.t-meta .sep { margin: 0 2px; }

.t-aside {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}
.assignee {
  width: 27px; height: 27px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink-2);
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: var(--paper);
}
.due { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.cmts {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}
.cmts svg { stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linejoin: round; }
.chev { stroke: var(--line-2); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ticket:hover .chev { stroke: var(--ink-2); }

/* ------------------------------------------------------------
   Empty state
   ------------------------------------------------------------ */
.empty {
  padding: 72px 36px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.empty svg rect {
  fill: none;
  stroke: var(--line-2);
  stroke-width: 1.6;
}
.empty svg rect.empty-slot { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.empty-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin-top: 14px; }
.empty-copy { max-width: 44ch; font-size: 14px; line-height: 1.6; color: var(--ink-2); }

.btn-primary {
  margin-top: 18px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #14170F; }
.btn-primary:active { transform: translateY(1px); }

/* ------------------------------------------------------------
   Detail — the pulled ticket
   ------------------------------------------------------------ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(28, 30, 25, 0.45);
  opacity: 0;
  transition: opacity 0.24s ease;
  z-index: 5;
  border: 0;
}
.scrim.show { opacity: 1; }

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(600px, 100vw);
  background: var(--paper);
  z-index: 6;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  transform: translateX(103%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: -16px 0 48px rgba(24, 26, 21, 0.18);
}
.detail.open { transform: none; }

/* punched ticket edge is drawn on .detail-paper */
.detail-paper {
  position: relative;
  padding: 30px 40px 34px 58px;
  min-height: 100dvh;
  background:
    radial-gradient(circle 2.5px at 29px 15px, var(--paper-3) 96%, transparent 100%) 0 0 / 100% 30px repeat-y,
    var(--paper);
}
.detail-paper::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 40px;
  border-left: 1px dashed var(--line-2);
  pointer-events: none;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  margin-bottom: 20px;
}
.close-detail {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  background: none;
  border: 1.5px solid var(--line-2);
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
}
.close-detail:hover { background: var(--paper-2); border-color: var(--ink-2); color: var(--ink); }
.close-detail svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.detail-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.18;
  max-width: 24ch;
  margin-bottom: 16px;
}
.detail-title:focus { outline: none; }

.detail-statusline { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.detail-statusline .chip { font-size: 10.5px; padding: 4.5px 10px 4px; }
.status-word {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 28px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.meta div { min-width: 0; }
.meta dt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.meta dd { font-size: 14px; color: var(--ink); line-height: 1.45; }
.meta .assignee { display: inline-grid; width: 24px; height: 24px; font-size: 8.5px; vertical-align: -7px; margin-right: 7px; }
.meta .tagchip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  margin: 0 4px 4px 0;
  color: var(--ink-2);
}
.meta .cmts { color: var(--ink-2); }

.detail-body { padding-top: 26px; max-width: 62ch; }
.detail-body p {
  font-size: 15px;
  line-height: 1.68;
  color: #32352E;
  margin-bottom: 16px;
}
.detail-body strong { color: var(--ink); }

/* sticky action bar */
.detail-action {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: end;
  gap: 16px;
  margin: 30px -40px 0 -58px;
  padding: 18px 40px 22px 58px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  box-shadow: 0 -10px 24px rgba(24, 26, 21, 0.07);
}
.action-field { display: flex; flex-direction: column; gap: 6px; }
.action-field .rail-label { color: var(--ink-2); }
.status-select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 190px;
  background: var(--paper) 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.5 6 6.5 11 1.5' fill='none' stroke='%234C5049' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1.5px solid var(--ink-2);
  border-radius: 8px;
  padding: 10px 36px 10px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.status-select:hover { border-color: var(--ink); }
.action-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-3);
  padding-bottom: 11px;
}

/* rubber stamp flash */
.stamp-flash {
  position: absolute;
  left: 50%;
  top: 40%;
  translate: -50% -50%;
  rotate: -7deg;
  padding: 13px 26px;
  border: 5px double currentColor;
  border-radius: 8px;
  font-size: clamp(19px, 2.6vw, 27px);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--stamp-c, var(--ink));
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.stamp-flash.show { animation: stamp-thunk 1s cubic-bezier(0.2, 0.75, 0.25, 1) forwards; }

@keyframes stamp-thunk {
  0%   { opacity: 0; transform: scale(1.55); filter: blur(3px); }
  42%  { opacity: 1; transform: scale(1);    filter: blur(0); }
  58%  { transform: scale(1.045); }
  100% { opacity: 0; transform: scale(1); }
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .rail {
    padding: 18px 18px 14px;
    gap: 14px;
    overflow: visible;
  }
  .brand { margin-bottom: 2px; }
  .slots {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .slot {
    grid-template-columns: auto auto;
    padding: 7px 11px;
    flex: 0 0 auto;
    border: 1px solid var(--rail-line);
    border-radius: 999px;
  }
  .slot[aria-pressed="true"] { box-shadow: none; border-color: var(--accent-light); }
  .slot .tally { display: none; }
  .slot-count { color: var(--rail-text); font-size: 11px; }
  .rail-foot { display: none; }

  .board-head { padding: 20px 18px 12px; }
  .board-head h1 { font-size: 21px; }
  .board-count { font-size: 10.5px; }

  .ticket {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "chip chip"
      "main aside";
    padding: 14px 18px;
    row-gap: 6px;
  }
  .chip { grid-area: chip; align-self: start; margin-top: 1px; }
  .t-main { grid-area: main; }
  .t-aside { grid-area: aside; gap: 10px; }
  .chev, .cmts { display: none; }

  .detail { width: 100vw; box-shadow: none; }
  .detail-paper { padding: 20px 20px 24px 20px; background: var(--paper); }
  .detail-paper::after { display: none; }
  .detail-title { font-size: 23px; max-width: none; }
  .meta { grid-template-columns: 1fr; gap: 13px; }
  .detail-action {
    margin: 26px -20px 0;
    padding: 14px 20px 18px;
    gap: 12px;
  }
  .action-hint { display: none; }
  .status-select { flex: 1; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  /* the chip + live region carry the feedback without motion */
  .stamp-flash.show { opacity: 0; }
}
