/* Conversation surface: current pair + composer. No inner scroll area. */

.pair {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 38rem;
  margin: 0 auto;
}

.pair-entry {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: pair-in 400ms var(--ease) both;
}

.pair-entry.is-leaving {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  animation: pair-out 600ms ease forwards;
}

.pair-prompt {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--muted);
}

.pair-answer {
  margin: 0;
  font-family: var(--font-reading);
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  line-height: 1.5;
  color: var(--text);
}

.thinking-dots {
  display: none;
  align-items: center;
  gap: 0.3em;
  height: 1.5em;
}

.pair-answer .thinking-dots span {
  width: 0.4em;
  height: 0.4em;
  border-radius: 50%;
  background: var(--muted);
  animation: thinking-pulse 1.2s ease-in-out infinite;
}

.pair-answer .thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.pair-answer .thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

.stage[data-phase='thinking'] .pair-answer .thinking-dots { display: inline-flex; }

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

@keyframes pair-out {
  from { opacity: 1; transform: translateY(0); filter: blur(0); }
  to { opacity: 0; transform: translateY(-40px); filter: blur(4px); }
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* Composer: writing on the surface, not a form. One soft fading line, no frame. */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
  max-width: 38rem;
  margin: 0 auto;
  padding: 1.15rem 0.25rem calc(0.8rem + env(safe-area-inset-bottom));
  border: 0;
  /* Fades the page content out behind the sticky composer without a hard edge. */
  background: linear-gradient(
    180deg,
    rgba(237, 228, 211, 0) 0%,
    rgba(237, 228, 211, 0.82) 38%,
    rgba(237, 228, 211, 0.96) 100%
  );
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.composer-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.45rem 0.35rem 0.6rem;
  font-family: var(--font-reading);
  font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
  caret-color: var(--accent);
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 10px;
  background-color: transparent;
  /* The single soft line: fades to nothing at both ends. */
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(74, 63, 53, 0.26) 10%,
    rgba(74, 63, 53, 0.26) 90%,
    transparent 100%
  );
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 1px;
  transition:
    background-size 260ms var(--ease),
    box-shadow 260ms var(--ease),
    border-radius 260ms var(--ease);
}

.composer-input:focus {
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    var(--focus-ring) 12%,
    var(--focus-ring) 88%,
    transparent 100%
  );
  background-size: 100% 2px;
  box-shadow: 0 8px 24px -16px rgba(138, 75, 34, 0.55);
  border-radius: 12px;
  outline: none;
}

/* Keyboard focus keeps a conventional, high-contrast ring (WCAG 2.4.7 / 1.4.11). */
/* Owner: no box around the input. The glowing 2px underline above is the
   focus indicator (focus-ring colour, ≥3:1 against the background). */
.composer-input:focus-visible {
  outline: none;
  background-size: 100% 2px;
}

.composer-input::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

.composer-send {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-family: var(--font);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.85;
  transition:
    color 220ms var(--ease),
    background-color 220ms var(--ease),
    opacity 220ms var(--ease),
    transform 220ms var(--ease),
    box-shadow 220ms var(--ease);
}

.composer-send svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 220ms var(--ease);
}

/* The arrow gains weight once there is something to send (and while focused). */
.composer:has(.composer-input:not(:placeholder-shown)) .composer-send,
.composer .composer-input:focus ~ .composer-send {
  color: var(--text);
  opacity: 1;
  background-color: rgba(193, 122, 77, 0.14);
}

.composer-send:hover {
  color: var(--text);
  opacity: 1;
  background-color: rgba(193, 122, 77, 0.14);
  box-shadow: 0 6px 18px -14px rgba(138, 75, 34, 0.75);
}

.composer-send:hover svg { transform: translateY(-1px); }

.composer-send:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: none;
}

.composer-send:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (max-width: 40rem) {
  .composer {
    position: sticky;
    bottom: 0;
    width: 100%;
    max-width: none;
    gap: 0.4rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Keep 16px+ so mobile browsers do not zoom on focus. */
  .composer-input { font-size: 1.0625rem; }

  .composer-send { width: 2.75rem; height: 2.75rem; }
}

@media (prefers-contrast: more) {
  .composer {
    background: var(--bg-end);
  }

  .composer-input {
    background-image: linear-gradient(90deg, var(--text), var(--text));
    background-size: 100% 2px;
  }

  .composer-send {
    color: var(--text);
    opacity: 1;
    border: 1px solid var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  .composer-input,
  .composer-send,
  .composer-send svg {
    transition: none;
  }

  .composer-send:hover svg,
  .composer-send:active {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pair-entry,
  .pair-entry.is-leaving,
  .pair-answer .thinking-dots span {
    animation: none;
    transition: none;
  }

  .pair-entry.is-leaving { opacity: 0; }
}
