/* Trayline — flat design system, teal primary */
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --color-primary: #0d9488;
  --color-primary-strong: #0f766e;
  --color-primary-soft: #ccfbf1;
  --color-accent: #ea580c;
  --color-background: #f4f7f7;
  --color-foreground: #10221f;
  --color-card: #ffffff;
  --color-muted: #e6ecec;
  --color-muted-foreground: #52605d;
  --color-border: #d3dedb;
  --color-destructive: #dc2626;
  --ring: #0d9488;

  --status-todo-fg: #334155;
  --status-todo-bg: #e7edf3;
  --status-in-progress-fg: #0f766e;
  --status-in-progress-bg: #ccfbf1;
  --status-blocked-fg: #9a3412;
  --status-blocked-bg: #ffedd5;
  --status-done-fg: #166534;
  --status-done-bg: #dcfce7;

  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
  --speed: 180ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-foreground);
  background: var(--color-background);
  min-height: 100vh;
}

/* ---------- Focus & motion ---------- */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-primary-strong);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 50;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Header ---------- */
.app-header {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-heading);
}
.brand-mark {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-primary);
  color: #fff;
}
.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.header-tools {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted-foreground);
  letter-spacing: 0.02em;
}
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted-foreground);
  pointer-events: none;
}
input[type="search"], select {
  font: inherit;
  color: inherit;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 42px;
  transition: border-color var(--speed) ease;
}
input[type="search"] { padding-left: 32px; width: 280px; }
select { min-width: 170px; cursor: pointer; }
input[type="search"]:hover, select:hover { border-color: var(--color-primary); }

/* ---------- List ---------- */
.list-meta {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 28px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.list-heading {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  outline: none;
}
.count { margin: 0; color: var(--color-muted-foreground); font-size: 14px; }

main { max-width: 980px; margin: 0 auto; padding: 8px 28px 48px; }

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.task-row {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "main meta open";
  gap: 12px 16px;
  align-items: center;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.task-row:hover {
  border-color: var(--color-primary);
  box-shadow: 0 1px 0 0 var(--color-primary-soft);
}
.task-main { grid-area: main; min-width: 0; }
.task-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.task-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.task-summary {
  margin: 4px 0 0;
  color: var(--color-muted-foreground);
  font-size: 14px;
  max-width: 62ch;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-meta {
  grid-area: meta;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 13px;
  color: var(--color-muted-foreground);
}
.meta-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.meta-item svg { flex: none; }
.meta-date { font-family: var(--font-mono); font-size: 12.5px; }
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-muted);
  color: var(--color-primary-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.assignee { font-weight: 500; color: var(--color-foreground); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-todo { color: var(--status-todo-fg); background: var(--status-todo-bg); }
.badge-in-progress { color: var(--status-in-progress-fg); background: var(--status-in-progress-bg); }
.badge-blocked { color: var(--status-blocked-fg); background: var(--status-blocked-bg); }
.badge-done { color: var(--status-done-fg); background: var(--status-done-bg); }

.prio { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.prio-high { color: var(--color-accent); }
.prio-medium { color: #a16207; }
.prio-low { color: var(--color-muted-foreground); }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  min-height: 42px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background-color var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}
.btn-secondary {
  background: var(--color-card);
  border-color: var(--color-border);
  color: var(--color-foreground);
}
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary-strong); }
.btn-ghost {
  background: transparent;
  color: var(--color-muted-foreground);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--color-muted); color: var(--color-foreground); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-strong); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.open-btn {
  grid-area: open;
  min-height: 40px;
  padding: 8px 14px;
  background: var(--color-primary-soft);
  color: #0f766e;
}
.open-btn:hover { background: var(--color-primary); color: #fff; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  background: var(--color-card);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  color: var(--color-muted-foreground);
  margin-top: 12px;
}
.empty-state svg { color: var(--color-border); }
.empty-state h2 {
  font-family: var(--font-heading);
  color: var(--color-foreground);
  font-size: 20px;
  margin: 12px 0 4px;
}
.empty-state p { margin: 0 0 20px; }

/* ---------- Detail panel ---------- */
.detail-scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 31, 0.35);
  z-index: 28;
}
.detail {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(520px, 100%);
  background: var(--color-card);
  border-left: 1px solid var(--color-border);
  z-index: 30;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(16, 34, 31, 0.08);
}
.detail-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.detail-body {
  overflow-y: auto;
  padding: 24px 28px 40px;
  flex: 1;
}
.detail-project {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary-strong);
  margin: 0 0 6px;
}
.detail-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 16px;
}
.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.fact dt {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted-foreground);
  margin: 0 0 2px;
}
.fact dd { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.fact dd.tags { flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--color-muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted-foreground);
}
.status-control-wrap { margin-bottom: 24px; }
.status-control-wrap label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted-foreground);
  margin-bottom: 6px;
}
.status-control-wrap select { width: 100%; max-width: 260px; font-weight: 500; }
.status-hint { margin: 8px 0 0; font-size: 13px; color: var(--status-done-fg); min-height: 1.4em; font-weight: 500; }
.detail-body-text { margin: 0; }
.detail-body-text p { margin: 0 0 14px; max-width: 60ch; }
.detail-comments {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted-foreground);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--color-foreground);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) ease, transform var(--speed) ease;
  z-index: 60;
  max-width: min(90vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .app-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .header-tools { flex-direction: column; align-items: stretch; gap: 10px; }
  input[type="search"] { width: 100%; }
  select { width: 100%; }
  .list-meta, main { padding-left: 16px; padding-right: 16px; }

  .task-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "meta"
      "open";
    gap: 10px;
  }
  .task-meta { justify-content: flex-start; }
  .open-btn { justify-content: center; }

  .detail {
    width: 100%;
    border-left: none;
  }
  .close-label { font-weight: 600; }
  .detail-facts { grid-template-columns: 1fr; }
}
