/*
 * The projects screen (§8): a shelf.
 *
 * A page, not a pane. It was a column of boxes, which read as a form; books are
 * things you recognise by sight and pick up, so they are cards on a grid, and
 * the widest the shelf gets is set by the cards rather than by a measure meant
 * for prose.
 */

.novely-screen-projects {
  overflow-y: auto;
  padding: clamp(1.5rem, 6vh, 4rem) 1.5rem;
}

.novely-screen-projects > * {
  max-width: 62rem;
  margin-inline: auto;
}

.novely-projects-head {
  margin-bottom: 2rem;
}

.novely-projects-title {
  margin: 0 0 0.5rem;
  font: 400 1.5rem/1.2 var(--font-prose);
}

.novely-projects-blurb {
  margin: 0;
  max-width: 38rem;
  color: var(--muted-2);
  font-size: var(--size-13-5);
  line-height: 1.5;
}

/* Back to the book, from the header where the eye already is. */
.novely-projects-back {
  margin-top: 0.75rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted-2);
  font: 400 var(--size-13) / 1 var(--font-ui);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* -- the shelf ------------------------------------------------------------- */

/*
 * Books as cards, most recently opened first, the open one marked rather than
 * moved: a shelf that reorders itself under the eye is one nobody learns the
 * shape of.
 */
.novely-projects-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}

.novely-project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 118px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

/* The one you are in. A left edge rather than a fill: it marks without
   shouting, and the card still reads as a card. */
.novely-project-card.is-current {
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--text);
  background: var(--companion);
}

.novely-project-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 0.9rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

/* The current book is pressable now, so it keeps the pointer. Only a control
   that genuinely does nothing gets the cursor that says so. */
.novely-project-open[disabled] {
  cursor: default;
}

.novely-project-name {
  font: 400 var(--size-14) / 1.3 var(--font-prose);
  color: var(--text);
  /* Two lines, then ellipsis: a long title must not stretch the shelf. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novely-project-when {
  font: 400 var(--size-11) / 1 var(--font-mono);
  color: var(--muted-3);
}

.novely-project-card.is-current .novely-project-when {
  color: var(--muted-1);
}

/* Still listed, and plainly not openable. Dropping the card silently is how
   someone concludes the app lost their book. */
.novely-project-card.is-missing .novely-project-name {
  text-decoration: line-through;
  color: var(--muted-3);
}

.novely-project-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
}

.novely-project-forget,
.novely-project-keep {
  border: 0;
  padding: 2px 6px;
  border-radius: 3px;
  background: transparent;
  color: var(--muted-4);
  font: 400 var(--size-11) / 1 var(--font-mono);
  cursor: pointer;
}

/* Shown on approach, not always: a control that changes the list does not need
   to be the first thing the eye lands on. It stays reachable by keyboard. */
.novely-project-card:hover .novely-project-actions,
.novely-project-actions:focus-within {
  opacity: 1;
}

.novely-project-forget:hover,
.novely-project-keep:hover {
  color: var(--text);
  background: var(--row-hover-strong);
}

/*
 * Asking.
 *
 * The card is taken over by the question -- always visible, not on hover,
 * because a card in the middle of asking something must not be able to hide
 * that by the pointer moving away. Two sentences: what is about to happen, and
 * the one an author actually needs at that moment, which is that the
 * manuscript is not going anywhere.
 */
.novely-project-actions.is-asking {
  position: absolute;
  inset: 0;
  opacity: 1;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 7px;
  padding: 14px;
  border-radius: inherit;
  background: var(--panel);
  overflow: auto;
}

.novely-project-ask {
  color: var(--text);
  font: 400 var(--size-11) / 1.45 var(--font-ui);
}

.novely-project-reassure {
  color: var(--muted-4);
  font: 400 var(--size-10) / 1.45 var(--font-ui);
  overflow-wrap: anywhere;
}

.novely-project-answers {
  display: flex;
  gap: 6px;
}

.novely-project-answers .novely-project-forget,
.novely-project-answers .novely-project-keep {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  font: 400 var(--size-11) / 1 var(--font-ui);
}

.novely-project-forget.is-asking {
  border-color: transparent;
  color: var(--page);
  background: var(--secondary);
}

/* -- starting another ------------------------------------------------------ */

.novely-project-add {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: var(--muted-3);
  font: 300 28px / 1 var(--font-ui);
  cursor: pointer;
}

.novely-project-add:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.novely-project-add.is-open {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border-style: solid;
  cursor: default;
}

.novely-projects-field {
  width: 100%;
  min-height: 32px;
  box-sizing: border-box;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--page);
  color: var(--text);
  font: 400 var(--size-13) / 1 var(--font-ui);
}

.novely-projects-field:focus-visible {
  outline: none;
  border-color: var(--border-hover);
}

.novely-project-begins {
  display: grid;
  gap: 0.35rem;
}

.novely-project-begin {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 400 var(--size-12) / 1 var(--font-ui);
  cursor: pointer;
}

.novely-project-begin.is-primary {
  border-color: transparent;
  background: var(--text);
  color: var(--page);
}

.novely-project-begin[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* -- what happened --------------------------------------------------------- */

.novely-projects-status {
  margin: 1.5rem 0 0;
  color: var(--muted-2);
  font-size: var(--size-13);
}

.novely-projects-trouble {
  margin: 1.5rem 0 0;
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--deletion);
  color: var(--text);
  font-size: var(--size-13);
  line-height: 1.5;
}
