/* ============================================================
   北工大孙宇晨 · 个人博客  共用样式
   ------------------------------------------------------------
   设计系统移植自 Java 课设的 personal-blog：
   橄榄绿主色 + 无衬线/衬线混排 + Hero 四个纯 CSS 动效。
   Hero 全部由 CSS 绘制（clip-path / linear-gradient），不依赖任何图片。
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  --c-primary:       #97a00d;
  --c-primary-dark:  #6f7609;
  --c-primary-light: #f1f4df;

  --c-bg:      #f6f7f2;
  --c-surface: #ffffff;
  --c-text:    #2b2f26;
  --c-muted:   #737a6c;
  --c-border:  #e2e5d9;
  --c-danger:  #b4453a;

  --font-sans:  "Microsoft YaHei", "微软雅黑", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", "宋体", Georgia, "Times New Roman", serif;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.8;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); }

/* ============================================================
   Hero 区
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #262a21 0%, #343a28 50%, #565c1a 100%);
  background-size: 200% 200%;
  color: #ffffff;
  animation: heroGradient 6s ease-in-out infinite;
}

@keyframes heroGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 右侧斜切装饰块：right 取负值 + 宽度加宽，保证左右滑动时右侧不露缝 */
.hero-art {
  position: absolute;
  top: 0;
  right: -80px;
  bottom: 0;
  width: calc(48% + 80px);
  background: linear-gradient(160deg, #97a00d 0%, #6f7609 100%);
  clip-path: polygon(24% 0, 100% 0, 100% 100%, 0 100%);
  animation: heroSlide 8s ease-in-out infinite;
}

@keyframes heroSlide {
  0%   { transform: translateX(0) skewX(-2deg); }
  50%  { transform: translateX(140px) skewX(2deg); }
  100% { transform: translateX(0) skewX(-2deg); }
}

/* 扫光：一道斜向亮带循环扫过 Hero 区 */
.hero-inner::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  z-index: 2;
  width: 26%;
  height: 200%;
  background: linear-gradient(90deg,
              rgba(255, 255, 255, 0) 0%,
              rgba(255, 255, 255, 0.22) 50%,
              rgba(255, 255, 255, 0) 100%);
  transform: rotate(18deg);
  pointer-events: none;
  animation: heroShine 4.5s ease-in-out infinite;
}

@keyframes heroShine {
  0%   { left: -60%; }
  100% { left: 135%; }
}

/* 装饰块上的点阵纹理，沿斜向缓慢漂移 */
.hero-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 18px 18px;
  animation: dotDrift 3s linear infinite;
}

@keyframes dotDrift {
  from { background-position: 0 0; }
  to   { background-position: 36px 36px; }
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 900px;
  min-height: 300px;
  margin: 0 auto;
  padding: 44px 20px;
}

/* 首页 Hero 高一些，内页矮一些 */
.hero--home .hero-inner { min-height: 52vh; }

.hero-text { max-width: 560px; }

.hero-eyebrow {
  color: #c8cf9a;
  font-size: 12px;
  letter-spacing: 4px;
}

.hero-title {
  margin: 12px 0 0;
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 4px;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

/* 文案错落入场：逐级延迟；fill-mode: both 让延迟期间保持透明，结束后停在终态 */
.hero-eyebrow,
.hero-title,
.hero-actions {
  animation: heroIn .7s cubic-bezier(.22, .61, .36, 1) both;
}

.hero-eyebrow { animation-delay: .05s; }
.hero-title   { animation-delay: .18s; }
.hero-actions { animation-delay: .32s; }

@keyframes heroIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-block;
  padding: 9px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--c-primary); color: #ffffff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); }

.btn-ghost {
  border-color: rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #ffffff;
}
.btn-ghost:hover:not(:disabled) {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* 内页（浅色底）用的次要按钮 */
.btn-outline {
  border-color: var(--c-border);
  background: var(--c-surface);
  color: var(--c-muted);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--c-primary);
  color: var(--c-primary-dark);
}

.btn-danger {
  border-color: #e6d3d0;
  background: transparent;
  color: var(--c-danger);
}
.btn-danger:hover:not(:disabled) {
  background: #fbf1f0;
  border-color: var(--c-danger);
}

.btn-sm { padding: 5px 14px; font-size: 13px; }

/* ============================================================
   主体容器
   ============================================================ */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 20px 0;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.list-head h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.list-head .count { color: var(--c-muted); font-size: 13px; }

/* ============================================================
   文章卡片
   ============================================================ */
.entry {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-bottom: 18px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.entry:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(43, 47, 38, 0.09);
  border-color: #d6dac6;
}

.entry .date {
  font-size: 13px;
  color: var(--c-primary);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.entry h3 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
  margin: 6px 0 12px;
}

.entry h3 a { color: inherit; }
.entry h3 a:hover { color: var(--c-primary-dark); }

.entry .summary {
  color: var(--c-muted);
  font-size: 14.5px;
}

.entry .more {
  display: inline-block;
  margin-top: 14px;
  font-size: 13.5px;
}

/* ============================================================
   单篇文章正文
   ============================================================ */
.article {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px 48px;
}

.article .meta {
  font-size: 13px;
  color: var(--c-primary);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.article h1 {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 1px;
  margin: 10px 0 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--c-border);
}

/* 关键：正文按纯文本存储，靠 pre-wrap 保留换行与空行，
   同时不做任何 HTML 解析 —— 这是防 XSS 的第一道闸。 */
.article .body {
  font-size: 15.5px;
  line-height: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   表单（登录 / 写作）
   ============================================================ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 30px;
  margin-bottom: 22px;
}

.card > h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13.5px;
  color: var(--c-muted);
  margin-bottom: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 13px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--c-text);
  background: #fdfdfb;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(151, 160, 13, 0.13);
}

.field textarea {
  min-height: 320px;
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   后台：已发布文章列表
   ============================================================ */
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--c-border);
}

.admin-row:last-child { border-bottom: none; }

.admin-row .info { min-width: 0; }

.admin-row .t {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row .d {
  font-size: 12.5px;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

.admin-row .ops { display: flex; gap: 8px; flex-shrink: 0; }

/* ============================================================
   状态提示
   ============================================================ */
.state {
  color: var(--c-muted);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

.notice {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.notice-error {
  background: #fbf1f0;
  border: 1px solid #ecd6d2;
  color: var(--c-danger);
}

.notice-ok {
  background: var(--c-primary-light);
  border: 1px solid #dde3bd;
  color: var(--c-primary-dark);
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.topbar .who { font-size: 13.5px; color: var(--c-muted); }

/* ============================================================
   页脚
   ============================================================ */
.site-footer {
  margin-top: 56px;
  padding: 26px 0 56px;
  border-top: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: 13px;
  text-align: center;
}

.site-footer .links { margin-top: 8px; }
.site-footer .links a { margin: 0 8px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 720px) {
  .hero-art { width: 100%; opacity: 0.25; }
  .hero-title { font-size: 30px; letter-spacing: 2px; }
  .hero-inner { min-height: 260px; padding: 40px 20px; }
  .hero--home .hero-inner { min-height: 46vh; }
  .entry { padding: 22px 20px; }
  .article { padding: 26px 20px 34px; }
  .article h1 { font-size: 23px; }
  .admin-row { flex-direction: column; align-items: flex-start; }
  .admin-row .ops { width: 100%; }
  .field textarea { min-height: 240px; }
}

/* ---------- 尊重系统的「减少动效」偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero, .hero-art, .hero-art::after, .hero-inner::after,
  .hero-eyebrow, .hero-title, .hero-actions {
    animation: none;
  }
  .entry { transition: none; }
}
