/* =============================================================================
   KINKO DESIGN SYSTEM — Chat Bubble Component
   Spec: components/chat-bubble.md
   Collection: Chat Bubble (VariableCollectionId:2346:67237)
   ============================================================================= */

/* 1. Component token definitions — aliases to semantic tokens */
:root {
  --chat-bubble-bg:   var(--surface-brand-inverse);
  --chat-bubble-text: var(--text-inverse);
}

/* 2. Component styles — use only --chat-bubble-* vars below this line */

/* ── Outer wrapper ── */
.chat-bubble {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--spacing-2);
}

/* ── Bubble body ── */
.chat-bubble__body {
  display: flex;
  gap: var(--spacing-8);
  align-items: flex-start;
  padding: var(--spacing-8);
  background: var(--chat-bubble-bg);
  border-radius: var(--radius-16);
  max-width: 200px;
  overflow: hidden;
}

/* ── Icon slot ── */
.chat-bubble__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--chat-bubble-text);
}

.chat-bubble__icon img,
.chat-bubble__icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Text column — wraps heading + body-text ── */
.chat-bubble__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  color: var(--chat-bubble-text);
}

/* ── Heading (12px Medium) ── */
.chat-bubble__heading {
  margin: 0;
  padding: 0;
}

/* ── Body text (10px Regular) ── */
.chat-bubble__body-text {
  margin: 0;
  padding: 0;
}

/* ── Icon color — same token as text ── */
.chat-bubble__icon svg {
  width: 100%;
  height: 100%;
  color: inherit; /* inherits --chat-bubble-text from .chat-bubble__icon */
}

/* ── Tail wrapper — horizontal tails (top-left, top-right, down-left, down-right) ── */
/* 54×10px container matching Figma frame; triangle (14px) is centered → 20px space each side */
.chat-bubble__tail-wrap {
  width: 54px;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Tail — shared base ── */
/* Tail SVG dimensions and paths are defined per-variant in HTML.
   All tails use the same 14×10 isosceles triangle (M 0 10 L 14 10 L 7 0 Z),
   rotated for each direction. */
.chat-bubble__tail {
  display: block;
  flex-shrink: 0;
  color: var(--chat-bubble-bg); /* SVG paths use fill="currentColor" */
}

/* ── Tail position variants ── */

/* Top: tail above bubble */
.chat-bubble--tail-top-left,
.chat-bubble--tail-top-right {
  flex-direction: column;
}
.chat-bubble--tail-top-left  { align-items: flex-start; }
.chat-bubble--tail-top-right { align-items: flex-end; }

/* Down: tail below bubble */
.chat-bubble--tail-down-left,
.chat-bubble--tail-down-right {
  flex-direction: column;
}
.chat-bubble--tail-down-left  { align-items: flex-start; }
.chat-bubble--tail-down-right { align-items: flex-end; }

/* Right: tail after bubble on the right side */
.chat-bubble--tail-right {
  flex-direction: row;
  align-items: center;
}

/* Left: tail before bubble on the left side */
.chat-bubble--tail-left {
  flex-direction: row;
  align-items: center;
}

/* Side variants: bubble body fills available space */
.chat-bubble--tail-right .chat-bubble__body,
.chat-bubble--tail-left .chat-bubble__body {
  flex: 1;
  min-width: 0;
  max-width: 200px;
}
