/* Bonjour Bob — the only screen: the header, the conversation, the sheet to write on.
   Everything Bob shows (a person, a call sheet, a table) is a card inside the conversation. */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- header --- */

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) max(var(--space-4), (100% - var(--width-thread)) / 2 - var(--space-4));
  background: var(--color-bg);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.2;
}

/* The mark: half a sun on the horizon. */
.brand-mark {
  flex: none;
  width: 1.15em;
  height: 0.575em;
  border-radius: 1.15em 1.15em 0 0;
  background: var(--color-mark);
}

/* Good news in the thread (a payment went through): the small sun rises once, next to the title. */
.sun-rise {
  position: relative;
  display: inline-block;
  margin-inline-end: 0.5em;
  transform-origin: 50% 100%;
}

.sun-rise::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--color-mark);
  opacity: 0;
  transform-origin: 50% 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .sun-rise {
    animation: mark-rise 0.9s var(--ease-out) both;
  }

  .sun-rise::after {
    animation: mark-glow 1.6s var(--ease-out) 0.5s both;
  }
}

@keyframes mark-rise {
  from {
    opacity: 0;
    transform: translateY(0.4em) scale(0.6);
  }
}

@keyframes mark-glow {
  from {
    opacity: 0.55;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(2.6);
  }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
}

.badge {
  min-width: 1.5rem;
  padding-inline: 0.375rem;
  border-radius: 0.75rem;
  color: var(--color-bg);
  background: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  line-height: 1.5rem;
  text-align: center;
}

/* --- page --- */

.page {
  width: 100%;
  max-width: calc(var(--width-thread) + 2 * var(--space-4));
  min-width: 0;
  margin-inline: auto;
  padding: var(--space-2) var(--space-4) var(--space-8);
}

/* Something the person must know before reading the rest. One at a time. */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-block-end: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sheet);
  background: var(--color-accent-soft);
}

.banner > .icon {
  color: var(--color-accent);
}

.banner > p {
  flex: 1 1 14rem;
}

.banner.offline {
  color: var(--color-muted);
  background: var(--color-sunken);
}

.thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.day-name {
  margin-block: var(--space-6) var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.day-name::first-letter {
  text-transform: uppercase;
}

/* --- today: the greeting, then the three groups --- */

.today {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding-block: var(--space-4);
}

.greeting {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.suggestion {
  margin-block-start: var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-md);
  text-wrap: pretty;
}

.groups,
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.group > h3 {
  margin-block-end: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-regular);
}

.group-note {
  margin-inline-start: var(--space-2);
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.lines {
  border-radius: var(--radius-sheet);
  background: var(--color-surface);
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 var(--space-4);
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.line + .line {
  border-block-start: 1px solid var(--color-line);
}

.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-3);
  min-width: 0;
}

.button.name {
  font-size: var(--text-md);
}

.company {
  color: var(--color-muted);
}

.reason {
  margin-block-end: var(--space-3);
}

/* Somebody is waiting for an answer: the only line in the warm colour. */
.line-reply .reason {
  color: var(--color-accent);
  font-weight: var(--weight-strong);
}

@media (min-width: 38rem) {
  .line {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    align-items: center;
  }

  .line > .reason {
    max-width: 22rem;
    margin: 0;
    text-align: end;
  }

  .line > .buttons {
    grid-column: 1 / -1;
  }
}

/* Nothing to follow yet. Bob says what to do; the box says where. */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6);
  border: 2px dashed var(--color-control);
  border-radius: var(--radius-bubble);
}

.drop-zone > .icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--color-primary);
}

/* --- messages --- */

.messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  max-width: 100%;
  min-width: 0;
}

.message .text {
  max-width: var(--measure);
  white-space: pre-wrap;
}

/* Bob speaks on the page itself, a size above the rest. */
.message-assistant .text {
  font-size: var(--text-md);
}

/* The person's words are the only bubbles. */
.message-user {
  align-self: flex-end;
  max-width: min(100%, 34rem);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--space-1);
  background: var(--color-bubble);
}

.message-user .stamp {
  align-self: flex-end;
}

/* Bob is writing: three small suns. */
.thinking {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 1.5rem;
}

.thinking .dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-mark);
}

@media (prefers-reduced-motion: no-preference) {
  .thinking .dot {
    animation: beat 1.4s ease-in-out infinite;
  }

  .thinking .beat-2 {
    animation-delay: 160ms;
  }

  .thinking .beat-3 {
    animation-delay: 320ms;
  }
}

@keyframes beat {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: none;
  }

  30% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}

/* --- cards: what Bob lays in the thread --- */

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-sheet);
  background: var(--color-surface);
}

.card > * {
  max-width: 100%;
}

/* Bob proposes, the person decides: always two buttons, the expected answer first. */
.question {
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
}

/* What was just written, and the way back. */
.undo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-regular);
  line-height: var(--leading-snug);
}

.person-card .reason {
  margin: 0;
}

/* The call sheet: who, why now, then what helps during the call. */
.call-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  width: 100%;
}

.blocks {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4) var(--space-6);
  width: 100%;
}

@media (min-width: 38rem) {
  .blocks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.block {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.block h4 {
  color: var(--color-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.block-why {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  background: var(--color-accent-soft);
}

.block-why p {
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
}

.block .source {
  display: block;
}

.after-call {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--color-line);
}

/* A table is never shown by itself: a few rows in the thread, the rest on request. */
.table-scroller {
  position: relative; /* keeps the hidden labels of its cells inside the scroller */
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-control);
  background: var(--color-raised);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: var(--space-3) var(--space-4);
  text-align: start;
  vertical-align: top;
  overflow-wrap: normal;
}

thead th {
  color: var(--color-muted);
  font-weight: var(--weight-strong);
  white-space: nowrap;
}

tbody tr {
  border-block-start: 1px solid var(--color-line);
}

tbody th {
  font-weight: var(--weight-strong);
  white-space: nowrap;
}

td.number {
  text-align: end;
  white-space: nowrap;
}

.total {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* What Bob understood from a file, before anything else happens. */
.report ul {
  padding-inline-start: var(--space-5);
}

/* A long pasted text is somebody else's words: set apart, never mixed with the person's own. */
.pasted {
  width: 100%;
  max-height: 9rem;
  padding: var(--space-3) var(--space-4);
  overflow: auto;
  border-radius: var(--radius-control);
  background: var(--color-sunken);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* --- the sheet: the place to write --- */

.bottom {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: var(--space-2) max(var(--space-4), (100% - var(--width-thread)) / 2) var(--space-4);
  padding-block-end: max(var(--space-4), env(safe-area-inset-bottom));
  background: var(--color-bg);
}

/* Markup: form.composer.paper > label.composer-label + textarea + .attachments + .composer-row.
   The sheet is the lightest thing on the page: nobody has to look for where to write. */
.composer {
  position: relative;
  width: 100%;
  min-width: 0;
  padding: clamp(0.875rem, 2.2vh, 1.25rem) clamp(0.875rem, 2vw, 1.375rem);
  border-radius: var(--radius-bubble);
  background: var(--color-paper);
  color: var(--color-ink);
  box-shadow:
    inset 0 0 0 1.5px var(--color-edge),
    0 1.75rem 4.5rem -1.5rem var(--color-shadow);
  outline: 3px solid transparent;
  outline-offset: 4px;
  text-align: start;
  cursor: text;
}

.composer:hover {
  box-shadow:
    inset 0 0 0 1.5px var(--color-edge),
    0 0 0 2px var(--color-halo),
    0 1.75rem 4.5rem -1.5rem var(--color-shadow);
}

.composer:focus-within {
  outline-color: var(--color-halo);
}

.composer-label {
  display: block;
  font-weight: var(--weight-strong);
  line-height: 1.4;
  letter-spacing: 0.01em;
  cursor: text;
}

.composer textarea {
  width: 100%;
  min-height: 0;
  margin: var(--space-1) 0 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  font-size: clamp(1.125rem, 1rem + 0.45vw, 1.3125rem);
  line-height: 1.5;
  caret-color: var(--color-caret);
  field-sizing: fixed;
  max-height: 6em; /* four lines, then the field scrolls */
  overflow-y: auto;
}

.composer textarea:focus-visible {
  outline: none;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-block-start: clamp(0.5rem, 1.6vh, 0.875rem);
}

.composer-row .button {
  min-height: var(--size-control-large);
  padding-block: 0;
  white-space: nowrap;
}

.send {
  padding-inline: 1.375rem;
}

.send .icon {
  transition: transform var(--duration-base) ease;
}

.send:hover .icon {
  transform: translateX(3px);
}

/* Something to send: the button lights up like the sun. No fade: its label must stay readable. */
.composer.is-ready .send {
  color: var(--color-ink);
  background: var(--color-sun);
  box-shadow: inset 0 0 0 2px var(--color-ink);
}

.composer.is-ready .send:hover {
  background: var(--color-sun-light);
}

/* A file or a pasted text waiting to be sent, and the way to take it back. */
.paste {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-start: 0.625rem;
  padding: 0.375rem 0.375rem 0.375rem var(--space-3);
  border-radius: var(--space-3);
  background: var(--color-sunken);
  font-weight: var(--weight-strong);
}

.paste-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paste .button {
  min-height: 2.75rem;
}

/* A file is being dragged over the page: the whole sheet says where to drop it. */
.drop-veil {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: var(--color-paper);
  box-shadow: inset 0 0 0 3px var(--color-ink);
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.875rem);
  pointer-events: none;
}

.composer.is-dropping {
  outline-color: var(--color-halo);
}

.composer.is-dropping .drop-veil {
  display: flex;
}

/* On a phone the long label gives its place to a short one. */
.narrow-only {
  display: none;
}

@media (max-width: 34rem) {
  .wide-only {
    display: none;
  }

  .narrow-only {
    display: inline;
  }

  .composer textarea {
    max-height: 4.5em;
  }

  .composer-row .button {
    padding-inline: 0.875rem;
  }

  .composer-row .send {
    padding-inline: 1.125rem;
  }
}

/* A short window, or a zoomed one: nothing sticks over the text. */
@media (max-height: 28rem) {
  .top,
  .bottom {
    position: static;
  }
}

@media (forced-colors: active) {
  .composer,
  .card,
  .lines {
    border: 2px solid CanvasText;
  }

  .button {
    border: 2px solid ButtonText;
  }
}

@media print {
  .top,
  .bottom,
  .buttons {
    display: none;
  }
}
