/* Waypoint — Team Inbox
   System font stack, no external assets required. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e4e0d6;
  --border-strong: #d3cdbe;
  --text: #1f1c16;
  --text-secondary: #6b6558;
  --text-muted: #8b8577;
  --accent: #1d3f6e;
  --accent-hover: #163055;
  --accent-contrast: #ffffff;
  --focus-ring: #1d3f6e;

  --status-todo-bg: #eceef1;
  --status-todo-fg: #4b5563;
  --status-progress-bg: #dbe6fb;
  --status-progress-fg: #1d4ed8;
  --status-blocked-bg: #fbe1de;
  --status-blocked-fg: #b91c1c;
  --status-done-bg: #dcf1e0;
  --status-done-fg: #157347;

  --priority-high: #c2410c;
  --priority-medium: #a16207;
  --priority-low: #57606a;

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

  --shadow-card: 0 1px 2px rgba(31, 28, 22, 0.06);
  --shadow-panel: -8px 0 32px rgba(31, 28, 22, 0.14);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, ui-sans-serif, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body {
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top 0.15s ease;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus-visible {
  top: 8px;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
}

/* ---------- Layout ---------- */

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 28px 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  color: var(--accent);
  align-self: center;
}

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

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

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

#search {
  width: 260px;
  max-width: 60vw;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}

#search::placeholder {
  color: var(--text-muted);
}

#filter {
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B6558' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 168px;
  cursor: pointer;
}

.main-content {
  padding-top: 20px;
}

.list-meta {
  margin-bottom: 12px;
}

.result-count {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Task list ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  border-radius: var(--radius-md);
}

.task-card {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  align-items: center;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.task-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 10px rgba(31, 28, 22, 0.09);
}

.task-card:active {
  transform: translateY(1px);
}

.task-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 0;
}

.task-meta .dot-sep::before {
  content: "·";
  margin-right: 8px;
  color: var(--text-muted);
}

.task-project {
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.priority-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.priority-high .priority-dot {
  background: var(--priority-high);
}
.priority-medium .priority-dot {
  background: var(--priority-medium);
}
.priority-low .priority-dot {
  background: var(--priority-low);
}

.task-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.assignee-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eee9dd;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-todo {
  background: var(--status-todo-bg);
  color: var(--status-todo-fg);
}
.status-in-progress {
  background: var(--status-progress-bg);
  color: var(--status-progress-fg);
}
.status-blocked {
  background: var(--status-blocked-bg);
  color: var(--status-blocked-fg);
}
.status-done {
  background: var(--status-done-bg);
  color: var(--status-done-fg);
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-state svg {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.empty-body {
  margin: 0 0 8px;
  max-width: 40ch;
}

.btn {
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

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

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Detail dialog ---------- */

.detail-dialog {
  border: none;
  padding: 0;
  margin: 0;
  position: fixed;
  inset: 0 0 0 auto;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(480px, 100vw);
  max-width: 100vw;
  max-height: 100vh;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  overscroll-behavior: contain;
}

.detail-dialog::backdrop {
  background: rgba(24, 21, 15, 0.38);
}

.detail-dialog[open] {
  display: flex;
  animation: slide-in 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .detail-dialog[open] {
    animation: none;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.detail-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.detail-project {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex: none;
}

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

.detail-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  min-height: 0;
}

.detail-title {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-md);
}

.fact {
  min-width: 0;
}

.fact dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.fact dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: break-word;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.status-field {
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.status-field .field-label {
  margin-bottom: 8px;
  display: block;
}

#status-control {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B6558' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.status-feedback {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--status-done-fg);
  min-height: 18px;
}

.detail-body-heading {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.detail-body {
  margin: 0;
  color: var(--text);
  white-space: pre-line;
  overflow-wrap: break-word;
  line-height: 1.6;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .app-shell {
    padding: 0 16px 48px;
  }

  .app-header {
    padding: 18px 0 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  #search {
    width: 100%;
    max-width: none;
  }

  #filter {
    width: 100%;
  }

  .task-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .task-side {
    justify-content: space-between;
  }

  .task-project {
    max-width: 100%;
  }

  .detail-dialog {
    width: 100vw;
  }

  .detail-facts {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 641px) {
  .task-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
