/* Conversational maturity assessment. Layered on styles.css + services.css. */

.chat {
  display: flex;
  flex-direction: column;
  height: min(82vh, 760px);
  min-height: 520px;
  margin-top: 28px;
  border-radius: 24px;
  overflow: hidden;
}

/* Header: who you're talking to, progress, current NIST function. */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.chat-head .avatar {
  width: 36px;
  height: 36px;
}
.chat-who {
  flex: 1;
  min-width: 0;
}
.chat-who b {
  display: block;
  font-family: var(--font-head);
  font-size: 15px;
}
.chat-who small {
  color: var(--ink-3);
  font-size: 12.5px;
}
.chat-who [data-section] {
  color: var(--mint);
}
.chat-count {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chat-meter {
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
}
.chat-meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--mint));
  box-shadow: 0 0 12px rgba(69, 216, 195, 0.6);
  transition: width 0.5s var(--ease-out);
}

/* Messages. */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(69, 216, 195, 0.3) transparent;
}
.msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 88%;
  animation: msg-in 0.35s var(--ease-out) both;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.msg.me {
  align-self: flex-end;
}
.msg .bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
}
.msg.bot .bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-end-start-radius: 6px;
  color: var(--ink);
}
.msg.me .bubble {
  background: var(--mint);
  color: #032220;
  font-weight: 500;
  border-end-end-radius: 6px;
}
.msg.question .bubble {
  font-family: var(--font-head);
  font-size: 16.5px;
  font-weight: 500;
  border-color: rgba(69, 216, 195, 0.28);
}
.q-tag {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--mint);
}

/* CYBRT avatar: a tiny dotted mark. */
.avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(69, 216, 195, 0.35);
  background:
    radial-gradient(circle, var(--mint) 1.4px, transparent 1.8px) 0 0 / 6px 6px,
    radial-gradient(circle at 50% 50%, rgba(13, 130, 116, 0.6), rgba(3, 17, 18, 0.9));
}

/* Typing indicator. */
.dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  opacity: 0.35;
  animation: blink 1s infinite;
}
.dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes blink {
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Reply chips. */
.chat-replies {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 16px;
}
.chat-replies:empty {
  padding: 0;
  border-top: 0;
}
.reply {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 520px);
  padding: 11px 14px;
  border: 1px solid rgba(69, 216, 195, 0.35);
  border-radius: 14px;
  background: rgba(69, 216, 195, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease-out);
  animation: msg-in 0.35s var(--ease-out) both;
}
.reply:nth-child(2) {
  animation-delay: 0.05s;
}
.reply:nth-child(3) {
  animation-delay: 0.1s;
}
.reply:hover,
.reply:focus-visible {
  background: rgba(69, 216, 195, 0.16);
  border-color: var(--mint);
  transform: translateX(-3px);
}
[dir='rtl'] .reply:hover,
[dir='rtl'] .reply:focus-visible {
  transform: translateX(3px);
}
.reply kbd {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(69, 216, 195, 0.4);
  font-family: var(--font-head);
  font-size: 12px;
  color: var(--mint);
}
.reply.primary {
  width: auto;
  justify-content: center;
  padding: 12px 22px;
  background: var(--mint);
  border-color: var(--mint);
  color: #032220;
  font-weight: 600;
}
.reply.undo {
  width: auto;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reply.undo:hover {
  color: var(--ink);
  transform: none;
}

/* Lead form, inside a bot message. */
.msg.form {
  max-width: 100%;
  width: 100%;
}
.msg.form .bubble {
  flex: 1;
  padding: 20px;
}
.lead {
  display: grid;
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-size: 13px;
  color: var(--ink-2);
}
.field input,
.field select {
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(3, 17, 18, 0.6);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(69, 216, 195, 0.18);
}
.field input:user-invalid,
.field select:user-invalid {
  border-color: #ff7b7b;
}
.hp {
  position: absolute;
  inset-inline-start: -9999px;
}
.lead-note {
  font-size: 12.5px;
  color: var(--ink-3);
}
.lead .btn {
  justify-self: start;
  border: 0;
  cursor: pointer;
}
.msg.form.sent {
  opacity: 0.55;
}

/* Results. */
.msg.result-msg {
  max-width: 100%;
  width: 100%;
}
.msg.result-msg .bubble {
  flex: 1;
  padding: 22px;
}
.result-top {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 20px;
  align-items: center;
}
.ring {
  position: relative;
  width: 132px;
  height: 132px;
}
.ring svg {
  width: 100%;
  height: 100%;
}
.ring circle {
  fill: rgba(157, 189, 183, 0.25);
}
.ring circle.on {
  fill: var(--mint);
  opacity: 0;
  transition: opacity 0.2s;
  transition-delay: calc(var(--k) * 22ms);
}
.result-msg.in .ring circle.on {
  opacity: 1;
}
.ring-score {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring-score b {
  font-family: var(--font-head);
  font-size: 38px;
  line-height: 1;
}
.ring-score span {
  font-size: 12px;
  color: var(--ink-3);
}
.band {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  color: var(--mint);
  margin-bottom: 4px;
}
.result-top p:not(.band) {
  color: var(--ink-2);
}
.fns {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.fn {
  display: grid;
  grid-template-columns: 76px 1fr 40px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}
.fn-name {
  color: var(--ink-2);
}
.fn-dots {
  display: flex;
  gap: 6px;
}
.fn-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(157, 189, 183, 0.22);
}
.fn-dots i.on {
  background: var(--mint);
  box-shadow: 0 0 8px rgba(69, 216, 195, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
  transition-delay: calc(0.5s + var(--k) * 40ms);
}
.result-msg.in .fn-dots i.on {
  opacity: 1;
}
.fn-pct {
  text-align: end;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.result h3 {
  font-size: 16px;
  margin: 24px 0 10px;
}
.gaps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: gap;
}
.gaps li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(3, 17, 18, 0.35);
}
.gaps li::before {
  counter-increment: gap;
  content: counter(gap);
  font-family: var(--font-head);
  color: var(--mint);
  margin-inline-end: -6px;
}
.gaps li > span {
  flex: 1;
}
.gaps small {
  display: block;
  color: var(--ink-3);
}
.gaps a {
  color: var(--mint);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.gaps a:hover {
  text-decoration: underline;
}
.result-note {
  margin-top: 18px;
  color: var(--ink-2);
}
.result-status {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-3);
}
.result .actions {
  margin-top: 18px;
}

/* "What we assess" cards. */
.fn-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}
.fn-card {
  border-radius: 18px;
  padding: 22px;
}
.fn-card .idx {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--mint);
}
.fn-card h3 {
  font-size: 18px;
  margin: 8px 0 8px;
}
.fn-card p {
  color: var(--ink-2);
  font-size: 14.5px;
}

.hero-meta {
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--ink-3);
}

@media (min-width: 900px) {
  .chat {
    max-width: 860px;
  }
  .chat-log {
    padding: 26px 28px 14px;
  }
  .chat-replies {
    padding: 14px 28px 22px;
  }
  .lead {
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
  }
  .lead-note,
  .lead .btn {
    grid-column: 1 / -1;
  }
  .fn-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 560px) {
  .result-top {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .msg {
    max-width: 94%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg,
  .reply,
  .dots i,
  .chat-meter span {
    animation: none;
    transition: none;
  }
  .ring circle.on,
  .fn-dots i.on {
    opacity: 1;
    transition: none;
  }
}
