/* Handoff - dark ops console */

@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0b0d11;
  --bg-elev: #111419;
  --bg-row: #14171d;
  --bg-row-hover: #181c23;
  --border: #232833;
  --border-soft: #1a1e25;
  --text: #e7e9ed;
  --text-dim: #99a0ac;
  --text-faint: #5b626f;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, 0.14);
  --accent-line: rgba(91, 157, 255, 0.45);

  --s-todo: #99a0ac;
  --s-in-progress: #f0b04a;
  --s-blocked: #f06a6a;
  --s-done: #4ade80;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  --font-sans: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --rail-w: 256px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* Focus visibility */
:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -48px;
  z-index: 80;
  padding: 8px 12px;
  background: var(--accent);
  color: #06101f;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: top 0.18s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Rail ---------- */
.rail {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 26px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #06101f;
  border-radius: 7px;
}
.brand-name {
  font-size: 18px;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-left: 2px;
}

.rail-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 12px;
}

.rail-counts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-count {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
}
.rail-count:hover { background: var(--bg-row); color: var(--text); }
.rail-count[aria-current="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}
.rail-count .dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex: none;
  background: var(--c, var(--text-faint));
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
}
.rail-count .label { flex: 1; }
.rail-count .count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}
.rail-count[aria-current="true"] .count { color: var(--text-dim); }

.rail-foot { margin-top: auto; }
.rail-foot-line { font-size: 12.5px; color: var(--text-dim); margin: 0 0 4px; }
.rail-foot-hint { font-size: 12px; color: var(--text-faint); margin: 0; line-height: 1.45; }

/* ---------- Main ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 28px 32px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.topbar-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.page-title {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 600;
}
.page-sub {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.toolbar {
  display: flex;
  gap: 14px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-soft);
  align-items: flex-end;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-search { flex: 1 1 320px; min-width: 220px; }
.field-filter { width: 200px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  pointer-events: none;
}
input#search {
  width: 100%;
  background: var(--bg-row);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px 10px 34px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.16s ease, background 0.16s ease;
}
input#search::placeholder { color: var(--text-faint); }
input#search:focus { border-color: var(--accent); background: var(--bg-row-hover); outline: none; }

select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-row);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 34px 10px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 5l3 3 3-3' stroke='%2399a0ac' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.16s ease;
}
select:focus { border-color: var(--accent); outline: none; }

/* ---------- List ---------- */
.list-wrap { padding: 8px 32px 48px; }

.list { list-style: none; margin: 0; padding: 0; }

.list-item {
  border-bottom: 1px solid var(--border-soft);
  opacity: 0;
  transform: translateY(6px);
  animation: row-in 0.42s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.list-item:nth-child(1) { animation-delay: 0.02s; }
.list-item:nth-child(2) { animation-delay: 0.05s; }
.list-item:nth-child(3) { animation-delay: 0.08s; }
.list-item:nth-child(4) { animation-delay: 0.11s; }
.list-item:nth-child(5) { animation-delay: 0.14s; }
.list-item:nth-child(6) { animation-delay: 0.17s; }
.list-item:nth-child(7) { animation-delay: 0.20s; }
.list-item:nth-child(n+8) { animation-delay: 0.23s; }

@keyframes row-in {
  to { opacity: 1; transform: none; }
}

.open-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 14px 12px 14px 4px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  border-radius: var(--radius-sm);
  transition: background 0.14s ease;
}
.open-item:hover { background: var(--bg-row); }
.open-item:focus-visible { background: var(--bg-row); outline: none; }
.open-item:active { background: var(--bg-row-hover); }

.row-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--c, var(--text-faint));
  margin-left: 5px;
  flex: none;
}

.row-main { min-width: 0; }
.row-title {
  font-size: 14.5px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-summary {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}
.row-meta .project {
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.row-meta .due { white-space: nowrap; }
.row-meta .due.over { color: var(--s-blocked); }
.row-meta .comments { display: inline-flex; align-items: center; gap: 4px; }

.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: #06101f;
  background: var(--ac, var(--accent));
  letter-spacing: 0.02em;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 64px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-title { font-size: 16px; margin: 0; color: var(--text); }
.empty-body { font-size: 13.5px; color: var(--text-dim); margin: 0 0 8px; max-width: 42ch; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--bg-row);
  color: var(--text);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}
.btn:hover { background: var(--bg-row-hover); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-row);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.icon-btn:hover { background: var(--bg-row-hover); color: var(--text); }

/* ---------- Drawer ---------- */
.detail-root {
  position: fixed;
  inset: 0;
  z-index: 70;
}
.detail-root[hidden] { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 9, 0.6);
  opacity: 0;
  transition: opacity 0.24s ease;
}
.detail-root.is-open .scrim { opacity: 1; }

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(540px, 100%);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.detail-root.is-open .drawer { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.drawer-project {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.drawer-body {
  padding: 22px 26px 40px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.drawer-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}
.drawer-title {
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 10px;
  font-weight: 600;
}
.drawer-summary {
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 0 0 22px;
  line-height: 1.55;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin: 0 0 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.meta-grid dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 4px;
}
.meta-grid dd {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta-grid .meta-tags { flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  letter-spacing: 0.02em;
}

.status-block { margin-bottom: 26px; }
.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.status-row select { flex: 1 1 auto; min-width: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-row);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  flex: none;
}
.status-pill .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-faint)); }

.status-feedback {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--s-done);
  margin: 8px 0 0;
  min-height: 16px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.status-feedback.show { opacity: 1; }

.block-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.body-block { margin-bottom: 24px; }
.body-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-line;
}
.comments-line {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  :root { --rail-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .rail {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
  }
  .rail-nav { flex: 1 1 100%; order: 3; }
  .rail-label { display: none; }
  .rail-counts {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
  }
  .rail-count { width: auto; padding: 6px 10px; white-space: nowrap; }
  .rail-count .count { margin-left: 2px; }
  .rail-foot { display: none; }

  .topbar { padding: 18px 16px 10px; }
  .page-title { font-size: 22px; }
  .toolbar { padding: 12px 16px; gap: 10px; }
  .field-filter { width: 100%; }
  .list-wrap { padding: 4px 14px 40px; }

  .open-item {
    grid-template-columns: 16px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 6px 12px;
    padding: 12px 6px;
  }
  .row-dot { margin-left: 3px; }
  .row-meta {
    grid-column: 2 / -1;
    flex-wrap: wrap;
    gap: 10px 14px;
  }

  .drawer { width: 100%; box-shadow: none; }
  .drawer-body { padding: 18px 18px 36px; }
  .meta-grid { grid-template-columns: 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
  .list-item { opacity: 1; transform: none; }
  .detail-root .scrim { transition: none; }
  .detail-root .drawer { transition: none; }
}
