/* ==========================================================================
   My Site — 基础样式
   1. 设计令牌（改这里就能全站换肤）
   2. 基础重置与排版
   3. 通用组件：按钮、卡片、列表
   4. 页头 / 导航 / 主题切换
   5. 首页与内页版块
   6. 页脚
   7. 响应式与动效偏好
   ========================================================================== */

/* 1. 设计令牌
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --bg: #f6f4ee;
  --surface: #fffdf8;
  --surface-soft: #efece2;
  --text: #1b1d18;
  --muted: #66655c;
  --line: #e2ddcf;

  --accent: #2e6b55;
  --accent-strong: #245443;
  --accent-soft: rgba(46, 107, 85, 0.10);
  --accent-contrast: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(25, 24, 15, 0.05), 0 14px 34px -22px rgba(25, 24, 15, 0.35);

  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101210;
  --surface: #171a15;
  --surface-soft: #1e221b;
  --text: #eceade;
  --muted: #a3a197;
  --line: #2c2f26;

  --accent: #86c2a7;
  --accent-strong: #a6d6bf;
  --accent-soft: rgba(134, 194, 167, 0.12);
  --accent-contrast: #0e110d;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -24px rgba(0, 0, 0, 0.8);
}

/* 没有 JS 时跟随系统偏好（有 JS 时上面两套规则已足够） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #101210;
    --surface: #171a15;
    --surface-soft: #1e221b;
    --text: #eceade;
    --muted: #a3a197;
    --line: #2c2f26;
    --accent: #86c2a7;
    --accent-strong: #a6d6bf;
    --accent-soft: rgba(134, 194, 167, 0.12);
    --accent-contrast: #0e110d;
  }
}

/* 2. 基础重置与排版
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

/* 跳转链接聚焦到 main 时，避免内容被吸顶页头遮住 */
#main { scroll-margin-top: 4.5rem; }

img, svg, video { display: block; max-width: 100%; height: auto; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 {
  margin: 0 0 0.6em;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.05rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
}

.container {
  width: min(100% - 2.5rem, var(--maxw));
  margin-inline: auto;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 1rem;
  text-decoration: none;
}

.eyebrow {
  margin-bottom: 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  max-width: 62ch;
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  color: var(--muted);
}

/* 3. 通用组件
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.68rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 1rem;
}

.card {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

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

.card h3 { margin-bottom: 0.5rem; }

.card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.card-meta {
  margin-bottom: 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.card-empty {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.card-empty:hover { transform: none; }

.list-check {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 70ch;
}

.list-check li {
  position: relative;
  padding-left: 2rem;
  color: var(--muted);
}

.list-check li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.3rem;
  height: 1.3rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.note {
  max-width: 70ch;
  margin-top: 1.75rem;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.92rem;
}

.note:last-child { margin-bottom: 0; }

/* 4. 页头 / 导航
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.9rem;
  font-weight: 800;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
}

.main-nav a {
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.92rem;
}

.main-nav a:hover {
  color: var(--text);
  background: var(--surface-soft);
  text-decoration: none;
}

.main-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

.nav-toggle { display: none; }

.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* 5. 首页与内页版块
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(3.5rem, 9vw, 7rem);
  border-bottom: 1px solid var(--line);
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 42rem;
  height: 42rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 62%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.28;
  mask-image: radial-gradient(ellipse at 70% 20%, #000, transparent 68%);
  -webkit-mask-image: radial-gradient(ellipse at 70% 20%, #000, transparent 68%);
  pointer-events: none;
}

.hero .container { position: relative; z-index: 1; }

.hero h1 { max-width: 18ch; }

.hero .lead { margin-top: 1.25rem; }

.section { padding-block: clamp(2.75rem, 6vw, 4.5rem); }

.section-alt {
  border-block: 1px solid var(--line);
  background: var(--surface);
}

.section-tight { padding-top: 1.5rem; }

.section-head { margin-bottom: 2rem; }

.section-head h2 { margin-bottom: 0; }

.page-head {
  padding-block: clamp(2.5rem, 6vw, 4rem) 0.5rem;
}

.page-head h1 { margin-bottom: 1rem; }

.prose {
  max-width: 68ch;
}

.prose h2 { margin-top: 2.25rem; }
.prose h2:first-child { margin-top: 0; }

.prose p,
.prose li { color: var(--muted); }

.prose ol { padding-left: 1.25rem; }

.prose li { margin-bottom: 0.4rem; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 1rem;
}

.contact-item {
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.contact-item p:last-child { margin-bottom: 0; }

.notfound {
  display: grid;
  place-items: center;
  padding-block: clamp(4rem, 10vw, 8rem);
  text-align: center;
}

.notfound .lead { margin-inline: auto; }
.notfound .actions { justify-content: center; }

.notfound-code {
  margin: 0;
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--accent);
  opacity: 0.35;
}

.notfound h1 { margin-top: 0.5rem; }

/* 6. 页脚
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 1.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.site-footer p { margin: 0; }

/* 7. 响应式
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .nav-toggle { display: inline-grid; margin-left: auto; }

  .main-nav {
    display: none;
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    right: 0;
    z-index: 60;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    margin-left: 0;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .main-nav.is-open { display: flex; }

  .main-nav a { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); }

  .theme-toggle { margin-left: 0; }

  .hero h1 { max-width: none; }
}

@media (max-width: 420px) {
  .container { width: min(100% - 1.75rem, var(--maxw)); }

  .brand span:last-child { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
