/* ============================================================
   Fihag · 作品集
   暖纸感编辑风：米白底 / 近黑墨 / 陶土橘
   ============================================================ */

:root {
  --bg: #f0eee6;            /* 象牙纸底 */
  --card: #faf9f5;          /* 卡片纸面 */
  --ink: #141413;           /* 近黑墨色 */
  --ink-70: rgba(20, 20, 19, 0.70);
  --ink-55: rgba(20, 20, 19, 0.55);
  --line: rgba(20, 20, 19, 0.14);
  --line-strong: rgba(20, 20, 19, 0.34);
  --accent: #cc785c;        /* 陶土橘 */
  --accent-deep: #b4633f;
  --accent-soft: rgba(204, 120, 92, 0.14);
  --paper-dark: #191918;    /* 近黑反白分区 */
  --paper-dark-ink: #f0eee6;
  --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, "Times New Roman", "STSong", "SimSun", serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 8px;
}

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

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.container {
  width: min(1120px, calc(100% - 48px));
  margin-inline: auto;
}

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

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

/* ---- 跳转链接 ---- */
.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  top: 16px;
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: var(--radius);
}
.skip-link:focus { inset-inline-start: 16px; }

/* ---- 光标跟随光晕（置于内容之上，乘法混合产生环境光效果） ---- */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  background: radial-gradient(circle,
              rgba(204, 120, 92, 0.55) 0%,
              rgba(214, 138, 106, 0.28) 32%,
              rgba(214, 138, 106, 0.10) 55%,
              transparent 72%);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 50;
  transform: translate(-600px, -600px);
  will-change: transform;
}

/* ---- 头部 ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 16px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-start: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.nav-list {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-link {
  color: var(--ink-70);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 150ms ease-out;
}
.nav-link:hover { color: var(--ink); }

/* ---- 下划线展开 ---- */
.u-link { position: relative; }

.u-link::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: -4px;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: inline-start;
  transition: transform 250ms var(--ease-out);
}
.u-link:hover::after,
.u-link:focus-visible::after { transform: scaleX(1); }

/* ---- Hero ---- */
.hero {
  padding-block: clamp(64px, 12vh, 128px);
}

/* ---- Hero 打字机 kicker ---- */
.hero-kicker {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  margin-bottom: 20px;
  min-height: 22px;
}

.type-text { display: inline-block; }

.type-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-inline-start: 3px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: type-blink 0.9s steps(1) infinite;
}

@keyframes type-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ---- Hero 标题逐字浮现 ---- */
.hero-title {
  font-size: clamp(44px, 7.5vw, 88px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-title .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em) rotate(2deg);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
  transition-delay: var(--char-delay, 0ms);
}
.hero-title.is-split .char {
  opacity: 1;
  transform: none;
}

.hero-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--accent-deep);
}

.hero-sub {
  margin-top: 28px;
  max-width: 56ch;
  font-size: 18px;
  color: var(--ink-70);
}

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

/* ---- 数据统计条 ---- */
.stats { position: relative; z-index: 1; padding-block: 8px 64px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line-strong);
}

.stat {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat + .stat { border-inline-start: 1px solid var(--line); }

.stat-num {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 14px;
  color: var(--ink-55);
  font-weight: 500;
}

/* ---- 跑马灯 ---- */
.marquee {
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--card);
  padding-block: 18px;
  position: relative;
  z-index: 1;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 36s linear infinite;
}

.marquee:hover .marquee-track { animation-play-state: paused; }

.mq-group { display: flex; align-items: center; flex: none; }

.mq-item {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-70);
  padding-inline: 22px;
  white-space: nowrap;
}

.mq-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.75;
}

@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 150ms ease-out, background 150ms ease-out, color 150ms ease-out;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-deep); }

.btn-ghost {
  color: var(--ink);
  padding-inline: 4px;
  border-radius: 0;
}
.btn-ghost::after { bottom: 0; }

/* ---- 分区 ---- */
.section { padding-block: 40px; position: relative; z-index: 1; scroll-margin-top: 84px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 16px;
  margin-bottom: 36px;
}

.section-title {
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-count {
  font-family: var(--font-serif);
  font-size: 22px;
  font-style: italic;
  color: var(--ink-55);
}

/* ---- 暗色分区 ---- */
.section-dark {
  background: var(--paper-dark);
  color: var(--paper-dark-ink);
  padding-block: 72px;
}

.section-dark .section-head { border-bottom-color: rgba(240, 238, 230, 0.24); }
.section-dark .section-count { color: rgba(240, 238, 230, 0.45); }

.section-dark .card {
  background: rgba(240, 238, 230, 0.05);
  border-color: rgba(240, 238, 230, 0.16);
}
.section-dark .card:hover { border-color: rgba(240, 238, 230, 0.38); }

.section-dark .card-num { color: rgba(240, 238, 230, 0.12); }
.section-dark .card:hover .card-num { color: rgba(204, 120, 92, 0.55); }

.section-dark .card-title { color: var(--paper-dark-ink); }
.section-dark .card-desc { color: rgba(240, 238, 230, 0.68); }

.section-dark .tag {
  border-color: rgba(240, 238, 230, 0.28);
  color: rgba(240, 238, 230, 0.75);
}
.section-dark .card:hover .tag {
  background: rgba(204, 120, 92, 0.22);
  border-color: rgba(204, 120, 92, 0.5);
  color: #f3c9b4;
}
.section-dark .tag-local {
  border-style: dashed;
}
.section-dark .card:hover .tag-local {
  background: transparent;
  border-color: rgba(240, 238, 230, 0.45);
  color: rgba(240, 238, 230, 0.75);
}

.section-dark .card-link { color: #e8a586; }

.section-dark .card-cover:focus-visible {
  outline-color: var(--accent);
}

/* ---- 卡片栅格 ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  perspective: 1200px;
}

/* ---- 卡片 ---- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  transform-style: preserve-3d;
  transition: border-color 200ms ease-out, background 200ms ease-out;
  min-height: 216px;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card.tilt {
    transition: border-color 200ms ease-out, background 200ms ease-out,
                transform 300ms var(--ease-out);
  }
}

.card:hover { border-color: var(--line-strong); }

.card-num {
  position: absolute;
  top: 12px;
  inset-inline-end: 18px;
  font-family: var(--font-serif);
  font-size: 56px;
  font-style: italic;
  line-height: 1;
  color: var(--accent-soft);
  color: rgba(20, 20, 19, 0.08);
  transition: color 250ms ease-out;
  pointer-events: none;
}
.card:hover .card-num { color: rgba(204, 120, 92, 0.38); }

.card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-70);
  transition: background 200ms ease-out, color 200ms ease-out, border-color 200ms ease-out;
}
.card:hover .tag {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.tag-live {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.card:hover .tag-live { background: var(--accent-deep); color: var(--card); }

/* 本地运行标记：虚线边框，提示需下载源码 */
.tag-local {
  border-style: dashed;
  border-color: var(--line-strong);
  cursor: help;
}
.card:hover .tag-local {
  background: transparent;
  border-color: var(--ink-55);
  color: var(--ink-70);
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  width: fit-content;
  position: relative;
}

.card-title::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: -3px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: inline-start;
  transition: transform 300ms var(--ease-out);
}
.card:hover .card-title::after { transform: scaleX(1); }

.card-desc {
  font-size: 14.5px;
  color: var(--ink-70);
  line-height: 1.65;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-deep);
}

.arrow {
  display: inline-block;
  transition: transform 250ms var(--ease-out);
}
.card:hover .arrow { transform: translateX(6px); }

.card-link-dim { color: var(--ink-55); font-weight: 500; }
.card:hover .card-link-dim { color: var(--ink-55); }

/* 覆盖整卡的链接（磁性按钮在 header 内，卡内不做磁吸避免嵌套冲突） */
.card-cover {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 2;
}
.card-cover:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

/* GitHub 源码链接行：置于覆盖层之上，避免被 card-cover 挡住 */
.card-links {
  margin-top: 16px;
  display: flex;
  gap: 16px;
  position: relative;
  z-index: 3;
}

.gh-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-70);
  text-decoration: none;
  padding: 5px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: color 200ms ease-out, border-color 200ms ease-out,
              background 200ms ease-out, transform 200ms var(--ease-out);
}

.gh-link::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  background-color: currentColor;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>') center / contain no-repeat;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>') center / contain no-repeat;
}

.gh-link:hover,
.gh-link:focus-visible {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.gh-link:active { transform: translateY(1px); }

/* 鼠标位置高光（JS 写入 --mx / --my） */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
              rgba(204, 120, 92, 0.10), transparent 65%);
  opacity: 0;
  transition: opacity 250ms ease-out;
  pointer-events: none;
}
.card:hover::before { opacity: 1; }

.section-dark .card::before {
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
              rgba(204, 120, 92, 0.16), transparent 65%);
}

.section-dark .gh-link {
  color: rgba(240, 238, 230, 0.75);
  border-color: rgba(240, 238, 230, 0.28);
}
.section-dark .gh-link:hover,
.section-dark .gh-link:focus-visible {
  color: #f3c9b4;
  border-color: rgba(204, 120, 92, 0.5);
  background: rgba(204, 120, 92, 0.22);
}

/* ---- 引言区 ---- */
.quote-section {
  padding-block: clamp(72px, 12vh, 128px);
  position: relative;
  z-index: 1;
}

.quote {
  font-size: clamp(30px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  max-width: 22ch;
}

.quote em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--accent-deep);
}

/* ---- 关于 ---- */
.about { padding-block: 40px 96px; }

.about-text {
  max-width: 58ch;
  font-size: 19px;
  line-height: 1.8;
  color: var(--ink-70);
  margin-top: 20px;
}

.about-text em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink);
}

.about-text strong { color: var(--ink); font-weight: 700; }

.about-actions { margin-top: 28px; }

/* ---- 页脚 ---- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 40px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-brand { font-weight: 700; font-size: 17px; }

.footer-note {
  font-size: 13.5px;
  color: var(--ink-55);
}

.footer-gh { color: var(--ink-70); }

/* ---- 磁性按钮位移（JS 写入 translate 变量） ---- */
.magnetic {
  display: inline-block;
  transform: translate(var(--magx, 0), var(--magy, 0));
  will-change: transform;
}

/* ---- 滚动渐显 ---- */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
  }
  .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* ---- 响应式 ---- */
@media (max-width: 720px) {
  .container { width: calc(100% - 40px); }
  .header-inner { padding-block: 12px; }
  .nav-list { gap: 18px; }
  .hero-sub { font-size: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .section-dark { padding-block: 56px; }
  .about { padding-block: 24px 64px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(odd) { border-inline-start: none; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .mq-item { font-size: 17px; padding-inline: 16px; }
  .quote { max-width: none; }
}

/* ---- 窄屏（≤380px） ---- */
@media (max-width: 380px) {
  .container { width: calc(100% - 32px); }
  .nav-list { gap: 12px; }
  .brand { font-size: 16px; }
  .stat { padding: 20px 16px; }
}

/* ---- 触屏：加大点击目标 ---- */
@media (hover: none) {
  .gh-link { padding: 9px 18px; }
  .nav-link { padding-block: 8px; }
  .tag-local { cursor: default; }
}

/* ---- 触屏 / 减弱动效降级 ---- */
@media (hover: none), (prefers-reduced-motion: reduce) {
  .cursor-glow { display: none; }
  .magnetic { transform: none; }
  .card { transform: none; }
  .reveal { opacity: 1; transform: none; }
  .u-link::after { transition: none; }
}

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