/* ==========================================================================
   theme-zhihu — 通知中心
   顶栏铃铛 + 一块面板。面板挂在 body 层（见 notification.html 的注释），桌面上
   由 notification.js 按铃铛矩形定位成下拉，手机上由 responsive 段变成底部升起
   的单子——和目录单、分享单同一套壳：[hidden] + 下一帧 .is-open + 180ms 退场。

   只有登录用户才渲染这套 DOM，匿名访客连铃铛都没有。
   ========================================================================== */

.notify {
  position: relative;
  display: flex;
  align-items: center;
}

.notify__trigger {
  position: relative;
}

/* 未读徽标骑在铃铛右上角。外圈 2px 底色把它和图标线条隔开，不然数字会糊在
   铃铛的轮廓上。0 的时候整块 hidden，不留一个空点。
   数字用 grid 居中而不是 line-height 撑：16px 的盒子里塞 12px 行高会让字形
   整体偏上 2px，实测墨迹中心比盒子中心高 2px。 */
.notify__badge {
  position: absolute;
  top: 1px;
  right: 0;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.notify__badge[hidden] {
  display: none;
}

/* 只有数字真的变了才弹一下。刷新时徽标由内联脚本从缓存同步画出，不带这个类，
   所以它和导航条一起出现在首帧，不会每次刷新都重新入场一遍。 */
.notify__badge.is-bump {
  animation: notify-badge-in 0.22s ease;
}

@keyframes notify-badge-in {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

/* ---------- 面板外壳 ---------- */

.notify-pop {
  position: fixed;
  z-index: 100;
  display: flex;
  pointer-events: none;
}

.notify-pop.is-open {
  pointer-events: auto;
}

.notify-pop__scrim {
  display: none;
}

.notify-pop__panel {
  display: flex;
  flex-direction: column;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: inherit;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

.notify-pop.is-open .notify-pop__panel {
  opacity: 1;
  transform: none;
}

/* 与搜索 / 目录同一块材质，跟随全局磨砂开关。 */
html[data-glass="on"] .notify-pop__panel {
  -webkit-backdrop-filter: blur(var(--nav-blur)) saturate(115%);
  backdrop-filter: blur(var(--nav-blur)) saturate(115%);
  background: rgba(var(--surface-rgb), var(--nav-veil-panel));
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html[data-glass="on"] .notify-pop__panel {
    background: var(--surface);
  }
}

.notify-pop__panel:focus {
  outline: none;
}

/* ---------- 头部 ---------- */

.notify-pop__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 9px 16px;
  /* 半透明分隔线：面板开磨砂时背后可能是亮图，实色的 --divider 在那种底上
     会变成一道比面板还深的黑划痕。让它跟着背景一起透，就永远只是「淡一档」。 */
  border-bottom: 1px solid color-mix(in srgb, var(--divider) 65%, transparent);
}

.notify-pop__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.notify-pop__count {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.notify-pop__readall {
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.notify-pop__readall[hidden] {
  display: none;
}

.notify-pop__readall:disabled {
  color: var(--muted);
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .notify-pop__readall:not(:disabled):hover {
    background: rgba(var(--accent-rgb), 0.1);
  }
}

.notify-pop__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  color: var(--muted-strong);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.notify-pop__close .icon {
  width: 16px;
  height: 16px;
}

@media (hover: hover) and (pointer: fine) {
  .notify-pop__close:hover {
    background: var(--surface-3-hover);
    color: var(--text);
  }
}

/* ---------- 滚动区 ---------- */

.notify-pop__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.notify-pop__body::-webkit-scrollbar {
  width: 8px;
}

.notify-pop__body::-webkit-scrollbar-track {
  background: transparent;
}

.notify-pop__body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  background-clip: content-box;
  background-color: var(--border-strong);
}

.notify-pop__body::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted);
}

/* ---------- 状态 ---------- */

.notify-state {
  padding: 14px 16px;
}

.notify-state[hidden] {
  display: none;
}

.notify-state--empty,
.notify-state--error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 20px 38px;
  text-align: center;
}

.notify-state--empty .icon {
  width: 26px;
  height: 26px;
  margin-bottom: 2px;
  color: var(--border-strong);
}

.notify-state--empty p,
.notify-state--error p {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}

.notify-state--empty span {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.notify-state__retry {
  height: 28px;
  margin-top: 4px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
}

/* 骨架：四条和真实条目同高的灰块，加载完不会跳高度。 */
.notify-skeleton {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}

.notify-skeleton__dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
}

.notify-skeleton__lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.notify-skeleton__lines i {
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.notify-skeleton__lines i:last-child {
  width: 62%;
}

.notify-state[data-notify-loading] .notify-skeleton {
  animation: notify-pulse 1.3s ease-in-out infinite;
}

.notify-state[data-notify-loading] .notify-skeleton:nth-child(2) { animation-delay: 0.12s; }
.notify-state[data-notify-loading] .notify-skeleton:nth-child(3) { animation-delay: 0.24s; }
.notify-state[data-notify-loading] .notify-skeleton:nth-child(4) { animation-delay: 0.36s; }

@keyframes notify-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- 列表 ---------- */

.notify-list {
  margin: 0;
  padding: 4px;
  list-style: none;
}

.notify-list[hidden] {
  display: none;
}

.notify-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .notify-item:hover {
    background: var(--surface-2);
  }
}

.notify-item.is-unread {
  background: rgba(var(--accent-rgb), 0.055);
}

@media (hover: hover) and (pointer: fine) {
  .notify-item.is-unread:hover {
    background: rgba(var(--accent-rgb), 0.1);
  }
}

.notify-item__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted-strong);
}

.notify-item.is-unread .notify-item__icon {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

.notify-item__icon .icon {
  width: 16px;
  height: 16px;
}

.notify-item__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notify-item__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.notify-item__title {
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.notify-item.is-unread .notify-item__title {
  color: var(--text);
  font-weight: 600;
}

.notify-item__time {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.notify-item__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* 未读点放在图标右下角，读过后淡出——条目不重排。 */
.notify-item__dot {
  position: absolute;
  top: 9px;
  left: 32px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.notify-item.is-unread .notify-item__dot {
  opacity: 1;
}

/* ---------- 底部 ---------- */

.notify-pop__foot {
  border-top: 1px solid color-mix(in srgb, var(--divider) 65%, transparent);
  padding: 4px;
}

.notify-pop__all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.notify-pop__all .icon {
  width: 13px;
  height: 13px;
  color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
  .notify-pop__all:hover {
    background: var(--surface-2);
    color: var(--accent);
  }

  .notify-pop__all:hover .icon {
    color: var(--accent);
  }
}

/* ---------- 手机：底部升起 ---------- */

@media (max-width: 768px) {
  .notify-pop {
    inset: auto 0 0 0;
    max-height: 76vh;
  }

  /* 遮罩逐档照抄搜索 / 目录：不开玻璃两种配色都是 .42，开玻璃后浅色 .24、
     深色 .36。同一块材质不该在两个面板上是两个浓度。 */
  .notify-pop__scrim {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(18, 18, 18, 0.42);
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .notify-pop.is-open .notify-pop__scrim {
    opacity: 1;
  }

  html[data-glass="on"] .notify-pop__scrim {
    background: rgba(18, 18, 18, 0.24);
  }

  html.dark[data-glass="on"] .notify-pop__scrim {
    background: rgba(0, 0, 0, 0.36);
  }

  .notify-pop__panel {
    width: 100%;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    opacity: 1;
    transform: translateY(100%);
  }

  .notify-pop.is-open .notify-pop__panel {
    transform: none;
  }

  .notify-pop__head {
    padding: 12px 10px 10px 16px;
  }

  .notify-item {
    padding: 11px 10px;
  }

  .notify-item__title {
    font-size: 14px;
  }

  .notify-item__text {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notify-pop__panel,
  .notify-pop__scrim,
  .notify-item__dot {
    transition: none;
  }

  .notify-state[data-notify-loading] .notify-skeleton {
    animation: none;
  }
}