/* The session window, styled as a chat. Plan:
   1. warm background; three columns: the face, the chat, the role card
   2. top of the chat: who is talking (the name) and, on the right, "talk to a human", always visible
   3. middle: messages, one under another, styled like typed messages
   4. before each message: three dots, as if someone is typing
   5. bottom: one quiet control at a time ("Next", then yes / no, then the input field)
   6. right: the role card; it appears when the persona mentions it
   7. if the person has turned animation off: nothing moves */

/* 1. Background and text */
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.5;
}

/* An element with the "hidden" attribute is never shown.
   Without this rule, "display: flex" below would win over "hidden". */
[hidden] {
  display: none !important;
}

/* Three columns: the face, the chat, the role card.
   The window is exactly one screen high.
   grid-template-areas is a small map of the window: each word is a place. */
.session {
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.2fr) 260px;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "face chat card";
  gap: var(--space-10);
}

/* The face: a large sand plate. The animated face must be easy to see,
   so the plate takes the whole width of its column.
   align-items: center puts the plate in the middle of the column's height,
   at eye level, not in the top corner.
   aspect-ratio: 3 / 4 keeps the shape of a portrait: 3 wide, 4 high.
   max-height: never higher than the screen. */
.face-column {
  grid-area: face;
  display: flex;
  align-items: center;
}

.face {
  position: relative; /* the sound wave stands on the plate */
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: calc(100vh - 2 * var(--space-6));
  background: var(--sand);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* The placeholder drawing fills the plate */
.face-figure {
  display: block;
  width: 100%;
  height: 100%;
}

/* #D9B8A6 is a placeholder skin colour; it is not a token of the design system */
.face-head {
  fill: #D9B8A6;
}

.face-neck {
  fill: var(--ink);
}

.face-shoulders {
  fill: var(--teal); /* the teal uniform (decision of 2 Dec 2026) */
}

/* The seven placeholder expressions: one group per emotion in the SVG, only the current one shows.
   .face[data-face] is set by session.js from the server's choice. Placeholders until the drawings. */
.mood {
  display: none;
}

.face[data-face="neutral"] .mood-neutral,
.face[data-face="attentive"] .mood-attentive,
.face[data-face="empathic"] .mood-empathic,
.face[data-face="concerned"] .mood-concerned,
.face[data-face="thoughtful"] .mood-thoughtful,
.face[data-face="warm"] .mood-warm,
.face[data-face="thinking"] .mood-thinking {
  display: inline;
}

.mood .brow,
.mood .mouth,
.mood .eye-arc {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
}

.mood .eye {
  fill: var(--ink);
}

.mood .dot {
  fill: var(--ink);
  opacity: 0.35;
}

/* The chat column: top, middle, bottom */
.chat {
  grid-area: chat;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 2. Who is talking */
.persona {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) 0 var(--space-4);
  border-bottom: 1px solid var(--line);
}

.persona-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
}

/* The line under the name: always visible, so nobody forgets who is talking */
.persona-kind {
  margin: 0;
  font-size: 15px;
  color: var(--ink-muted);
}

/* 3. The messages. This part takes all the free height and scrolls. */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-6) 0;
}

/* The shape of a typed message: a light card with one sharper corner */
.bubble {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}

.message {
  margin: 0;
  max-width: 90%;
  padding: var(--space-4) var(--space-6);
  box-sizing: border-box;
  /* A very long word (or a link) with no spaces breaks onto the next line
     instead of running out of the bubble */
  overflow-wrap: anywhere;
  animation: appear 0.6s ease;
}

/* The participant's own message: on the right, berry, the sharper corner on the other side */
.message.mine {
  align-self: flex-end;
  background: var(--berry);
  border-color: var(--berry);
  color: var(--on-berry);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
  white-space: pre-wrap; /* keep the line breaks the person typed */
}

/* A line from the page itself (for example "something went wrong"):
   no bubble, in the middle, so nobody takes it for the persona's words */
.notice {
  align-self: center;
  margin: 0;
  max-width: 30em;
  text-align: center;
  font-size: 16px;
  color: var(--berry);
}

/* Information and consent: a plate across the chat, before anything else */
.consent {
  align-self: stretch;
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-top: 8px solid var(--turquoise);
  border-radius: var(--radius-lg);
}

.consent-title {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: 22px;
}

.consent-placeholder {
  color: var(--ink-muted);
  font-style: italic;
}

/* The consent form: a long text in the plate, headings for its parts */
.consent-text {
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.consent-text h3 {
  margin: 0 0 var(--space-4);
  font-size: 18px;
}

.consent-text h4 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.consent-text p,
.consent-text li {
  font-size: 16px;
}

.consent-text ul {
  padding-left: 1.4em;
}

.consent-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* The questionnaire after a session: the same plate as the consent screen */
.questionnaire {
  align-self: stretch;
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-top: 8px solid var(--turquoise);
  border-radius: var(--radius-lg);
}

.q-part {
  margin: var(--space-6) 0 0;
  padding: 0;
  border: 0;
}

.q-lead {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
}

/* "1 = Disagree strongly    7 = Agree strongly" over the buttons */
.q-scale {
  margin: 0 0 var(--space-2);
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--ink-muted);
}

.q-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--line);
}

.q-row-label {
  font-size: 16px;
}

/* Seven round choices; the number stays readable inside */
.q-choices {
  display: flex;
  gap: 6px;
}

.q-choice {
  position: relative;
}

.q-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.q-choice span {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink-muted);
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}

.q-choice input:checked + span {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--sand);
  font-weight: 500;
}

.q-choice input:focus-visible + span {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* A row left empty after "Send": a berry edge, words say why */
.q-row.q-missing .q-row-label {
  color: var(--berry);
}

/* CARE: the short instruction under the lead, the explanation under each item, and word choices
   (Poor … Excellent, Does not apply) as pills instead of numbered circles */
.q-note {
  margin: 0 0 var(--space-2);
  font-size: 14px;
  color: var(--ink-muted);
}

.q-row-hint {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-muted);
}

.q-row-words {
  grid-template-columns: minmax(0, 1fr);
}

.q-row-words .q-choices {
  flex-wrap: wrap;
}

.q-row-words .q-choice span {
  width: auto;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  font-size: 14px;
}

.q-choice-na span {
  border-style: dashed;
}

/* RoSAS has nine choices: a little smaller, so the row still fits next to the word */
.q-rosas .q-choice span {
  width: 30px;
  height: 30px;
  font-size: 14px;
}

.q-open-text {
  width: 100%;
  resize: vertical;
}

.q-message {
  min-height: 1.5em;
  color: var(--berry);
}

.q-send {
  margin-top: var(--space-2);
}

/* The pause: a light plate with a teal edge across the chat. It is lighter than the stop
   message on purpose: a pause can be undone, a stop cannot. */
.pause-message {
  align-self: stretch;
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--teal);
  border-left-width: 4px;
  border-radius: var(--radius-lg);
  animation: appear 0.6s ease;
}

.pause-message p {
  margin: 0 0 var(--space-2);
}

.pause-message .continue {
  margin-top: var(--space-2);
}

/* Inside the button the name is plain text, not the coloured key word */
.continue .persona-name {
  font: inherit;
  color: inherit;
}

/* The stop message: a calm teal plate across the chat, clearly not a bubble of the persona */
.stop-message {
  align-self: stretch;
  padding: var(--space-6);
  background: var(--teal);
  color: var(--sand);
  border-radius: var(--radius-lg);
  animation: appear 0.6s ease;
}

.stop-message p {
  margin: 0 0 var(--space-2);
}

.stop-message p:last-child {
  margin-bottom: 0;
}

/* A message written by a team member: a bubble with a teal edge and a small label on top */
.message.from-team {
  border-color: var(--teal);
  border-left-width: 4px;
}

.team-label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

/* A line about the team (for example after "Talk to a human"): calm teal, not alarm red */
.notice-team {
  color: var(--teal);
  font-weight: 500;
}

/* The persona's replies can have several paragraphs: keep their line breaks */
.message {
  white-space: pre-wrap;
}

/* The persona's name inside a message: the one key word in italic colour */
.persona-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  color: var(--accent-text);
}

/* 4. The typing dots */
.typing {
  display: inline-flex;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
}

.typing span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typing-dot 1.2s ease-in-out infinite;
}

/* Each dot starts a little later than the one before: a wave */
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-4px); }
}

/* 5. The bottom. The controls row keeps its height, so nothing jumps. */
.bottom {
  border-top: 1px solid var(--line);
  padding: var(--space-4) 0 var(--space-6);
}

.controls {
  min-height: 52px;
  display: flex;
  align-items: center;
}

.choice {
  display: flex;
  gap: var(--space-4);
}

/* A quiet button: no fill, muted text, a thin border.
   "Да, начнём" and "Нет" look the same on purpose: neither answer is pushed. */
.quiet-button {
  padding: var(--space-2) var(--space-6);
  border: 1px solid var(--ink-muted);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.5;
  cursor: pointer;
  animation: appear 0.6s ease;
}

.quiet-button:hover,
.quiet-button:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
}

.input-row {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  animation: appear 0.6s ease;
}

/* The microphone (voice participants): a quiet button; while it records, berry with a pulsing dot */
.mic[data-state="recording"] {
  background: var(--berry);
  border-color: var(--berry);
  color: var(--sand);
}

.mic[data-state="recording"]::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--sand);
  vertical-align: middle;
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* .controls is a row: the hint takes a line of its own under the input row */
.controls {
  flex-wrap: wrap;
}

.mic-hint {
  flex-basis: 100%;
  margin: var(--space-2) 0 0;
  font-size: 14px;
  color: var(--ink-muted);
}

/* The hint only with the input row (not during the welcome or after the end) */
.input-row[hidden] + .mic-hint {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .mic[data-state="recording"]::before {
    animation: none;
  }
}

/* Locked while the persona is "typing" */
.input:disabled,
.quiet-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.input {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  box-sizing: border-box;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--ink-muted);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.5;
  resize: none;
}

/* The two buttons on the right of the top row.
   margin-left: auto pushes the pair to the right end of the row. */
.persona-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

/* The question after "End conversation", in the place of the input field */
.end-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  animation: appear 0.6s ease;
}

.end-question {
  margin: 0;
}

/* The end: two calm lines in the place of the input field */
.ended {
  animation: appear 0.6s ease;
}

.ended-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
}

.ended-text {
  margin: 0;
  color: var(--ink-muted);
}

/* "Talk to a human": in the top row, to the right of the name.
   Always there, bright, and far from "Next" and "Send",
   so nobody presses it by mistake. */
.human {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--teal);
  border-radius: var(--radius-md);
  background: var(--teal);
  color: var(--sand);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  cursor: pointer;
}

.human:hover {
  opacity: 0.9;
}

/* A clear ring for people who use the keyboard */
.quiet-button:focus-visible,
.input:focus-visible,
.human:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

/* 6. The role card */
.card-column {
  grid-area: card;
  min-height: 0;
  overflow-y: auto;
}

.card {
  margin: var(--space-6) 0;
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-top: 8px solid var(--turquoise);
  border-radius: var(--radius-lg);
  font-size: 16px;
  animation: appear 0.6s ease;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* The fields of the card: a small label, then its text */
.card-fields {
  margin: 0;
}

.card-fields dt {
  margin-top: var(--space-4);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-muted);
}

.card-fields dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

@keyframes appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* A narrow window: a new map. The face and the card stand side by side
   on top, both smaller; the chat takes the whole width under them. */
@media (max-width: 1180px) {
  .session {
    grid-template-columns: 160px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "face card"
      "chat chat";
    column-gap: var(--space-4);
    row-gap: 0;
  }

  .face-column {
    align-items: flex-start;
    padding-top: var(--space-6);
  }

  .face {
    height: 160px;
    aspect-ratio: auto;
  }

  .card-column {
    max-height: 184px;
  }
}

/* 7. Animation turned off in the system: nothing moves */
@media (prefers-reduced-motion: reduce) {
  .message,
  .quiet-button,
  .input-row,
  .card,
  .typing span {
    animation: none;
  }

  .typing span {
    opacity: 0.6;
  }
}

/* --- 8. In the mood of the public pages (27 Nov): round buttons, soft messages and cards,
   small labels in the text font. The layout above (face, chat, card; one screen high) stays. --- */

/* The persona's name larger; the line under it a small label */
.persona-title {
  font-size: 30px;
}

.persona-kind {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* The persona's messages: soft, without a frame, like the front page's cards */
.bubble {
  background: var(--surface-soft);
  border-color: transparent;
  border-radius: 20px 20px 20px 6px;
}

.message.mine {
  border-radius: 20px 20px 6px 20px;
}

/* Round buttons */
.quiet-button,
.human {
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 16px;
}

.quiet-button {
  border-color: var(--line);
  background: var(--surface-raised);
  color: var(--ink);
}

.quiet-button:hover,
.quiet-button:focus-visible {
  border-color: var(--ink-muted);
}

/* The field where one writes: rounder, with a quiet frame */
.input {
  border-color: var(--line);
  border-radius: 22px;
  padding: 10px 18px;
}

/* The role card (and the client card of GENERATE): like an item of the CTRS form on the rating page:
   white, a thin frame, a teal band down the left edge */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-left: 6px solid var(--teal);
  border-radius: var(--radius-md);
}

.eyebrow {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.1em;
}

/* The consent screen and the questionnaire: white plates with a thin frame, without the coloured top edge */
.consent,
.questionnaire {
  border-top: 1px solid var(--line);
}

/* --- 9. The card's width can be changed (js/columns.js), the card stays inside the window (27 Nov) --- */

/* A wide window: the face keeps its width; between the chat and the card stands a thin grip */
@media (min-width: 1181px) {
  .session {
    grid-template-columns: min(32vw, 460px) minmax(360px, 1fr) 12px var(--card-width, 300px);
    grid-template-areas: "face chat grip card";
    column-gap: var(--space-6);
  }
}

.grip {
  grid-area: grip;
  position: relative;
  cursor: col-resize;
  touch-action: none;
}

/* The grip is a thin line with a small handle in the middle; teal when it is touched */
.grip::before {
  content: "";
  position: absolute;
  top: var(--space-6);
  bottom: var(--space-6);
  left: 5px;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}

.grip::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 8px;
  height: 44px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--line);
}

.grip:hover::before,
.grip:hover::after,
.grip:focus-visible::before,
.grip:focus-visible::after,
.resizing .grip::before,
.resizing .grip::after {
  background: var(--teal);
}

.grip:focus-visible {
  outline: none;
}

/* While the grip is dragged, no text gets selected */
.resizing {
  user-select: none;
  cursor: col-resize;
}

/* The card column does not scroll as a whole; the card's own text scrolls inside the card,
   so the card's frame always stays inside the window */
.card-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card {
  min-height: 0;
  max-height: calc(100vh - 2 * var(--space-6));
  box-sizing: border-box;
  overflow-y: auto;
  flex: 0 1 auto;
}

/* A narrow window: the old map (face and card on top, the chat under them), no grip */
@media (max-width: 1180px) {
  .grip {
    display: none;
  }
}

/* --- The persona's voice (decisions of 2 Dec 2026) ---
   The wave: five bars on the shoulders while the voice plays. ▶: a small button at the end of each
   reply of the persona, it plays the reply again. */
.voice-wave {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
}

.voice-wave[hidden] {
  display: none;
}

.voice-wave span {
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: var(--sand);
  transform: scaleY(0.35);
  animation: voice-wave 0.9s ease-in-out infinite;
}

.voice-wave span:nth-child(2) { animation-delay: -0.7s; }
.voice-wave span:nth-child(3) { animation-delay: -0.4s; }
.voice-wave span:nth-child(4) { animation-delay: -0.2s; }
.voice-wave span:nth-child(5) { animation-delay: -0.55s; }

@keyframes voice-wave {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .voice-wave span {
    animation: none;
    transform: scaleY(0.7);
  }
}

.replay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: var(--space-2);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  vertical-align: middle;
  cursor: pointer;
}

.replay:hover,
.replay:focus-visible {
  color: var(--teal);
  border-color: var(--teal);
}

.replay svg {
  width: 10px;
  height: 10px;
  margin-left: 2px; /* the triangle looks centred */
  fill: currentColor;
}

/* No voice in this session (or it failed): no ▶ anywhere */
.no-voice .replay {
  display: none;
}
