/* ════════════════════════════════════════════════════════════════════
   Chat figure (2026-10-17): a story told as an iMessage group chat.
   Used by the homepage hero and the About page. No window frame: a group
   header with avatars, centred timestamps, grey incoming and blue
   outgoing bubbles with tails, read receipts, rich-link cards. iMessage's
   own palette (a mock of a third-party surface), the blue deepened to
   pass AA (4.7:1). chat.js plays it; the HTML is the finished chat.
   ════════════════════════════════════════════════════════════════════ */
.ab-chat {
  --im-blue: #0b6fe8; --im-grey: #e9e9eb; --im-text: #000; --im-meta: #6c6c70; --im-line: #e5e5ea;
  margin: 0; min-width: 0; max-width: 460px; width: 100%; justify-self: center;
}
.ab-chat .fig-caption { margin-bottom: 14px; }
.ab-chat__head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 6px; }
.ab-chat__avs { display: flex; }
.ab-chat__avs .ab-av { width: 44px; height: 44px; box-shadow: 0 0 0 3px var(--bg); }
.ab-chat__avs .ab-av + .ab-av { margin-left: -10px; }
.ab-chat__avs .ab-av--logo img { width: 22px; height: 22px; }
.ab-chat__avs .ab-av--xyz img { width: 30px; height: 30px; }
.ab-chat__avs .ab-av--emoji { font-size: 24px; }
.ab-chat__name { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 500; color: var(--im-text); }
.ab-chat__name svg { width: 12px; height: 12px; fill: none; stroke: var(--im-meta); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.ab-chat__scroll {
  height: 470px; overflow-y: auto; padding: 18px 8px 8px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(10,10,35,.18) transparent;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 40px);
  mask-image: linear-gradient(180deg, transparent 0, #000 40px);
}
.ab-chat__scroll::-webkit-scrollbar { width: 6px; }
.ab-chat__scroll::-webkit-scrollbar-thumb { background: rgba(10,10,35,.18); border-radius: 3px; }
.ab-chat__scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 12px; }
.ab-chat__log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.ab-stamp { margin: 14px 0 4px; text-align: center; font-size: 11.5px; color: var(--im-meta); }
.ab-stamp b { font-weight: 600; }

/* avatars: logos on white, a developer as iOS's grey initials */
.ab-av {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--white); box-shadow: inset 0 0 0 1px var(--im-line); overflow: hidden;
}
.ab-av--logo img { width: 14px; height: 14px; }
.ab-av--xyz img { width: 20px; height: 20px; }
.ab-av--emoji { background: linear-gradient(180deg, #eef0f5, #d9dce4); box-shadow: none; font-size: 16px; line-height: 1; }
.ab-av--blank { visibility: hidden; }

/* messages */
.ab-msg { display: flex; flex-direction: column; gap: 3px; max-width: 82%; }
.ab-msg--in { align-self: flex-start; align-items: flex-start; }
.ab-msg--out { align-self: flex-end; align-items: flex-end; }
.ab-msg__name { margin-left: 48px; font-size: 11.5px; color: var(--im-meta); }
.ab-msg__row { display: flex; align-items: flex-end; gap: 8px; }
.ab-msg__bub {
  position: relative; padding: 7px 13px; border-radius: 18px;
  font-size: 15px; line-height: 1.35; overflow-wrap: anywhere;
}
.ab-msg--in .ab-msg__bub { background: var(--im-grey); color: var(--im-text); }
.ab-msg--out .ab-msg__bub { background: var(--im-blue); color: #fff; }
.ab-msg--tail .ab-msg__bub::after {
  content: ""; position: absolute; bottom: 0; width: 20px; height: 20px; background: inherit;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M0 0H14C14 11 16 17 20 20C15 20.5 10 19 7 16.5C5 18.5 2.5 20 0 20Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M0 0H14C14 11 16 17 20 20C15 20.5 10 19 7 16.5C5 18.5 2.5 20 0 20Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}
.ab-msg--out.ab-msg--tail .ab-msg__bub::after { right: -6px; }
.ab-msg--in.ab-msg--tail .ab-msg__bub::after { left: -6px; transform: scaleX(-1); }
.ab-msg__bub code { font-family: var(--font-mono); font-size: 13px; }
.ab-msg__eco { display: inline-block; width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; }
.ab-msg__st { padding: 0 4px; font-size: 11.5px; font-weight: 500; color: var(--im-meta); }
.ab-msg__st em { font-style: normal; color: var(--im-blue); }
.ab-sev {
  display: inline-block; margin-right: 3px; padding: 0 6px; border-radius: 6px; vertical-align: 1px;
  background: var(--x-danger-50); color: var(--x-danger-700);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
}

/* the CyberXYZ verdict as a rich link */
.ab-link { width: 250px; max-width: 100%; overflow: hidden; border-radius: 18px; border: 1px solid var(--im-line); background: var(--white); }
.ab-link__art {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  height: 128px; background: var(--wash-grade);
}
.ab-link__art img { width: 64px; height: 64px; }
.ab-link__tx { display: flex; flex-direction: column; gap: 2px; padding: 9px 13px 10px; background: var(--im-grey); }
.ab-link__tx b { font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--im-text); }
.ab-link__tx span { font-size: 13px; line-height: 1.35; color: var(--im-text); }
.ab-link__tx small { margin-top: 2px; font-size: 12px; color: var(--im-meta); }
.ab-verdict {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--x-radius-pill);
  background: var(--white); border: 1px solid var(--x-danger-200); color: var(--x-danger-700);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.ab-verdict svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* typing indicator + controls */
.ab-chat__typing { display: none; align-items: flex-end; gap: 8px; margin-top: 6px; }
.ab-chat__typing.on { display: flex; }
.ab-chat__dots { display: inline-flex; gap: 4px; padding: 11px 13px; border-radius: 18px; background: var(--im-grey); }
.ab-chat__dots i { width: 7px; height: 7px; border-radius: 50%; background: #8e8e93; animation: abDot 1.2s ease-in-out infinite; }
.ab-chat__dots i:nth-child(2) { animation-delay: .15s; }
.ab-chat__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes abDot { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
.ab-chat__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.ab-chat__foot .frame__cap { margin: 0; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.ab-chat__btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--x-radius-pill); cursor: pointer;
  background: var(--white); border: 1px solid var(--line); color: var(--ink-2); font: 600 13px/1 var(--font-body);
  transition: border-color .2s ease, color .2s ease;
}
.ab-chat__btn[hidden] { display: none; }
.ab-chat__btn:hover { border-color: var(--im-blue); color: var(--im-blue); }
.ab-chat__btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ab-chat__btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* playback: only shown items render; bubbles pop in from their own side */
.ab-chat.is-playing .ab-chat__log > li:not(.on) { display: none; }
.ab-chat.is-playing .ab-chat__log > li.on { animation: abIn .38s cubic-bezier(.34,1.3,.64,1) both; }
.ab-chat.is-playing .ab-msg--in.on { transform-origin: bottom left; }
.ab-chat.is-playing .ab-msg--out.on { transform-origin: bottom right; }
.ab-chat.is-playing .ab-msg--out.on .ab-msg__st { animation: abFade .3s ease .6s both; }
@keyframes abIn { from { opacity: 0; transform: translateY(8px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes abFade { from { opacity: 0; } to { opacity: 1; } }

/* outgoing code and pasted terminal output */
.ab-msg--out .ab-msg__bub code { color: #fff; }
.ab-msg__term { display: block; margin: 0; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; }

@media (max-width: 720px) {
  .ab-chat__scroll { height: 440px; padding: 14px 2px 8px; }
  .ab-msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  .ab-chat__dots i { animation: none; }
}
