/* ============================================================
   Relay — Team inbox
   Minimal Swiss workspace with a warm paper palette.
   ============================================================ */

/* ---------- Fonts (local, OFL licensed) ---------- */
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-display: "Space Grotesk", "Work Sans", system-ui, sans-serif;
  --font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-3: #f0eee7;
  --ink: #1b1d1b;
  --ink-2: #565954;
  --ink-3: #62675f;
  --line: #e4e1d8;
  --line-strong: #d2cec1;

  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --brand-soft: #e3f1ee;
  --brand-contrast: #ffffff;
  --accent: #b45309;

  --focus: #0f766e;

  --st-todo: #475569;
  --st-todo-bg: #eceff3;
  --st-in-progress: #1d4ed8;
  --st-in-progress-bg: #e7edfd;
  --st-blocked: #b91c1c;
  --st-blocked-bg: #fbe9e7;
  --st-done: #12733a;
  --st-done-bg: #e4f4e8;

  --p-high: #b91c1c;
  --p-high-bg: #fbe9e7;
  --p-medium: #b45309;
  --p-medium-bg: #fbeedb;
  --p-low: #475569;
  --p-low-bg: #eceff3;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(27, 29, 27, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(27, 29, 27, 0.22), 0 2px 6px -2px rgba(27, 29, 27, 0.08);
  --shadow-lg: 0 30px 60px -24px rgba(27, 29, 27, 0.4);

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 220ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131513;
    --surface: #1c1f1d;
    --surface-2: #202321;
    --surface-3: #262a27;
    --ink: #f2f3f0;
    --ink-2: #aeb3ac;
    --ink-3: #838981;
    --line: #2e332f;
    --line-strong: #3d443e;

    --brand: #2dd4bf;
    --brand-strong: #5eead4;
    --brand-soft: #123330;
    --brand-contrast: #06231f;
    --accent: #f59e0b;

    --focus: #2dd4bf;

    --st-todo: #cbd5e1;
    --st-todo-bg: #2b323c;
    --st-in-progress: #bfdbfe;
    --st-in-progress-bg: #1e2b45;
    --st-blocked: #fecaca;
    --st-blocked-bg: #3c2020;
    --st-done: #bbf7d0;
    --st-done-bg: #14301f;

    --p-high: #fecaca;
    --p-high-bg: #3c2020;
    --p-medium: #fcd9a0;
    --p-medium-bg: #3a2c15;
    --p-low: #cbd5e1;
    --p-low-bg: #2b323c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
  }
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  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: fixed;
  top: 10px; left: 10px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: none;
  flex-direction: column;
  gap: 28px;
  padding: 26px 18px 22px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: none;
  color: var(--brand-contrast);
  background: var(--brand);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand__tag {
  font-size: 0.72rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.views { display: flex; flex-direction: column; gap: 8px; }
.views__title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px;
}
.views__list { display: flex; flex-direction: column; gap: 2px; }

.view {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
  color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view:hover { background: var(--surface-3); color: var(--ink); }
.view[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.view__label { flex: 1; }
.view__count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.view[aria-pressed="true"] .view__count { color: var(--brand); }

.view__icon { display: grid; place-items: center; color: var(--ink-3); }
.view[aria-pressed="true"] .view__icon { color: var(--brand); }

.view__dot {
  width: 9px; height: 9px;
  flex: none;
  margin: 0 4px;
  border-radius: 50%;
  background: var(--st-todo);
}
.view__dot[data-status-dot="todo"] { background: var(--st-todo); }
.view__dot[data-status-dot="in-progress"] { background: var(--st-in-progress); }
.view__dot[data-status-dot="blocked"] { background: var(--st-blocked); }
.view__dot[data-status-dot="done"] { background: var(--st-done); }

.sidebar__foot {
  margin-top: auto;
  padding: 0 10px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--ink-3);
}

/* ---------- Workspace ---------- */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__mobile-brand .brand__mark { width: 32px; height: 32px; border-radius: 9px; }
.topbar__mobile-brand .brand__name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field__control {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field__control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.field__control--plain { background: var(--surface); }
.field__icon {
  display: grid;
  place-items: center;
  padding-left: 11px;
  color: var(--ink-3);
  pointer-events: none;
}
.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus,
.field select:focus { outline: none; }

.field input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.field select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237e837c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 17px;
}

/* ---------- Content ---------- */
.content {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 20px 64px;
}
.content:focus { outline: none; }

.content__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.content__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.content__sub {
  margin-top: 5px;
  font-size: 0.85rem;
  color: var(--ink-2);
}

/* ---------- Task list ---------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.task:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.task:has(.task__hit:focus-visible) {
  border-color: var(--brand);
}
.task[data-status="done"] .task__title { color: var(--ink-2); }

.task__hit {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 15px 16px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
  color: inherit;
  transition: background var(--dur) var(--ease);
}
.task__hit:hover { background: var(--surface-2); }
.task__hit:focus-visible { outline-offset: -2px; }

.task__status {
  flex: none;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--st-todo-bg);
  color: var(--st-todo);
}
.task__status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.task[data-status="todo"] .task__status { background: var(--st-todo-bg); color: var(--st-todo); }
.task[data-status="in-progress"] .task__status { background: var(--st-in-progress-bg); color: var(--st-in-progress); }
.task[data-status="blocked"] .task__status { background: var(--st-blocked-bg); color: var(--st-blocked); }
.task[data-status="done"] .task__status { background: var(--st-done-bg); color: var(--st-done); }

.task__main { flex: 1; min-width: 0; }
.task__title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.012em;
  color: var(--ink);
}
.task__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  margin-top: 7px;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.task__meta-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.task__meta-item svg { color: var(--ink-3); flex: none; }
.task__meta-item--nowrap { white-space: nowrap; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.task__side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  padding-left: 4px;
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--p-low-bg);
  color: var(--p-low);
}
.priority::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}
.priority[data-priority="high"] { background: var(--p-high-bg); color: var(--p-high); }
.priority[data-priority="medium"] { background: var(--p-medium-bg); color: var(--p-medium); }
.priority[data-priority="low"] { background: var(--p-low-bg); color: var(--p-low); }

.avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.task__chevron {
  color: var(--ink-3);
  margin-top: 2px;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.task:hover .task__chevron { color: var(--brand); transform: translateX(2px); }

/* Keep the row readable on small phones: priority lives in the detail view. */
@media (max-width: 559px) {
  .task__side .priority { display: none; }
  .task__hit { gap: 11px; }
}

/* ---------- Empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 24px 60px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-3);
}
.empty__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.empty__text {
  margin-top: 6px;
  max-width: 34ch;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.empty .btn { margin-top: 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--brand);
  color: var(--brand-contrast);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--brand-strong); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

/* ---------- Detail drawer ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(18, 20, 15, 0.42);
  background: color-mix(in srgb, #12140f 42%, transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.scrim[data-open="true"] { opacity: 1; }

.detail {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  inset: 0;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.detail[data-open="true"] { opacity: 1; transform: translateY(0); }

.detail__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.detail__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 24px;
  padding: 0 10px 0 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--st-todo-bg);
  color: var(--st-todo);
}
.detail__eyebrow::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.detail__eyebrow[data-status="todo"] { background: var(--st-todo-bg); color: var(--st-todo); }
.detail__eyebrow[data-status="in-progress"] { background: var(--st-in-progress-bg); color: var(--st-in-progress); }
.detail__eyebrow[data-status="blocked"] { background: var(--st-blocked-bg); color: var(--st-blocked); }
.detail__eyebrow[data-status="done"] { background: var(--st-done-bg); color: var(--st-done); }

.detail__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 48px;
  overscroll-behavior: contain;
}
.detail__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.025em;
}

.detail__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-top: 22px;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.fact { min-width: 0; }
.fact__term {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fact__value {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.fact__value .avatar { display: inline-grid; vertical-align: middle; margin-right: 8px; }

.detail__block { margin-top: 26px; }
.detail__heading {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.detail__body {
  white-space: pre-line;
  font-size: 0.97rem;
  line-height: 1.62;
  color: var(--ink);
  max-width: 62ch;
}

.detail__tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.field--status { max-width: 320px; }
.field--status .field__control { border-color: var(--line-strong); }

.detail__feedback {
  margin-top: 10px;
  min-height: 20px;
  font-size: 0.85rem;
  color: var(--brand-strong);
  font-weight: 500;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 80;
  transform: translate(-50%, 14px);
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast[data-open="true"] { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive: tablet / desktop ---------- */
@media (min-width: 720px) {
  .topbar { padding: 20px 32px; }
  .toolbar { grid-template-columns: minmax(0, 1fr) 240px; align-items: end; }
  .content { padding: 30px 32px 80px; }
  .content__title { font-size: 1.9rem; }
  .topbar__mobile-brand { display: none; }
  .task__hit { padding: 17px 18px; }
}

@media (min-width: 960px) {
  .app { grid-template-columns: 264px minmax(0, 1fr); }
  .sidebar { display: flex; }
  .topbar { padding: 22px 40px; }
  .content { padding: 34px 40px 96px; }

  .detail {
    inset: 0 0 0 auto;
    width: min(520px, 46vw);
    transform: translateX(24px);
    border-left: 1px solid var(--line);
    border-top-left-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-lg);
  }
  .detail[data-open="true"] { transform: translateX(0); }
  .detail__scroll { padding: 28px 30px 56px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .task:hover .task__chevron { transform: none; }
}

/* ---------- Forced colors ---------- */
@media (forced-colors: active) {
  .task,
  .field__control,
  .icon-btn,
  .btn { border: 1px solid ButtonBorder; }
}
