/* Docket — the shared task desk */

@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: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* paper + ink */
  --paper: #e8eaec;
  --paper-2: #f2f3f5;
  --paper-3: #ffffff;
  --edge: #cfd4d9;
  --edge-soft: #dde1e5;
  --perforation: #aab2bb;
  --ink: #15222d;
  --ink-2: #475563;
  --ink-3: #7e8a95;
  --ink-4: #a3adb6;

  /* the one warm accent: active / brand */
  --accent: #c0720f;
  --accent-ink: #8a4f0a;
  --accent-soft: #f3e3c8;

  /* status */
  --st-todo: #46586b;
  --st-progress: #b06a0e;
  --st-blocked: #a8331f;
  --st-done: #2b6b50;
  --st-todo-bg: #dde2e7;
  --st-progress-bg: #f4e4c9;
  --st-blocked-bg: #f0d3cb;
  --st-done-bg: #d2e6dc;

  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Work Sans", system-ui, -apple-system, sans-serif;

  --row-max: 1080px;
  --radius: 4px;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 12% -10%, rgba(21,34,45,.05), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(192,114,15,.06), transparent 35%);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip {
  position: absolute;
  left: 12px;
  top: -44px;
  background: var(--ink);
  color: var(--paper-3);
  padding: 8px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  z-index: 100;
  transition: top .15s ease;
}
.skip:focus { top: 12px; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 18px clamp(16px, 4vw, 40px) 16px;
  border-bottom: 1px solid var(--edge);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  color: var(--paper-3);
  background: var(--accent);
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(0,0,0,.12);
  transform: rotate(-3deg);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-tag {
  color: var(--ink-3);
  font-size: .85rem;
  border-left: 1px solid var(--edge);
  padding-left: 10px;
  margin-left: 4px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  font-size: .8rem;
  color: var(--ink-2);
}
.summary .sum-total {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
}
.summary .sum-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--edge-soft);
  font-variant-numeric: tabular-nums;
}
.summary .sum-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ---------- controls ---------- */
.desk {
  flex: 1;
  width: 100%;
  max-width: var(--row-max);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 18px;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--edge);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-3);
}
.control-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap {
  background: var(--paper-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  width: 100%;
  min-width: 0;
}
.search-wrap:focus-within {
  border-color: var(--ink-3);
  box-shadow: var(--focus);
}
.search-icon {
  margin-left: 12px;
  color: var(--ink-3);
  flex: none;
}
.search-wrap input {
  border: 0;
  background: transparent;
  padding: 11px 12px 11px 8px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  border-radius: var(--radius);
}
.search-wrap input::placeholder { color: var(--ink-4); }
.search-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; }

.select-wrap {
  background: var(--paper-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
}
.select-wrap:focus-within {
  border-color: var(--ink-3);
  box-shadow: var(--focus);
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  padding: 11px 30px 11px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 9.5rem;
}
.select-chevron {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--ink-2);
}

.count {
  font-size: .85rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-bottom: 4px;
}

/* ---------- list ---------- */
.list { padding: 6px 0 40px; }

.ticket {
  border-bottom: 1px dashed var(--perforation);
}
.ticket:first-child { border-top: 1px dashed var(--perforation); }

.ticket-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 168px;
  align-items: center;
  gap: 18px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 16px 4px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: var(--radius);
  transition: background .12s ease;
}
.ticket-row:hover { background: rgba(255,255,255,.5); }
.ticket-row:focus-visible {
  outline: none;
  background: var(--paper-2);
  box-shadow: var(--focus);
}

/* status stamp */
.status-stamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-self: start;
  padding: 5px 10px 5px 9px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-stamp .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}
.status-stamp[data-status="todo"]      { background: var(--st-todo-bg);     color: var(--st-todo);     border-color: #c8d2da; }
.status-stamp[data-status="todo"] .dot { background: var(--st-todo); }
.status-stamp[data-status="in-progress"]      { background: var(--st-progress-bg); color: var(--st-progress); border-color: #e4caa0; }
.status-stamp[data-status="in-progress"] .dot { background: var(--st-progress); box-shadow: 0 0 0 3px rgba(192,114,15,.16); }
.status-stamp[data-status="blocked"]      { background: var(--st-blocked-bg); color: var(--st-blocked); border-color: #e6b7ac; }
.status-stamp[data-status="blocked"] .dot { background: var(--st-blocked); }
.status-stamp[data-status="done"]      { background: var(--st-done-bg); color: var(--st-done); border-color: #b4d4c6; }
.status-stamp[data-status="done"] .dot { background: var(--st-done); }

.ticket-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ticket-title {
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: .82rem;
  color: var(--ink-3);
  row-gap: 2px;
}
.ticket-meta > span { display: inline-flex; align-items: center; }
.ticket-meta > span + span::before {
  content: "";
  display: inline-block;
  width: 1px; height: 11px;
  background: var(--edge);
  margin: 0 9px;
}
.meta-project { color: var(--ink-2); font-weight: 600; }
.meta-due { font-variant-numeric: tabular-nums; }
.meta-due.is-soon { color: var(--accent-ink); font-weight: 600; }

.ticket-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  font-size: .8rem;
  color: var(--ink-3);
}
.priority {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}
.priority-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.priority-bars i {
  width: 4px;
  background: var(--edge);
  border-radius: 1px;
}
.priority-bars i:nth-child(1) { height: 6px; }
.priority-bars i:nth-child(2) { height: 10px; }
.priority-bars i:nth-child(3) { height: 14px; }
.priority[data-priority="high"] i:nth-child(-n+3) { background: var(--st-blocked); }
.priority[data-priority="medium"] i:nth-child(-n+2) { background: var(--st-progress); }
.priority[data-priority="low"] i:nth-child(-n+1) { background: var(--st-todo); }

.comments {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}
.comments svg { color: var(--ink-3); }

/* ---------- empty state ---------- */
.empty { padding: 50px 0; }
.empty-card {
  text-align: center;
  max-width: 26rem;
  margin: 0 auto;
  padding: 34px 24px;
  border: 1px dashed var(--perforation);
  border-radius: 8px;
  background: var(--paper-2);
}
.empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 0 6px;
}
.empty-detail {
  color: var(--ink-3);
  margin: 0 0 18px;
  font-size: .92rem;
}
.empty-reset {
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid #e4caa0;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.empty-reset:hover { background: #ecd2a8; }

/* ---------- detail dialog ---------- */
.detail {
  margin: 0;
  margin-left: auto;
  padding: 0;
  border: 0;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  background: var(--paper-3);
  color: var(--ink);
  box-shadow: -24px 0 60px -30px rgba(0,0,0,.4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail::backdrop {
  background: rgba(21,34,45,.34);
  backdrop-filter: blur(2px);
}
.detail[open] { animation: slide-in .26s cubic-bezier(.2,.7,.2,1); }
.detail[open]::backdrop { animation: fade-in .26s ease; }

@keyframes slide-in { from { transform: translateX(40px); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--edge);
  position: sticky;
  top: 0;
  background: var(--paper-3);
  z-index: 1;
}
.close-detail {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
}
.close-detail:hover { background: #e6e9ec; }
.close-detail svg { color: var(--ink-2); }
.detail-id {
  font-size: .76rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  text-transform: lowercase;
}

.detail-body {
  padding: 26px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.detail-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
.detail-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* form fields */
.detail-fields {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px 16px;
  padding: 18px 0;
  border-top: 1px solid var(--edge-soft);
  border-bottom: 1px solid var(--edge-soft);
}
.dfield { display: contents; }
.dlabel {
  font-size: .8rem;
  color: var(--ink-3);
  font-weight: 500;
  align-self: center;
}
.dvalue {
  font-size: .95rem;
  color: var(--ink);
  align-self: center;
  min-width: 0;
}
.dvalue .tag-list { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.dvalue .tag {
  font-size: .76rem;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--edge-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* status control inside detail */
.status-control-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.status-control-wrap select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 8px 30px 8px 12px;
  cursor: pointer;
  min-width: 10rem;
}
.status-control-wrap:focus-within { box-shadow: var(--focus); border-radius: var(--radius); }
.status-control-wrap .select-chevron { right: 10px; color: var(--ink-2); }

.detail-section-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.detail-body-text {
  font-size: .98rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
  max-width: 62ch;
}
.detail-expected {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--paper);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 62ch;
}
.detail-expected strong { color: var(--ink); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper-3);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .toast-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}

.pagefoot {
  padding: 22px clamp(16px, 4vw, 40px) 34px;
  font-size: .78rem;
  color: var(--ink-4);
  text-align: center;
  max-width: var(--row-max);
  margin: 0 auto;
}

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .count { grid-column: 1 / -1; padding-bottom: 0; }
  .ticket-row {
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 12px 14px;
  }
  .ticket-side {
    grid-column: 2 / 3;
    justify-content: flex-start;
    padding-top: 2px;
  }
  .ticket-title { white-space: normal; }
}

@media (max-width: 600px) {
  .topbar { padding: 14px 16px 12px; gap: 10px; }
  .brand-tag { display: none; }
  .summary { width: 100%; }
  .desk { padding: 0 16px; }
  .controls { grid-template-columns: 1fr; gap: 14px; }
  .filter-field { min-width: 0; }
  .select-wrap select { width: 100%; }
  .ticket-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 2px;
  }
  .ticket-side { grid-column: 1 / 2; }
  .detail { width: 100vw; }
  .detail-body { padding: 22px 18px 36px; }
  .detail-head { padding: 14px 18px; }
  .detail-title { font-size: 1.4rem; }
  .detail-fields { grid-template-columns: 84px 1fr; gap: 10px 12px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .detail[open] { transform: none; }
}
