/* Tiny decorative character figures + speech bubbles */

.figure-chat {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: flex-start;
  pointer-events: none;
  user-select: none;
}

.figure-chat--right {
  align-items: flex-end;
}

.figure-chat--center {
  align-items: center;
  width: 100%;
}

/* Comic dialogue bubbles — tail only on last line before sprites */
.speech-bubble {
  margin: 0;
  font-family: var(--font-ui, "Pixelify Sans", system-ui, sans-serif);
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
  font-weight: 700;
  line-height: 1.35;
  padding: 0.55rem 0.9rem;
  max-width: min(17rem, 92vw);
  color: var(--text);
  background: var(--surface);
  border: 3px solid var(--pixel);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--pixel) 85%, transparent);
  position: relative;
  transform: rotate(-0.8deg);
  border-radius: 1.5rem;
  border-bottom-left-radius: 0.35rem;
}

.figure-chat > .speech-bubble:not(:last-of-type) {
  border-radius: 1.5rem;
  margin-bottom: 0.15rem;
}

.figure-chat > .speech-bubble:last-of-type {
  margin-bottom: 0.65rem;
}

/* Tail outline + fill (points down to characters) */
.figure-chat > .speech-bubble:last-of-type::before,
.figure-chat > .speech-bubble:last-of-type::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  top: 100%;
  z-index: 1;
  pointer-events: none;
}

.figure-chat > .speech-bubble:last-of-type::before {
  margin-top: 0;
  left: 1.35rem;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 14px solid var(--pixel);
}

.figure-chat > .speech-bubble:last-of-type::after {
  margin-top: -3px;
  left: calc(1.35rem + 3px);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 11px solid var(--surface);
}

.figure-chat .speech-bubble:nth-child(even) {
  transform: rotate(0.9deg);
  align-self: flex-end;
  border-radius: 1.5rem;
  border-bottom-right-radius: 0.35rem;
}

.figure-chat .speech-bubble:nth-child(even):last-of-type::before {
  left: auto;
  right: 1.25rem;
}

.figure-chat .speech-bubble:nth-child(even):last-of-type::after {
  left: auto;
  right: calc(1.25rem + 3px);
}

.figure-chat--right .speech-bubble:nth-child(even) {
  align-self: flex-start;
}

.figure-chat--right > .speech-bubble:last-of-type::before {
  left: auto;
  right: 1.5rem;
}

.figure-chat--right > .speech-bubble:last-of-type::after {
  left: auto;
  right: calc(1.5rem + 3px);
}

.figure-chat--right .speech-bubble:nth-child(even):last-of-type::before {
  left: 1.25rem;
  right: auto;
}

.figure-chat--right .speech-bubble:nth-child(even):last-of-type::after {
  left: calc(1.25rem + 3px);
  right: auto;
}

.speech-bubble--tilt-left {
  transform: rotate(-1.2deg);
}

.speech-bubble--tilt-right {
  transform: rotate(1.1deg);
}

.figure-chat--hero .speech-bubble:nth-child(1) {
  align-self: flex-start;
}

.figure-chat--hero .speech-bubble:nth-child(2) {
  align-self: center;
}

.figure-chat--hero .speech-bubble:nth-child(3) {
  align-self: flex-end;
}

/* Hero: last bubble sits right — tail aims at the sprite row */
.figure-chat--hero > .speech-bubble:last-of-type {
  border-bottom-left-radius: 1.5rem;
  border-bottom-right-radius: 0.35rem;
}

.figure-chat--hero > .speech-bubble:last-of-type::before {
  left: auto;
  right: 1.35rem;
}

.figure-chat--hero > .speech-bubble:last-of-type::after {
  left: auto;
  right: calc(1.35rem + 3px);
}

/* Product cards: tail centered over the two icons */
.figure-chat--product > .speech-bubble:last-of-type::before {
  left: calc(50% - 12px);
  right: auto;
}

.figure-chat--product > .speech-bubble:last-of-type::after {
  left: calc(50% - 9px);
  right: auto;
}

.figure-chat--product > .speech-bubble:last-of-type {
  border-bottom-left-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
}

/* Footer: tail hangs from center */
.figure-chat--footer > .speech-bubble:last-of-type::before {
  left: calc(50% - 12px);
  right: auto;
}

.figure-chat--footer > .speech-bubble:last-of-type::after {
  left: calc(50% - 9px);
  right: auto;
}

.figure-chat--footer > .speech-bubble:last-of-type {
  border-radius: 1.5rem;
  border-bottom-left-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
}

.tiny-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
  pointer-events: none;
  user-select: none;
}

.tiny-figure {
  width: clamp(36px, 7vw, 52px);
  height: clamp(36px, 7vw, 52px);
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--pixel);
  box-shadow: 2px 2px 0 var(--pixel);
  image-rendering: auto;
  display: block;
  flex-shrink: 0;
}

.tiny-figure--flip {
  transform: scaleX(-1);
  box-shadow: -2px 2px 0 var(--pixel);
}

.hero-with-figures {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
}

.hero-with-figures .hero-copy {
  flex: 1 1 min(100%, 22rem);
  min-width: 0;
}

.hero-figures-wrap {
  flex: 0 1 auto;
  max-width: min(100%, 20rem);
  padding-bottom: 0.15rem;
}

.hero-figures .tiny-figure:nth-child(2) {
  margin-bottom: 8px;
}

.hero-figures .tiny-figure:nth-child(4) {
  margin-bottom: 5px;
}

.figure-chat.section-figures {
  margin: 0.35rem 0 1rem;
  opacity: 0.95;
}

.figure-chat.section-figures--right {
  align-items: flex-end;
}

.figure-chat.section-figures--right .tiny-figures {
  justify-content: flex-end;
}

.card-figures {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.card-figures .tiny-figure {
  width: clamp(32px, 6vw, 44px);
  height: clamp(32px, 6vw, 44px);
}

.coursework-card .figure-chat {
  margin-bottom: 0.35rem;
}

.coursework-card .card-figures {
  margin-bottom: 0;
  margin-top: 0.15rem;
}

.projects-section .section-figures {
  margin-bottom: 1.25rem;
}

.product-card-figures {
  margin-bottom: 0;
}

.figure-chat--product {
  margin-bottom: 0.85rem;
}

.figure-chat--product .speech-bubble {
  font-size: clamp(0.72rem, 1.4vw, 0.82rem);
  max-width: 100%;
  padding: 0.4rem 0.55rem;
}

.figure-chat.contact-figures {
  margin-top: 0.85rem;
  align-items: flex-start;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.footer-figures .tiny-figure {
  width: 40px;
  height: 40px;
}

.footer-figures .tiny-figure:nth-child(2),
.footer-figures .tiny-figure:nth-child(4) {
  margin-bottom: 6px;
}

.figure-chat--footer .speech-bubble {
  font-size: 0.82rem;
  max-width: 22rem;
  text-align: center;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .speech-bubble,
  .figure-chat .speech-bubble:nth-child(even) {
    transform: none;
  }
}

@media (max-width: 520px) {
  .hero-figures-wrap {
    width: 100%;
  }

  .hero-figures-wrap .tiny-figures {
    justify-content: center;
  }

  .hero-figures-wrap .figure-chat--hero .speech-bubble {
    align-self: center !important;
    text-align: center;
  }

  .hero-figures-wrap .figure-chat--hero > .speech-bubble:last-of-type {
    border-radius: 1.5rem;
    border-bottom-left-radius: 1.5rem;
    border-bottom-right-radius: 1.5rem;
  }

  .hero-figures-wrap .figure-chat--hero > .speech-bubble:last-of-type::before {
    left: calc(50% - 12px);
    right: auto;
  }

  .hero-figures-wrap .figure-chat--hero > .speech-bubble:last-of-type::after {
    left: calc(50% - 9px);
    right: auto;
  }
}
