/* Cadence — dark ops-console team inbox */

@font-face {
  font-family: 'Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
  font-style: normal;
}

:root {
  --bg: #0b0d10;
  --bg-grid: #101419;
  --surface: #13171d;
  --surface-2: #181d24;
  --surface-3: #1e242d;
  --border: #262d36;
  --border-soft: #1b212a;
  --text: #e7ebf2;
  --text-muted: #9099a6;
  --text-faint: #5b6571;
  --accent: #5eead4;
  --accent-ink: #051815;
  --accent-soft: rgba(94, 234, 212, 0.12);
  --accent-line: rgba(94, 234, 212, 0.32);

  --todo: #7c8aa0;
  --in-progress: #f5a623;
  --blocked: #f87171;
  --done: #4ade80;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 10px 30px rgba(0, 0, 0, 0.45);

  --mono: 'Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;

  --side-w: 248px;
  --detail-w: 540px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

/* faint dotted grid texture, no external image */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 70%);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -44px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

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

/* ---------- App grid ---------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
  max-width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 18px 16px;
  padding-top: max(22px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%), var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.01em;
  color: var(--text);
}
.brand-sub {
  margin: 2px 0 18px 44px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.status-nav { display: flex; flex-direction: column; gap: 2px; }

.status-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.status-chip:hover { background: var(--surface); color: var(--text); }
.status-chip .chip-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
  flex: none;
}
.status-chip .chip-label { flex: 1; }
.status-chip .chip-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  font-size: 12px;
}
.status-chip[aria-current="true"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.status-chip[aria-current="true"] .chip-count { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--done);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 18px;
  padding-top: max(22px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.page-title::after {
  content: "";
  display: inline-block;
  width: 9px; height: 9px; margin-left: 10px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 4px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.search-field { width: min(340px, 46vw); position: relative; }
.search-field input {
  width: 100%;
  padding: 10px 34px 10px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.search-field input::placeholder { color: var(--text-faint); }
.search-icon {
  position: absolute;
  left: 11px; bottom: 10px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 6px; bottom: 6px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.search-clear:hover { background: var(--surface-3); color: var(--text); }

.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 34px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  min-width: 168px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.12s ease;
}
.select-wrap select:hover { border-color: var(--text-faint); }
.select-caret {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ---------- List ---------- */
.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.list-meta b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.task {
  position: relative;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.12s ease, transform 0.12s ease, background-color 0.12s ease;
}
.task::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--task-color, var(--text-faint));
}
.task:hover { border-color: var(--border); background: var(--surface-2); }
.task.is-active { border-color: var(--accent-line); background: var(--surface-2); }

.task-card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 18px 14px 22px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.task-card:hover { background: transparent; }

.task-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--task-color);
  background: color-mix(in srgb, var(--task-color) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--task-color) 32%, transparent);
}
.status-pill .pd {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.priority {
  margin-left: auto;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.priority.high { color: #fca5a5; }
.priority.medium { color: var(--in-progress); }
.priority.low { color: var(--text-faint); }

.task-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0 0 6px;
  text-wrap: balance;
}
.task-summary {
  margin: 0 0 11px;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-faint);
}
.task-foot .meta { display: inline-flex; align-items: center; gap: 6px; }
.task-foot .meta b { color: var(--text-muted); font-weight: 500; }
.task-foot .meta .ico { display: inline-flex; opacity: 0.85; }
.task-foot .spacer { flex: 1; min-width: 0; }
.task-foot .comments {
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 5px;
}
.task-foot .due { font-variant-numeric: tabular-nums; }
.due.overdue { color: var(--blocked); }
.tag {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  background: var(--bg-grid);
}
.chev {
  position: absolute;
  right: 14px; top: 16px;
  color: var(--text-faint);
  transition: transform 0.14s ease, color 0.12s ease;
}
.task:hover .chev { color: var(--accent); transform: translateX(2px); }

/* ---------- Empty / placeholder states ---------- */
.empty {
  display: grid;
  place-content: center;
  text-align: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.01);
}
.empty .e-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.empty .e-sub { font-size: 13px; color: var(--text-faint); }
.empty .reset-btn {
  justify-self: center;
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.empty .reset-btn:hover { background: var(--surface-3); border-color: var(--accent-line); }

/* ---------- Detail pane ---------- */
.detail-pane {
  display: none;
  grid-row: 1;
  border-left: 1px solid var(--border-soft);
  background: var(--bg);
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* desktop: persistent inline panel */
@media (min-width: 1080px) {
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--detail-w); }
  .detail-pane {
    display: flex;
    position: relative;
    overflow: hidden;
  }
}

/* mobile / tablet overlay */
@media (max-width: 1079px) {
  .detail-pane.is-open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--bg);
    border-left: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.detail-head .kicker {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.close-detail {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.close-detail:hover { background: var(--surface-3); border-color: var(--text-faint); }

.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 40px;
}
.detail-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 6px 0 14px;
  text-wrap: balance;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}
.badge .b-ico { color: var(--text-faint); display: inline-flex; }
.badge b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.badge.status-badge {
  color: var(--task-color);
  border-color: color-mix(in srgb, var(--task-color) 38%, var(--border));
  background: color-mix(in srgb, var(--task-color) 12%, var(--surface));
}

.detail-section-label {
  margin: 26px 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.detail-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: #d7dce4;
  white-space: pre-line;
}
.detail-body p { margin: 0 0 14px; }
.detail-body .outcome {
  font-style: italic;
  color: var(--text-muted);
}

.tags-row { display: flex; flex-wrap: wrap; gap: 7px; }

.status-control-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}
.status-control-field .sc-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.status-control-field select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 11px 36px 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.status-control-field select:hover { border-color: var(--text-faint); }
.status-control-field .sc-wrap { position: relative; }
.status-control-field .sc-caret {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.detail-feedback {
  margin-top: 12px;
  min-height: 22px;
  font-size: 12.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* placeholder (desktop, no selection) */
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 40px;
  color: var(--text-faint);
}
.detail-placeholder .ph-mark {
  width: 64px; height: 64px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  display: grid; place-items: center;
  color: var(--text-faint);
}
.detail-placeholder .ph-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-muted);
}
.detail-placeholder .ph-sub { font-size: 13px; max-width: 320px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 80;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--accent-line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 24px);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .t-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---------- Focus states ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.task-card:focus-visible {
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}
.search-field input:focus-visible,
.select-wrap select:focus-visible,
.status-control-field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* ---------- Responsive: collapse sidebar on small screens ---------- */
@media (max-width: 1079px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    grid-row: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 16px 12px;
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .brand-sub { margin-bottom: 12px; }
  .status-nav {
    flex-direction: row;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .status-chip { width: auto; flex: 0 0 auto; }
  .sidebar-foot { display: none; }
  .topbar { padding: 16px 18px 14px; gap: 12px; }
  .page-title { font-size: 22px; }
  .list { padding: 14px 18px 36px; }
  .search-field { width: min(260px, 50vw); }
  .detail-scroll { padding: 18px 20px 36px; }
  .detail-title { font-size: 21px; }
}

@media (max-width: 480px) {
  body { font-size: 14.5px; }
  .controls { width: 100%; }
  .search-field { width: 100%; flex: 1 1 100%; }
  .filter-field { flex: 1 1 100%; }
  .select-wrap select { width: 100%; }
  .page-title { font-size: 20px; }
  .task-card { padding: 13px 16px 13px 18px; }
  .task-title { font-size: 15px; }
  .chev { display: none; }
}

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