/* Tokens ------------------------------------------------------------ */

:root {
  --fs-s: 12px;
  --fs-m: 14px;
  --fs-l: 18px;

  --bg: #f7f6f2;
  --surface: #fff;
  --sunken: #f0eee8;
  --text: #1c1c1a;
  --text2: #5f5e5a;
  --muted: #8a8982;
  --line: #e2e0d8;
  --line2: #c9c7be;
  --accent: #185fa5;

  --now: #c0392b;
  --next: #d98e04;
  --later: #9a988f;
  --warn: #d98e04;
  --warn-bg: #fbf1da;
  --over: #c0392b;
  --over-bg: #f9e1de;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b19;
    --surface: #242422;
    --sunken: #2c2c29;
    --text: #ecebe6;
    --text2: #b4b2a9;
    --muted: #8a8982;
    --line: #3a3a36;
    --line2: #53524c;
    --accent: #85b7eb;

    --now: #e5685b;
    --next: #e8a62a;
    --later: #77756d;
    --warn: #e8a62a;
    --warn-bg: #3a3020;
    --over: #e5685b;
    --over-bg: #3d2522;
  }
}

/* Base -------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-m) / 1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

h1, h2, h4, p, ul {
  margin: 0;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

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

button,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: var(--line2);
}

:is(button, select, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Small building blocks --------------------------------------------- */

.id {
  font-size: var(--fs-s);
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  font-size: var(--fs-s);
  color: var(--text2);
}

.spacer {
  flex: 1;
}

.fact {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.icon {
  width: 14px;
  height: 14px;
  flex: none;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 3px;
  border-radius: 50%;
}

.dot.now { background: var(--now); }
.dot.next { background: var(--next); }
.dot.later { background: var(--later); }

.note {
  padding: 4px;
  font-size: var(--fs-s);
  color: var(--muted);
}

.note.empty {
  padding: 12px 4px;
  font-size: var(--fs-m);
}

.heading {
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sha {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--sunken);
  color: var(--accent);
  font-size: var(--fs-s);
  text-decoration: none;
}

.sha:hover {
  text-decoration: underline;
}

/* Header and tabs --------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.site-header h1 {
  font-size: var(--fs-l);
  font-weight: 600;
}

.site-header small {
  margin-left: 8px;
  font-size: var(--fs-s);
  font-weight: 400;
  color: var(--muted);
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.bar select {
  margin-bottom: 6px;
}

.tabs {
  display: flex;
  gap: 20px;
}

.tab {
  margin-bottom: -1px;
  padding: 8px 2px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text2);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

/* Board ------------------------------------------------------------- */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.column {
  min-width: 0;
  padding: 10px;
  background: var(--sunken);
  border-radius: 10px;
}

.column.at-limit {
  background: var(--warn-bg);
  outline: 1px solid var(--warn);
}

.column.over-limit {
  background: var(--over-bg);
  outline: 1px solid var(--over);
}

.column h2 {
  display: flex;
  justify-content: space-between;
  margin: 2px 4px 10px;
}

.limit {
  padding: 0 8px;
  border-radius: 10px;
  font-weight: 600;
}

.at-limit .limit {
  background: var(--warn);
  color: #1c1c1a;
}

.over-limit .limit {
  background: var(--over);
  color: #fff;
}

.card {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 9px 11px;
  text-align: left;
}

.card.selected {
  border-color: var(--accent);
}

.card-title {
  margin: 2px 0 8px;
  line-height: 1.35;
}

/* Backlog ----------------------------------------------------------- */

.group {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 20px 0 4px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px 4px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.row:hover {
  background: var(--surface);
}

.row .id {
  width: 64px;
  flex: none;
}

.row-title {
  flex: 1;
  min-width: 0;
}

/* Changelog --------------------------------------------------------- */

.entry {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  width: 100%;
  padding: 14px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.entry-date {
  padding-top: 2px;
  font-size: var(--fs-s);
  color: var(--text2);
}

.entry-title {
  font-weight: 600;
}

.entry p {
  margin: 4px 0 8px;
  color: var(--text2);
}

/* Detail drawer ----------------------------------------------------- */

#detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: min(480px, 100%);
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s 0.2s;
}

#detail.open {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}

#backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  padding: 20px 22px 32px;
}

.panel-top {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.panel h2 {
  margin-top: 2px;
  font-size: var(--fs-l);
  font-weight: 600;
  line-height: 1.3;
}

.panel h4 {
  margin: 20px 0 6px;
}

.panel p + p {
  margin-top: 8px;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 0 4px;
  color: var(--text2);
}

.commits {
  padding: 0;
  list-style: none;
}

.commits li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

/* Responsive and motion --------------------------------------------- */

@media (max-width: 560px) {
  .entry {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .row .id {
    width: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #detail,
  #detail.open,
  #backdrop {
    transition: none;
  }
}
