/* 应龙计算 · 投稿模块共用样式
   三套主题：明亮(light) / 暗黑(dark) / 霓虹(neon)，由 <html data-theme="..."> 切换 */

/* ---------- 主题变量 ---------- */
:root{
  --green: #219912;
  --pad-x: clamp(18px, 5vw, 34px);   /* 页面左右留白，窄屏自动收窄 */
  --page-bg: #ffffff;
  --ink: #0a0e13;
  --text-soft: #6b7684;
  --muted: #9aa3ad;
  --line: #e6eaef;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --chip-bg: #f2f7f4;
  --tag-bg: #eef8ee;
  --ok-bg: #f0fbf0;   --ok-ink: #14660a;   --ok-line: #bfe6b8;
  --err-bg: #fdf3f2;  --err-ink: #8a1f19;  --err-line: #f0c9c5;
  --glow: none;
}

html[data-theme="dark"]{
  --green: #3ec22c;
  --page-bg: #0d1117;
  --ink: #e6edf3;
  --text-soft: #98a2ad;
  --muted: #6e7781;
  --line: #2a313c;
  --card-bg: #131922;
  --input-bg: #0f141b;
  --chip-bg: rgba(255,255,255,.08);
  --tag-bg: rgba(62,194,44,.16);
  --ok-bg: rgba(62,194,44,.12);   --ok-ink: #8ce87b;  --ok-line: rgba(62,194,44,.35);
  --err-bg: rgba(226,72,60,.12);  --err-ink: #ff9b91; --err-line: rgba(226,72,60,.35);
  --glow: none;
}

html[data-theme="neon"]{
  --green: #2bf5a0;
  --page-bg: #0a0714;
  --ink: #ecf7ff;
  --text-soft: #a99ad6;
  --muted: #8b7cc8;
  --line: rgba(0,240,255,.22);
  --card-bg: rgba(255,255,255,.03);
  --input-bg: rgba(255,255,255,.045);
  --chip-bg: rgba(0,240,255,.12);
  --tag-bg: rgba(0,240,255,.14);
  --ok-bg: rgba(43,245,160,.12);  --ok-ink: #7dffcf;  --ok-line: rgba(43,245,160,.35);
  --err-bg: rgba(255,45,149,.12); --err-ink: #ff8ad0; --err-line: rgba(255,45,149,.35);
  --glow: 0 0 14px rgba(0,240,255,.45);
}

/* ---------- 基础 ---------- */
*{ margin:0; padding:0; box-sizing:border-box; }

html{ height:100%; }

body{
  min-height: 100%;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans SC", "HarmonyOS Sans SC",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  transition: background-color .45s ease, color .45s ease;
}

/* ---------- 顶部导航 ---------- */
.site-nav{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--pad-x);
  border-bottom: 1px solid var(--line);
  background: var(--page-bg);
  flex-wrap: wrap;
}

.brand{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand svg{ width: 34px; height: auto; display: block; }
.brand span{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .04em;
  transform: skewX(-7deg);
  display: inline-block;
  text-shadow: var(--glow);
}

.nav-right{ display: flex; align-items: center; gap: clamp(14px, 2.5vw, 22px); flex-wrap: wrap; }

.nav-links{ display: flex; align-items: center; gap: clamp(14px, 3vw, 26px); }
.nav-links a{
  font-size: 14px;
  color: var(--text-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color .2s ease, border-color .2s ease;
}
.nav-links a:hover{ color: var(--ink); }
.nav-links a.active{ color: var(--ink); font-weight: 700; border-bottom-color: var(--green); }

/* ---------- 主题切换按钮（色块 + 文字）---------- */
.theme-switch{ display: flex; align-items: center; gap: 8px; }

.theme-btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px 5px 7px;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.theme-btn:hover{ color: var(--ink); border-color: var(--green); }
.theme-btn.active{
  color: var(--ink);
  border-color: var(--green);
  background: var(--chip-bg);
  font-weight: 700;
}

.swatch{
  width: 14px; height: 14px;
  border-radius: 4px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(127,127,127,.25);
}
.swatch-neon{ background: linear-gradient(135deg, #00f0ff 0%, #a855f7 55%, #ff2bd6 100%); }
.swatch-dark{ background: linear-gradient(135deg, #252c36 0%, #0d1117 100%); }
.swatch-light{ background: linear-gradient(135deg, #ffffff 0%, #dfe5ec 100%); }

/* ---------- 主体 ---------- */
.container{
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 56px) var(--pad-x) 64px;
  flex: 1;
}

.page-title{
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 900;
  letter-spacing: .04em;
  transform: skewX(-7deg);
  display: inline-block;
  text-shadow: var(--glow);
}
.page-desc{
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
}

/* ---------- 表单 ---------- */
.form{ margin-top: 28px; }
.field{ margin-bottom: 20px; }

.label{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.label span:first-child{ font-size: 14px; font-weight: 700; }
.label .optional{ font-size: 12px; color: var(--muted); }
.counter{ font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over{ color: #d0342c; }

input[type="text"], select, textarea{
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .3s ease;
}
textarea{ min-height: 180px; line-height: 1.75; resize: vertical; }
input[type="text"]:focus, select:focus, textarea:focus{
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33,153,18,.12);
}
select{ cursor: pointer; }
select option{ background: var(--page-bg); color: var(--ink); }

.btn{
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border: none;
  border-radius: 8px;
  padding: 12px 26px;
  cursor: pointer;
  transition: filter .2s ease, opacity .2s ease;
}
.btn:hover{ filter: brightness(1.08); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }

.msg{
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: none;
}
.msg.show{ display: block; }
.msg.ok{ color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-line); }
.msg.err{ color: var(--err-ink); background: var(--err-bg); border-color: var(--err-line); }

/* ---------- 文章列表 ---------- */
.posts{ margin-top: 28px; display: flex; flex-direction: column; gap: 18px; }

.post{
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  transition: border-color .2s ease, background-color .3s ease;
}
.post:hover{ border-color: var(--green); }

.post-head{
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 10px;
}
.tag{
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  background: var(--tag-bg);
  border-radius: 999px;
  padding: 3px 10px;
}
.post-title{
  flex: 1 1 60%;
  min-width: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
  word-break: break-word;
}
/* 只有列表里的标题可点击展开，后台预览里的同名样式不受影响 */
.post .post-title[role="button"]{ cursor: pointer; transition: color .2s ease; }
.post .post-title[role="button"]:hover{ color: var(--green); }
.post .post-title[role="button"]:focus-visible{
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 4px;
}
.post-meta{ margin-bottom: 12px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.post-body{
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 折叠：正文超出卡片只露一部分，底部渐隐提示还有内容 */
.post.is-clamped:not(.expanded) .post-body{
  max-height: 7.4em;      /* 约 4 行（行高 1.85） */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 58%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 58%, transparent 100%);
}

/* 脚部：左侧展开 / 收起，右侧复制，始终贴在帖子最右下角 */
.post-foot{
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  margin-top: 14px;
}
.toggle-btn{
  margin-right: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.toggle-btn:hover{ background: var(--chip-bg); border-color: var(--line); }
.post:not(.is-clamped) .toggle-btn{ display: none; }   /* 没超出的帖子不需要展开 */

.copy-btn{
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 32px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.copy-btn:hover{ color: var(--green); border-color: var(--green); }
.copy-btn.copied{ color: var(--green); border-color: var(--green); background: var(--tag-bg); }
.copy-btn.failed{ color: var(--err-ink); border-color: var(--err-line); background: var(--err-bg); }

/* 点赞：圆圈（空心绿圈）→ 点一下变实心绿圈，再点一下变回空心 */
.like-wrap{
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.like-btn{
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1.5px solid var(--green);
  border-radius: 50%;              /* 圆圈 */
  background: transparent;         /* 空心 */
  color: var(--green);
  cursor: pointer;
  transition: background-color .22s ease, color .22s ease, transform .12s ease;
}
.like-btn svg{ width: 15px; height: 15px; display: block; }
.like-btn:hover{ background: var(--tag-bg); }
.like-btn:focus-visible{ outline: 2px solid var(--green); outline-offset: 2px; }
.like-btn:active{ transform: scale(.92); }

.like-btn.liked{                   /* 已点赞：实心绿圈 + 白色图标 */
  background: var(--green);
  color: #fff;
}
.like-btn.liked:hover{ filter: brightness(1.06); }
.like-btn.busy{ cursor: progress; }

.like-btn.pop{ animation: likePop .34s cubic-bezier(.3,1.4,.5,1); }
@keyframes likePop{
  0%   { transform: scale(1); }
  40%  { transform: scale(1.32); }
  100% { transform: scale(1); }
}

/* 圆圈的自动外边距已经把右侧两个元素推到右边了，复制按钮不用再抢一次 */
.like-wrap ~ .copy-btn{ margin-left: 0; }

.like-count{
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  min-width: 1ch;
  font-variant-numeric: tabular-nums;   /* 数字宽度固定，加减时不跳动 */
  user-select: none;
}
.like-btn.liked + .like-count{ color: var(--green); }

@media (prefers-reduced-motion: reduce){
  .like-btn.pop{ animation: none; }
  .like-btn:active{ transform: none; }
}

.empty, .loading{ font-size: 14px; color: var(--muted); padding: 24px 0; }

/* ---------- 底部 ---------- */
.site-footer{
  padding: 18px var(--pad-x) 26px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .52em;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- 手机端：不留白挤压、不让导航与内容叠在一起 ---------- */
@media (max-width: 640px){
  :root{ --pad-x: 16px; }

  .site-nav{
    padding: 12px var(--pad-x);
    gap: 10px 12px;
    align-items: center;
  }
  .brand svg{ width: 30px; }
  .brand span{ font-size: 16px; }
  /* 导航整行换行到第二排，避免和 logo/站名挤在一行导致重叠 */
  .nav-right{
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
  }
  .nav-links{ gap: 16px; flex-wrap: nowrap; }
  .nav-links a{ font-size: 13px; }
  .theme-btn{ padding: 5px 10px 5px 6px; }

  .container{ padding: 24px var(--pad-x) 48px; }
  .page-title{ font-size: 24px; }

  .posts{ margin-top: 20px; gap: 14px; }
  .post{ padding: 16px 16px 14px; }
  .post-head{ gap: 6px 8px; }
  .post-title{ flex: 1 1 100%; font-size: 17px; }
  .post-body{ font-size: 15px; line-height: 1.8; }
  .post.is-clamped:not(.expanded) .post-body{ max-height: 7.2em; }
  .post-foot{ margin-top: 12px; gap: 8px; }
  .toggle-btn, .copy-btn{ min-height: 36px; padding: 7px 14px; font-size: 13px; }
  .like-btn{ width: 34px; height: 34px; }        /* 手机上圆圈放大一点，更好点 */
  .like-btn svg{ width: 17px; height: 17px; }
}

@media (max-width: 360px){
  .nav-links{ gap: 12px; }
  .nav-links a{ font-size: 12px; }
  .theme-btn .theme-label{ display: none; }   /* 极窄屏只留色块，防止挤出边界 */
  .theme-btn{ padding: 6px; }
}
