/* Sorting Office — team inbox */

@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: "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: #f3efe6;
  --paper-deep: #e9e3d6;
  --sheet: #fffdf7;
  --ink: #1c1b18;
  --ink-2: #45413a;
  --muted: #656056;
  --line: #d9d1c1;
  --line-strong: #b9af9b;
  --accent: #c2381f;
  --accent-ink: #9e2a15;
  --focus: #1f4fd1;

  --todo: #274690;
  --todo-bg: #e1e8f7;
  --progress: #7f4c00;
  --progress-bg: #fae8c3;
  --blocked: #a4231a;
  --blocked-bg: #f8dcd6;
  --done: #2a6538;
  --done-bg: #ddeeda;

  --font-display: "Space Grotesk", "Avenir Next", system-ui, sans-serif;
  --font-text: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 10px;
  --shadow: 0 1px 0 rgba(28, 27, 24, .04), 0 8px 24px -12px rgba(28, 27, 24, .18);
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--sheet);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

kbd {
  font-family: var(--font-mono);
  font-size: .78em;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--sheet);
  color: var(--ink-2);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--sheet);
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.2;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--paper-deep); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.btn-primary:hover { background: #3a3730; }
.btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-quiet:hover { background: var(--paper-deep); }
.btn-icon { width: 40px; padding: 0; justify-content: center; }

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; color: var(--accent); flex: none; }
.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.brand-sub {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.masthead-aside { display: flex; align-items: center; gap: 12px; }
.today {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--ink-2);
}

/* ---------- Workspace layout ---------- */

@media (min-width: 861px) {
  body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 600px; }
}
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 480px;
  grid-template-areas: "rail board detail";
}
.rail { grid-area: rail; }
.board { grid-area: board; }
.detail-pane { grid-area: detail; }

.rail, .board, .detail-pane { overflow-y: auto; overscroll-behavior: contain; }

/* ---------- Rail ---------- */

.rail {
  padding: 24px 18px 24px 24px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.rail-heading {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.tally, .workload-list { list-style: none; margin: 0; padding: 0; }
.tally { display: grid; gap: 4px; }

.tally-btn {
  --c: var(--ink);
  --cbg: var(--paper-deep);
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-weight: 500;
}
.tally-btn:hover { background: var(--paper-deep); }
.tally-btn[aria-pressed="true"] {
  background: var(--sheet);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
}
.tally-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.tally-count {
  font-family: var(--font-mono);
  font-size: .85rem;
  min-width: 2ch;
  text-align: right;
}
.tally-btn[data-status="all"] .tally-dot { background: repeating-linear-gradient(90deg, var(--todo) 0 3px, var(--progress) 3px 6px, var(--blocked) 6px 9px, var(--done) 9px 12px); }

.workload-list { display: grid; gap: 8px; }
.workload-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
}
.workload-num { font-family: var(--font-mono); font-size: .82rem; color: var(--ink-2); }

.rail-tip { margin: auto 0 0; font-size: .82rem; color: var(--muted); line-height: 1.7; }

/* ---------- Status tokens ---------- */

[data-status="todo"] { --c: var(--todo); --cbg: var(--todo-bg); }
[data-status="in-progress"] { --c: var(--progress); --cbg: var(--progress-bg); }
[data-status="blocked"] { --c: var(--blocked); --cbg: var(--blocked-bg); }
[data-status="done"] { --c: var(--done); --cbg: var(--done-bg); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--cbg);
  color: var(--c);
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
}
.pill::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 2px;
  background: currentColor;
}
.pill[data-status="blocked"]::before { border-radius: 50%; }
.pill[data-status="done"]::before {
  width: 10px; height: 6px;
  border-radius: 0;
  background: none;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
}

/* ---------- Board ---------- */

.board { padding: 24px 28px 48px; }
.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.board-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.result-count { margin: 0; font-family: var(--font-mono); font-size: .82rem; color: var(--ink-2); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 210px;
  gap: 12px;
  margin: 18px 0 20px;
  align-items: end;
}
.field { display: grid; gap: 5px; }
.field label, .status-box label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-2);
}
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
input[type="search"], select {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  background: var(--sheet);
  padding: 9px 12px;
}
input[type="search"] { padding-left: 38px; padding-right: 36px; }
input[type="search"]:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--ink);
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%231c1b18' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

/* ---------- Task list ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.task {
  position: relative;
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr) 150px 104px;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 14px;
  border-top: 1px solid var(--line);
  border-left: 4px solid transparent;
  transition: background-color .15s ease;
}
.task:first-child { border-top: 0; }
.task:hover { background: #fbf7ee; }
.task.is-open { background: #f7f1e3; border-left-color: var(--ink); }
.task.is-flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: #fff1b8; } 100% { background: transparent; } }

.task-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.04rem;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.open-item {
  all: unset;
  cursor: pointer;
  color: inherit;
}
.open-item::after { content: ""; position: absolute; inset: 0; border-radius: 2px; }
.open-item:focus-visible { outline: none; }
.open-item:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -3px; }
.task:hover .open-item { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.open-item mark { background: #ffe08a; color: inherit; border-radius: 2px; padding: 0 1px; }

.task-meta {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: .82rem;
  color: var(--muted);
}
.task-meta .mono { font-family: var(--font-mono); font-size: .76rem; color: var(--ink-2); }
.prio { display: inline-flex; align-items: center; gap: 4px; }
.prio-bars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 10px; }
.prio-bars i { display: block; width: 3px; background: var(--line-strong); border-radius: 1px; }
.prio-bars i:nth-child(1) { height: 4px; }
.prio-bars i:nth-child(2) { height: 7px; }
.prio-bars i:nth-child(3) { height: 10px; }
.prio[data-p="low"] i:nth-child(1),
.prio[data-p="medium"] i:nth-child(-n+2),
.prio[data-p="high"] i { background: var(--ink-2); }
.prio[data-p="high"] { color: var(--accent-ink); font-weight: 600; }
.prio[data-p="high"] i { background: var(--accent); }
.edited { color: var(--ink-2); font-style: italic; }

.task-who { display: flex; align-items: center; gap: 8px; font-size: .88rem; min-width: 0; }
.task-who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--av, #e5dccb);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .02em;
}

.task-due { display: grid; justify-items: end; gap: 2px; text-align: right; }
.task-due time { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-2); }
.due-flag { font-size: .74rem; font-weight: 700; color: var(--muted); }
.due-flag.is-late { color: var(--blocked); }
.due-flag.is-today { color: var(--progress); }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--sheet);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-art { width: 120px; height: 80px; color: var(--line-strong); }
.empty-title { margin: 12px 0 6px; font-family: var(--font-display); font-size: 1.3rem; }
.empty-text { margin: 0 auto 18px; max-width: 42ch; color: var(--ink-2); }
.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ---------- Detail pane ---------- */

.detail-pane {
  border-left: 1px solid var(--line);
  background: var(--sheet);
}
.detail-placeholder {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 32px;
  color: var(--muted);
}
.detail-placeholder svg { width: 56px; height: 56px; color: var(--line-strong); }
.placeholder-title { margin: 12px 0 4px; font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--ink-2); }
.placeholder-text { margin: 0; max-width: 30ch; font-size: .92rem; }

.detail { display: flex; flex-direction: column; min-height: 100%; background: var(--sheet); }
.detail-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 20px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}
.detail-nav { display: flex; align-items: center; gap: 6px; }
.detail-position { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); min-width: 6ch; text-align: center; }

.detail-scroll { padding: 22px 28px 40px; }
.detail-id {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.detail-title {
  margin: 6px 0 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -.025em;
}
.detail-title:focus-visible { outline-offset: 4px; }

.status-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--cbg, var(--paper));
  box-shadow: 4px 4px 0 var(--ink);
  transition: background-color .25s ease;
}
.status-select-wrap { position: relative; }
.status-swatch {
  position: absolute;
  left: 12px; top: 50%;
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--c, var(--ink));
  transform: translateY(-50%);
  pointer-events: none;
}
.status-select-wrap select { padding-left: 34px; font-weight: 700; }
.status-feedback { margin: 0; min-height: 1.4em; font-size: .86rem; color: var(--ink-2); }
.status-feedback.is-fresh { color: var(--ink); font-weight: 600; animation: pop .5s ease; }
.status-feedback .check { color: var(--done); font-weight: 700; }
@keyframes pop { 0% { transform: translateY(3px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin: 24px 0;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
}
.facts div { min-width: 0; }
.facts dt {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 3px 0 0; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.facts .wide { grid-column: 1 / -1; }
.tag {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
}

.detail-subhead {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-body p { margin: 0 0 14px; font-size: 1.02rem; line-height: 1.65; max-width: 62ch; }
.detail-body p.outcome {
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--paper);
  border-radius: 0 8px 8px 0;
}
.detail-body p.outcome strong { display: block; font-family: var(--font-display); margin-bottom: 2px; }

/* ---------- Toast ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 60;
  width: min(460px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  background: var(--ink);
  color: var(--sheet);
  border-radius: 12px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .45);
  animation: toast-in .22s ease;
}
.toast p { margin: 0; flex: 1; font-size: .9rem; line-height: 1.4; }
.toast .btn { background: transparent; border-color: rgba(255, 253, 247, .5); color: var(--sheet); min-height: 36px; }
.toast .btn:hover { background: rgba(255, 253, 247, .12); }
.toast :focus-visible { outline-color: #9db5ff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Medium: rail becomes a strip ---------- */

@media (max-width: 1179px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 420px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail detail" "board detail";
  }
  .rail {
    flex-direction: row;
    align-items: center;
    padding: 12px 28px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .rail-heading, .workload, .rail-tip { display: none; }
  .tally { grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px; min-width: 0; max-width: 100%; overflow-x: auto; padding: 2px 6px 6px 2px; }
  .tally-btn { grid-template-columns: 10px auto auto; padding: 6px 12px; border-color: var(--line); border-radius: 999px; }
  .tally-dot { width: 10px; height: 10px; }
  .tally-btn[aria-pressed="true"] { box-shadow: 2px 2px 0 var(--ink); }
  .task { grid-template-columns: minmax(0, 1fr) 104px; grid-template-areas: "status due" "main main" "who who"; row-gap: 6px; }
  .task > .pill { grid-area: status; justify-self: start; }
  .task-main { grid-area: main; }
  .task-who { grid-area: who; }
  .task-due { grid-area: due; }
}

/* ---------- Small: single column, detail as dialog ---------- */

@media (max-width: 860px) {
  .masthead { padding: 12px 16px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 1.15rem; }
  .today { display: none; }
  .workspace { display: block; }
  .rail, .board { overflow: visible; }
  .rail { padding: 10px 0 10px 16px; }
  .tally { padding-right: 16px; scrollbar-width: none; }
  .tally::-webkit-scrollbar { display: none; }
  .board { padding: 18px 16px 96px; }
  .board-title { font-size: 1.7rem; }
  .toolbar { grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 16px; }
  .field-search { grid-column: 1 / -1; }
  .search-kbd { display: none; }
  input[type="search"] { padding-right: 12px; }

  .task { padding: 14px 14px 14px 12px; }
  .task-who { font-size: .84rem; }
  .avatar { width: 24px; height: 24px; font-size: .62rem; }

  .detail-pane { border: 0; background: none; overflow: visible; }
  .detail-placeholder { display: none; }
  .detail {
    position: fixed;
    inset: 0;
    z-index: 50;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: sheet-in .24s cubic-bezier(.2, .8, .2, 1);
  }
  .detail-bar { padding: 10px 12px; }
  .detail-scroll { padding: 18px 18px 48px; }
  .detail-title { font-size: 1.45rem; }
  .facts { grid-template-columns: 1fr 1fr; gap: 12px; }
  body.has-overlay { overflow: hidden; }
  .toast-region { bottom: 14px; }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
