/* Overrides on top of Pico v2. Pico styles raw <input>/<button>/<form>/etc.;
   this file only handles the bits Pico can't infer: the todo-row layout, the
   project/due chips, and the in-row edit state. */

:root {
  /* Tighter container than Pico's defaults — todo lists read better narrow. */
  --pico-spacing: 0.75rem;
}

main.container { max-width: 760px; }

/* Header: full-width divider, centred content via inner .container. */
.site-header {
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-block: 0.6rem;
  margin-bottom: 1rem;
}
.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-header h1 { font-size: 1.1rem; margin: 0; }
.site-header h1 a { color: inherit; text-decoration: none; }
.site-header form { margin: 0; }

/* "log out" rendered as a quiet inline link, not a Pico button. */
button.link {
  background: none;
  border: none;
  color: var(--pico-muted-color);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin: 0;
  font: inherit;
  width: auto;
}

/* ---------- Controls (top of index page) ---------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.controls form { margin: 0; }

/* New-todo form: stack on mobile, inline at >=600px. */
.controls .new {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
@media (min-width: 600px) {
  .controls .new {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: stretch;
  }
}
/* Pico stretches inputs to 100% width which is exactly what we want here. */
.controls .new input,
.controls .new button { margin: 0; }

.controls .search input { margin: 0; }

.controls .filter {
  display: flex;
  gap: 0.5rem;
}
.controls .filter select {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
}

/* ---------- Todo rows ---------- */

.todos {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

/* Status select: compact, no full-width. */
.todo .status {
  margin: 0;
  flex: 0 0 auto;
}
.todo .status select {
  margin: 0;
  padding: 0.2rem 0.4rem;
  width: auto;
  font-size: 0.85em;
}

/* Title button: looks like text but is clickable to open the edit form. */
.todo .title {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  cursor: pointer;
  padding: 0.25rem 0;
  word-break: break-word;
  margin: 0;
  width: auto;
}
.todo .title:hover { background: var(--pico-secondary-background); }

/* Project chip: compact, accent-coloured. */
.todo .project {
  flex: 0 0 auto;
  font-size: 0.8em;
  color: var(--pico-primary-inverse);
  background: var(--pico-primary);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Due-date chip: muted. */
.todo .due {
  flex: 0 0 auto;
  font-size: 0.8em;
  color: var(--pico-muted-color);
  white-space: nowrap;
}

/* Body wraps to a new line below everything else. */
.todo .body {
  flex: 1 1 100%;
  margin: 0.25rem 0 0;
  color: var(--pico-muted-color);
  font-size: 0.9em;
  white-space: pre-wrap;
}

/* Blocker sections also wrap to their own lines below the body. */
.todo .blockers,
.todo .blocking,
.todo .blocker-reason {
  flex: 1 1 100%;
  margin: 0.15rem 0 0;
  color: var(--pico-muted-color);
  font-size: 0.85em;
}
.todo .blocker-reason { white-space: pre-wrap; font-style: italic; }

/* Status visualisation. */
.todo-done .title {
  color: var(--pico-muted-color);
  text-decoration: line-through;
}
.todo-archived .title {
  color: var(--pico-muted-color);
  font-style: italic;
}

/* Delete button: minimal, hover-red. */
.todo .delete {
  flex: 0 0 auto;
  margin: 0;
  margin-left: auto;
  padding: 0.1rem 0.5rem;
  width: auto;
  background: none;
  border: none;
  color: var(--pico-muted-color);
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
}
.todo .delete:hover { color: var(--pico-color-red-500); }

/* ---------- Edit-mode row ---------- */

.todo.editing {
  display: block;
  padding: 0.75rem 0;
}
.todo.editing form { margin: 0; display: grid; gap: 0.5rem; }
.todo.editing input,
.todo.editing textarea,
.todo.editing select { margin: 0; }
.todo.editing .actions {
  display: flex;
  gap: 0.5rem;
}
.todo.editing .actions button {
  margin: 0;
  width: auto;
}

/* ---------- Empty + load-more rows ---------- */

.empty, .more {
  list-style: none;
  text-align: center;
  color: var(--pico-muted-color);
  padding: 1rem;
}

/* ---------- Login page ---------- */

.login {
  max-width: 320px;
  margin: 4rem auto;
}
.login .error {
  color: var(--pico-color-red-500);
  margin: 0;
}

/* ---------- Site nav ---------- */

.site-nav {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  margin-right: 1rem;
  font-size: 0.9rem;
}
.site-nav a {
  color: var(--pico-muted-color);
  text-decoration: none;
}
.site-nav a:hover { color: var(--pico-color); }

/* ---------- Research backlinks on todo rows ---------- */

.todo .research-backlinks {
  flex: 1 1 100%;
  margin: 0.15rem 0 0;
  color: var(--pico-muted-color);
  font-size: 0.85em;
}

/* ---------- Research index ---------- */

.research-controls .filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.research-controls .filter input { flex: 1 1 auto; margin: 0; }
.research-controls .filter button { margin: 0; width: auto; }

.research-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.research-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.research-item .path {
  flex: 1 1 auto;
  font-family: var(--pico-font-family-monospace);
}
.research-item .version,
.research-item .updated {
  font-size: 0.8em;
  color: var(--pico-muted-color);
}

/* ---------- Research document view ---------- */

.research-doc-header h2 { margin-bottom: 0.25rem; font-family: var(--pico-font-family-monospace); }
.research-doc-header .meta {
  color: var(--pico-muted-color);
  font-size: 0.85em;
  margin-block: 0;
}
.research-doc.historical .research-doc-header { background: var(--pico-secondary-background); padding: 0.75rem; border-radius: 4px; }

.research-doc .research-links {
  background: var(--pico-secondary-background);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-block: 1rem;
  font-size: 0.9em;
}
.research-doc .research-links h3 { font-size: 0.95em; margin: 0 0 0.25rem; }
.research-doc .research-links p { margin-block: 0.25rem; }

.research-doc .research-body {
  margin-block: 1.5rem;
}
.research-doc .research-body pre {
  white-space: pre-wrap;
  word-break: break-word;
}
.research-doc .research-body .language-mermaid {
  background: transparent;
  padding: 0;
}

.research-doc .research-versions {
  margin-top: 2rem;
  border-top: 1px solid var(--pico-muted-border-color);
  padding-top: 1rem;
}
.research-doc .research-versions ul { list-style: none; padding: 0; margin: 0; }
.research-doc .research-versions li {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding-block: 0.25rem;
}
.research-doc .research-versions .ts {
  color: var(--pico-muted-color);
  font-size: 0.85em;
}
.research-doc .research-versions .current {
  color: var(--pico-primary);
  font-size: 0.85em;
}
