/* The screen after step 3: the matched model as a chat (same screen as on tyan-create-ai-girlfriend-3). */

.match-screen {
  position: fixed;
  inset: 0;
  z-index: 9000; /* above the builder, below the sign-up form (10000) */
  overflow-y: auto;
  overscroll-behavior: contain;
  background: radial-gradient(120% 60% at 50% 0%, rgba(254, 60, 179, .16) 0%, rgba(5, 5, 7, 0) 60%), var(--bg);
}
.match-screen[hidden] { display: none; }
body.match-open { overflow: hidden; }

.match-creating {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 100%;
  padding: 24px;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
}
.match-creating p { margin: 0; }
.match-ring {
  width: 64px;
  height: 64px;
  border: 5px solid rgba(255, 255, 255, .14);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: match-spin .9s linear infinite;
}
@keyframes match-spin { to { transform: rotate(360deg); } }

.match-chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  min-height: 100%;
  margin: 0 auto;
  padding: 0 12px;
}

.match-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(5, 5, 7, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.match-back {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-light);
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
}
.match-back svg { width: 18px; height: 18px; }
.match-avatar { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.match-who { min-width: 0; }
.match-name { overflow: hidden; font-size: 16px; font-weight: 600; line-height: 22px; white-space: nowrap; text-overflow: ellipsis; }
.match-status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; line-height: 16px; }
.match-status i { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; }

.match-feed { display: flex; flex: 1 0 auto; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 0 12px; }
.match-msg { max-width: 86%; border: 1px solid var(--line); border-radius: 18px 18px 18px 5px; background: var(--surface-2); animation: match-in .25s ease-out both; }
.match-photo { width: 70%; max-width: 300px; overflow: hidden; border-radius: 18px; }
.match-photo img { display: block; width: 100%; height: auto; } /* the whole photo, its own proportions */
/* "Sending a photo": a frame of the photo's size with a spinner, replaced by the photo itself. */
.match-photo.is-sending { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; aspect-ratio: 2 / 3; color: var(--muted); font-size: 13px; background: linear-gradient(110deg, var(--surface-2) 30%, rgba(255, 255, 255, .07) 50%, var(--surface-2) 70%) 0 0 / 220% 100%; animation: match-in .25s ease-out both, match-shimmer 1.4s linear infinite; }
.match-photo.is-sending .match-ring { width: 34px; height: 34px; border-width: 3px; }
@keyframes match-shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
/* The visitor's own message: right side, brand colour. */
.match-out { align-self: flex-end; padding: 10px 14px; border: 0; border-radius: 18px 18px 5px 18px; background: var(--gradient); font-size: 15px; line-height: 22px; white-space: pre-line; overflow-wrap: anywhere; }
.match-text { padding: 10px 14px; font-size: 15px; line-height: 22px; white-space: pre-line; overflow-wrap: anywhere; }
@keyframes match-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.match-typing { display: flex; gap: 5px; padding: 15px 16px; }
.match-typing i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .5); animation: match-dot 1s ease-in-out infinite; }
.match-typing i:nth-child(2) { animation-delay: .15s; }
.match-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes match-dot { 0%, 60%, 100% { opacity: .5; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.match-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -12px;
  padding: 22px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(5, 5, 7, 0) 0, var(--bg) 22px);
}
.match-replies { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; animation: match-in .25s ease-out both; }
.match-replies[hidden] { display: none; }
.match-reply {
  max-width: 88%;
  padding: 9px 14px;
  border: 1px solid var(--pink);
  border-radius: 18px 18px 5px 18px;
  background: var(--pink-soft);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
}
.match-reply:active { background: var(--pink-glow); }

.match-input { display: flex; align-items: center; gap: 8px; }
.match-input input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line-light);
  border-radius: 24px;
  outline: none;
  background: var(--surface-2);
  color: #fff;
  font-size: 16px;
}
.match-input input::placeholder { color: rgba(255, 255, 255, .45); }
.match-send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--gradient);
  box-shadow: 0 5px 20px var(--pink-glow);
  cursor: pointer;
}
.match-send svg { width: 22px; height: 22px; }

@media (prefers-reduced-motion: reduce) {
  .match-ring, .match-typing i, .match-msg, .match-replies { animation: none; }
}
