/* ============================================================
   Emoji Picker — light + dark + mobile responsive
   ============================================================ */

/* ── Trigger button (in comment form) ─────────────────────── */
.emoji-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid rgba(27, 42, 65, 0.12);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.emoji-trigger-btn:hover {
  background: rgba(219, 122, 18, 0.08);
  border-color: rgba(219, 122, 18, 0.35);
  transform: scale(1.08);
}
.emoji-trigger-btn:active {
  transform: scale(0.96);
}

/* ── Panel (desktop: absolute popup) ──────────────────────── */
.emoji-picker {
  position: absolute;
  z-index: 9000;
  width: 304px;
  background: #fff;
  border: 1px solid rgba(27, 42, 65, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(27, 42, 65, 0.14), 0 2px 8px rgba(27, 42, 65, 0.08);
  overflow: hidden;
  animation: ep-appear 0.15s ease;
}

@keyframes ep-appear {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Tab bar ───────────────────────────────────────────────── */
.emoji-picker__tabs {
  display: flex;
  align-items: center;
  padding: 6px 8px 0;
  gap: 2px;
  border-bottom: 1px solid rgba(27, 42, 65, 0.07);
  background: rgba(245, 247, 250, 0.7);
}

.emoji-picker__tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.emoji-picker__tab:hover {
  opacity: 0.85;
  background: rgba(219, 122, 18, 0.07);
}
.emoji-picker__tab.is-active {
  opacity: 1;
  background: #fff;
  box-shadow: 0 -1px 0 0 #db7a12 inset;
}

/* ── Emoji grid ────────────────────────────────────────────── */
.emoji-picker__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.emoji-picker__grid::-webkit-scrollbar {
  width: 4px;
}
.emoji-picker__grid::-webkit-scrollbar-thumb {
  background: rgba(27, 42, 65, 0.15);
  border-radius: 4px;
}

.emoji-picker__item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  min-height: 34px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
}
.emoji-picker__item:hover {
  background: rgba(219, 122, 18, 0.1);
  transform: scale(1.2);
}
.emoji-picker__item:active {
  transform: scale(0.9);
  background: rgba(219, 122, 18, 0.18);
}

/* ── Dark mode ─────────────────────────────────────────────── */
html[data-theme="dark"] .emoji-picker {
  background: #1e2535;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .emoji-picker__tabs {
  background: rgba(255, 255, 255, 0.04);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] .emoji-picker__tab.is-active {
  background: #1e2535;
}
html[data-theme="dark"] .emoji-picker__item:hover {
  background: rgba(219, 122, 18, 0.18);
}
html[data-theme="dark"] .emoji-trigger-btn {
  border-color: rgba(255, 255, 255, 0.12);
}
html[data-theme="dark"] .emoji-trigger-btn:hover {
  background: rgba(219, 122, 18, 0.12);
  border-color: rgba(219, 122, 18, 0.4);
}

/* ── Mobile: bottom sheet ──────────────────────────────────── */
@media (max-width: 768px) {
  .emoji-picker {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    box-shadow: 0 -4px 24px rgba(27, 42, 65, 0.16);
    animation: ep-slide-up 0.2s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  @keyframes ep-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }

  /* drag handle */
  .emoji-picker::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(27, 42, 65, 0.15);
    border-radius: 2px;
    margin: 10px auto 4px;
  }

  .emoji-picker__tabs {
    padding: 4px 10px 0;
    gap: 4px;
  }

  .emoji-picker__tab {
    height: 44px;
    font-size: 1.3rem;
  }

  .emoji-picker__grid {
    grid-template-columns: repeat(8, 1fr);
    max-height: 44vw;
    padding: 10px 8px 12px;
    gap: 4px;
  }

  .emoji-picker__item {
    min-height: 40px;
    font-size: 1.4rem;
    border-radius: 8px;
  }

  .emoji-picker__item:hover {
    transform: none; /* no hover effect on touch */
  }

  .emoji-trigger-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    font-size: 1.2rem;
  }
}

/* ── Backdrop (mobile only, semi-transparent overlay) ─────── */
.emoji-picker-backdrop {
  display: none;
}
@media (max-width: 768px) {
  .emoji-picker-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 8999;
    background: rgba(0, 0, 0, 0.3);
    animation: ep-fade-in 0.2s ease;
  }
  @keyframes ep-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}
