/*
 * The editor chat: the collapsed rail, and the panel.
 *
 * Two shapes, one surface. Shut, it is a 44px strip with the word `Editor`
 * running up it and a 6px dot when something arrived -- reachable, and
 * incapable of being in the way. Open, it is a 320-352px panel on the page
 * background, so it reads as part of the room rather than as a window over it.
 *
 * The asymmetry between the two kinds of turn is deliberate: the author's words
 * are bubbled and right-aligned, the editor's are unbubbled prose under a
 * byline. A reading of the book is not a message, and should not arrive looking
 * like one.
 */

/* --- collapsed rail ----------------------------------------------------- */

.novely-chat-rail {
  width: var(--chat-rail-w);
  flex: none;
  border-left: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 12px;
  background: var(--panel);
}

.novely-chat-open {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  border-radius: var(--r-card);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--size-12);
  color: var(--muted-2);
}

.novely-chat-open:hover {
  border-color: var(--border-hover);
}

.novely-chat-rail-label {
  writing-mode: vertical-rl;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--size-10-5);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-6);
  padding: 2px;
}

.novely-chat-rail-label:hover {
  color: var(--text);
}

.novely-chat-rail-gap {
  flex: 1;
}

.novely-chat-unread {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* --- panel -------------------------------------------------------------- */

.novely-chat {
  width: var(--chat-w);
  max-width: var(--chat-w-wide);
  flex: none;
  border-left: 1px solid var(--hairline);
  background: var(--page);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.novely-chat-head {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--hairline);
}

.novely-chat-tab {
  font-family: var(--font-mono);
  font-size: var(--size-10-5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-5);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 0;
}

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

.novely-chat-tab-on {
  color: var(--text);
  font-weight: 500;
}

.novely-chat-head-gap {
  flex: 1;
}

.novely-chat-icon {
  font-family: var(--font-mono);
  font-size: var(--size-13);
  color: var(--muted-4);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px;
}

.novely-chat-icon:hover {
  color: var(--text);
}

/* --- transcript --------------------------------------------------------- */

.novely-chat-transcript {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.novely-chat-gap {
  flex: 1;
}

.novely-turn {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.novely-turn-author {
  align-items: flex-end;
}

.novely-turn-byline {
  font-family: var(--font-mono);
  font-size: var(--size-10);
  color: var(--muted-5);
}

/* The kind travels with the byline, which is where the design puts it. */
.novely-turn-editor .novely-turn-byline::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--border-strong);
}

.novely-bubble {
  margin: 0;
  max-width: 88%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-bubble) var(--r-bubble) 3px var(--r-bubble);
  padding: 9px 12px;
  font-family: var(--font-ui);
  font-size: var(--size-13);
  line-height: var(--leading-ui-prose);
  color: var(--secondary);
}

.novely-turn-prose {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--size-13);
  line-height: 1.62;
  color: var(--secondary);
}

.novely-ref {
  font-family: var(--font-mono);
  font-size: var(--size-12);
  background: var(--row-active);
  padding: 1px 4px;
  border-radius: var(--r-code);
}

.novely-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.novely-chip {
  font-family: var(--font-mono);
  font-size: var(--size-10-5);
  color: var(--muted-2);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-bubble);
  padding: 5px 9px;
  cursor: pointer;
}

.novely-chip:hover {
  border-color: var(--border-hover);
}

/*
 * Nothing to show, and why.
 *
 * One line of muted type where the turns would be. Not an error state and not
 * an illustration: a fresh project has no notes and no key, and both of those
 * are ordinary states of a working installation.
 */
.novely-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.novely-chat-empty-text {
  margin: 0;
  font-size: var(--size-12);
  line-height: var(--leading-ui-prose);
  color: var(--muted-3);
  text-wrap: pretty;
}

.novely-chat-empty-go {
  font-family: var(--font-ui);
  font-size: var(--size-11);
  color: var(--muted-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-button);
  padding: 3px 8px;
  cursor: pointer;
}

.novely-chat-empty-go:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/*
 * Said once, permanently, at the foot of every conversation. It is a promise
 * about what this pane is allowed to do, not a status message.
 */
.novely-chat-footer {
  font-family: var(--font-mono);
  font-size: var(--size-10);
  line-height: 1.5;
  color: var(--muted-6);
}

/* --- composer ----------------------------------------------------------- */

.novely-chat-foot {
  flex: none;
  padding: 12px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.novely-composer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-composer);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.novely-composer:focus-within {
  border-color: var(--border-hover);
}

.novely-chat-input {
  border: 0;
  background: transparent;
  resize: none;
  font-family: var(--font-ui);
  font-size: var(--size-13);
  line-height: 1.4;
  color: var(--secondary);
  field-sizing: content;
  max-height: 140px;
}

.novely-chat-input:focus {
  outline: none;
}

.novely-chat-input::placeholder {
  color: var(--muted-5);
}

.novely-composer-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--size-10);
  color: var(--muted-6);
}

.novely-composer-scope,
.novely-composer-return {
  color: var(--muted-6);
}

/*
 * The editor is reading, said where the answer will be.
 *
 * Unbubbled prose under the ordinary byline, exactly as a real turn is, so
 * that when the answer lands it *replaces* this rather than arriving beside
 * it. The only difference is the colour, which is the same difference the rest
 * of this interface uses for a thing that is not finished yet.
 */
.novely-turn-reading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted-4);
}

/*
 * How long it has been waiting. The one moving thing in this panel, and it
 * appears only after four seconds -- see `waitedLabel`, where the reasoning
 * is. Mono, because it is a number that changes and a proportional face makes
 * a changing number twitch sideways.
 */
.novely-turn-waited {
  font-family: var(--font-mono);
  font-size: var(--size-10);
  color: var(--muted-6);
}

.novely-chat-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.novely-chat-suggestion {
  font-family: var(--font-mono);
  font-size: var(--size-10);
  color: var(--muted-3);
  background: var(--row-active);
  border: 0;
  border-radius: var(--r-popover);
  padding: 4px 8px;
  cursor: pointer;
}

.novely-chat-suggestion:hover {
  color: var(--text);
}

/*
 * A note or a codex line in the panel.
 *
 * Flat, and quieter than a turn: this panel is not the inbox, and a row here
 * that looked like a finding card would be a second place to learn the same
 * vocabulary.
 */
.novely-chat-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  width: 100%;
  padding: 0.5rem 0.25rem;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

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

.novely-chat-row-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.novely-chat-row-text {
  font: 400 var(--size-13) / 1.45 var(--font-ui);
  color: var(--text);
}

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