/*
Theme Name: Moments 朋友圈
Theme URI: https://uu.ci
Author: Moments
Author URI: https://uu.ci
Description: 高度还原微信朋友圈的 WordPress 主题。封面 + 头像叠加、九宫格图片、点赞与评论气泡、发表动态、无限滚动、图片灯箱，移动端优先，无需任何插件。
Version: 1.0.0
Requires at least: 5.3
Tested up to: 6.6
Requires PHP: 7.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: moments
Tags: blog, one-column, custom-colors, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* =========================================================
   1. 变量与基础
   ========================================================= */
:root {
  --blue: #576b95;
  --text: #191919;
  --text-2: #7f7f7f;
  --sub: #b2b2b2;
  --line: #e6e6e6;
  --gray-box: #f7f7f7;
  --page-bg: #ededed;
  --card-bg: #ffffff;
  --green: #07c160;
  --danger: #fa5151;
  --max: 640px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: var(--blue);
  text-decoration: none;
}

img {
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app {
  position: relative;
  max-width: var(--max);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--card-bg);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.07);
}

@media (max-width: 640px) {
  .app {
    box-shadow: none;
  }
}

/* =========================================================
   2. 封面 + 头像
   ========================================================= */
.hero {
  position: relative;
  background: #fff;
}

.hero-cover {
  position: relative;
  height: 0;
  padding-bottom: 60%;
  background: #3d4450 center / cover no-repeat;
}

.hero-cover.is-default {
  background-image: linear-gradient(135deg, #2b3445 0%, #4c5b74 55%, #7d8ba3 100%);
}

.hero-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 8px 0 6px;
  color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0) 100%);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.icon-btn.dark {
  color: #191919;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.hero-profile {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0 16px 14px;
  margin-top: -34px;
}

.hero-avatar-link {
  flex: 0 0 auto;
  display: block;
}

.hero-avatar {
  display: block;
  width: 68px;
  height: 68px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #ddd;
  object-fit: cover;
}

.hero-info {
  min-width: 0;
  padding-top: 40px;
}

.hero-name {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.hero-bio {
  margin-top: 3px;
  font-size: 13px;
  color: #8c8c8c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 内页顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 6px;
  background: #f7f7f7;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  flex: 1;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   3. 时间线
   ========================================================= */
.feed {
  padding-bottom: calc(80px + var(--safe-bottom));
}

.moment {
  display: flex;
  padding: 18px 16px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.moment:last-child {
  border-bottom: 0;
}

.m-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin-right: 12px;
}

.m-avatar img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #eee;
}

.m-body {
  flex: 1;
  min-width: 0;
  padding-bottom: 16px;
}

.m-name {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  color: var(--blue);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.m-text {
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
  white-space: normal;
}

.m-text.is-clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

.m-text p {
  margin: 0 0 6px;
}

.m-text p:last-child {
  margin-bottom: 0;
}

.m-text a {
  color: var(--blue);
}

.m-text img {
  height: auto;
  border-radius: 2px;
}

.m-unfold {
  display: inline-block;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 16px;
}

/* ---------- 九宫格 ---------- */
.m-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  max-width: 100%;
}

.m-imgs a {
  display: block;
  overflow: hidden;
  border-radius: 2px;
  background: #f2f2f2;
}

.m-imgs img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 单图：大图 */
.m-imgs.n1 a {
  width: 62%;
  max-width: 320px;
}

.m-imgs.n1 img {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: cover;
}

/* 2 张及以上：每格 1/3，4 张时容器收窄成 2×2 */
.m-imgs:not(.n1) a {
  width: calc((100% - 8px) / 3);
  aspect-ratio: 1 / 1;
}

.m-imgs.n4 {
  max-width: calc(66.6667% + 4px);
}

.m-imgs.n4 a {
  width: calc((100% - 4px) / 2);
}

/* 兼容不支持 aspect-ratio 的老浏览器 */
@supports not (aspect-ratio: 1 / 1) {
  .m-imgs:not(.n1) a {
    height: 0;
    padding-bottom: calc((100% - 8px) / 3);
    position: relative;
  }
  .m-imgs:not(.n1) img {
    position: absolute;
    inset: 0;
  }
}

/* ---------- 位置 ---------- */
.m-loc {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
  color: var(--blue);
  font-size: 13px;
}

.m-loc svg {
  width: 13px;
  height: 13px;
}

/* ---------- 时间 + 操作按钮 ---------- */
.m-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  margin-top: 8px;
}

.m-time {
  color: var(--sub);
  font-size: 13px;
}

.m-tools {
  position: relative;
  flex: 0 0 auto;
}

.m-action {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 24px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: var(--gray-box);
  color: var(--blue);
}

.m-action svg {
  width: 16px;
  height: 16px;
}

.m-action:active {
  background: #ececec;
}

.m-pop {
  position: absolute;
  right: 0;
  top: 30px;
  z-index: 20;
  display: flex;
  overflow: hidden;
  border-radius: 6px;
  background: #4c4c4c;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.m-pop button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 14px;
}

.m-pop button + button {
  border-left: 1px solid #5d5d5d;
}

.m-pop button:active {
  background: #3d3d3d;
}

.m-pop svg {
  width: 16px;
  height: 16px;
}

/* =========================================================
   4. 点赞 / 评论气泡
   ========================================================= */
.m-interact {
  display: none;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--gray-box);
  font-size: 15px;
}

.m-interact.has {
  display: block;
}

.m-likes {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 7px 10px;
  color: var(--blue);
  line-height: 1.5;
}

.m-likes svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 3px;
  color: var(--blue);
}

.like-names {
  word-break: break-word;
}

.like-name + .like-name::before {
  content: "，";
}

.m-cmts {
  padding: 2px 10px 6px;
  border-top: 1px solid #ececec;
}

.m-interact > .m-cmts:first-child {
  border-top: 0;
  padding-top: 6px;
}

.m-likes + .m-cmts {
  margin-top: 0;
}

.m-cmt {
  padding: 3px 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  cursor: pointer;
}

.m-cmt .who {
  color: var(--blue);
  font-weight: 600;
}

.m-cmt .reply-to,
.m-cmt .colon {
  color: var(--text);
}

.m-cmt .colon {
  margin-right: 1px;
}

.m-cmt:active {
  background: #efefef;
}

/* =========================================================
   5. 底部评论输入条
   ========================================================= */
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  display: block;
  visibility: hidden;
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  transform: translateY(100%);
  transition: transform 0.22s ease, visibility 0.22s ease;
}

.composer.show {
  visibility: visible;
  transform: translateY(0);
}

.c-reply {
  margin-bottom: 6px;
  color: #8a8a8a;
  font-size: 13px;
}

.c-reply b {
  color: var(--blue);
  font-weight: 600;
}

.c-name {
  width: 100%;
  height: 34px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid #e2e2e2;
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
  outline: none;
}

.c-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.c-text {
  flex: 1;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #e2e2e2;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.c-text:focus,
.c-name:focus {
  border-color: #c9c9c9;
}

.c-send {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
}

.c-send:disabled {
  opacity: 0.6;
}

/* =========================================================
   6. 图片灯箱
   ========================================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 94vw;
  max-height: 86vh;
  object-fit: contain;
  user-select: none;
}

.lb-close,
.lb-prev,
.lb-next {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lb-close {
  top: 18px;
  right: 18px;
}

.lb-prev {
  top: 50%;
  left: 14px;
  margin-top: -22px;
}

.lb-next {
  top: 50%;
  right: 14px;
  margin-top: -22px;
}

.lb-close svg,
.lb-prev svg,
.lb-next svg {
  width: 22px;
  height: 22px;
}

.lb-prev[hidden],
.lb-next[hidden] {
  display: none !important;
}

/* =========================================================
   7. 列表尾部 / 空状态 / 作者页
   ========================================================= */
.feed-end {
  padding: 22px 16px calc(30px + var(--safe-bottom));
  text-align: center;
}

.feed-tip {
  padding: 20px 0;
  color: var(--sub);
  font-size: 13px;
  text-align: center;
}

.load-more {
  padding: 8px 22px;
  border: 1px solid #ddd;
  border-radius: 16px;
  background: #fff;
  color: var(--text-2);
  font-size: 14px;
}

.load-more:disabled {
  opacity: 0.5;
}

.empty {
  padding: 80px 24px;
  color: var(--sub);
  font-size: 15px;
  text-align: center;
}

.author-title {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 14px;
}

/* =========================================================
   8. 发表动态
   ========================================================= */
.publish-form {
  padding: 0 0 40px;
  background: #fff;
}

.pf-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  background: #f7f7f7;
  border-bottom: 1px solid var(--line);
}

.pf-title {
  font-size: 17px;
  font-weight: 600;
}

.pf-cancel {
  color: var(--text);
  font-size: 15px;
}

.pf-submit {
  padding: 6px 14px;
  border: 0;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
}

.pf-submit:disabled {
  opacity: 0.6;
}

#pf-content {
  display: block;
  width: 100%;
  min-height: 130px;
  padding: 16px;
  border: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  outline: none;
  resize: none;
}

.pf-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px;
}

.pf-images figure {
  position: relative;
  width: calc((100% - 12px) / 3);
  margin: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 3px;
  background: #f2f2f2;
}

.pf-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pf-images .rm {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

.pf-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px 0;
}

.pf-add {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 64px;
  width: 64px;
  flex-direction: column;
  justify-content: center;
  border: 1px dashed #dcdcdc;
  border-radius: 3px;
  background: #fafafa;
  color: #b2b2b2;
  font-size: 12px;
  cursor: pointer;
}

.pf-add span {
  font-size: 22px;
  line-height: 1;
}

.pf-add em {
  font-style: normal;
}

#pf-location {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #ececec;
  border-radius: 4px;
  background: #fafafa;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.pf-tip {
  padding: 12px 16px 0;
  color: var(--danger);
  font-size: 13px;
}

.publish-guest {
  padding: 90px 24px;
  text-align: center;
}

.publish-guest p {
  margin: 0 0 18px;
  color: var(--text-2);
}

.btn-primary {
  display: inline-block;
  padding: 9px 26px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
}

/* 单页 */
.page-wrap {
  padding: 22px 16px 60px;
}

.page-title {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.35;
}

.page-body {
  font-size: 16px;
  line-height: 1.75;
  word-break: break-word;
}

.page-body img {
  height: auto;
  border-radius: 3px;
}

.page-body h2,
.page-body h3 {
  margin: 22px 0 10px;
  font-size: 18px;
}

.page-body a {
  color: var(--blue);
}

/* =========================================================
   9. 桌面端微调
   ========================================================= */
@media (min-width: 641px) {
  .moment {
    padding-top: 20px;
  }

  .m-text,
  .m-cmt,
  .m-likes {
    font-size: 15px;
  }

  .hero-cover {
    padding-bottom: 52%;
  }
}
