/* Perch - team inbox
   Aesthetic: calm internal product surface. Native CSS, no frameworks.
   Theme tokens: light / dark via [data-theme] with system preference default.
   Shape rule (documented): inputs + buttons 8px, containers 14px, badges pill. */

@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: "Work Sans";
  src: url("assets/work-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: 400 600;
  font-display: swap;
}

:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --text: #1b1d1b;
  --muted: #5c615b;
  --faint: #878d85;
  --line: #dcded8;
  --line-strong: #c3c7bf;

  /* Single brand accent: deep pine. */
  --accent: #1f6f5c;
  --accent-strong: #14513f;
  --accent-soft: #e1efe9;
  --on-accent: #ffffff;

  /* Semantic status system, kept low-saturation. */
  --status-todo-bg: #e7e9e4;
  --status-todo-fg: #4b504a;
  --status-progress-bg: #dbe9f2;
  --status-progress-fg: #24567a;
  --status-blocked-bg: #f6e2d7;
  --status-blocked-fg: #8a3f1e;
  --status-done-bg: #dcecdf;
  --status-done-fg: #2c5f3c;

  --radius-ctl: 8px;
  --radius-card: 14px;
  --radius-pill: 999px;

  --shadow: 0 1px 2px rgba(26, 32, 28, 0.06), 0 10px 30px rgba(26, 32, 28, 0.05);
  --font-ui: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Work Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

[data-theme="dark"] {
  --bg: #141714;
  --surface: #1b1f1c;
  --surface-2: #232823;
  --text: #eceee9;
  --muted: #a6ada4;
  --faint: #7f877e;
  --line: #2e342e;
  --line-strong: #414841;

  --accent: #6fc7ae;
  --accent-strong: #93dcc6;
  --accent-soft: #1e3a31;
  --on-accent: #0f1a16;

  --status-todo-bg: #2a2f2a;
  --status-todo-fg: #c3c8bf;
  --status-progress-bg: #1d2f3d;
  --status-progress-fg: #9cc4e0;
  --status-blocked-bg: #3a261b;
  --status-blocked-fg: #e6b090;
  --status-done-bg: #1f3628;
  --status-done-fg: #9ccfae;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

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

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

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

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-ctl);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.theme-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-label {
  font-size: 12px;
  color: var(--muted);
}
.theme-field select {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
}

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100dvh - 64px);
}

.list-pane {
  padding: 28px clamp(16px, 3vw, 28px) 56px;
  border-right: 1px solid var(--line);
}

.pane-head {
  margin-bottom: 18px;
}
.pane-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}
.pane-sub {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 12px;
  margin-bottom: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.field input,
.field select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 9px 30px 9px 11px;
  width: 100%;
}
.field input {
  padding-right: 11px;
}
.field input::placeholder {
  color: var(--faint);
}
.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task {
  border-top: 1px solid var(--line);
}
.task:first-child {
  border-top: 0;
}
.task-open {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: var(--radius-card);
  padding: 14px 12px;
  margin: 2px 0;
  cursor: pointer;
  transition: background-color 0.16s ease, transform 0.16s ease;
}
.task-open:hover {
  background: var(--surface-2);
}
.task-open:active {
  transform: translateY(1px);
}
.task.is-selected .task-open {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.task-line1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.task-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}
.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}
.avatar {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.meta-project {
  color: var(--text);
  font-weight: 500;
}
.meta-due-late {
  color: var(--status-blocked-fg);
}

/* ---------- Status + priority badges ---------- */
.status-badge,
.priority-badge {
  display: inline-block;
  white-space: nowrap;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  line-height: 1.3;
}
.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);
}
.priority-high,
.priority-medium,
.priority-low {
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: transparent;
}
.priority-high {
  border-color: var(--status-blocked-fg);
  color: var(--status-blocked-fg);
}

/* ---------- Empty state ---------- */
.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  padding: 32px 22px;
  text-align: center;
  background: var(--surface);
}
.empty-title {
  margin: 0 0 6px;
  font-size: 17px;
}
.empty-body {
  margin: 0 auto 18px;
  max-width: 40ch;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-ctl);
  padding: 9px 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.16s ease, transform 0.16s ease,
    border-color 0.16s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-strong);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover {
  background: var(--surface-2);
}

/* ---------- Detail pane ---------- */
.detail-pane {
  padding: 28px clamp(16px, 3vw, 40px) 64px;
  min-width: 0;
}

.detail-placeholder {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--muted);
}
.detail-placeholder h2 {
  font-size: 18px;
  color: var(--text);
  margin: 0 0 6px;
}
.detail-placeholder p {
  margin: 0;
  font-size: 14px;
}

.detail {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 32px);
}
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-top .status-badge {
  font-size: 12px;
  padding: 4px 11px;
}
.close-detail {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.close-detail:hover {
  color: var(--text);
  background: var(--surface-2);
}
.close-detail:active {
  transform: translateY(1px);
}

.detail-title {
  margin: 0 0 18px;
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.2;
  font-weight: 700;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px 20px;
  margin: 0 0 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.meta-grid dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-bottom: 3px;
}
.meta-grid dd {
  margin: 0;
  font-size: 14px;
}

.detail-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 16px;
  margin-bottom: 22px;
}
.status-field {
  flex: 0 0 220px;
}
.status-field select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 9px 30px 9px 11px;
  width: 100%;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.status-field select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.status-feedback {
  flex: 1 1 160px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--accent-strong);
  min-height: 20px;
}
.status-feedback.is-flash {
  animation: feedback-in 0.3s ease;
}
@keyframes feedback-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 22px;
  list-style: none;
  padding: 0;
}
.tag {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.detail-body p {
  margin: 0 0 14px;
  color: var(--text);
  max-width: 68ch;
}
.detail-body .outcome {
  color: var(--muted);
  font-size: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .list-pane {
    border-right: 0;
    padding-bottom: 40px;
  }
  .theme-label {
    display: none;
  }

  .detail-pane {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--bg);
    overflow-y: auto;
    padding: 18px 16px 48px;
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
  }
  body.detail-open .detail-pane {
    transform: translateY(0);
    visibility: visible;
  }
  body.detail-open {
    overflow: hidden;
  }
  .detail {
    border-radius: var(--radius-card);
  }
  .detail-placeholder {
    display: none;
  }
}

@media (max-width: 420px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
  .status-field {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
