/*
 * The phone surface (§15).
 *
 * Written in the same tokens as the desk, so it is recognisably the same
 * application, but laid out for one thumb: a tab bar at the bottom where a
 * thumb reaches, a composer that fills the screen above it, and controls no
 * smaller than 44px because anything smaller is a mis-tap waiting to happen.
 *
 * `dvh` rather than `vh`: on a phone the URL bar grows and shrinks, and `vh`
 * measures the tallest state, which puts the send button under the browser
 * chrome exactly when the keyboard is up.
 */

.novely-phone {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100dvh;
  background: var(--novely-bg, #f7f5f0);
  color: var(--novely-ink, #1c1a17);
  font-family: var(--novely-font-ui, system-ui, sans-serif);
}

.novely-phone-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.novely-phone-screen {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1rem 1.5rem;
  /* Clear of the notch at the top and the home indicator at the bottom. */
  padding-top: max(1rem, env(safe-area-inset-top));
}

/* -- capture --------------------------------------------------------------- */

.novely-phone-composer {
  width: 100%;
  min-height: 8rem;
  box-sizing: border-box;
  padding: 0.85rem;
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 0.5rem;
  background: var(--novely-surface, #fffdf8);
  color: inherit;
  /* 16px minimum: anything smaller and iOS zooms the page on focus. */
  font: 400 1rem/1.5 var(--novely-font-book, Georgia, serif);
  resize: none;
}

.novely-phone-composer:focus-visible {
  outline: 2px solid var(--novely-accent, #7a6a4f);
  outline-offset: 1px;
}

.novely-phone-kinds {
  display: flex;
  gap: 0.5rem;
}

.novely-phone-kind {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 999px;
  background: transparent;
  color: var(--novely-ink-muted, #6b6455);
  font: inherit;
}

.novely-phone-kind.is-current {
  background: var(--novely-ink, #1c1a17);
  border-color: var(--novely-ink, #1c1a17);
  color: var(--novely-bg, #f7f5f0);
}

.novely-phone-send {
  min-height: 52px;
  border: 0;
  border-radius: 0.5rem;
  background: var(--novely-ink, #1c1a17);
  color: var(--novely-bg, #f7f5f0);
  font: 500 1.0625rem/1 var(--novely-font-ui, system-ui, sans-serif);
}

.novely-phone-send.is-inline {
  min-height: 44px;
  padding: 0 1rem;
}

.novely-phone-send[disabled] {
  opacity: 0.5;
}

.novely-phone-status {
  margin: 0;
  min-height: 1.25rem;
  color: var(--novely-ink-muted, #6b6455);
  font-size: 0.875rem;
}

/*
 * The queue is not a warning colour. Nothing has gone wrong: the words are
 * written down, they are simply still here. Saying it in red would teach the
 * author to distrust a surface whose whole point is that it can be trusted.
 */
.novely-phone-queue {
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--novely-surface, #fffdf8);
}

.novely-phone-queue-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--novely-ink-muted, #6b6455);
}

.novely-phone-queue-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.5rem;
  font: 400 0.9375rem/1.4 var(--novely-font-book, Georgia, serif);
}

.novely-phone-retry {
  margin-top: 0.75rem;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  font: inherit;
}

.novely-phone-trouble {
  margin: 0;
  color: var(--novely-warn, #8a4b2a);
  font-size: 0.875rem;
}

/* -- chat ------------------------------------------------------------------ */

.novely-phone-transcript {
  display: grid;
  gap: 0.75rem;
}

.novely-phone-turn {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  font: 400 1rem/1.5 var(--novely-font-book, Georgia, serif);
  white-space: pre-wrap;
}

.novely-phone-turn.is-author {
  background: var(--novely-ink, #1c1a17);
  color: var(--novely-bg, #f7f5f0);
  justify-self: end;
  max-width: 85%;
}

.novely-phone-turn.is-editor {
  background: var(--novely-surface, #fffdf8);
  border: 1px solid var(--novely-rule, #ddd8cd);
}

.novely-phone-askrow {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.novely-phone-ask {
  flex: 1;
  box-sizing: border-box;
  padding: 0.65rem;
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 0.5rem;
  background: var(--novely-surface, #fffdf8);
  color: inherit;
  font: 400 1rem/1.4 var(--novely-font-ui, system-ui, sans-serif);
  resize: none;
}

.novely-phone-footnote,
.novely-phone-empty {
  margin: 0;
  color: var(--novely-ink-muted, #6b6455);
  font-size: 0.875rem;
}

/* -- read and notes -------------------------------------------------------- */

.novely-phone-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.novely-phone-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  min-height: 52px;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid var(--novely-rule, #ddd8cd);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
}

.novely-phone-row-title {
  font-size: 1rem;
}

.novely-phone-row-meta {
  color: var(--novely-ink-muted, #6b6455);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.novely-phone-back {
  align-self: flex-start;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--novely-ink-muted, #6b6455);
  font: inherit;
  padding: 0;
}

.novely-phone-chapter-title {
  margin: 0;
  font: 500 1.25rem/1.3 var(--novely-font-book, Georgia, serif);
}

/*
 * The prose, exactly as stored -- comment syntax and all. It is a `div`, not a
 * text field: on this surface there is no element that can take a keystroke.
 */
.novely-phone-prose {
  white-space: pre-wrap;
  font: 400 1.0625rem/1.65 var(--novely-font-book, Georgia, serif);
}

.novely-phone-note {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--novely-rule, #ddd8cd);
}

.novely-phone-note-where {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--novely-ink-muted, #6b6455);
}

.novely-phone-note-body {
  margin: 0 0 0.5rem;
  font: 400 1rem/1.5 var(--novely-font-book, Georgia, serif);
}

.novely-phone-note-actions {
  display: flex;
  gap: 0.5rem;
}

.novely-phone-note-act {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--novely-rule, #ddd8cd);
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  font: inherit;
}

/* -- the tab bar ----------------------------------------------------------- */

.novely-phone-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border-top: 1px solid var(--novely-rule, #ddd8cd);
  background: var(--novely-surface, #fffdf8);
  padding-bottom: env(safe-area-inset-bottom);
}

.novely-phone-tab {
  position: relative;
  min-height: 52px;
  border: 0;
  background: transparent;
  color: var(--novely-ink-muted, #6b6455);
  font: 400 0.8125rem/1 var(--novely-font-ui, system-ui, sans-serif);
}

.novely-phone-tab.is-current {
  color: var(--novely-ink, #1c1a17);
  font-weight: 500;
  box-shadow: inset 0 2px 0 var(--novely-ink, #1c1a17);
}

.novely-phone-badge {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  color: var(--novely-ink-muted, #6b6455);
}

/* Something is written down here and has not reached the desk. */
.novely-phone-dot {
  position: absolute;
  top: 0.6rem;
  right: 50%;
  translate: 1.6rem 0;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--novely-accent, #7a6a4f);
}
