/* ============================================================
   Rain Pages · 个人文章存储
   全新设计：清爽、克制、以写作为中心
   ============================================================ */

:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0f1b2d;
  --muted: #64748b;
  --faint: #9aa7b8;
  --line: #e5eaf2;
  --line-strong: #cfd8e4;
  --accent: #1e3a8a;
  --accent-strong: #16296b;
  --accent-soft: #e8edf9;
  --mono-bg: #f0f3f8;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: Georgia, "Noto Serif SC", "Songti SC", "STSong", SimSun, serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --topbar-h: 58px;
  --main-pad-y: 30px;
  --main-pad-x: 40px;
  /* 首页顶部背景图：修改下面这行路径即可替换（当前使用 src/shiki.jpg）；?v= 与站点版本号同步，用于缓存刷新 */
  --hero-img: url('src/shiki.jpg?v=1.0.1');
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 14px rgba(15, 27, 45, .04);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

a { color: inherit; }
button { font: inherit; color: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ 顶栏 ============ */

/* --tb-progress 由 script.js 随滚动驱动：
   页面顶部为 0（顶栏隐藏），下滑时渐进浮现（不透明度、背景、位移同步过渡） */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  --tb-progress: 1;
  opacity: var(--tb-progress);
  transform: translateY(calc((1 - var(--tb-progress)) * -100%));
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) calc(var(--tb-progress) * 100%), transparent);
  border-bottom: 1px solid var(--line);
  border-bottom-color: color-mix(in srgb, var(--line) calc(var(--tb-progress) * 100%), transparent);
}

/* 首页（列表视图）：顶栏不占布局位置，让 Hero 从页面最顶端铺满整屏 */
body.topbar-fixed .topbar {
  position: fixed;
  left: 0;
  right: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--muted);
  margin-top: 3px;
}

.search-wrap {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .15s, background .15s;
}

.search-wrap:focus-within {
  background: var(--panel);
  border-color: var(--accent);
}

.search-icon { width: 15px; height: 15px; color: var(--muted); flex: none; }

.search-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
}

.search-wrap input::placeholder { color: var(--faint); }

/* ============ 友链（顶栏下拉面板） ============ */

.links-wrap {
  position: relative;
  flex: none;
  margin-left: auto;
}

.links-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.links-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.links-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.links-icon { width: 15px; height: 15px; flex: none; }

.links-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 28px);
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 27, 45, .14);
}

.links-panel[hidden] { display: none; }

.links-panel:not([hidden]) { animation: linksIn .16s ease-out; }

@keyframes linksIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.links-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 14px;
}

.links-count {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}

.links-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background .12s;
}

.links-item:hover { background: var(--bg); }

.links-info { min-width: 0; }

.links-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.links-desc {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.links-note {
  margin: 10px 2px 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
}

/* ============ 布局 ============ */

.layout { display: flex; align-items: stretch; }

.main {
  flex: 1;
  min-width: 0;
  padding: var(--main-pad-y) var(--main-pad-x) 60px;
}

/* ============ 按钮 ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}

.btn.ghost {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.btn.ghost:hover { border-color: var(--faint); background: var(--bg); }

/* ============ 首页顶部展示区（Hero：整页背景 + 滚动自动收缩） ============ */

/* 外层容器：固定占满一屏高度，保证内部收缩时页面布局稳定 */
.hero-wrap {
  height: 100vh;
  margin: calc(var(--main-pad-y) * -1) calc(var(--main-pad-x) * -1) 0;
  position: relative;
}

@supports (height: 100dvh) {
  .hero-wrap { height: 100dvh; }
}

/* 内层：吸顶显示，高度由 script.js 随滚动从满屏收缩到 0 */
.hero {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 clamp(24px, 6vw, 72px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(246, 248, 251, 0) 55%, rgba(246, 248, 251, .88) 100%),
    linear-gradient(115deg, rgba(10, 22, 48, .82) 0%, rgba(10, 22, 48, .45) 55%, rgba(30, 58, 138, .38) 100%),
    var(--hero-img) center / cover no-repeat,
    linear-gradient(120deg, #16327a, #0a1740);
  color: #f5f8ff;
  --shrink: 0;
}

/* 内容随收缩进度淡出上移 */
.hero-inner {
  max-width: 760px;
  opacity: calc(1 - var(--shrink));
  transform: translateY(calc(var(--shrink) * -24px));
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .8);
}

.hero-eyebrow::before {
  content: '';
  width: 34px;
  height: 2px;
  background: #bfdbfe;
}

/* 标题 + 头像 并排一行 */
.hero-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 26px;
  margin-bottom: 18px;
}

.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(44px, 6.5vw, 84px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .01em;
}

.hero-title em { font-style: normal; color: #bfdbfe; }

/* GitHub 头像链接 */
.hero-avatar {
  display: inline-block;
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .6);
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.hero-avatar:hover {
  transform: scale(1.06);
  border-color: #bfdbfe;
  box-shadow: 0 0 0 4px rgba(191, 219, 254, .3);
}

.hero-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-sub {
  margin: 0 0 36px;
  font-size: 22px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .92);
}

/* 轮换动画：旧文案沉入水下（下坠 + 模糊） */
.hero-sub.hero-sink {
  animation: heroSink .38s ease-in forwards;
}

/* 轮换动画：新文案从水底浮出水面（模糊渐清 + 破水回弹） */
.hero-sub.hero-rise {
  animation: heroRise .9s cubic-bezier(.22, .9, .25, 1) forwards;
}

@keyframes heroSink {
  from { opacity: 1; filter: blur(0); transform: translateY(0); }
  to   { opacity: 0; filter: blur(7px); transform: translateY(14px); }
}

@keyframes heroRise {
  0%   { opacity: 0; filter: blur(12px); transform: translateY(26px) scale(.97); }
  55%  { opacity: .92; filter: blur(3px); transform: translateY(-4px) scale(1.01); }
  75%  { opacity: 1; filter: blur(1px); transform: translateY(2px) scale(1); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

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

.hero .btn {
  padding: 13px 28px;
  font-size: 15.5px;
  border-radius: 11px;
}

.hero .btn.hero-ghost {
  border-color: rgba(255, 255, 255, .55);
  color: #f5f8ff;
  background: rgba(255, 255, 255, .08);
}

.hero .btn.hero-ghost:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .85); }

#articleGrid { scroll-margin-top: 90px; }

@media (max-width: 860px) {
  .hero { padding: 0 28px; }
}

@media (max-width: 560px) {
  .hero { padding: 0 22px; }
  .hero-title { font-size: 40px; }
  .hero-sub { font-size: 18px; }
  .hero-avatar { width: 60px; height: 60px; }
}

/* ============ 列表视图 ============ */

.view { animation: viewIn .18s ease-out; }

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

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

/* 文章区域：左侧 3/4 宽，右侧留白 */
.list-head,
.article-grid,
.empty-state {
  width: 75%;
  max-width: 1000px;
}

.list-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.list-head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.list-count {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.sort-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.sort-select select {
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* 文章行 */

.article-grid { display: flex; flex-direction: column; gap: 14px; }

.article-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  cursor: pointer;                    /* 整张卡片可点击 */
  transition: border-color .12s, box-shadow .12s, transform .12s;
}

.article-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.row-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-top h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--muted);
}

.row-excerpt {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex: none;
}

.row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* 通用小组件 */

.chip {
  display: inline-block;
  flex: none;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-chip {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  white-space: nowrap;
}

/* 空状态 */

.empty-state {
  padding: 70px 20px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, .5);
}

.empty-icon { font-size: 40px; margin-bottom: 10px; }

.empty-state h2 { margin: 0 0 6px; font-size: 18px; }

.empty-state p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ============ 主页底部区块 ============ */

.home-footer {
  margin: 64px calc(var(--main-pad-x) * -1) calc(-1 * 60px);
  padding: 60px 40px 72px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-inner { max-width: 640px; margin: 0 auto; }

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
}

.footer-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--muted);
  margin-top: 3px;
}

.footer-desc {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  color: var(--muted);
}

/* 页脚版本戳 */
.footer-version {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--faint);
}

.footer-top {
  display: inline-block;
  margin-top: 28px;
  padding: 8px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.footer-top:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

@media (max-width: 560px) {
  .home-footer { padding: 44px 20px 56px; }
}

/* ============ 阅读视图 ============ */

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}

.reader {
  max-width: 760px;
  margin: 0 auto;
  padding: 44px 56px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.reader-header { margin-bottom: 34px; }

.reader-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.reader-header h1 {
  margin: 14px 0 12px;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .01em;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.reader-footer {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ============ Markdown 正文 ============ */

.markdown-body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  color: var(--ink);
  word-wrap: break-word;
}

.markdown-body > :first-child { margin-top: 0; }

.markdown-body p { margin: 0 0 1.1em; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.4;
  margin: 1.7em 0 .6em;
  letter-spacing: -.01em;
}

.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 21px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body h4 { font-size: 16px; }

.markdown-body ul,
.markdown-body ol { margin: 0 0 1.1em; padding-left: 1.5em; }

.markdown-body li { margin: .3em 0; }

.markdown-body blockquote {
  margin: 0 0 1.2em;
  padding: 6px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  color: #4c4a3f;
}

.markdown-body blockquote p { margin: .4em 0; }

.markdown-body code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--mono-bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .12em .42em;
}

.markdown-body pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  background: var(--mono-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre;
}

.markdown-body a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body a:hover { color: var(--accent); }

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--line-strong);
  margin: 2em 0;
}

.markdown-body img { max-width: 100%; border-radius: 10px; }

.markdown-body table {
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-family: var(--sans);
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
  text-align: left;
}

.markdown-body th { background: var(--bg); font-weight: 700; }

/* ============ 响应式 ============ */

@media (max-width: 980px) {
  :root { --main-pad-y: 24px; --main-pad-x: 22px; }

  .reader { padding: 32px 28px; }
  .reader-header h1 { font-size: 28px; }
}

@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .brand-sub { display: none; }

  /* 窄屏恢复全宽 */
  .list-head,
  .article-grid,
  .empty-state { width: 100%; }

  .article-row { flex-direction: column; gap: 12px; }
  .row-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .row-meta { flex-direction: row; align-items: center; gap: 12px; }
}

@media (max-width: 560px) {
  :root { --main-pad-y: 18px; --main-pad-x: 14px; }
  .list-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .reader { padding: 24px 18px; border-radius: 12px; }
  .reader-head { flex-wrap: wrap; }
  .reader-header h1 { font-size: 24px; }
  .search-wrap { max-width: none; }
}
