/* Docket — a ledger-styled task inbox */

:root {
  --paper: #f2f3f6;
  --surface: #ffffff;
  --surface-hover: #eceefb;
  --ink: #14171c;
  --muted: #5b6270;
  --line: #d8dbe1;
  --line-strong: #8a8f99;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef0fc;
  --accent-light: #a5b4fc;
  --focus: #4338ca;

  --todo-bg: #e4e7ec;
  --todo-ink: #344054;
  --inprogress-bg: #e0e7ff;
  --inprogress-ink: #3730a3;
  --blocked-bg: #fde2e1;
  --blocked-ink: #b42318;
  --done-bg: #dcfce7;
  --done-ink: #15803d;

  --font-display: 'Avenir Next', 'Segoe UI Semibold', 'Helvetica Neue', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip;
}

body.panel-open {
  overflow: hidden;
}

h1,
h2 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  margin: 0;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: top 0.2s var(--ease);
  z-index: 60;
}

.skip-link:focus {
  top: 12px;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ---------- header ---------- */

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 32px;
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-tagline {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

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

.field label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  min-width: 220px;
}

.field-filter select {
  min-width: 170px;
}

@media (hover: hover) and (pointer: fine) {
  .field input:hover,
  .field select:hover {
    border-color: var(--ink);
  }
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- ledger strip ---------- */

.ledger-strip {
  position: relative;
  display: flex;
  background: var(--ink);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ledger-tile {
  flex: 1 0 auto;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px 24px;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  text-align: left;
  min-height: 64px;
  transition: background-color 0.2s var(--ease);
}

.ledger-tile:last-child {
  border-right: 0;
  padding-right: 32px;
}

.ledger-tile--total {
  min-width: 150px;
  background: var(--accent);
}

.ledger-count {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ledger-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.ledger-tile[aria-pressed='true'] {
  background: rgba(255, 255, 255, 0.14);
}

.ledger-tile--total[aria-pressed='true'] {
  background: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent-light);
}

@media (hover: hover) and (pointer: fine) {
  .ledger-tile:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .ledger-tile--total:hover {
    background: #372fb0;
  }
}

.ledger-tile:active {
  transform: scale(0.98);
}

.ledger-tile:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* ---------- main list ---------- */

.task-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}

.list-caption {
  margin: 0 0 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.row-open {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto auto;
  grid-template-areas: 'index main tags status';
  align-items: center;
  column-gap: 20px;
  width: 100%;
  padding: 18px 24px;
  background: var(--surface);
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.18s var(--ease);
}

.row-index {
  grid-area: index;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.row-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-tags {
  grid-area: tags;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  list-style: none;
  white-space: nowrap;
}

.chip--flat {
  background: var(--paper);
  color: var(--muted);
  border: 1px solid var(--line);
}

.row-status {
  grid-area: status;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  justify-self: end;
}

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

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

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

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

@media (hover: hover) and (pointer: fine) {
  .row-open:hover {
    background: var(--surface-hover);
  }

  .row-open:hover .row-title {
    color: var(--accent);
  }
}

.row-open:active {
  background: var(--accent-soft);
}

.row-open:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -3px;
  z-index: 1;
  position: relative;
}

/* ---------- empty state ---------- */

.empty-state {
  margin-top: 24px;
  padding: 40px 32px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  background: var(--surface);
}

.empty-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
}

.empty-body {
  margin: 0 0 20px;
  color: var(--muted);
}

.clear-btn {
  min-height: 44px;
  padding: 10px 22px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.15s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .clear-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
  }
}

.clear-btn:active {
  transform: scale(0.97);
}

.clear-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- footer ---------- */

.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px 48px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- detail panel + backdrop ---------- */

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 28, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s var(--ease);
  z-index: 40;
}

.panel-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: var(--surface);
  border-left: 2px solid var(--ink);
  box-shadow: -24px 0 48px rgba(20, 23, 28, 0.18);
  transform: translateX(24px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease), visibility 0.24s var(--ease);
  z-index: 50;
  overflow-y: auto;
}

.detail-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.detail-scroll {
  padding: 28px 28px 48px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.detail-index {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.close-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .close-btn:hover {
    background: var(--paper);
    border-color: var(--ink);
  }
}

.close-btn:active {
  transform: scale(0.96);
}

.close-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.detail-status-badge {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
}

.detail-title {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 20px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 0 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-meta-item dt {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.detail-meta-item dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}

.detail-body {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  margin-bottom: 16px;
  white-space: pre-line;
}

.detail-comments {
  margin: 0 0 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.status-form {
  padding-top: 20px;
  border-top: 2px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-form label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-form select {
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .status-form select:hover {
    border-color: var(--ink);
  }
}

.status-form select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.status-feedback {
  min-height: 20px;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--done-ink);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .app-header {
    padding: 20px;
  }

  .controls {
    width: 100%;
  }

  .field {
    flex: 1 1 auto;
  }

  .field input,
  .field select {
    min-width: 0;
    width: 100%;
  }

  .task-main {
    padding: 24px 20px 72px;
  }

  .ledger-strip {
    padding-right: 24px;
  }

  .ledger-strip::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to right, rgba(20, 23, 28, 0), rgba(20, 23, 28, 0.85));
    pointer-events: none;
  }

  .ledger-tile {
    min-width: 108px;
  }

  .row-open {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
      'index main'
      'tags tags'
      'status status';
    row-gap: 10px;
    padding: 16px;
  }

  .row-tags {
    justify-content: flex-start;
  }

  .row-status {
    justify-self: start;
  }

  .detail-panel {
    width: 100%;
    border-left: 0;
  }

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

@media (max-width: 420px) {
  .detail-meta {
    grid-template-columns: 1fr;
  }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .detail-panel,
  .panel-backdrop,
  .row-open,
  .ledger-tile,
  .close-btn,
  .clear-btn,
  .skip-link {
    transition: opacity 0.01ms linear !important;
    transform: none !important;
  }
}
