/* Relay — Team inbox */

@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 1 999;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 1 999;
  font-display: swap;
  font-style: normal;
}

:root {
  --bg: #f7f5f2;
  --bg-elev: #ffffff;
  --bg-sunken: #efece7;
  --ink: #1c1b1a;
  --ink-soft: #4b4844;
  --ink-faint: #8a8580;
  --line: #e3dfd8;
  --line-strong: #d3cec5;
  --accent: #5b43c4;
  --accent-soft: #ece7fb;
  --accent-ink: #42338f;

  --todo: #6f7785;
  --todo-soft: #eceef1;
  --progress: #2c6cf2;
  --progress-soft: #e4edff;
  --blocked: #b8581c;
  --blocked-soft: #fbeadd;
  --done: #2f8a52;
  --done-soft: #e3f3ea;

  --shadow-1: 0 1px 2px rgba(20, 18, 16, 0.06), 0 1px 1px rgba(20, 18, 16, 0.04);
  --shadow-2: 0 8px 28px rgba(28, 27, 26, 0.12), 0 2px 6px rgba(28, 27, 26, 0.06);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

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

  --focus-ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --bg-elev: #211f1d;
    --bg-sunken: #1c1a18;
    --ink: #f4f1ec;
    --ink-soft: #c8c2ba;
    --ink-faint: #8a837a;
    --line: #332f2c;
    --line-strong: #423d39;
    --accent: #b3a4ff;
    --accent-soft: #2a2350;
    --accent-ink: #d9cdff;

    --todo: #aab0bd;
    --todo-soft: #2a2c30;
    --progress: #8fb4ff;
    --progress-soft: #1f2c4a;
    --blocked: #e09b5e;
    --blocked-soft: #3c2a1c;
    --done: #7fd0a6;
    --done-soft: #1d3a2d;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.5);

    --focus-ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

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

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

.skip-link {
  position: fixed;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 150ms ease-out;
}
.skip-link:focus { top: 12px; }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input, select { font: inherit; touch-action: manipulation; }

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

/* App shell */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: clamp(20px, 1.4rem + .4vw, 26px);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.brand-tag {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.app-bar-meta { display: flex; align-items: center; gap: 10px; }
.pill {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px) clamp(16px, 4vw, 40px) 96px;
  flex: 1;
  scroll-margin-top: 80px;
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: end;
  margin-bottom: 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.field-help {
  font-size: 12px;
  color: var(--ink-faint);
}

.input-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.input-icon {
  position: absolute; left: 12px;
  color: var(--ink-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 11px 12px 11px 38px;
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 15px;
}
#search::placeholder { color: var(--ink-faint); }
/* remove default search decoration */
#search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.filter-field select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%238a8580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-color: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 34px 11px 14px;
  min-width: 168px;
  font-size: 15px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
.filter-field select:focus-visible { box-shadow: var(--focus-ring); }

.active-filter-field { grid-column: 1 / -1; }
.chip-reset {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--accent-ink);
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.chip-reset-btn {
  border: 0; background: transparent;
  color: inherit;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.chip-reset-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* List meta */
.list-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 18px;
  margin-bottom: 14px;
}
.list-count { margin: 0; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-soft); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--line-strong); }
.dot-todo { background: var(--todo); }
.dot-progress { background: var(--progress); }
.dot-blocked { background: var(--blocked); }
.dot-done { background: var(--done); }

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

.task-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.task-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.task-card.is-done { opacity: 0.92; }

.task-card-main {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px;
  border-left: 3px solid transparent;
}
.task-card[data-status="todo"] .task-card-main { border-left-color: var(--todo); }
.task-card[data-status="in-progress"] .task-card-main { border-left-color: var(--progress); }
.task-card[data-status="blocked"] .task-card-main { border-left-color: var(--blocked); }
.task-card[data-status="done"] .task-card-main { border-left-color: var(--done); }

.task-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.status-pill[data-status="todo"] { color: var(--todo); background: var(--todo-soft); border-color: color-mix(in srgb, var(--todo) 22%, transparent); }
.status-pill[data-status="in-progress"] { color: var(--progress); background: var(--progress-soft); border-color: color-mix(in srgb, var(--progress) 22%, transparent); }
.status-pill[data-status="blocked"] { color: var(--blocked); background: var(--blocked-soft); border-color: color-mix(in srgb, var(--blocked) 22%, transparent); }
.status-pill[data-status="done"] { color: var(--done); background: var(--done-soft); border-color: color-mix(in srgb, var(--done) 22%, transparent); }

.task-comments {
  font-size: 12px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 4px;
}
.task-comments::before { content: "💬"; font-size: 12px; filter: grayscale(1) opacity(0.6); }

.task-title { margin: 0; font-size: 17px; line-height: 1.3; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.task-open {
  border: 0; background: transparent; padding: 0;
  text-align: left; font: inherit; color: var(--ink);
  width: 100%;
  border-radius: 6px;
  text-wrap: balance;
  transition: color 140ms ease;
}
.task-open:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.task-open:active { color: var(--accent); }

.task-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  font-size: 13px; color: var(--ink-soft);
}
.task-meta > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.task-meta dt { display: none; }
.task-project { font-weight: 600; color: var(--ink); }
.task-project::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: 0.85; }
.task-assignee::before { content: "@"; color: var(--ink-faint); margin-right: -2px; }
.task-due { font-variant-numeric: tabular-nums; }
.task-due.is-overdue { color: var(--blocked); font-weight: 600; }
.task-due.is-soon { color: var(--ink); font-weight: 600; }

.task-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--ink-soft);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Empty state */
.empty-state { margin-top: 8px; }
.empty-card {
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 6vw, 48px) 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: 520px; margin: 0 auto;
  box-shadow: var(--shadow-1);
}
.empty-icon { color: var(--ink-faint); }
.empty-title { margin: 0; font-family: var(--font-display); font-size: 20px; text-wrap: balance; }
.empty-body { margin: 0 0 6px; color: var(--ink-soft); font-size: 14px; max-width: 42ch; text-wrap: pretty; }

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--ink); border-color: var(--line-strong); }

/* Detail dialog */
dialog.detail {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  max-width: none; max-height: none;
  width: 100vw; height: 100vh;
  height: 100dvh;
  inset: 0;
  display: none;
  overflow: hidden;
}
dialog.detail[open] {
  display: grid;
  place-items: end stretch;
}
@media (min-width: 760px) {
  dialog.detail[open] { place-items: center end; }
}
dialog.detail::backdrop {
  background: color-mix(in srgb, #0c0b0a 46%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.detail-panel {
  width: 100%;
  max-width: 640px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  max-height: 100dvh;
  overscroll-behavior: contain;
  animation: slide-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
@media (min-width: 760px) {
  .detail-panel {
    border-radius: var(--radius-lg);
    margin: 24px;
    max-height: calc(100dvh - 48px);
  }
}

@keyframes slide-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .detail-panel { animation: none; }
}

.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
}
.detail-head-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-project { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); }
.detail-id { font-size: 12px; color: var(--ink-faint); font-family: "Space Grotesk", monospace; }

.detail-body {
  padding: 10px 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 6px 0 16px;
  text-wrap: balance;
}

.detail-meta {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px 14px;
  margin: 0 0 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.detail-meta dt { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); padding-top: 6px; font-weight: 600; }
.detail-meta dd { margin: 0; min-width: 0; }

.status-select-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#status-control {
  appearance: none; -webkit-appearance: none;
  background-color: var(--bg-elev);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%238a8580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 30px 9px 12px;
  font-size: 14px;
  font-weight: 600;
  min-width: 150px;
  cursor: pointer;
}
#status-control:focus-visible { box-shadow: var(--focus-ring); }

.status-badge {
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.status-badge[data-status="todo"] { color: var(--todo); background: var(--todo-soft); border-color: color-mix(in srgb, var(--todo) 24%, transparent); }
.status-badge[data-status="in-progress"] { color: var(--progress); background: var(--progress-soft); border-color: color-mix(in srgb, var(--progress) 24%, transparent); }
.status-badge[data-status="blocked"] { color: var(--blocked); background: var(--blocked-soft); border-color: color-mix(in srgb, var(--blocked) 24%, transparent); }
.status-badge[data-status="done"] { color: var(--done); background: var(--done-soft); border-color: color-mix(in srgb, var(--done) 24%, transparent); }

.status-feedback {
  margin: 6px 0 0; font-size: 13px; color: var(--done); font-weight: 600;
  min-height: 1.2em;
  transition: opacity 160ms ease;
}
.status-feedback.is-empty { opacity: 0; }

.detail-summary-section, .detail-body-section { margin-top: 4px; }
.detail-summary-section h3, .detail-body-section h3 {
  font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 6px; font-weight: 700;
}
.detail-summary { margin: 0; color: var(--ink); font-size: 15px; line-height: 1.55; text-wrap: pretty; }
.detail-text { color: var(--ink-soft); font-size: 15px; line-height: 1.6; text-wrap: pretty; white-space: pre-line; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.priority { font-weight: 600; }
.priority-high { color: var(--blocked); }
.priority-medium { color: var(--ink); }
.priority-low { color: var(--ink-faint); }

.detail-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg-elev);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 200;
  max-width: min(90vw, 420ch);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Mobile layout */
@media (max-width: 759px) {
  .toolbar { grid-template-columns: 1fr; gap: 12px; }
  .filter-field { justify-self: stretch; }
  .filter-field select { width: 100%; min-width: 0; }
  .legend { width: 100%; }
  .list-meta { flex-direction: column; align-items: flex-start; }
  .app-bar { padding: 12px 16px; }
  .pill { font-size: 12px; }
}

/* Make sure focused item cards aren't hidden behind sticky header */
.task-card:focus-within, .task-card:target { scroll-margin-top: 84px; }
