/* ═══════════════════════════════════════════════════════════════════════
   start-msg.css — Chat start message card                      v3.0

   Rich card layout:
     .smsg-card-hd    gradient header with large avatar / icon
     .smsg-card-bd    body: left accent bar + content + CTA button
     .smsg-card-md    markdown content (agent start_message)
     .smsg-card-btn   CTA — focuses the message input on click

   Variants:
     .smsg-agent   uses the agent's own gradient (set as inline style)
     .smsg-p2p     green gradient header  (.smsg-card-hd-p2p)
     .smsg-group   purple gradient header (.smsg-card-hd-grp)
═══════════════════════════════════════════════════════════════════════ */

/* ── Outer container ─────────────────────────────────────────────────── */
.smsg {
  display: flex;
  justify-content: center;
  padding: 6px 20px 16px;
  flex-shrink: 0;
}

/* ── Card shell ──────────────────────────────────────────────────────── */
.smsg-card {
  width: 100%;
  max-width: 300px;
  border-radius: var(--hz-radius-18);
  overflow: hidden;
  background: var(--raised);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

/* ── Header ──────────────────────────────────────────────────────────── */
.smsg-card-hd {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Fallback gradient — overridden by inline style for agents */
  background: linear-gradient(135deg, var(--hz-brand) 0%, var(--hz-accent-cyan) 100%);
}

.smsg-card-av {
  font-size: 54px;
  line-height: 1;
  user-select: none;
  position: relative;
  /* No filter here — drop-shadow is clipped by overflow:hidden on iOS Safari.
     The gradient header provides enough visual depth without it. */
}

/* When a profile image is present the avatar container needs explicit dimensions
   so .av-img (width/height:100%) can fill it. Matches the sidebar .av size. */
.smsg-card-av.has-img {
  width: 80px;
  height: 80px;
  border-radius: var(--hz-radius-avatar);
  overflow: hidden;
  color: transparent;
}
.smsg-card-av .av-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Lock icon — P2P header */
.smsg-hd-icon {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: rgba(255,255,255,.92);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.2));
}

/* Variant header colours */
.smsg-card-hd-p2p  { background: linear-gradient(135deg, #00C9A0 0%, #0891b2 100%); }
.smsg-card-hd-grp  { background: linear-gradient(135deg, var(--hz-brand) 0%, var(--hz-accent-cyan) 100%); }

/* ── Body ────────────────────────────────────────────────────────────── */
.smsg-card-bd {
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Row: left accent bar + content side by side */
.smsg-card-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.smsg-card-bar {
  width: 3px;
  min-height: 22px;
  align-self: stretch;
  background: var(--accent);
  border-radius: var(--hz-radius-2);
  flex-shrink: 0;
  margin-top: 1px;
}

.smsg-card-bar-p2p { background: var(--p2p); }

/* Plain text (no start_message or P2P/Group) */
.smsg-card-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--t1);
  line-height: 1.5;
  margin: 0;
  flex: 1;
  text-align: start;
}

/* Encryption note — P2P only */
.smsg-card-sub {
  font-size: 12px;
  color: var(--t3);
  margin: -4px 0 0;
  text-align: start;
}

/* ── Markdown content ────────────────────────────────────────────────── */
/*
 * .smsg-card-md wraps the .md div produced by fmtText().
 * Three visual levels:
 *   p:first-child  headline — t1, 14.5px, weight inherited from surrounding text
 *   p subsequent   body copy — t2, 13.5px
 *   em             specs / attribution — t3, .9em, italic
 */

.smsg-card-md {
  flex: 1;
  min-width: 0;
}

.smsg-card-md .md {
  font-size: 14px;
  color: var(--t2);
  line-height: 1.65;
  text-align: start;
}

.smsg-card-md .md p {
  text-align: start;
  margin-bottom: .4em;
}
.smsg-card-md .md p:last-child { margin-bottom: 0; }

/* Headline paragraph */
.smsg-card-md .md p:first-child {
  font-size: 15px;
  color: var(--t1);
  margin-bottom: .45em;
}

.smsg-card-md .md strong {
  font-weight: 700;
  color: var(--t1);
}

/* Specs / attribution */
.smsg-card-md .md em {
  color: var(--t3);
  font-style: italic;
  font-size: .9em;
}

/* Inline code */
.smsg-card-md .md code {
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--t1);
  font-size: .82em;
  padding: 1px 5px;
  border-radius: var(--hz-radius-4);
}

/* Links */
.smsg-card-md .md a { color: var(--accent); }

/* ── CTA button ──────────────────────────────────────────────────────── */
.smsg-card-btn {
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--hz-radius-10);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--t1);
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
  line-height: 1;
  text-align: center;
}

.smsg-card-btn:hover {
  background: color-mix(in srgb, var(--hz-brand) 7%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.smsg-card-btn:active { transform: scale(.98); }

/* ── Light theme ─────────────────────────────────────────────────────── */
[data-theme="light"] .smsg-card {
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.09);
}

[data-theme="light"] .smsg-card-md .md code {
  background: rgba(0,0,0,.04);
  border-color: rgba(0,0,0,.08);
}

/* Mobile */
@media (max-width: 640px) {
  .smsg { padding: 4px 12px 12px; }
  .smsg-card { max-width: 360px; }   /* cap — avoids edge-to-edge stretch on narrow phones */
  .smsg-card-hd { height: 120px; }
  .smsg-card-av { font-size: 46px; }
}
