/* Relay - team task inbox. Native CSS, light-first, dark via prefers-color-scheme. */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
  font-style: normal;
}

:root {
  /* Light theme tokens */
  --bg: #f7f6f3;
  --bg-grain: #f2f1ec;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --surface-hover: #f4f2ee;
  --border: #e6e2d8;
  --border-strong: #d6d1c4;
  --text: #1c1917;
  --text-soft: #57534e;
  --text-faint: #8a847b;
  --accent: #c2410c;        /* ember */
  --accent-contrast: #ffffff;
  --accent-soft: #fff1e8;
  --accent-border: #f6c3a3;
  --ring: #c2410c;

  /* status colors (semantic, separate from brand accent) */
  --st-todo: #57534e;
  --st-todo-bg: #f0eee9;
  --st-todo-bd: #d9d4c8;
  --st-prog: #b45309;       /* amber-700 */
  --st-prog-bg: #fdf3e2;
  --st-prog-bd: #f1d6a8;
  --st-blocked: #b91c1c;    /* red-700 */
  --st-blocked-bg: #fbe6e6;
  --st-blocked-bd: #f1b4b4;
  --st-done: #15803d;       /* green-700 */
  --st-done-bg: #e7f3ea;
  --st-done-bd: #b6d8bd;
  --danger: #b91c1c;

  --radius-card: 14px;
  --radius-input: 8px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 6px 18px -10px rgba(28, 25, 23, 0.18);

  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --bg-grain: #100f0c;
    --surface: #1d1b16;
    --surface-2: #221f1a;
    --surface-hover: #2a2722;
    --border: #322e26;
    --border-strong: #423d33;
    --text: #f4f1ea;
    --text-soft: #b5ad9f;
    --text-faint: #807868;
    --accent: #f97316;       /* brighter ember for dark */
    --accent-contrast: #1a1208;
    --accent-soft: #2a1c10;
    --accent-border: #6b3d18;
    --ring: #f97316;

    --st-todo: #c7c0b1;
    --st-todo-bg: #2a2722;
    --st-todo-bd: #3d3830;
    --st-prog: #fbbf24;
    --st-prog-bg: #2e2110;
    --st-prog-bd: #5a3d12;
    --st-blocked: #f87171;
    --st-blocked-bg: #2c1414;
    --st-blocked-bd: #5a2424;
    --st-done: #4ade80;
    --st-done-bg: #112819;
    --st-done-bd: #1d4a2c;
    --danger: #f87171;

    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 16px 36px -18px rgba(0,0,0,0.7);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-contrast); }

/* Focus ring everywhere, visible */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 17px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name b { font-weight: 600; }
.brand-name span { color: var(--text-faint); font-weight: 400; }

.topbar-spacer { flex: 1; }

.summary {
  display: flex;
  gap: 6px;
  align-items: center;
}
.summary-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
}
.summary-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-todo); }
.summary-chip[data-st="in-progress"] .dot { background: var(--st-prog); }
.summary-chip[data-st="blocked"] .dot { background: var(--st-blocked); }
.summary-chip[data-st="done"] .dot { background: var(--st-done); }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(340px, 440px) 1fr;
  gap: 0;
  min-height: 0;
}

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: transparent;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 60px;
  z-index: 5;
}
.toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.input, .select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:hover, .select:hover { border-color: var(--text-faint); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a847b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
.field.count { flex: 0 0 auto; }
.result-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  padding-top: 22px;
}
.result-count b { color: var(--text); font-weight: 600; }

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.task-item {
  display: block;
  padding: 14px 14px 13px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}
.task-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.task-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
  background: var(--surface);
}
.open-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  border-radius: 8px;
}
.open-item:focus-visible { outline-offset: 3px; }

.item-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.item-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  padding-top: 3px;
  flex: none;
}
.item-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
}
.item-item.is-done .item-title { color: var(--text-soft); }

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.item-meta .meta-pair { display: inline-flex; align-items: center; gap: 6px; }
.item-meta .meta-pair svg { width: 14px; height: 14px; color: var(--text-faint); }
.item-meta .due { font-family: var(--font-mono); font-size: 11.5px; }
.item-meta .assignee { color: var(--text-soft); }
.item-tags { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-soft);
  background: var(--bg-grain);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  letter-spacing: 0.01em;
}

.priority {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.priority::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
}
.priority[data-p="high"] { color: var(--danger); }
.priority[data-p="high"]::before { background: var(--danger); }
.priority[data-p="medium"] { color: var(--st-prog); }
.priority[data-p="medium"]::before { background: var(--st-prog); }
.priority[data-p="low"] { color: var(--text-faint); }

/* status pill (shared component, used in list + detail) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 11px 4px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.status-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex: none;
}
.status-pill[data-status="todo"] { color: var(--st-todo); background: var(--st-todo-bg); border-color: var(--st-todo-bd); }
.status-pill[data-status="todo"] .dot { background: var(--st-todo); }
.status-pill[data-status="in-progress"] { color: var(--st-prog); background: var(--st-prog-bg); border-color: var(--st-prog-bd); }
.status-pill[data-status="in-progress"] .dot { background: var(--st-prog); animation: pulse 2.4s ease-in-out infinite; }
.status-pill[data-status="blocked"] { color: var(--st-blocked); background: var(--st-blocked-bg); border-color: var(--st-blocked-bd); }
.status-pill[data-status="blocked"] .dot { background: var(--st-blocked); }
.status-pill[data-status="done"] { color: var(--st-done); background: var(--st-done-bg); border-color: var(--st-done-bd); }
.status-pill[data-status="done"] .dot { background: var(--st-done); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.78); }
}
@media (prefers-reduced-motion: reduce) {
  .status-pill[data-status="in-progress"] .dot { animation: none; }
}

.item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.item-foot .open-hint {
  font-size: 12px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.task-item:hover .open-hint { color: var(--accent); }
.item-foot .open-hint svg { width: 13px; height: 13px; }
.item-foot .comments {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: inline-flex; align-items: center; gap: 5px;
}
.item-foot .comments svg { width: 13px; height: 13px; }

/* ---------- Empty state ---------- */
.empty-state {
  margin: 28px 14px;
  padding: 40px 22px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  color: var(--text-soft);
}
.empty-state .empty-mark {
  width: 54px; height: 54px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-faint);
}
.empty-state .empty-mark svg { width: 26px; height: 26px; }
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}
.empty-state p { margin: 0 0 16px; font-size: 13.5px; }
.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-input);
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease;
}
.btn:active { transform: scale(0.97); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-hover); }

/* ---------- Detail pane ---------- */
.detail-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  overflow: hidden;
}
.detail-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-faint);
  gap: 14px;
}
.detail-placeholder .ph-mark {
  width: 64px; height: 64px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-faint);
}
.detail-placeholder .ph-mark svg { width: 30px; height: 30px; }
.detail-placeholder h2 { font-size: 16px; color: var(--text-soft); margin: 0; font-weight: 600; }
.detail-placeholder p { margin: 0; font-size: 13.5px; max-width: 32ch; }

.detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  animation: detail-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .detail { animation: none; }
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
}
.detail-head .head-main { flex: 1; min-width: 0; }
.detail-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  margin-bottom: 7px;
}
.detail-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 0 0 10px;
  color: var(--text);
}
.detail-head .status-pill { font-size: 12px; }

.close-detail {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}
.close-detail:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.close-detail:active { transform: scale(0.94); }
.close-detail svg { width: 18px; height: 18px; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 22px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.detail-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.detail-body-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  max-width: 64ch;
  white-space: pre-line;
  margin: 0;
}
.detail-body-text p { margin: 0 0 14px; }
.detail-body-text p:last-child { margin-bottom: 0; }
.detail-body-text .outcome-line {
  margin-top: 4px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  line-height: 1.6;
}
.detail-body-text .outcome-line::first-letter {
  /* keep verbatim text; just tint the leading label via color emphasis */
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.fact {
  background: var(--surface-2);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fact .k {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.fact .k svg { width: 13px; height: 13px; }
.fact .v { font-size: 14px; color: var(--text); font-weight: 500; }
.fact .v.mono { font-family: var(--font-mono); font-size: 13px; }
.fact .tags-cell { display: flex; flex-wrap: wrap; gap: 5px; }

/* status control block */
.status-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.status-block-head h3 { margin: 0; }
.status-feedback {
  font-size: 12px;
  color: var(--st-done);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.status-feedback.show { opacity: 1; transform: translateY(0); }
.status-feedback svg { width: 14px; height: 14px; }
.status-control-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.status-control-row .select { flex: 1; }
@media (prefers-reduced-motion: reduce) {
  .status-feedback { transition: none; transform: none; }
}

/* ---------- Mobile: detail becomes a full-screen dialog overlay ---------- */
.backdrop {
  display: none;
}
@media (max-width: 880px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .list-pane {
    border-right: none;
  }
  .detail-pane {
    position: fixed;
    inset: 0;
    z-index: 60;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow);
  }
  .detail-pane.is-open {
    transform: translateX(0);
  }
  .backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(20, 18, 14, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fade 0.2s ease;
  }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .detail-head { padding: 16px 18px 14px; }
  .detail-body { padding: 18px 18px 24px; gap: 22px; }
  .detail-title { font-size: 19px; }
  .facts { grid-template-columns: 1fr; }
}
@media (max-width: 880px) and (prefers-reduced-motion: reduce) {
  .detail-pane { transition: none; }
  .backdrop.is-open { animation: none; }
}

/* ---------- Mobile: topbar / list tweaks ---------- */
@media (max-width: 560px) {
  .topbar { padding: 11px 14px; gap: 10px; }
  .summary { display: none; }
  .brand-name span { display: none; }
  .toolbar { padding: 14px 14px 12px; }
  .task-list { padding: 8px 10px 22px; }
  .item-meta { font-size: 12px; gap: 6px 12px; }
}

.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;
}

/* toast (global status change feedback, used when detail is closed on mobile) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 15px; height: 15px; color: var(--st-done); }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: translateX(-50%); }
}
