/* Pixel Art Chat Bubble Styles */
.chat-bubble {
  display: none;
  position: fixed; /* Changed to fixed for better viewport positioning */
  background-color: #FAF0E6;
  border: 4px solid #657C6A;
  border-radius: 3px;
  padding: 8px;
  width: 250px;
  height: auto; /* Auto height to fit content */
  min-height: 50px;
  font-family: 'Press Start 2P', cursive;
  font-size: 4px !important; /* Further reduced text size */
  line-height: 1.4;
  color: #9E3500;
  z-index: 9999; /* Ensure it's above everything */
  box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  image-rendering: pixelated;
  transform: scale(0);
  transform-origin: center center;
  pointer-events: none; /* Prevent bubble from interfering with mouse events */
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: hidden; /* Hide overflow content */
}

/* Position calculation will be done by JavaScript */

/* Ensure bubbles stay within viewport */
.feed-item {
  position: relative;
}

/* Chat bubble tail/pointer with custom positioning */
.chat-bubble {
  --tail-top: 50%; /* Default position, will be set by JS */
  --tail-display: block; /* Default display, will be set by JS */
}

.chat-bubble::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  display: var(--tail-display);
}

.chat-bubble.left-bubble::after {
  border-width: 10px 0 10px 15px;
  border-color: transparent transparent transparent #657C6A;
  right: -15px; /* Stick out more */
  top: var(--tail-top);
  transform: translateY(-50%);
}

.chat-bubble.right-bubble::after {
  border-width: 10px 15px 10px 0;
  border-color: transparent #657C6A transparent transparent;
  left: -15px; /* Stick out more */
  top: var(--tail-top);
  transform: translateY(-50%);
}

/* Animation for chat bubble appearance */
@keyframes bubblePop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (hover: hover) and (pointer: fine) {
  .feed-item:hover .chat-bubble {
    display: block;
    animation: bubblePop 0.3s forwards;
  }
}

@media (hover: none), (pointer: coarse) {
  .feed-item {
    position: relative;
    cursor: pointer;
  }
  
  .feed-item::after {
    content: 'ⓘ';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #657C6A;
    font-size: 16px;
    opacity: 0.8;
  }
  
  /* Center bubble styles for mobile */
  .chat-bubble.center-bubble {
    width: 80%;
    max-width: 300px;
    border-radius: 8px;
    background-color: #FAF0E6;
    border: 4px solid #657C6A;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    padding: 15px;
    z-index: 10000;
  }
  
  /* Close button for mobile */
  .chat-bubble.center-bubble::before {
    content: '×';
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 20px;
    color: #657C6A;
    font-weight: bold;
    cursor: pointer;
  }
}

/* Pixel-style text inside chat bubble */
.bubble-text {
  margin: 0;
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
  font-size: 10px !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
}
