/* ============================================================
   RELAY — Team Inbox
   Direction: dark "command center" / brutalist
   Fonts: Space Grotesk (display + UI), IBM Plex Mono (data, IDs, meta)
   ============================================================ */

@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 {
  --font-ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Surfaces */
  --bg: #0a0d12;
  --bg-elev: #11151d;
  --bg-elev-2: #161b25;
  --border: #232b38;
  --border-strong: #38445a;
  --hairline: #1a212c;

  /* Text */
  --text: #e6edf3;
  --text-muted: #9aa6b6;
  --text-dim: #7a8699;

  /* Brand / accent */
  --accent: #4f8ff7;
  --accent-soft: rgba(79, 143, 247, 0.14);
  --accent-line: rgba(79, 143, 247, 0.45);

  /* Status */
  --st-todo: #8b98a8;
  --st-todo-bg: rgba(139, 152, 168, 0.12);
  --st-prog: #f0b34d;
  --st-prog-bg: rgba(240, 179, 77, 0.14);
  --st-block: #f26464;
  --st-block-bg: rgba(242, 100, 100, 0.14);
  --st-done: #46cf8a;
  --st-done-bg: rgba(70, 207, 138, 0.14);

  /* Priority */
  --pri-high: #f26464;
  --pri-med: #f0b34d;
  --pri-low: #8b98a8;

  --radius: 0px;
  --radius-soft: 2px;
  --focus: #4f8ff7;

  --sidebar-w: 264px;
  --topbar-h: 132px;
  --maxw: 1440px;

  --shadow-panel: -16px 0 48px rgba(0, 0, 0, 0.55);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
select { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
a { color: var(--accent); }

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

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
:focus { outline-color: var(--focus); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--accent);
  color: #05070a;
  padding: 8px 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* App grid */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  max-width: var(--maxw);
  margin: 0 auto;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 26px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #05070a;
  border: 1px solid var(--accent);
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 18px;
}
.brand-tag {
  margin: -14px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.nav-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 10px;
  font-weight: 500;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms linear, color 120ms linear, border-color 120ms linear;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item[aria-current="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.nav-dot {
  width: 8px; height: 8px;
  flex: none;
  border: 1px solid currentColor;
}
.nav-item[aria-current="true"] .nav-dot { background: currentColor; }
.nav-label { flex: 1; }
.nav-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.nav-item[aria-current="true"] .nav-count { color: var(--text); }

.sidebar-foot { margin-top: auto; font-family: var(--font-mono); font-size: 11px; }
.foot-line { margin: 2px 0; color: var(--text); }
.foot-line.muted { color: var(--text-dim); }

/* ---------------- Topbar ---------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 13, 18, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 20px 28px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "menu title controls"
    "menu controls controls";
  align-items: end;
  gap: 6px 22px;
}
.menu-btn { display: none; }
.topbar-title { grid-area: title; }
.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.topbar-sub {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.controls {
  grid-area: controls;
  display: flex;
  gap: 14px;
  align-items: end;
  justify-content: flex-end;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field-control { position: relative; display: flex; align-items: center; }
.field-icon {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  pointer-events: none;
}
input, select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 120ms linear, background 120ms linear;
}
input:hover, select:hover { border-color: var(--text-dim); }
input:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--accent-line); outline-offset: 0; }
.search-field input { padding-left: 32px; width: 300px; }
.filter-field select { padding-right: 32px; min-width: 180px; cursor: pointer; }
.select-caret {
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: var(--text-muted);
}

/* ---------------- List ---------------- */
.list-wrap { padding: 0 28px 60px; }
.list-head {
  display: grid;
  grid-template-columns: 130px 1fr 150px 170px 110px 44px;
  gap: 16px;
  padding: 14px 14px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.col-open { text-align: right; }

.list { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 130px 1fr 150px 170px 110px 44px;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
  transition: background 120ms linear;
}
.row:hover { background: var(--bg-elev); }
.row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.row[data-status="todo"]::before      { background: var(--st-todo); }
.row[data-status="in-progress"]::before{ background: var(--st-prog); }
.row[data-status="blocked"]::before   { background: var(--st-block); }
.row[data-status="done"]::before      { background: var(--st-done); }

.cell-status { display: flex; align-items: center; gap: 8px; }
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.status-tag .dot { width: 6px; height: 6px; background: currentColor; }
.s-todo  { color: var(--st-todo); background: var(--st-todo-bg); }
.s-in-progress { color: var(--st-prog); background: var(--st-prog-bg); }
.s-blocked { color: var(--st-block); background: var(--st-block-bg); }
.s-done { color: var(--st-done); background: var(--st-done-bg); }

.cell-title { min-width: 0; }
.row-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.row-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: 2px 6px;
}

.cell-project, .cell-assignee, .cell-due {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cell-due { font-family: var(--font-mono); font-size: 12px; }
.cell-due .due-rel { color: var(--text-dim); font-size: 11px; }
.meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 22px; height: 22px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
}
.cell-open { display: flex; justify-content: flex-end; }
.open-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms linear, color 120ms linear, border-color 120ms linear;
}
.open-item:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.row:focus-within { background: var(--bg-elev); }

/* priority marker on title */
.pri {
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid currentColor;
}
.pri-high { color: var(--pri-high); }
.pri-med  { color: var(--pri-med); }
.pri-low  { color: var(--pri-low); }

/* ---------------- Empty state ---------------- */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  margin: 24px 14px;
}
.empty-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.empty-sub { margin: 0 0 18px; color: var(--text-muted); font-size: 14px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #05070a;
  border: 1px solid var(--accent);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 120ms linear, background 120ms linear;
}
.btn:hover { filter: brightness(1.08); }

/* ---------------- Detail dialog ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}
.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  animation: fade 160ms linear;
}
.detail {
  position: relative;
  width: min(620px, 92vw);
  height: 100vh;
  background: var(--bg-elev);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: slide 220ms cubic-bezier(0.16, 0.84, 0.44, 1);
}
.detail[hidden] { display: none; }
.overlay[hidden] { display: none; }

.detail-head {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 2;
}
.detail-head-meta { display: flex; align-items: center; gap: 10px; }
.detail-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.detail-status-tag { /* uses .status-tag */ }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms linear, border-color 120ms linear;
}
.icon-btn:hover { background: var(--bg-elev-2); border-color: var(--text-dim); }
.icon-btn-text { font-size: 13px; font-weight: 600; }

.detail-title {
  margin: 22px 24px 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.detail-summary {
  margin: 0 24px 18px;
  color: var(--text-muted);
  font-size: 15px;
}
.detail-meta {
  margin: 0 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.detail-meta > div { display: flex; flex-direction: column; gap: 3px; }
.detail-meta dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.detail-meta dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}
.detail-meta dd.mono { font-family: var(--font-mono); font-size: 13px; }

.detail-status-row {
  margin: 18px 24px 4px;
  display: grid;
  grid-template-columns: auto 220px;
  grid-template-areas:
    "label label"
    "control feedback";
  gap: 6px 16px;
  align-items: center;
}
.detail-status-row .field-label { grid-area: label; }
.status-control-wrap { grid-area: control; position: relative; }
.status-control-wrap select { padding-right: 32px; cursor: pointer; }
.status-feedback {
  grid-area: feedback;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--st-done);
  opacity: 0;
  transition: opacity 200ms linear;
}
.status-feedback.show { opacity: 1; }

.detail-body { margin: 24px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.detail-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 18px 0 10px;
}
.detail-body-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  z-index: 120;
  opacity: 0;
  transition: opacity 180ms linear, transform 180ms cubic-bezier(0.16,0.84,0.44,1);
  max-width: min(92vw, 460px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ---------------- Animations ---------------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0.4; } to { transform: translateX(0); opacity: 1; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .list-head { grid-template-columns: 120px 1fr 130px 130px 96px 44px; }
  .row { grid-template-columns: 120px 1fr 130px 130px 96px 44px; }
  .search-field input { width: 240px; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 84vw);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.16,0.84,0.44,1);
    box-shadow: var(--shadow-panel);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-area: menu;
    width: 40px; height: 40px;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    color: var(--text);
    cursor: pointer;
  }
  .topbar {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "menu title"
      "controls controls";
    padding: 16px 18px 14px;
  }
  .controls { justify-content: stretch; flex-wrap: wrap; }
  .search-field, .filter-field { flex: 1 1 220px; min-width: 0; }
  .search-field input { width: 100%; }
  .filter-field select { width: 100%; min-width: 0; }

  .list-wrap { padding: 0 14px 60px; }
  .list-head { display: none; }
  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "status open"
      "title title"
      "project assignee"
      "due due";
    gap: 8px 12px;
    padding: 14px 12px;
  }
  .cell-status { grid-area: status; }
  .cell-title  { grid-area: title; }
  .cell-project { grid-area: project; }
  .cell-assignee { grid-area: assignee; justify-self: end; text-align: right; }
  .cell-due { grid-area: due; }
  .cell-open { grid-area: open; }
  .open-item { width: 44px; height: 44px; }

  .detail { width: 100vw; border-left: 0; }
  .detail-meta { grid-template-columns: 1fr; }
  .detail-status-row { grid-template-columns: 1fr; grid-template-areas: "label" "control" "feedback"; }
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 24px; }
  .detail-title { font-size: 22px; margin: 18px 18px 6px; }
  .detail-summary, .detail-meta, .detail-status-row, .detail-body, .detail-head { padding-left: 18px; padding-right: 18px; }
  .detail-meta { margin-left: 18px; margin-right: 18px; }
  .detail-status-row { margin-left: 18px; margin-right: 18px; }
  .detail-body { margin: 18px; }
}

/* Scrim for mobile sidebar */
.scrim-mobile {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(5,7,10,0.55);
  animation: fade 160ms linear;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .detail { animation: none; }
  .overlay-scrim { animation: none; }
}
