/* The picker: emoji, GIFs and stickers in a conversation (picker.js).
 *
 * The one rule (the user, 11 Oct 2026: "its transparent overlap over the
 * messages is unusable"): the panel is SOLID — the theme's opaque surface,
 * never the see-through one — and on a narrow window it does not lie over the
 * conversation at all: it stands under the box, in the page's flow, where a
 * phone's keyboard stands, and the messages end above it. A wide window has
 * the room for a card over the box instead, hung from the smiley.
 * server/tests/picker.test.mjs holds both.
 */
.xp {
  --xp-cell: 44px;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  background: var(--surface-solid, #fff);
  color: var(--ink);
  border: 1px solid var(--border);
  /* a wide window: a card over the box */
  position: absolute; bottom: calc(100% + 8px); right: 12px; z-index: 14;
  width: 384px; max-width: calc(100% - 16px);
  height: min(440px, calc(100vh - 220px)); min-height: 280px;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  animation: xp-in 150ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.xp[hidden] { display: none; }
[data-theme='dark'] .xp { box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55); }
@keyframes xp-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .xp { animation: none; } }

/* a narrow window: a panel under the box, in the flow — the messages end above it */
@media (max-width: 720px) {
  .xp {
    position: static; width: auto; max-width: none; right: auto;
    height: min(46vh, 340px); min-height: 260px;
    margin-top: 6px; border-width: 1px 0 0; border-radius: 0; box-shadow: none; animation: none;
  }
}

/* the search box: one for all three tabs */
.xp-search { position: relative; flex: none; padding: 8px 10px 6px; }
.xp-search-glyph { position: absolute; left: 21px; top: 50%; transform: translateY(-46%); color: var(--ink-faint); pointer-events: none; display: flex; }
.xp-search-glyph svg { width: 16px; height: 16px; }
.xp-search-glyph svg, .xp-search-clear svg, .xp-tones-x svg { fill: none; stroke: currentColor; stroke-width: 40; stroke-linecap: round; stroke-linejoin: round; }
.xp-search-input {
  box-sizing: border-box; width: 100%; height: 36px; padding: 0 34px 0 34px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: 15px; outline: none; -webkit-appearance: none; appearance: none;
}
.xp-search-input::-webkit-search-cancel-button { display: none; }
.xp-search-input::placeholder { color: var(--ink-faint); }
.xp-search-input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.xp-search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-46%);
  width: 36px; height: 36px; border-radius: 18px; background: none; color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center;
}
.xp-search-clear[hidden] { display: none; }
.xp-search-clear svg { width: 14px; height: 14px; }
.xp-search-clear:hover { color: var(--ink); background: var(--accent-soft); }

/* the tab in front; all three stay in the page so each keeps its place */
.xp-body { position: relative; flex: 1; min-height: 0; }
.xp-body > .xp-pane { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--surface-solid, #fff); }
.xp-body > .xp-pane.on { display: flex; }
.xp-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; outline: none; }

/* emoji: the bar of categories, then every category in one scroll */
.xp-bar, .xp-chips, .xp-tones {
  flex: none; display: flex; align-items: center; gap: 2px; height: 38px; box-sizing: border-box;
  padding: 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.xp-bar::-webkit-scrollbar, .xp-chips::-webkit-scrollbar { display: none; }
.xp-bar[hidden], .xp-tones[hidden] { display: none; }
.xp-bar button {
  flex: none; width: 32px; height: 30px; border-radius: 9px; background: none; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center; filter: grayscale(1); opacity: 0.7;
}
.xp-bar button:hover { background: var(--accent-soft); opacity: 1; }
.xp-bar button.on { background: var(--accent-soft); filter: none; opacity: 1; }
.xp-bar.off button { opacity: 0.3; pointer-events: none; }
.xp-section { padding: 0 8px; content-visibility: auto; }
.xp-section h4 { margin: 0; padding: 10px 4px 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink-muted); }
.xp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--xp-cell), 1fr)); }
.xp-cell {
  height: var(--xp-cell); min-width: 0; padding: 0; border-radius: 10px; background: none; color: var(--ink);
  font-size: 27px; line-height: 1; display: flex; align-items: center; justify-content: center;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.xp-cell:hover, .xp-cell:focus-visible { background: var(--accent-soft); outline: none; }
.xp-cell:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.xp-cell.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.xp-tones { gap: 2px; }
.xp-tones-label { font-size: 12px; font-weight: 700; color: var(--ink-muted); margin: 0 6px 0 4px; white-space: nowrap; }
.xp-tones .xp-cell { flex: 1 1 0; min-width: 0; max-width: 44px; height: 32px; font-size: 22px; }
.xp-section[hidden] { display: none; }
.xp-tones-x { margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 15px; background: none; color: var(--ink-muted); display: flex; align-items: center; justify-content: center; }
.xp-tones-x svg { width: 14px; height: 14px; }
.xp-tones-x:hover { background: var(--accent-soft); }

/* the reactions' "more" (messages.js): the same grid in a small card */
.xp-emoji { display: flex; flex-direction: column; min-height: 0; }
.xp-emoji.compact { width: min(300px, calc(100vw - 48px)); height: 260px; --xp-cell: 40px; }
.xp-emoji.compact .xp-cell { font-size: 24px; }

/* GIFs: chips, then two columns */
.xp-chips { gap: 6px; }
.xp-chip {
  flex: none; height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--border); background: none;
  color: var(--ink-muted); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.xp-chip:hover { color: var(--ink); }
.xp-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.xp-columns { display: flex; gap: 6px; padding: 8px; align-items: flex-start; }
.xp-column { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.xp-gif { display: block; width: 100%; padding: 0; border-radius: 10px; overflow: hidden; background: var(--accent-soft); }
.xp-gif img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xp-gif:hover, .xp-gif:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.xp-skel { border-radius: 10px; background: var(--accent-soft); opacity: 0.6; animation: xp-wait 1.2s ease-in-out infinite alternate; }
@keyframes xp-wait { to { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .xp-skel { animation: none; } }
.xp-note { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 100%; box-sizing: border-box; padding: 24px 28px; text-align: center; }
.xp-note-glyph { font-size: 26px; filter: grayscale(1); opacity: 0.6; }
.xp-note strong { font-size: 15px; color: var(--ink); }
.xp-note span { font-size: 13px; line-height: 1.4; color: var(--ink-muted); }

/* stickers: three shelves on one page */
.xp-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.xp-sticker, .xp-classic, .xp-make {
  aspect-ratio: 1; min-width: 0; padding: 4px; border-radius: 12px; background: none;
  display: flex; align-items: center; justify-content: center;
}
.xp-sticker img { width: 100%; height: 100%; object-fit: contain; display: block; }
.xp-sticker:hover, .xp-classic:hover, .xp-sticker:focus-visible, .xp-classic:focus-visible { background: var(--accent-soft); outline: none; }
.xp-classic { font-size: 44px; line-height: 1; color: var(--ink); font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.xp-make { flex-direction: column; gap: 2px; border: 1px dashed var(--border); background: var(--accent-soft); color: var(--accent); }
.xp-make span { font-size: 24px; line-height: 1; }
.xp-make small { font-size: 11.5px; font-weight: 700; }
.xp-make:hover, .xp-make:focus-visible { border-color: var(--accent); outline: none; }
.xp-hint { grid-column: 1 / -1; margin: 0; padding: 8px 4px; font-size: 13px; line-height: 1.4; color: var(--ink-muted); }
.xp-hint[hidden] { display: none; }
.xp-stickers .xp-section:last-child { padding-bottom: 10px; }

/* the foot: the three tabs, where the thumb is */
.xp-foot { flex: none; padding: 6px 10px 8px; border-top: 1px solid var(--border); }
.xp-tabs { display: flex; height: 36px; padding: 2px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 18px; background: var(--bg); }
.xp-tabs button { flex: 1; border-radius: 16px; background: none; color: var(--ink-muted); font-size: 13.5px; font-weight: 600; }
.xp-tabs button:hover { color: var(--ink); }
.xp-tabs button.on { background: var(--surface-solid, #fff); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.xp-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 720px) {
  .xp-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .xp-tabs { height: 44px; border-radius: 22px; }
  .xp-tabs button { border-radius: 20px; }
  .xp-bar button { width: 40px; height: 34px; }
  .xp-chip { height: 32px; border-radius: 16px; }
  .xp-tones-label { display: none; }
  .xp-tones .xp-cell { height: 34px; }
}
