/* Relay — Team task inbox
   Design direction: clean productivity SaaS, high legibility, semantic status color,
   neutral surfaces with a single indigo accent. System font stack (no network fonts). */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e3e6ea;
  --color-border-strong: #78828f;

  --color-text: #15171c;
  --color-text-secondary: #4b5563;
  --color-text-muted: #6b7280;

  --color-accent: #4338ca;
  --color-accent-hover: #362fa8;
  --color-accent-contrast: #ffffff;
  --color-accent-tint: #eef0fd;

  --color-danger: #991b1b;
  --color-danger-bg: #fef2f2;

  --status-todo-bg: #f1f5f9;
  --status-todo-text: #334155;
  --status-inprogress-bg: #eff6ff;
  --status-inprogress-text: #1e40af;
  --status-blocked-bg: #fef2f2;
  --status-blocked-text: #991b1b;
  --status-done-bg: #f0fdf4;
  --status-done-text: #166534;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

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

button {
  font: inherit;
  color: inherit;
}

/* Focus visibility: never remove without replacing */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

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

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  flex-shrink: 0;
}

.brand-mark {
  color: var(--color-accent);
  display: inline-flex;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 12px;
  color: var(--color-text-muted);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-search {
  flex: 1 1 260px;
  min-width: 200px;
}

.field-filter {
  flex: 0 0 auto;
  min-width: 180px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3) 0 38px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
}

#search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

#filter-select {
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
  min-width: 180px;
}

/* ---------- Workspace layout ---------- */

.workspace {
  flex: 1;
  display: block;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 860px) {
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
  }
}

.list-pane {
  padding: var(--space-5);
  min-width: 0;
}

.list-pane-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.list-pane-header h1 {
  font-size: 24px;
}

.result-count {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ---------- Task list & items ---------- */

.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.task-list[hidden] {
  display: none;
}

.task-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.task-open {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-4);
  min-height: 44px;
  border-radius: inherit;
}

.task-item:hover,
.task-item:focus-within {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}

.task-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.task-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--color-text-muted);
}

.task-project {
  color: var(--color-text-secondary);
}

.task-side {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: 13px;
  color: var(--color-text-secondary);
  flex-wrap: wrap;
  white-space: nowrap;
}

.task-assignee {
  font-weight: 500;
  color: var(--color-text);
}

.task-due.due-overdue {
  color: var(--color-danger);
  font-weight: 600;
}

/* ---------- Badges & priority ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-todo {
  background: var(--status-todo-bg);
  color: var(--status-todo-text);
}

.status-in-progress {
  background: var(--status-inprogress-bg);
  color: var(--status-inprogress-text);
}

.status-blocked {
  background: var(--status-blocked-bg);
  color: var(--status-blocked-text);
}

.status-done {
  background: var(--status-done-bg);
  color: var(--status-done-text);
}

.badge-overdue {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-high .priority-dot {
  background: #b42318;
}

.priority-medium .priority-dot {
  background: #b45309;
}

.priority-low .priority-dot {
  background: #64748b;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  margin-top: var(--space-3);
}

.empty-state[hidden] {
  display: none;
}

.empty-message {
  font-size: 15px;
  color: var(--color-text-secondary);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.btn-close {
  background: none;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  padding: 0 var(--space-3);
}

.btn-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-close .icon {
  width: 16px;
  height: 16px;
}

/* ---------- Detail pane ---------- */

.detail-pane {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
}

.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  height: 100%;
  min-height: 260px;
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}

.placeholder-icon {
  width: 40px;
  height: 40px;
  color: var(--color-border-strong);
}

.detail {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.detail-toolbar {
  display: flex;
  justify-content: flex-end;
}

.detail-project {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-title {
  font-size: 22px;
  line-height: 1.3;
}

.detail-badges {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
  margin: 0;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.detail-facts dt {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.detail-facts dd {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.tag-list {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tag {
  background: var(--color-accent-tint);
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
}

.status-field select {
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 15px;
  width: 100%;
}

.status-feedback {
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
}

.status-feedback:empty {
  display: none;
}

.detail-body h3 {
  font-size: 14px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-2);
}

.detail-body p {
  font-size: 15px;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.detail-body p:last-child {
  margin-bottom: 0;
}

/* ---------- Responsive: detail pane becomes a full-screen overlay ---------- */

@media (max-width: 859px) {
  .detail-pane {
    display: none;
    border-left: none;
  }

  .detail-pane.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
  }

  .list-pane {
    padding: var(--space-4);
  }

  .topbar-inner {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .toolbar {
    width: 100%;
  }

  .field-search,
  .field-filter {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .detail-pane.is-open {
    animation: relay-slide-in 0.18s ease-out;
  }
}

@keyframes relay-slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
