/* Faked edits, fake for the demo. A card's pencil sits in its heading row and opens the card's
   form in place of its values; a document's value has a small pencil opening a form below it. A
   corrected value shows who changed it and a link restoring what Lextant read. Built on
   product.css's variables. */

/* A card's pencil and its form in place. */

.editable {
  position: relative;
}

.card-edit > summary {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
}

.card-edit > summary::-webkit-details-marker,
.edit > summary::-webkit-details-marker {
  display: none;
}

.card-edit > summary:hover,
.card-edit[open] > summary {
  background: var(--hover);
  color: var(--ink);
}

.editable > .card-head {
  padding-right: 36px;
}

.editable:has(> .card-edit[open]) > .card-view {
  display: none;
}

.card-form {
  display: grid;
  gap: 14px;
  max-width: 820px;
  margin: 4px 0 6px;
}

.form-field {
  display: grid;
  gap: 5px;
}

.form-field label,
.edit-form label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.form-field textarea,
.form-field input[type="text"],
.form-field select,
.edit-form textarea,
.edit-form input[type="text"] {
  width: 100%;
  font-size: 14px;
  line-height: 1.5;
}

.form-field select {
  max-width: 22rem;
}

.form-field textarea {
  resize: vertical;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.edit-actions button {
  padding: 6px 13px;
}

/* Who changed a value, and the link restoring what Lextant read. */

.edited-line,
.facts .edited-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 4px 0 0;
}

.edited-line:empty,
.facts .edited-line:empty {
  display: none;
}

.edited-by {
  display: inline-flex;
  width: fit-content;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.restore {
  display: inline;
  margin: 0;
}

.restore .link-button {
  padding: 0;
  font-size: 12px;
}

.edit-done {
  color: var(--ok);
  font-size: 12px;
  font-weight: 600;
}

/* A document's value: its pencil, quiet until the value is pointed at, opens a small form. */

.edit-slot {
  position: relative;
  display: block;
}

.facts .edit-slot {
  display: block;
}

.edit-target[data-edit] {
  cursor: text;
  border-radius: 4px;
  transition: background-color 0.12s;
}

.edit-slot:hover > .edit-target[data-edit] {
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--panel);
}

/* A corrected value reads as any other; the chip below it says who changed it. */

.edited-value {
  white-space: pre-line;
}

.edit {
  display: inline-block;
  vertical-align: -2px;
}

.edit > summary {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 22px;
  margin-left: 2px;
  border-radius: 6px;
  color: #9aa39f;
  cursor: pointer;
  list-style: none;
}

.edit-slot:hover .edit > summary,
.edit > summary:focus-visible,
.edit[open] > summary {
  color: var(--ink-soft);
}

.edit > summary:hover,
.edit[open] > summary {
  background: var(--hover);
  color: var(--ink);
}

.edit-form {
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 6px);
  display: grid;
  gap: 8px;
  width: min(30rem, calc(100vw - 48px));
  padding: 14px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(22 32 28 / 12%), 0 1px 2px rgb(22 32 28 / 6%);
  font-size: 13.5px;
  font-weight: 400;
}

.edit-choice {
  display: inline-block;
  margin-left: 6px;
}

.edit-choice button {
  padding: 2px 9px;
  border-color: var(--edge);
  font-size: 12px;
  font-weight: 500;
}

.edit-choice + .edited-by {
  margin-left: 6px;
}
