/* Rowdy, the farm hand: his name tag and speech bubble on the 3D farm (world.js) and the chat panel
   (rowdy-chat.js). Uses the --fh-* tokens so light and dark both work. */

.rowdy-tag {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  font: inherit;
}
.rowdy-tag.hidden {
  display: none;
}
.rowdy-tag b {
  display: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #f4f1e8;
  background: rgba(20, 26, 22, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 2px 9px;
  box-shadow: 0 2px 10px #0003;
  animation: rowdy-pop 0.2s ease-out;
}
.rowdy-tag.named b {
  display: block;
}
.rowdy-say {
  display: none;
  max-width: 220px;
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--fh-surface, #fff);
  color: var(--fh-ink, #14291e);
  box-shadow: 0 4px 16px #0003;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  position: relative;
}
.rowdy-tag.talking .rowdy-say {
  display: block;
  animation: rowdy-pop 0.25s ease-out;
}
.rowdy-say::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  margin-left: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: var(--fh-surface, #fff);
}
.rowdy-tag:focus-visible b {
  display: block;
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
@keyframes rowdy-pop {
  from {
    transform: scale(0.85) translateY(4px);
    opacity: 0;
  }
}
html[data-motion='calm'] .rowdy-say,
html[data-motion='calm'] .rowdy-tag b {
  animation: none !important;
}

.rowdy-chat {
  position: fixed;
  z-index: 60;
  right: 18px;
  bottom: 18px;
  width: min(380px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  background: var(--fh-surface, #fff);
  color: var(--fh-ink, #14291e);
  border: 1px solid var(--fh-line-strong, #0003);
  border-radius: 14px;
  box-shadow: 0 14px 40px #0004;
  overflow: hidden;
}
.rowdy-chat header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #b3332a;
  color: #fff;
}
.rowdy-chat header div {
  flex: 1;
  min-width: 0;
}
.rowdy-chat header small {
  display: block;
  opacity: 0.85;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rowdy-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f4e2c4;
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
}
.rowdy-face {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
}
.rowdy-chat.talking .rowdy-avatar {
  animation: rowdy-talk 0.5s ease-in-out infinite alternate;
}
@keyframes rowdy-talk {
  to {
    box-shadow: 0 0 0 3px #b3332a88;
  }
}
html[data-motion='calm'] .rowdy-chat .rowdy-avatar {
  animation: none !important;
}
.rowdy-icon {
  background: #ffffff22;
  border: 0;
  color: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
}
.rowdy-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
  background: var(--fh-bg, #eef0e6);
}
.rowdy-msg {
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.35;
}
.rowdy-msg.from-rowdy {
  align-self: flex-start;
  background: var(--fh-surface, #fff);
  border: 1px solid var(--fh-line, #0001);
}
.rowdy-msg.from-you {
  align-self: flex-end;
  background: var(--fh-accent-soft, #e4b86033);
}
.rowdy-msg.thinking {
  font-style: italic;
  color: var(--fh-muted, #4c5d50);
}
.rowdy-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 10px 0;
}
.rowdy-chips button {
  flex: none;
  border: 1px solid var(--fh-line-strong, #0003);
  background: var(--fh-surface-2, #f5f6f0);
  color: var(--fh-ink, #14291e);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.rowdy-orders {
  align-items: center;
}
.rowdy-order-list {
  display: flex;
  gap: 6px;
}
.rowdy-chips-label {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--fh-muted, #4b5d52);
}
.rowdy-orders button {
  border-style: dashed;
}
.rowdy-form {
  display: flex;
  gap: 8px;
  padding: 10px;
}
.rowdy-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--fh-line-strong, #0003);
  background: var(--fh-input, #fff);
  color: var(--fh-ink, #14291e);
  font: inherit;
}
.rowdy-note {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 11px;
  color: var(--fh-faint, #66766a);
}
@media (max-width: 560px) {
  .rowdy-chat {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
  }
}
