/* ============================================================
   style.css —— 全站基础样式（公开页 + 表单组件 + 暗色模式）
   ============================================================ */

:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --surface-2: #f5f1ea;
  --ink: #1c1a17;
  --ink-2: #4a453e;
  --muted: #7b736a;
  --line: #e6e0d6;
  --line-strong: #d5cdc0;
  --accent: #b4472e;
  --accent-soft: #f6e9e4;
  --ok: #2f6b4f;
  --danger: #b02a20;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.04), 0 12px 30px -18px rgba(28, 26, 23, 0.22);
  --max: 1080px;
  --narrow: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif CJK SC",
    "Source Han Serif SC", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #141312;
  --surface: #1c1b19;
  --surface-2: #232120;
  --ink: #ece7df;
  --ink-2: #c8c2b8;
  --muted: #938b7f;
  --line: #2f2c28;
  --line-strong: #403b35;
  --accent: #e2836a;
  --accent-soft: #2c211d;
  --ok: #7fbb9b;
  --danger: #e0705f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -24px rgba(0, 0, 0, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}

::selection {
  background: var(--accent);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------- 布局骨架 ------------------------------- */
.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.narrow {
  max-width: var(--narrow);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.brand__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav__link {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav__link--quiet {
  color: var(--muted);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 50%;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  color: var(--accent);
}

/* --------------------------------- 首屏 --------------------------------- */
.hero {
  padding: 56px 0 8px;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 40px;
  align-items: start;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.hero__eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

.hero__name {
  font-size: clamp(34px, 5vw, 50px);
  margin-bottom: 12px;
}

.hero__headline {
  font-size: 17px;
  color: var(--ink-2);
  margin: 0 0 10px;
  font-family: var(--font-serif);
}

.hero__note {
  display: inline-block;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

.hero__bio {
  margin: 22px 0 0;
  max-width: 58ch;
  color: var(--ink-2);
  white-space: pre-line;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.avatar {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 44px;
  color: var(--muted);
  flex: none;
}

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

/* --------------------------------- 分区 --------------------------------- */
.section {
  padding: 54px 0 0;
  scroll-margin-top: 84px;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.section__title {
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section__count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------- 文章列表 ------------------------------- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-item {
  border-bottom: 1px solid var(--line);
}

.post-link {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 24px;
  gap: 20px;
  align-items: start;
  padding: 22px 4px;
  transition: background 0.15s ease, padding-left 0.18s ease;
}

.post-link:hover {
  background: var(--surface);
  padding-left: 12px;
  padding-right: 0;
}

.post-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding-top: 5px;
  letter-spacing: -0.02em;
}

.post-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.65;
}

.post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  font-family: var(--mono);
}

.post-arrow {
  color: var(--line-strong);
  padding-top: 4px;
  transition: transform 0.18s ease, color 0.18s ease;
}

.post-link:hover .post-arrow {
  color: var(--accent);
  transform: translate(3px, -3px);
}

.pin-mark {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--font);
  letter-spacing: 0.04em;
}

/* --------------------------------- 项目 --------------------------------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.project-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.project-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-card__name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.project-card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  flex: 1;
}

.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tech {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 5px;
  padding: 2px 7px;
}

.project-card__links {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--accent);
  padding-top: 4px;
}

.project-card__links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --------------------------------- 链接 --------------------------------- */
.link-groups {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.link-group__title {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 4px;
}

.link-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px dashed var(--line);
  transition: padding-left 0.15s ease;
}

.link-row:hover {
  padding-left: 10px;
}

.link-row__label {
  font-weight: 500;
  font-size: 14.5px;
  flex: none;
}

.link-row__desc {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row__url {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--line-strong);
  flex: none;
}

/* --------------------------------- 页脚 --------------------------------- */
.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
  font-size: 13px;
  color: var(--muted);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.site-footer a:hover {
  color: var(--accent);
}

/* -------------------------------- 文章详情 ------------------------------- */
.article {
  padding: 48px 0 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 26px;
}

.back-link:hover {
  color: var(--accent);
}

.article__title {
  font-size: clamp(28px, 4.4vw, 40px);
  margin-bottom: 16px;
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.prose {
  padding-top: 30px;
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--ink-2);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: 24px;
  margin: 42px 0 14px;
  color: var(--ink);
}

.prose h3 {
  font-size: 19px;
  margin: 32px 0 10px;
  color: var(--ink);
}

.prose p {
  margin: 0 0 18px;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 7px;
}

.prose li::marker {
  color: var(--accent);
}

.prose blockquote {
  margin: 0 0 18px;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}

.prose img {
  border-radius: var(--radius-sm);
  margin: 0 0 20px;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 14.5px;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.prose th {
  background: var(--surface-2);
}

/* -------------------------------- 通用控件 ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--ink-2);
}

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

.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.btn--primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-color: var(--danger);
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn--block {
  width: 100%;
}

/* 表单 */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field__label {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field__hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.65;
}

.textarea--code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}

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

.row > * {
  flex: 1;
  min-width: 160px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.18s ease;
  margin: 0;
  cursor: pointer;
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked {
  background: var(--ok);
}

.switch input:checked::after {
  transform: translateX(15px);
}

/* 提示条 / 空状态 / 骨架 */
.alert {
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13.5px;
  border: 1px solid;
  margin-bottom: 16px;
  display: none;
}

.alert.is-visible {
  display: block;
}

.alert--error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
}

.alert--ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  background: color-mix(in srgb, var(--ok) 8%, transparent);
}

.empty {
  padding: 34px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}

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

.sk-date {
  width: 64px;
  height: 12px;
}

.sk-title {
  width: 52%;
  height: 18px;
  margin-bottom: 9px;
}

.sk-text {
  width: 86%;
  height: 12px;
}

.fade-in {
  animation: fadeIn 0.4s ease both;
}

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

/* Toast */
.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  padding: 10px 15px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease both;
  max-width: 320px;
}

.toast--error {
  background: var(--danger);
  color: #fff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

.center {
  text-align: center;
}

/* -------------------------------- 响应式 -------------------------------- */
@media (max-width: 720px) {
  .container {
    padding: 0 18px;
  }

  .hero {
    padding-top: 36px;
  }

  .hero__grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .avatar {
    width: 84px;
    height: 84px;
    font-size: 30px;
    order: -1;
  }

  .post-link {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .post-date {
    grid-column: 1 / -1;
    padding-top: 0;
  }

  .site-header__inner {
    height: 58px;
  }

  .nav__link {
    padding: 6px 9px;
  }

  .link-row__url,
  .post-arrow {
    display: none;
  }

  .section {
    padding-top: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .back-link {
    display: none;
  }
  body {
    background: #fff;
  }
}
