/* Bảng tuỳ chọn của từng bài viết, mở khi bấm nút "..." trên thẻ bài ở trang Tin tức.
   Xem js/post-menu.js.

   Dựng theo kiểu bottom sheet: trên điện thoại trượt lên từ đáy, trên máy tính neo giữa
   màn hình như hộp thoại. Cùng một khối HTML, chỉ khác vài luật ở media query dưới cùng. */

.pm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.pm-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pm-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 0.5rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 1rem 1rem 0 0;
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  /* Cuộn mượt trên iOS và không kéo theo trang nền */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.pm-overlay.is-open .pm-sheet {
  transform: translateY(0);
}

/* Hàng đầu: vạch kéo ở giữa, nút đóng nằm góc phải.
   Dùng flex để vạch tự căn giữa theo bề ngang tấm bảng, không bị nút đóng đẩy lệch. */
.pm-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  margin-bottom: 0.4rem;
}

/* Thanh vạch nhỏ ở đầu, gợi ý kéo xuống để đóng */
.pm-grip {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: #c9c9cf;
}

.pm-close {
  position: absolute;
  top: 50%;
  right: 0.15rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e9e9ed;
  color: #4a4a52;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pm-close svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.pm-close:hover,
.pm-close:focus-visible {
  background: #dcdce2;
  color: #1c1c1e;
}

.pm-close:focus-visible {
  outline: 2px solid #522546;
  outline-offset: 2px;
}

.pm-close:active {
  background: #cfcfd6;
}

/* Tấm bảng nhận tiêu điểm khi mở (tabindex="-1") nhưng KHÔNG vẽ viền — viền ở đây
   trông như một mục đang được chọn sẵn. Xem chú thích trong js/post-menu.js. */
.pm-sheet:focus {
  outline: none;
}

/* Mỗi nhóm là một khối bo tròn nền xám nhạt, giống bảng tuỳ chọn quen thuộc */
.pm-group {
  background: #f2f2f5;
  border-radius: 0.85rem;
  overflow: hidden;
}

.pm-group + .pm-group {
  margin-top: 0.75rem;
}

.pm-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 0;
  background: transparent;
  color: #1c1c1e;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pm-item + .pm-item {
  /* Đường kẻ thụt vào cho thẳng hàng với chữ, không cắt qua ô biểu tượng */
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.07);
}

.pm-item:hover,
.pm-item:focus-visible {
  background: rgba(0, 0, 0, 0.045);
}

.pm-item:focus-visible {
  outline: 2px solid #522546;
  outline-offset: -2px;
}

.pm-item:active {
  background: rgba(0, 0, 0, 0.08);
}

.pm-item[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.pm-icon {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  margin-top: 0.1rem;
  color: #1c1c1e;
}

.pm-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* display:block cho cả ba: chúng là <span> nên mặc định chảy inline, thiếu luật này thì
   tiêu đề và mô tả dính liền nhau thành một dòng ("Quan tâmBạn sẽ nhìn thấy..."). */
.pm-text {
  display: block;
  min-width: 0;
}

.pm-title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.pm-desc {
  display: block;
  margin-top: 0.1rem;
  color: #6b6b73;
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Trạng thái đã chọn của cặp Quan tâm / Không quan tâm */
.pm-item.is-on .pm-title { color: #522546; }
.pm-item.is-on .pm-icon { color: #522546; }

/* Lời báo ngắn sau khi bấm, tự biến mất */
.pm-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 10001;
  transform: translateX(-50%) translateY(0.5rem);
  max-width: min(90vw, 26rem);
  padding: 0.7rem 1.1rem;
  border-radius: 0.7rem;
  background: rgba(28, 28, 30, 0.94);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pm-toast.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Máy tính: neo giữa màn hình như hộp thoại thay vì dán đáy */
@media (min-width: 768px) {
  .pm-overlay {
    align-items: center;
  }

  .pm-sheet {
    border-radius: 1rem;
    transform: translateY(1rem) scale(0.98);
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
  }

  .pm-overlay.is-open .pm-sheet {
    transform: translateY(0) scale(1);
  }

  /* Máy tính không có thao tác kéo nên bỏ vạch, nhưng GIỮ hàng đầu lại để nút đóng
     vẫn có chỗ đứng. */
  .pm-grip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pm-overlay,
  .pm-sheet,
  .pm-toast {
    transition: none;
  }
}
