/* The inbox and a single conversation as game screens (views/inbox.jsx,
   views/conversation.jsx): the trophy-hall frame from
   public/achievements-hall.css, conversations as stone rows with the
   partner's banner, the thread in a sunken panel. Theme tokens are
   re-pointed inside the hall so the older rules in style.css read
   light-on-dark in both themes. */

.ib-hall {
  --text: #f6e9cc;
  --papyrus-text: #f6e9cc;
  --surface-border: rgba(255, 220, 160, 0.16);
  --cloud-bg2: rgba(0, 0, 0, 0.45);
  --ib-gold: #ffd23a;
  --ib-ink-dim: #d4c39f;
  --ib-edge: rgba(255, 220, 160, 0.16);
  --ib-panel: rgba(18, 14, 10, 0.62);
  font-family: "Comfortaa", sans-serif;
}
.ib-hall.page-container { max-width: none; }

/* The old page boxes become the wood frame. */
.ib-hall .ib-frame.inbox-container,
.ib-hall .ib-frame.conversation-container {
  max-width: 760px;
  margin: 0 auto;
  border: 12px solid transparent;
  border-radius: 10px;
  padding: 16px 20px 22px;
}
/* .ach-hall-frame's background shorthand has to win over the dirt texture. */
.ib-hall .ib-frame {
  background:
    linear-gradient(rgba(14, 12, 10, 0.62), rgba(14, 12, 10, 0.74)) padding-box,
    url("/gui/backgroundwalltexture.webp") center top / 260px auto repeat padding-box,
    url("/gui/wooden_texture.png") center / 300px auto repeat border-box;
}

/* ── Inbox header ── */
.ib-hall .ib-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  text-align: left;
}
.ib-hall .ib-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 clamp(1.3rem, 1rem + 1.2vw, 1.8rem)/1.1 "Cinzel", serif;
  letter-spacing: 0.04em;
  color: #ffe9b0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.ib-hall .ib-title i { margin: 0; color: var(--ib-gold); }
.ib-count {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 210, 58, 0.35);
  font-size: 0.78rem;
  color: var(--ib-ink-dim);
}

/* ── Conversation rows ── */
.ib-hall .ib-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ib-hall .conversation-item,
.ib-hall .conversation-item:first-child,
.ib-hall .conversation-item:last-child {
  gap: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ib-panel);
  border: 1px solid var(--ib-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.ib-hall .conversation-item:hover {
  border: 1px solid rgba(255, 210, 58, 0.55);
  background: rgba(40, 30, 14, 0.75);
  transform: translateY(-1px);
}
.ib-hall .conversation-item.unread {
  border: 1px solid rgba(255, 210, 58, 0.6);
  background: linear-gradient(90deg, rgba(90, 62, 10, 0.55), var(--ib-panel) 60%);
  box-shadow: inset 3px 0 0 var(--ib-gold), 0 3px 8px rgba(0, 0, 0, 0.3);
}
.ib-hall .conversation-avatar {
  width: 48px;
  height: 54px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ib-gold);
  font-size: 26px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
}
.ib-hall .conversation-avatar.ib-crest svg { width: 44px; height: auto; display: block; }
.ib-hall .conversation-header { margin-bottom: 3px; gap: 10px; }
.ib-hall .conversation-name {
  font: 700 1rem/1.2 "Cinzel", serif;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ib-hall .conversation-item.unread .conversation-name { color: #ffe27a; }
.ib-hall .conversation-time { flex: none; color: var(--ib-ink-dim); opacity: 0.85; font-size: 0.75rem; }
.ib-hall .conversation-preview { margin-bottom: 3px; color: var(--text); opacity: 0.85; font-size: 0.88rem; }
.ib-hall .conversation-item.unread .conversation-preview { opacity: 1; font-weight: 700; }
.ib-hall .message-count { color: var(--ib-ink-dim); opacity: 0.8; font-size: 0.75rem; }
.ib-hall .unread-count {
  flex: none;
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #7a5310;
  background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%);
  color: #3d2000;
  font: 800 0.8rem/1 "Comfortaa", sans-serif;
  box-shadow: 0 0 10px rgba(255, 210, 58, 0.45);
}
.ib-go { flex: none; color: var(--ib-ink-dim); opacity: 0.6; font-size: 0.85rem; }
.ib-hall .conversation-item:hover .ib-go { color: var(--ib-gold); opacity: 1; }

/* ── Empty and signed-out states ── */
.ib-hall .inbox-empty,
.ib-hall .inbox-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 16px;
  border-radius: 12px;
  background: var(--ib-panel);
  border: 1px solid var(--ib-edge);
  text-align: center;
  color: var(--text);
}
.ib-hall .inbox-empty i,
.ib-hall .inbox-error > i {
  margin: 0 0 4px;
  font-size: 46px;
  color: var(--ib-gold);
  opacity: 0.85;
}
.ib-hall .inbox-empty p,
.ib-hall .inbox-error p { margin: 0; color: var(--text); font-size: 1rem; }
.ib-hall .inbox-empty-hint { color: var(--ib-ink-dim); font-size: 0.85rem; opacity: 1; }
.ib-hall .ib-btn,
.ib-hall .inbox-error .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 18px;
  border: 2px solid #7a5310;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%);
  color: #3d2000;
  font: 800 0.92rem/1 "Cinzel", serif;
  text-decoration: none;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #6b4410;
  cursor: pointer;
}
.ib-hall .ib-btn i,
.ib-hall .inbox-error .btn i { font-size: 1em; margin: 0; color: inherit; opacity: 1; }
.ib-hall .ib-btn:hover,
.ib-hall .inbox-error .btn:hover { filter: brightness(1.06); }

/* ── Conversation ── */
.ib-hall .ib-frame.conversation-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100dvh - 130px);
  max-height: 760px;
  min-height: 420px;
  padding: 12px 14px 14px;
}
.ib-hall .ib-conv-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
}
.ib-hall .ib-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(200, 150, 12, 0.55);
  background: linear-gradient(180deg, rgba(48, 44, 40, 0.92), rgba(22, 20, 18, 0.95));
  color: var(--text);
  font: 700 0.82rem/1 "Cinzel", serif;
}
.ib-hall .ib-back i { margin: 0; color: var(--ib-gold); }
.ib-hall .ib-back:hover { border-color: rgba(230, 206, 106, 0.9); color: #fff; background: linear-gradient(180deg, rgba(58, 52, 44, 0.95), rgba(28, 24, 20, 0.95)); }
.ib-hall .ib-partner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  text-align: left;
}
.ib-partner-crest svg { width: 40px; height: auto; display: block; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55)); }
.ib-hall .ib-partner-icon i { margin: 0; font-size: 26px; color: var(--ib-gold); }
.ib-partner-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 700 clamp(1.1rem, 0.9rem + 0.8vw, 1.45rem)/1.1 "Cinzel", serif;
  color: #ffe9b0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
/* Balances the Back button so the name sits in the middle. */
.ib-head-spacer { width: 0; }
@media (min-width: 481px) {
  .ib-head-spacer { width: 84px; }
}

.ib-hall .messages-thread {
  padding: 14px;
  gap: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--ib-edge);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}
.ib-hall .message-bubble { padding: 9px 13px; border-radius: 12px; }
.ib-hall .message-bubble.sent {
  background: linear-gradient(180deg, rgba(92, 64, 12, 0.92), rgba(56, 38, 6, 0.92));
  border: 1px solid rgba(255, 210, 58, 0.55);
  border-bottom-right-radius: 3px;
}
.ib-hall .message-bubble.sent .message-bubble-content { color: #fff3cf; }
.ib-hall .message-bubble.sent .message-bubble-time { color: rgba(255, 226, 122, 0.75); }
.ib-hall .message-bubble.received {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ib-edge);
  border-bottom-left-radius: 3px;
}
.ib-hall .message-bubble.received .message-bubble-time { color: var(--ib-ink-dim); }
.ib-hall .message-bubble-delete { color: rgba(246, 233, 204, 0.4); }
.ib-hall .conversation-empty { color: var(--ib-ink-dim); margin: auto; padding: 30px 10px; }
.ib-hall .conversation-empty i { color: var(--ib-gold); opacity: 0.6; font-size: 48px; }

/* Input row: same pieces as the chat page. */
.ib-hall .conversation-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}
.ib-hall .conversation-image-form { display: contents; }
.ib-hall .conversation-input-row .conversation-form { flex: 1; min-width: 0; }
.ib-hall .conversation-form {
  padding: 0;
  border: 0;
  background: none;
  gap: 8px;
}
.ib-hall .conversation-form textarea {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--ib-edge);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  resize: none;
}
.ib-hall .conversation-form textarea::placeholder { color: var(--ib-ink-dim); opacity: 0.8; }
.ib-hall .conversation-form textarea:focus { border-color: rgba(255, 210, 58, 0.7); box-shadow: none; }
.ib-hall .conversation-send-btn {
  border: 2px solid #7a5310;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%);
  color: #3d2000;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #6b4410;
}
.ib-hall .conversation-send-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%);
  color: #3d2000;
  filter: brightness(1.06);
}
.ib-hall .conversation-image-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid rgba(200, 150, 12, 0.55);
  background: linear-gradient(180deg, rgba(48, 44, 40, 0.92), rgba(22, 20, 18, 0.95));
  color: var(--ib-gold);
}
.ib-hall .conversation-form-disabled {
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--ib-edge);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ib-ink-dim);
  opacity: 1;
}
.ib-hall .conversation-gift-title { color: var(--ib-gold); }
.ib-hall .conversation-gift-panel { background: rgba(0, 0, 0, 0.3); border-color: rgba(255, 210, 58, 0.3); }
.ib-hall .btn-message-gift {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid #7a5310;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%);
  color: #3d2000;
  font: 800 0.88rem/1 "Cinzel", serif;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #6b4410;
}
.ib-hall .btn-message-gift:hover { filter: brightness(1.06); background: linear-gradient(180deg, #ffe48a 0%, #f0b52e 55%, #c98a12 100%); }
.ib-hall .conversation-gift-description { color: var(--text); }

@media (max-width: 768px) {
  .ib-hall.ach-hall { padding: 16px 6px 24px; }
  .ib-hall .ib-frame.inbox-container { padding: 12px 10px 16px; }
  .ib-hall .ib-frame.conversation-container {
    margin: 0 auto;
    padding: 10px 8px 10px;
    height: calc(100dvh - 120px);
  }
  .ib-hall .ib-conv-head { flex-wrap: nowrap; }
  .ib-hall .ib-partner { order: 0; width: auto; }
  .ib-hall .conversation-item { padding: 9px 10px; gap: 10px; }
  .ib-hall .conversation-avatar { width: 40px; height: 46px; font-size: 22px; }
  .ib-hall .conversation-avatar.ib-crest svg { width: 38px; }
  .ib-hall .messages-thread { padding: 10px; }
}
@media (max-width: 480px) {
  .ib-back-label { display: none; }
  .ib-hall .ib-back { padding: 9px 11px; }
}
/* Keep "Message <name>…" on one line in the narrow phone box. */
.ib-hall .conversation-form textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
