/* What the window asks of a design by meaning: a place's page, its head and each part the window drew; a chart, an
   address, a value by its type and a status by its tone. Drawn in Signal's own way: a part is a card on the raised ground, a heading in the design's face,
   a value in the words' face with figures that line up, a wait and a failure on the filament. */

/* The page: its head, then each part the window drew, 1.5rem apart; at a desk each part a card on the raised ground. */
.signal-parts-page {
  gap: 1.5rem;
}
.signal-parts-page > .signal-root:not(:has(> .signal-place-head)) > .signal-act-part,
.signal-parts-page > .signal-root:not(:has(> .signal-place-head)) > .signal-act {
  box-sizing: border-box;
  margin: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1.125rem;
  background: var(--raised);
}
.signal-act-part {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}
.signal-act-part > .signal-act {
  margin: 0;
  padding: 0;
}

/* A form's fields in a column, each its label over its control, its press under them. */
.signal-form {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.signal-form-press {
  margin: 0;
}
.signal-object .signal-form-press .signal-action {
  justify-content: center;
  width: 100%;
  min-height: 2.75rem;
}
.signal-object > .signal-told,
.signal-act-part > .signal-told {
  margin: 0;
}
.signal-more {
  margin: 0;
}

/* A record: its fields as terms in a grid, each its label over its value, as many to a row as the card holds. */
.signal-record {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0;
}
.signal-term {
  display: grid;
  align-content: start;
  gap: 0.125rem;
  min-width: 0;
  margin: 0;
}
.signal-term > .signal-shown-text {
  margin: 0;
}

/* A list's rows, ruled inside the card: each its name, its record and the methods offered on it. */
.signal-list-row {
  display: grid;
  gap: 0.625rem;
  padding-block: 0.875rem;
  border-bottom: 1px solid var(--line);
}
.signal-object .signal-list-row > .signal-record {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr));
}
.signal-object > .signal-rows > .signal-list-row:last-child {
  border-bottom: 0;
}
.signal-row-name {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

/* A method offered: a small press of its label, opening its form under the row. */
.signal-nexts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.signal-next {
  min-width: 0;
}
.signal-next[open] {
  flex-basis: 100%;
}
.signal-next > summary {
  width: max-content;
  list-style: none;
  cursor: pointer;
}
.signal-next > summary::-webkit-details-marker {
  display: none;
}
.signal-next[open] > summary {
  margin-bottom: 0.75rem;
  border-color: var(--accent);
  color: var(--accent);
}

/* A value as its type words it: figures that line up, so amounts in a column read as one. */
.signal-value {
  font-variant-numeric: tabular-nums;
}

/* A status by its tone: a pill, its ink and its rim in the tone's colour; neutral is the quiet ink. */
.signal-pill.signal-tone-neutral {
  border-color: var(--line);
  color: var(--muted);
}
.signal-pill.signal-tone-good {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}
.signal-pill.signal-tone-warn {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--signal-line-strong));
  color: color-mix(in srgb, var(--danger) 60%, var(--ink));
}
.signal-pill.signal-tone-bad {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

/* An address: its lines one under another beside the node of a place. */
.signal-address {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}
.signal-address > .signal-sign {
  flex: none;
  margin-top: 0.25rem;
  color: var(--accent);
}
.signal-address-lines {
  margin: 0;
  color: var(--signal-body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.signal-address-label {
  color: var(--ink);
}

/* A chart: the bars on their baseline, the series each its ink, the key under them, the table of the same values in
   its own box, which scrolls where it is wider than its room. */
.signal-chart {
  display: block;
  width: 100%;
  height: 8rem;
  overflow: visible;
}
.signal-chart-base {
  stroke: var(--signal-line-strong);
  stroke-width: 1;
}
.signal-chart-bar {
  fill: var(--accent);
}
.signal-chart-s2 {
  fill: color-mix(in srgb, var(--ink) 60%, transparent);
  background: color-mix(in srgb, var(--ink) 60%, transparent);
}
.signal-chart-s3 {
  fill: var(--signal-filament);
  background: var(--signal-filament);
}
.signal-chart-s4 {
  fill: var(--muted);
  background: var(--muted);
}
.signal-chart-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: var(--text-small);
  list-style: none;
}
.signal-chart-key > li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.signal-chart-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
}
.signal-chart-dot.signal-chart-s1 {
  background: var(--accent);
}
.signal-chart-box {
  max-width: 100%;
  overflow-x: auto;
}
.signal-chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
}
.signal-chart-table :is(th, td) {
  padding: 0.375rem 0.5rem 0.375rem 0;
  border-bottom: 1px solid var(--line);
  text-align: start;
  white-space: nowrap;
}
.signal-chart-table thead th {
  color: var(--muted);
  font-family: var(--signal-font-mono);
  font-size: var(--signal-size-tiny);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.signal-chart-table tbody th {
  color: var(--signal-body);
  font-weight: 500;
}
.signal-chart-table td {
  color: var(--ink);
}

/* What a press handed on: the place's words and the link the home opens on a yes. */
.signal-handoff {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}
.signal-handoff > p {
  margin: 0;
  color: var(--signal-body);
}

/* The place's zone enters: the page of the place stood on rises into place, so a person sees that they stood
   somewhere else. Where motion is reduced it stands at once. */
[data-zone='place'] {
  animation: signal-zone-enter calc(var(--motion) * 2) ease-out both;
}
@keyframes signal-zone-enter {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-zone='place'] {
    animation: none;
  }
}

/* A place in a pocket, met as an app, is the conversation (`_parts.ts` marks its page `signal-talking`). Its parts
   lie as one flow the sheet orders, laid low as a messenger's are, so a short page stands over the foot and the empty
   room under the bar: the talk first, its own box laid as a column reversed, so it opens at its newest saying with no
   scroll of the screen's; then the place's objects, each a card in the talk; then its quick asks, the methods that take
   nothing, small pills in one row; and last the thread's line, the form whose seat says it sends, of one field. The
   quick asks and the line are held at the foot of the screen while the talk is read, one raised band under one rule.
   The order is the sheet's alone: the page keeps its own for a reader that listens. */
.signal-talking {
  --signal-safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --signal-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --signal-talk-line: 4.25rem;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-end;
  gap: 0.75rem 0.5rem;
  box-sizing: border-box;
  /* As tall as the screen leaves under the bar and its rule: the line keeps the home indicator's room itself. */
  min-height: calc(100dvh - 3.75rem - 1px - var(--signal-safe-top));
  padding-top: 0.5rem;
}
.signal-talking > * {
  flex: 1 0 100%;
  order: 1;
  min-width: 0;
  padding-bottom: 0;
}
.signal-talking > .signal-root:has(> .signal-talk) {
  order: 0;
}
.signal-talking .signal-region.signal-talk {
  padding-block: 0;
}
.signal-talking .signal-region.signal-object {
  margin-block: 0;
}

/* Nothing said yet: the place's empty words, quiet in the middle of the talk, with no box around them. */
.signal-talk > .signal-empty {
  justify-items: center;
  border: 0;
  color: var(--muted);
  text-align: center;
}

/* The talk's box: as tall as the screen leaves it under the bar, the quick asks and the line, its newest saying at its
   foot where it opens, the rest read upward. */
.signal-talk-scroll {
  display: flex;
  flex-direction: column-reverse;
  max-height: calc(
    100dvh - 3.75rem - var(--signal-talk-line) - 4.5rem - var(--signal-safe-top) - var(--signal-safe-bottom)
  );
  overflow-y: auto;
  overscroll-behavior: contain;
}
.signal-talk-scroll > .signal-thread {
  padding-block: 0.25rem;
}

/* A quick ask: a pill of 2.25rem as wide as its words, outlined in the text's ink on the raised ground; what it was
   answered is kept for a reader that listens, since the place says it in the talk. */
.signal-talking > .signal-root:has(> .signal-quick) {
  position: sticky;
  bottom: calc(var(--signal-talk-line) + var(--signal-safe-bottom));
  z-index: 2;
  flex: 0 0 auto;
  order: 2;
  max-width: 100%;
  container-type: normal;
  padding-block: 0.25rem;
}
.signal-talking:not(:has(.signal-composer)) {
  padding-bottom: var(--signal-safe-bottom);
}
.signal-talking:not(:has(.signal-composer)) > .signal-root:has(> .signal-quick) {
  bottom: var(--signal-safe-bottom);
}
.signal-parts-page > .signal-root > .signal-act-part.signal-quick {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.signal-quick > .signal-act {
  margin: 0;
}
.signal-quick .signal-action {
  width: auto;
  min-height: 2.25rem;
  padding-inline: 0.875rem;
  border: 1px solid var(--signal-line-strong);
  background: var(--raised);
  box-shadow: none;
  color: var(--ink);
  font-size: var(--text-small);
  font-weight: 600;
}
.signal-quick :is(.signal-act > .signal-help, .signal-told) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* The thread's line: no name and no rule, the field's words inside it, its press a round one beside it whose word is
   kept for a reader that listens and whose sign, an arrow up, is the sheet's own. Its raised ground runs to the glass's
   sides, its words kept in the page's column, and under the home indicator, which it keeps the room of, and up behind
   the quick asks where they stand, drawn by a border's image and taking no room. */
.signal-talking > .signal-root:has(> .signal-composer) {
  position: sticky;
  bottom: 0;
  z-index: 1;
  order: 3;
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50%);
  padding-bottom: var(--signal-safe-bottom);
  border-image: linear-gradient(var(--line) 1px, var(--raised) 0) fill 0 / 0 / 0;
}
.signal-talking:has(.signal-quick) > .signal-root:has(> .signal-composer) {
  border-image-outset: 3.25rem 0 0;
}
.signal-region.signal-composer {
  padding-block: 0.625rem;
  border-top: 0;
}
.signal-composer :is(.signal-part-name, .signal-help, .signal-told, .signal-label) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.signal-composer > .signal-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.signal-composer .signal-field-row {
  flex: 1;
  min-width: 0;
}
.signal-composer .signal-field {
  box-sizing: border-box;
  width: 100%;
  min-height: 3rem;
  padding-inline: 1.125rem;
  border-color: var(--line);
  border-radius: 1.5rem;
  background: var(--surface);
}
.signal-composer .signal-field::placeholder {
  color: var(--muted);
}
.signal-composer .signal-form-press {
  flex: none;
}
.signal-composer .signal-form-press .signal-action {
  justify-content: center;
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
}
.signal-composer .signal-form-press .signal-action::before {
  width: 1.25rem;
  height: 1.25rem;
  background: currentColor;
  content: '';
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 13V3M3.5 7.5 8 3l4.5 4.5' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 13V3M3.5 7.5 8 3l4.5 4.5' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* On a tablet the talk, its objects, the quick asks and the line keep one column in the middle, 42rem, as a phone's. */
@container signal-site (min-width: 46rem) {
  .signal-talking {
    padding-inline: max(var(--signal-gutter), (100% - 42rem) / 2);
  }
}

/* Each card takes the column's width there: a card's own root is its container, so the screen's width decides. */
@media (min-width: 46rem) {
  .signal-talking .signal-region.signal-object {
    justify-self: stretch;
    width: auto;
  }
}
