/* Tally — broadsheet-style team inbox. System fonts only; no external resources. */

:root {
  --paper: #f4f1ea;
  --surface: #fbfaf6;
  --ink: #1c1b18;
  --ink-soft: #3a3833;
  --muted: #5b574e;
  --rule: rgba(28, 27, 24, 0.18);
  --focus: #1f4e79;
  --status-todo: #5b574e;
  --status-progress: #1f4e79;
  --status-blocked: #a4281e;
  --status-done: #2e6b3f;

  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 10;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
}

.skip-link:focus-visible {
  left: 12px;
}

/* Masthead */
.masthead {
  background: var(--ink);
  color: var(--paper);
  padding-block: 56px 40px;
}

.masthead-inner,
.workspace,
.colophon {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wordmark {
  margin: 8px 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(88px, 14vw, 200px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
  animation: rise 600ms var(--ease-out) both;
}

.dek {
  max-width: 46ch;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.5;
  color: #bdb7aa;
}

.tally {
  display: flex;
  flex-wrap: wrap;
  margin: 40px 0 0;
  border-top: 1px solid rgba(244, 241, 234, 0.3);
}

.tally > div {
  flex: 1 1 140px;
  padding: 16px 20px 0 0;
  margin-right: 20px;
}

.tally dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #bdb7aa;
}

.tally dd {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 40px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Workspace */
.workspace {
  padding-block: 48px 96px;
}

.index-band {
  border-top: 3px double var(--ink);
  padding-top: 24px;
}

.index-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
}

.section-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.result-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  margin-block: 24px 16px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field input,
.field select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

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

.notice {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--status-blocked);
  background: var(--surface);
}

/* Ledger */
.ledger {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 2px solid var(--ink);
}

.ledger li {
  border-top: 1px solid var(--rule);
}

.open-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  width: 100%;
  min-height: 44px;
  padding: 20px 12px 20px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.open-item:active {
  transform: scale(0.99);
}

.open-item:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.item-num {
  padding-top: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.item-main {
  display: block;
  min-width: 0;
}

.item-title {
  display: block;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.item-meta {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

.item-meta span + span::before {
  content: "·";
  margin: 0 8px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge[data-status="todo"] { color: var(--status-todo); }
.badge[data-status="in-progress"] { color: var(--status-progress); }
.badge[data-status="blocked"] { color: var(--status-blocked); }
.badge[data-status="done"] { color: var(--status-done); }

@media (hover: hover) and (pointer: fine) {
  .open-item:hover {
    background: rgba(28, 27, 24, 0.05);
  }

  .open-item:hover .item-title {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
  }

  .btn-ink:hover {
    background: var(--ink-soft);
  }

  .btn-quiet:hover {
    background: rgba(28, 27, 24, 0.06);
  }
}

/* Buttons */
.btn {
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid var(--ink);
  border-radius: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

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

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

.btn-ink {
  background: var(--ink);
  color: var(--paper);
}

.btn-quiet {
  background: transparent;
  color: var(--ink);
}

/* Empty state */
.empty {
  padding: 48px 0;
  border-top: 1px solid var(--rule);
}

.empty-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
}

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

/* Detail dialog */
.detail {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
}

.detail::backdrop {
  background: rgba(28, 27, 24, 0.55);
}

.detail-sheet {
  padding: 32px;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.detail-title {
  margin: 16px 0 24px;
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
  margin: 0 0 24px;
  border-top: 1px solid var(--rule);
}

.facts > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.facts dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.facts dd {
  margin: 2px 0 0;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 24px;
  margin-bottom: 24px;
}

.status-row .field {
  flex: 0 1 280px;
}

.feedback {
  flex: 1 1 200px;
  min-height: 1.6em;
  margin: 0;
  font-weight: 600;
  color: var(--status-progress);
}

.detail-body {
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.detail-body p {
  max-width: 65ch;
  margin: 0 0 16px;
  font-size: 17px;
  line-height: 1.65;
}

/* Footer */
.colophon {
  padding-block: 32px;
  border-top: 1px solid var(--rule);
}

.colophon p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* Narrow screens */
@media (max-width: 640px) {
  .masthead {
    padding-block: 40px 32px;
  }

  .tally > div {
    flex-basis: 45%;
    margin-right: 0;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .open-item {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
  }

  .open-item .badge {
    grid-column: 2;
    justify-self: start;
  }

  .detail {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
  }

  .detail-sheet {
    padding: 24px 20px 32px;
  }

  .detail-title {
    font-size: 28px;
  }

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark {
    animation: none;
  }

  .open-item,
  .btn {
    transition: background-color 180ms linear;
  }

  .open-item:active,
  .btn:active {
    transform: none;
  }
}
