/* ============================================================
   となりの英語 — Speech Bubbles
   Speakers: Uchi (left default) / Shiba (right default)
   Tones: default / learn / quip / think
   Tail: rounded soft (V1 丸み整合)
   ============================================================ */

/* ---------- Shiba color (4th temperature, independent) ---------- */
:root {
  --te-shiba:        #C97B4A;  /* 柴犬の茶色 */
  --te-shiba-light:  #E8C7A8;
  --te-shiba-dark:   #8C5232;
}

/* ---------- Container ---------- */
.te-bubble {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: flex-start;
  margin: 1.4em 0;
  font-family: var(--te-font-body);
}
.te-bubble--right {
  grid-template-columns: 1fr 56px;
}
.te-bubble--right .te-bubble-avatar { grid-column: 2; grid-row: 1; }
.te-bubble--right .te-bubble-body   { grid-column: 1; grid-row: 1; }

/* ---------- Avatar ---------- */
.te-bubble-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 1.5px solid var(--te-hairline);
  background: var(--te-cream-warm);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  /* paper inner texture */
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.5);
}
.te-bubble-avatar-name {
  text-align: center;
  font-family: var(--te-font-body);
  font-size: 10px;
  color: var(--te-ink-soft);
  margin-top: 4px;
  letter-spacing: 0.08em;
}
.te-bubble-avatar-wrap { display: flex; flex-direction: column; align-items: center; }

/* Uchi avatar — hand-drawn placeholder (override with bg-image) */
.te-bubble-avatar--uchi {
  background:
    radial-gradient(circle at 50% 38%, var(--te-cream-warm) 0 36%, transparent 38%),  /* head */
    radial-gradient(ellipse at 50% 95%, var(--te-primary-teal) 0 42%, transparent 44%), /* shoulders */
    var(--te-cream);
}
.te-bubble-avatar--uchi::after {
  /* hand-drawn outline ring */
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 56'><circle cx='28' cy='28' r='25' fill='none' stroke='%231F5A4C' stroke-width='1.4' stroke-dasharray='1,2.5' stroke-linecap='round' opacity='0.55'/></svg>") center/contain no-repeat;
}

/* Shiba avatar — brown mascot placeholder */
.te-bubble-avatar--shiba {
  background:
    radial-gradient(circle at 30% 30%, #fff 0 6%, transparent 7%),
    radial-gradient(circle at 70% 30%, #fff 0 6%, transparent 7%),
    radial-gradient(circle at 30% 33%, var(--te-shiba-dark) 0 3%, transparent 4%),
    radial-gradient(circle at 70% 33%, var(--te-shiba-dark) 0 3%, transparent 4%),
    radial-gradient(ellipse at 50% 60%, #fff 0 14%, transparent 15%),
    radial-gradient(circle at 50% 56%, var(--te-shiba-dark) 0 4%, transparent 5%),
    radial-gradient(circle at 18% 12%, var(--te-shiba-dark) 0 14%, transparent 15%),
    radial-gradient(circle at 82% 12%, var(--te-shiba-dark) 0 14%, transparent 15%),
    radial-gradient(circle at 50% 55%, var(--te-shiba) 0 60%, transparent 62%),
    var(--te-shiba-light);
}
.te-bubble-avatar--shiba::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 56'><circle cx='28' cy='28' r='25' fill='none' stroke='%238C5232' stroke-width='1.4' stroke-dasharray='1,2.5' stroke-linecap='round' opacity='0.5'/></svg>") center/contain no-repeat;
}

/* extension hook — drop image as bg */
.te-bubble-avatar[style*="background-image"]::after { display: none; }

/* ---------- Body / bubble ---------- */
.te-bubble-body {
  position: relative;
  background: var(--te-cream);
  border: 1px solid var(--te-hairline);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--te-ink);
  text-wrap: pretty;
  max-width: 100%;
}
.te-bubble-body p { margin: 0; }
.te-bubble-body p + p { margin-top: 0.5em; }

/* speaker label inside bubble */
.te-bubble-name {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--te-ink-soft);
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 500;
}

/* ---------- Tail (rounded soft) ---------- */
.te-bubble-body::before,
.te-bubble-body::after {
  content: "";
  position: absolute;
  top: 16px;
  width: 12px; height: 12px;
  border-radius: 4px 0 4px 0;
  transform: rotate(45deg);
  background: var(--te-cream);
  border: 1px solid var(--te-hairline);
}
/* mask the inner 2 borders so the tail feels glued */
.te-bubble-body::after {
  background: var(--te-cream);
  border: none;
  width: 14px; height: 14px;
  z-index: 1;
}

.te-bubble:not(.te-bubble--right) .te-bubble-body::before { left: -7px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.te-bubble:not(.te-bubble--right) .te-bubble-body::after  { left: -5px; }

.te-bubble--right .te-bubble-body::before { right: -7px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.te-bubble--right .te-bubble-body::after  { right: -5px; }

/* ============================================================
   Tones
   ============================================================ */

/* default — cream + hairline (already base) */

/* learn — teal soft */
.te-bubble--learn .te-bubble-body {
  background: rgba(59,135,117,0.08);
  border-color: rgba(59,135,117,0.30);
  color: var(--te-deep-green);
}
.te-bubble--learn .te-bubble-body::before { background: rgba(59,135,117,0.08); border-color: rgba(59,135,117,0.30); }
.te-bubble--learn .te-bubble-body::after  { background: rgba(59,135,117,0.08); }
.te-bubble--learn .te-bubble-name { color: var(--te-primary-teal); }
.te-bubble--learn .te-bubble-body::before::after { content: ""; }
/* learn marker (small bulb dot) */
.te-bubble--learn .te-bubble-body > strong:first-child,
.te-bubble--learn .te-bubble-tone-mark::before {
  content: "✦";
  color: var(--te-primary-teal);
  margin-right: 0.4em;
  font-size: 0.9em;
}

/* quip — salmon soft (柴犬の主戦場) */
.te-bubble--quip .te-bubble-body {
  background: rgba(232,165,152,0.16);
  border-color: rgba(232,165,152,0.45);
  color: #6F2E22;
}
.te-bubble--quip .te-bubble-body::before { background: rgba(232,165,152,0.16); border-color: rgba(232,165,152,0.45); }
.te-bubble--quip .te-bubble-body::after  { background: rgba(232,165,152,0.16); }
.te-bubble--quip .te-bubble-name { color: #B85F4E; }

/* think — dotted cloud */
.te-bubble--think .te-bubble-body {
  background: var(--te-cream);
  border: 1.5px dashed var(--te-hairline);
  color: var(--te-ink-soft);
  font-style: italic;
  border-radius: 18px;
}
.te-bubble--think .te-bubble-body::before,
.te-bubble--think .te-bubble-body::after { display: none; }
.te-bubble--think .te-bubble-body {
  /* small thought-bubble dots near avatar */
  background-image:
    radial-gradient(circle, var(--te-hairline) 1.8px, transparent 2.2px),
    radial-gradient(circle, var(--te-hairline) 1.2px, transparent 1.6px);
  background-repeat: no-repeat;
  background-size: 8px 8px, 5px 5px;
}
.te-bubble:not(.te-bubble--right).te-bubble--think .te-bubble-body {
  background-position: -14px 24px, -22px 14px;
}
.te-bubble--right.te-bubble--think .te-bubble-body {
  background-position: calc(100% + 14px) 24px, calc(100% + 22px) 14px;
}

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 600px) {
  .te-bubble { grid-template-columns: 44px 1fr; gap: 10px; }
  .te-bubble--right { grid-template-columns: 1fr 44px; }
  .te-bubble-avatar { width: 44px; height: 44px; }
  .te-bubble-body { font-size: 14px; padding: 10px 14px; }
}
