/* Trellis — team inbox styles */

@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 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #f6f3ec;
  --card: #fffefa;
  --ink: #232019;
  --muted: #6e6858;
  --line: #e4ddcc;
  --line-strong: #d3cab4;
  --accent: #1e6a4f;
  --accent-soft: #e2efe6;
  --danger: #a83a2e;

  --st-todo: #a4740f;
  --st-todo-bg: #f6ead0;
  --st-prog: #20618f;
  --st-prog-bg: #dbeaf5;
  --st-block: #a33a30;
  --st-block-bg: #f8e1de;
  --st-done: #2c6e46;
  --st-done-bg: #ddefe2;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(46, 40, 26, 0.06), 0 6px 18px rgba(46, 40, 26, 0.07);
  --font-ui: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
  --font-read: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

html.lock-scroll { overflow: hidden; }

#main:focus { outline: none; } /* skip-link target: region, not a control */

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

.skip-link {
  position: absolute;
  top: -48px; left: 12px;
  z-index: 60;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: top 150ms ease;
}
.skip-link:focus-visible { top: 12px; outline: 2px solid #fff; outline-offset: 2px; }

.shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

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

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 18px;
  border-bottom: 2px solid var(--ink);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-mark {
  width: 34px; height: 34px;
  flex: none;
  color: var(--accent);
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.brand-tag {
  margin: 2px 0 0;
  font-size: 0.83rem;
  color: var(--muted);
}
.nowrap { white-space: nowrap; }

.masthead-stat {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.stat-open { color: var(--accent); font-weight: 600; }
.stat-done { color: var(--st-done); font-weight: 600; }

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 12px;
  background: var(--paper);
}

.field { display: flex; align-items: center; gap: 0; min-width: 0; }

.field-search {
  flex: 1 1 auto;
  position: relative;
  max-width: 420px;
}
.field-icon {
  position: absolute;
  left: 13px;
  width: 17px; height: 17px;
  color: var(--muted);
  pointer-events: none;
}

input[type="search"], select {
  font: inherit;
  color: var(--ink);
  background-color: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
}

input[type="search"] {
  width: 100%;
  padding: 10px 14px 10px 38px;
}
input[type="search"]::placeholder { color: var(--muted); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.field-filter { flex: 0 0 auto; gap: 8px; }
.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.field-filter select { padding: 10px 34px 10px 12px; cursor: pointer; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' aria-hidden='true'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236e6858' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
}

.result-count {
  margin: 0 0 0 auto;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.task-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.task-item {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  scroll-margin-top: 120px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.task-item.is-done { opacity: 0.78; }
.task-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }

.item-open {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  width: 100%;
  padding: 14px 18px 13px;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(30, 106, 79, 0.12);
}

.item-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 10px 2.5px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.chip-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip.st-todo     { color: var(--st-todo);  background: var(--st-todo-bg); }
.chip.st-in-progress { color: var(--st-prog); background: var(--st-prog-bg); }
.chip.st-blocked  { color: var(--st-block); background: var(--st-block-bg); }
.chip.st-done     { color: var(--st-done);  background: var(--st-done-bg); }

.item-comments {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.icon-comment { width: 14px; height: 14px; }

.item-title {
  align-self: start;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  overflow-wrap: break-word;
  text-wrap: balance;
  min-width: 0;
}
.is-done .item-title { color: var(--muted); }

.item-arrow {
  align-self: start;
  margin-top: 4px;
  color: var(--muted);
  width: 18px; height: 18px;
  flex: none;
  transition: transform 140ms ease, color 140ms ease;
}
.task-item:hover .item-arrow { color: var(--accent); transform: translateX(2px); }

.item-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 0;
}
.meta-person { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.meta-person .person-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-sep::before {
  content: "·";
  color: var(--line-strong);
}
.meta-due { font-variant-numeric: tabular-nums; }
.meta-priority { font-weight: 600; }
.meta-priority.p-high { color: var(--danger); }
.meta-priority.p-medium { color: #8a6d1d; }
.meta-priority.p-low { color: var(--muted); }

.task-item.item-flash { animation: item-flash 900ms ease-out; }
@keyframes item-flash {
  0% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  100% { border-color: var(--line); box-shadow: none; }
}

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

.empty-state {
  margin-top: 28px;
  padding: 44px 24px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-icon { width: 40px; height: 40px; color: var(--line-strong); }
.empty-title {
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  text-wrap: balance;
}
.empty-note { margin: 0 0 18px; }
.empty-note .query { font-style: italic; color: var(--ink); }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 18px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(30, 106, 79, 0.12);
}
.btn:hover { background: #17563e; border-color: #17563e; }

/* ---------- Detail dialog ---------- */

.dialog-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: block;
}
.dialog-wrap[hidden] { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(30, 26, 18, 0.42);
  opacity: 1;
  transition: opacity 200ms ease;
}

.dialog {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1.5px solid var(--line-strong);
  box-shadow: -18px 0 48px rgba(30, 26, 18, 0.18);
  transform: translateX(0);
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.25, 1);
}
.dialog.is-entering { transform: translateX(102%); }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1.5px solid var(--line);
  flex: none;
}

.chip-project {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: none;
  background: none;
  border: 1.5px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(30, 106, 79, 0.12);
}
.btn-icon svg { width: 17px; height: 17px; }
.btn-icon:hover { background: var(--accent-soft); color: var(--accent); }

.dialog-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 24px 40px;
  scroll-padding-top: 16px;
}

.detail-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.status-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.select-status {
  padding: 8px 34px 8px 12px;
  font-weight: 600;
  cursor: pointer;
}
.save-note {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--st-done);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.save-note::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.save-note[hidden] { display: none; }

.detail-title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.detail-meta {
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.detail-meta dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 3px;
}
.detail-meta dd {
  margin: 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: break-word;
}
.meta-assignee { display: flex; align-items: center; gap: 8px; min-width: 0; }
.meta-assignee .avatar { width: 22px; height: 22px; font-size: 0.66rem; }
.meta-assignee .person-name { overflow-wrap: break-word; }

.meta-tags dd { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
}

.detail-body-heading {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.detail-body {
  font-family: var(--font-read);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: break-word;
  padding-bottom: 18px;
  border-bottom: 1.5px solid var(--line);
}
.detail-body:empty { display: none; }

.detail-comments {
  margin: 14px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.detail-comments .icon-comment { width: 16px; height: 16px; }

/* ---------- Focus ---------- */

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
input[type="search"]:focus-visible, .field-filter select:focus-visible { border-radius: 10px; }
.task-item:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Motion ---------- */

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

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .shell { padding: 0 16px 48px; }

  .masthead { padding: 18px 0 14px; align-items: center; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 1.4rem; }
  .brand-tag { font-size: 0.78rem; }
  .masthead-stat { font-size: 0.8rem; }

  .toolbar {
    flex-wrap: wrap;
    padding: 12px 0 10px;
    row-gap: 10px;
  }
  .field-search { max-width: none; flex-basis: 100%; order: 1; }
  .field-filter { order: 2; margin-left: auto; }
  .result-count { order: 3; flex-basis: 100%; margin: 0; }

  .item-open { padding: 13px 15px 12px; }

  .dialog {
    width: 100%;
    border-left: 0;
  }
  .dialog-scroll { padding: 18px 18px 40px; }
  .detail-title { font-size: 1.3rem; }
  .detail-meta { grid-template-columns: 1fr; }
}
