/* Hopper — the team task inbox. Routing-desk world: cool paper, ink navy, one cobalt accent. */

@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype-variations"),
       url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f2f4f3;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #182430;
  --ink-2: #46586a;
  --ink-3: #5d7080;
  --line: #dfe5e3;
  --line-strong: #c8d2cf;
  --accent: #2749c8;
  --accent-deep: #1e3aae;
  --accent-tint: #e7ecfa;
  --accent-line: #c2cef2;

  --st-todo-text: #44586b;   --st-todo-bg: #ebeff1;   --st-todo-dot: #8296a6;
  --st-prog-text: #1e3aae;   --st-prog-bg: #e4eafb;   --st-prog-dot: #2749c8;
  --st-blocked-text: #9e3524; --st-blocked-bg: #fae8e4; --st-blocked-dot: #c04a32;
  --st-done-text: #1e6c42;   --st-done-bg: #e1f0e6;   --st-done-dot: #35915f;

  --radius: 10px;
  --shadow-sheet: 0 1px 2px rgba(24, 36, 48, 0.05), 0 8px 24px -12px rgba(24, 36, 48, 0.18);
  --shadow-panel: -18px 0 48px -24px rgba(24, 36, 48, 0.35), -1px 0 0 var(--line);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --appbar-h: 56px;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Work Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

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

/* Browser surfaces carry the design */
input, select, button { font: inherit; color: inherit; }
input::placeholder { color: var(--ink-3); opacity: 1; }
input { caret-color: var(--accent); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.853em;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

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

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--ink); color: #fff; padding: 8px 14px;
  border-radius: 8px; text-decoration: none; font-weight: 550;
  transition: top 160ms var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- App bar ---------- */

.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(242, 244, 243, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  max-width: 1216px; margin: 0 auto;
  height: var(--appbar-h);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  border-radius: 8px;
}
.brand-mark { width: 24px; height: 24px; display: block; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.workspace { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ---------- Layout ---------- */

.layout { max-width: 1216px; margin: 0 auto; padding: 20px 24px 64px; }

.tray { transition: padding 260ms var(--ease); }
body.has-detail .tray { padding-right: 464px; }

.tray-sticky {
  position: sticky; top: var(--appbar-h); z-index: 20;
  background: var(--paper);
  padding: 12px 0 14px;
  display: grid; gap: 12px;
}

.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.tray-count { margin: 0; color: var(--ink-3); font-size: 13px; }

/* Route chips */
.routes { display: flex; gap: 6px; flex-wrap: wrap; }
.route-chip {
  appearance: none; cursor: pointer;
  border: 1px solid transparent; background: transparent;
  border-radius: 999px; padding: 5px 12px 5px 10px;
  font-size: 13px; font-weight: 550; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
}
.route-chip:hover { background: rgba(24, 36, 48, 0.06); color: var(--ink); }
.route-chip.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.route-num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px; color: inherit; opacity: 0.62;
  font-variant-numeric: tabular-nums;
}

/* Toolbar */
.toolbar { display: flex; gap: 10px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.field-search { flex: 1 1 260px; }
.field-filter { flex: 0 1 220px; }

.input-wrap, .select-wrap { position: relative; display: flex; }
.input-icon {
  position: absolute; left: 11px; top: 50%; translate: 0 -50%;
  width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
#task-search {
  width: 100%; height: 38px;
  padding: 0 12px 0 34px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
#task-search:hover { border-color: var(--ink-3); }
#task-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

select {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 38px;
  padding: 0 34px 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
select:hover { border-color: var(--ink-3); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.select-chevron {
  position: absolute; right: 11px; top: 50%; translate: 0 -50%;
  width: 14px; height: 14px; color: var(--ink-3); pointer-events: none;
}

/* ---------- Ledger sheet ---------- */

.sheet-wrap { position: relative; }
#ledger:focus { outline: none; }
.ledger {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}
.row { border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }

.row-btn {
  appearance: none; background: none; border: 0; cursor: pointer;
  width: 100%; text-align: left;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 128px 150px 56px 64px 108px 14px;
  align-items: center; gap: 12px;
  transition: background-color 130ms var(--ease);
}
.row-btn:hover { background: var(--surface-2); }
.row-btn:focus-visible { outline-offset: -2px; }
.row--open .row-btn { background: #edf1fc; }
.row--open .row-btn:hover { background: #e5ebfa; }
.row--open .row-chevron { color: var(--accent); }

/* While the detail sheet is open, the ledger narrows: collapse
   columns whose facts are visible in the sheet. */
body.has-detail .row-btn { grid-template-columns: 10px minmax(0, 1fr) 150px 64px 108px 14px; }
body.has-detail .row-project, body.has-detail .row-comments { display: none; }

.row--flash .row-btn { animation: row-flash 900ms var(--ease); }
@keyframes row-flash {
  0% { background-color: var(--accent-tint); }
  100% { background-color: transparent; }
}

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot, var(--st-todo-dot));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55);
  justify-self: center;
}
.row[data-status="todo"] .dot { --dot: var(--st-todo-dot); }
.row[data-status="in-progress"] .dot { --dot: var(--st-prog-dot); }
.row[data-status="blocked"] .dot { --dot: var(--st-blocked-dot); }
.row[data-status="done"] .dot { --dot: var(--st-done-dot); }

.row-main { min-width: 0; display: grid; gap: 1px; }
.row-title {
  font-size: 14.5px; font-weight: 550; color: var(--ink);
  letter-spacing: -0.005em; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-tags { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-project { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-assignee { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.row-assignee .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-comments { display: flex; align-items: center; gap: 5px; color: var(--ink-3); font-size: 12.5px; justify-self: start; }
.row-comments svg { width: 14px; height: 14px; flex: none; }
.row-due { color: var(--ink-3); font-size: 12.5px; text-align: right; }
.row-due.is-soon { color: var(--ink-2); font-weight: 500; }
.row-chevron { width: 14px; height: 14px; color: var(--line-strong); justify-self: end; transition: color 130ms var(--ease), translate 130ms var(--ease); }
.row-btn:hover .row-chevron { color: var(--ink-3); }

.avatar {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 650; letter-spacing: 0.02em;
}

/* Status chips */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--chip-bg, var(--st-todo-bg)); color: var(--chip-fg, var(--st-todo-text));
  justify-self: end; white-space: nowrap;
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip-dot, var(--st-todo-dot)); }
.chip--todo { --chip-bg: var(--st-todo-bg); --chip-fg: var(--st-todo-text); --chip-dot: var(--st-todo-dot); }
.chip--in-progress { --chip-bg: var(--st-prog-bg); --chip-fg: var(--st-prog-text); --chip-dot: var(--st-prog-dot); }
.chip--blocked { --chip-bg: var(--st-blocked-bg); --chip-fg: var(--st-blocked-text); --chip-dot: var(--st-blocked-dot); }
.chip--done { --chip-bg: var(--st-done-bg); --chip-fg: var(--st-done-text); --chip-dot: var(--st-done-dot); }

/* ---------- Empty / error states ---------- */

.empty-state, .load-error {
  padding: 72px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}
.empty-art { width: 56px; height: 56px; color: var(--line-strong); margin-bottom: 4px; }
.empty-state h2, .load-error h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.empty-state p, .load-error p { margin: 0 auto 20px; color: var(--ink-2); max-width: 42ch; }

.btn {
  appearance: none; cursor: pointer;
  border-radius: 9px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  border: 1px solid transparent;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 80ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

/* ---------- Detail sheet ---------- */

.detail {
  position: fixed; top: var(--appbar-h); right: 0; bottom: 0; z-index: 40;
  width: min(440px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  transform: translateX(106%);
  visibility: hidden;
  transition: transform 260ms var(--ease), visibility 0s 260ms;
}
.detail.is-open { transform: none; visibility: visible; transition: transform 260ms var(--ease); }

.detail-inner { height: 100%; display: flex; flex-direction: column; }
.detail-top {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  appearance: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

.detail-project { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.02em; }

.detail-scroll { overflow-y: auto; padding: 20px 24px 40px; flex: 1; }

.stamp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.stamp-row .chip { justify-self: start; font-size: 12.5px; padding: 5px 12px 5px 10px; }
.field-inline { display: flex; align-items: center; gap: 10px; }
.field-inline label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.field-inline .select-wrap { width: 168px; }
.select-wrap--tight select { height: 34px; border-radius: 8px; font-size: 13.5px; }

.detail.is-stamping .stamp-row .chip { animation: stamp 340ms var(--ease); }
@keyframes stamp {
  0% { transform: scale(0.82) rotate(-3deg); }
  55% { transform: scale(1.06) rotate(0.5deg); }
  100% { transform: scale(1) rotate(0); }
}

.detail-title {
  margin: 0 0 18px;
  font-size: 20px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.3;
  text-wrap: balance;
}

.meta {
  margin: 0 0 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.meta-item dt { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.meta-item dd { margin: 0; font-size: 13.5px; color: var(--ink); }
.meta-item--wide { grid-column: 1 / -1; }
.assignee { display: flex; align-items: center; gap: 9px; }

.prio {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 6px; letter-spacing: 0.02em;
  background: #edf0ef; color: var(--ink-2); border: 1px solid var(--line);
}
.prio--high { background: var(--st-blocked-bg); color: var(--st-blocked-text); border-color: transparent; }

.detail-text { display: grid; gap: 14px; }
.detail-text p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--ink); max-width: 62ch; }
.detail-text .expected {
  border-left: 1px solid var(--line-strong);
  padding: 2px 0 2px 14px;
  color: var(--ink-2);
}
.detail-text .expected strong { color: var(--ink); font-weight: 600; }

.detail-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 0; padding: 0; }
.detail-tags li {
  font-size: 12px; font-weight: 550; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px;
}

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

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  translate: -50% 16px;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px 10px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 550;
  display: flex; align-items: center; gap: 9px;
  box-shadow: 0 2px 6px rgba(24, 36, 48, 0.25), 0 12px 32px -12px rgba(24, 36, 48, 0.45);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 200ms var(--ease), translate 200ms var(--ease), visibility 0s 200ms;
  max-width: min(92vw, 480px);
}
.toast.is-show { opacity: 1; translate: -50% 0; visibility: visible; transition: opacity 200ms var(--ease), translate 200ms var(--ease); }
.toast svg { width: 15px; height: 15px; flex: none; color: #7ee2a8; }
.toast .toast-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .toast-label b { font-weight: 650; }

/* ---------- Scrim (mobile detail) ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(24, 36, 48, 0.42);
  opacity: 0; transition: opacity 220ms var(--ease);
}
.scrim.is-show { opacity: 1; }

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  body.has-detail .tray { padding-right: 0; }
  .detail { width: min(400px, 92vw); }
}

@media (max-width: 860px) {
  .layout { padding: 12px 14px 48px; }
  .appbar-inner { padding: 0 14px; }
  .workspace { font-size: 12px; }

  .tray-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .routes { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 2px 14px 6px; scrollbar-width: none; }
  .routes::-webkit-scrollbar { display: none; }
  .route-chip { flex: none; }

  .toolbar { flex-direction: column; gap: 10px; }
  .field-search, .field-filter { flex: none; }

  .row-btn {
    grid-template-columns: 10px minmax(0, 1fr) auto;
    grid-template-areas:
      "dot main chip"
      "dot meta meta";
    row-gap: 6px; padding: 12px 14px;
  }
  .dot { grid-area: dot; align-self: start; margin-top: 4px; }
  .row-main { grid-area: main; }
  .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .row-tags { display: none; }
  .row-project, .row-assignee, .row-comments, .row-chevron { display: none; }
  .row-btn > .row-due { display: none; }
  .row-meta {
    grid-area: meta; display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--ink-3); min-width: 0;
  }
  .row-meta .who, .row-meta .proj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-meta .sep { color: var(--line-strong); }
  .row-meta .row-due { text-align: left; }
  .chip { grid-area: chip; align-self: start; }
  body.has-detail .row-btn { grid-template-columns: 10px minmax(0, 1fr) auto; }
  body.has-detail .row-project { display: none; }

  .detail {
    top: 0; left: 0; right: 0; bottom: 0; width: 100%;
    box-shadow: none;
    transform: translateY(4%);
    opacity: 0;
    transition: transform 240ms var(--ease), opacity 240ms var(--ease), visibility 0s 240ms;
  }
  .detail.is-open { transform: none; opacity: 1; transition: transform 240ms var(--ease), opacity 240ms var(--ease); }
  .detail-scroll { padding: 16px 18px 40px; }
  .detail-title { font-size: 18px; }
  .meta { grid-template-columns: 1fr 1fr; }
}

/* Desktop-only helpers */
.row-meta { display: none; }
@media (min-width: 861px) {
  .row-meta { display: none; }
  .scrim { display: none; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .detail { transition: none; }
  .detail.is-open { transition: none; }
}
