/* ============================================================
   NekoHome 工作室 · 全局样式
   暖白 / 墨 · 炭灰双主题 · 克制的蓝色点缀 · 基于 Bootstrap 5.3 网格
   无玻璃拟态 / 无渐变文字，动效收敛；首页仅一层极淡静态网格
   平滑滚动由 Lenis 驱动（js 侧），此处仅保留原生降级方案
   ============================================================ */

/* ---------- 本地字体（首页主标题用 Manrope，SIL OFL 1.1，许可证见 assets/fonts/OFL.txt） ---------- */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/manrope-latin-600.woff2") format("woff2");
}

/* ---------- 主题变量 ---------- */
:root {
  /* 让 Bootstrap 组件保持克制的圆角 */
  --bs-border-radius: .9rem;
  --bs-border-radius-lg: 1.1rem;
  --bs-border-radius-sm: .6rem;

  /* 克制的蓝色点缀（仅用于链接、指示、悬停描边等少量场景） */
  --accent: #7fa8d9;        /* 深底上的点缀色 */
  --accent-strong: #9cc0ea; /* 深底上的链接/悬停 */
  --radius: .9rem;
  --radius-sm: .6rem;
  --topbar-h: 68px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;

  /* 深色主题（默认）：炭灰 */
  --bg-base: #191a1c;
  --line: rgba(236, 234, 229, .1);
  /* 背景图与遮罩（路径 / 强度可在 config.json 覆盖，JS 注入对应变量） */
  --bg-image: url("../assets/background.webp");
  --panel-color: 25, 26, 28;
  --panel-op: .7;             /* 其它页背景强度（与 config.json 默认值一致，0.7 = 70% 半透明） */
  --panel: rgba(var(--panel-color), var(--panel-op));
  --mask-color: 14, 15, 17;
  --mask-hero-op: .35;        /* 首页遮罩强度（与 config.json 默认值一致） */
  --grid-line: rgba(235, 233, 228, .06); /* 首页淡网格线色（深底） */
  --card: #222326;
  --card-hover: #28292d;
  --text: #ebe9e4;
  --muted: rgba(235, 233, 228, .62);
  --faint: rgba(235, 233, 228, .4);
  --topbar-bg: rgba(20, 21, 23, .9);
  --footer-bg: #131415;
  --toast-bg: #2a2b2e;
  --shadow: rgba(0, 0, 0, .35);
  /* 主按钮文字色：深底上浅色蓝配深色墨字，保证对比度 */
  --button-text: #14171c;
}

[data-bs-theme="light"] {
  /* 浅色主题：暖白 + 墨色文字 */
  --accent: #2e6bb4;
  --accent-strong: #275d9e;
  --bg-base: #fdfcf9;
  --line: rgba(32, 30, 26, .12);
  --panel-color: 253, 252, 249;
  --panel-op: .7;
  --panel: rgba(var(--panel-color), var(--panel-op));
  --mask-color: 250, 248, 244;
  --mask-hero-op: .35;
  --grid-line: rgba(33, 31, 27, .06); /* 首页淡网格线色（浅底） */
  --card: #ffffff;
  --card-hover: #f3f1ec;
  --text: #211f1b;
  --muted: rgba(33, 31, 27, .62);
  --faint: rgba(33, 31, 27, .42);
  --topbar-bg: rgba(253, 252, 249, .92);
  --footer-bg: #f2f0ea;
  --toast-bg: #2b2c2f;
  --shadow: rgba(32, 30, 26, .12);
  /* 浅底上深蓝配白字 */
  --button-text: #ffffff;
}

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

html {
  background: var(--bg-base);
  /* 平滑滚动由 Lenis 驱动；scroll-behavior 为降级方案（Lenis 未加载时由 JS 添加） */
}
html.native-scroll { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 隐藏根滚动条但保留滚动能力（Firefox 用属性，Chromium/WebKit 用伪元素） */
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }
::selection { background: rgba(127, 168, 217, .35); }
a, button { -webkit-tap-highlight-color: transparent; }

/* 键盘导航焦点环（仅 :focus-visible，鼠标点击不出现） */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}
/* 覆盖 Bootstrap 的 focus 环，避免胶囊形导航项出现双层焦点样式 */
.nav-link:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
  box-shadow: none;
}

/* 主题切换时的过渡动画（JS 会短暂加上 .theme-anim） */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .45s ease, border-color .45s ease, color .45s ease,
              fill .45s ease, stroke .45s ease, opacity .45s ease !important;
}

/* ---------- 固定背景层（最底部，滚动时被页面遮住） ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-base) var(--bg-image) center / cover no-repeat;
  transition: background-color .5s ease;
}

/* 首页遮罩层（强度由 --mask-hero-op 控制） */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgb(var(--mask-color));
  opacity: var(--mask-hero-op);
  transition: opacity .5s ease, background-color .5s ease;
}

/* 首页专属淡网格：仅 .hero 内，64px 细线 + 径向渐隐，位于遮罩之上、文字之下，不拦截点击 */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 70% 62% at 32% 45%, black 20%, transparent 80%);
  mask-image: radial-gradient(ellipse 70% 62% at 32% 45%, black 20%, transparent 80%);
  transition: opacity .5s ease;
}

/* 动态网格画布：JS 增强就绪前隐藏，静态 ::after 网格始终兜底；
   .hero.grid-live 时画布接管、静态网格移除（两者首帧画面一致，无闪烁） */
.hero-grid-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: none;
  pointer-events: none;
}
.hero.grid-live .hero-grid-canvas { display: block; }
.hero.grid-live::after { content: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 64px);
  animation: fadeIn .6s ease .1s both;
}
/* 顶栏背景由伪元素承载，opacity 过渡实现「透明 → 实底」变化 */
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--topbar-bg);
  border-bottom: 1px solid transparent;
  opacity: 0;
  transition: opacity .35s ease, border-color .35s ease;
}
.topbar.scrolled::before { opacity: 1; border-bottom-color: var(--line); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand-logo { height: 34px; width: auto; border-radius: 8px; }
.brand-name { font-size: 17px; }

/* 名称可配置为图片：位图用 <img>，SVG 内联 <svg>（可继承主题变量）；
   高度跟随所在名称字号，config 里可用 height 覆盖 */
.brand-name img,
.footer-name img,
.brand-name svg,
.footer-name svg {
  display: block;
  height: 1.25em;
  width: auto;
  max-width: 100%;
}

.brand-name img,
.footer-name img { object-fit: contain; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 深浅色切换按钮 */
.theme-toggle {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .3s ease, border-color .3s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg {
  width: 17px; height: 17px;
  grid-area: 1 / 1;
  transition: opacity .3s ease, transform .35s var(--ease);
}
[data-bs-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg) scale(.3); }
[data-bs-theme="light"] .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.3); }

/* 导航 + 滑动指示器（移动端保持横向） */
.nav { position: relative; display: flex; gap: 2px; }
.nav-link {
  position: relative;
  z-index: 1;
  padding: 8px 16px;
  font-size: 15px;
  color: var(--muted);
  border-radius: 999px;
  transition: color .3s ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.is-active { color: var(--text); font-weight: 600; }

.nav-indicator {
  position: absolute;
  top: 50%;
  left: 0;
  height: 35px;
  border-radius: 999px;
  background: var(--card-hover);
  border: 1px solid var(--line);
  opacity: 0;
  transform: translateY(-50%);
  transition: left .35s var(--ease), width .35s var(--ease), opacity .3s ease, background .45s ease;
  pointer-events: none;
}

/* ---------- 第 1 页 · 首页（左对齐 + 明确的主按钮） ---------- */
.hero {
  position: relative;
  z-index: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: var(--topbar-h) clamp(20px, 5vw, 64px) 96px;
}
.hero-stage { animation: fadeUp .8s var(--ease) .05s both; }
/* 只有文字区参与滚动缩小/上移/渐隐，transform-origin 靠左保持左对齐缩放 */
.hero-inner {
  will-change: transform, opacity;
  max-width: 640px;
  transform-origin: left center;
}

.hero-eyebrow {
  color: var(--muted);
  letter-spacing: .32em;
  font-size: 14px;
  margin-bottom: 16px;
}
.hero-title {
  font-family: "Manrope", var(--font);
  font-size: var(--hero-title-size, clamp(44px, 10vw, 128px));
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.12;
  color: var(--text);
}
.hero-slogan {
  margin-top: 20px;
  font-size: clamp(15px, 1.6vw, 19px);
  color: var(--muted);
  letter-spacing: .12em;
}
.hero-actions { margin-top: 34px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* 滚动提示 */
.scroll-hint {
  position: absolute;
  left: clamp(20px, 5vw, 64px);
  bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 13px;
  animation: fadeIn .8s ease .5s both;
  transition: color .3s ease;
}
.scroll-hint > span:first-child { letter-spacing: .28em; text-indent: .28em; }
.scroll-hint:hover { color: var(--text); }
.scroll-hint-line {
  width: 1px;
  height: 40px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.scroll-hint-line i {
  position: absolute;
  left: 0; top: -40%;
  width: 100%; height: 40%;
  background: var(--faint);
  animation: hintDrop 1.9s var(--ease) infinite;
}
@keyframes hintDrop { 0% { top: -40%; } 60%, 100% { top: 110%; } }

/* ---------- 通用页面（第 2/3/4 页，遮住底部背景；高度由内容决定） ---------- */
.panel {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: calc(var(--topbar-h) + 48px) clamp(16px, 4vw, 48px) 72px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  transition: background .5s ease, border-color .5s ease;
}

.panel-inner { width: 100%; }

/* 左对齐的页标题块（作品 / 加入共用），介绍文字限宽保证可读行长 */
.section-heading { max-width: 640px; }
.section-heading .panel-sub { max-width: 54ch; }

.kicker {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .3em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
}
.panel-title {
  font-size: clamp(26px, 3.2vw, 36px);
  font-weight: 800;
  letter-spacing: .04em;
}
.panel-sub { color: var(--muted); margin-top: 10px; }

/* ---------- 第 2 页 · 关于（无卡片盒，文字与图直接排布） ---------- */
.about-text { margin-top: 18px; }
.about-text p { color: var(--muted); margin-top: 14px; max-width: 56ch; }

/* 标签为轻量纯文字，用间隔号分隔，而非胶囊 */
.about-tags {
  margin-top: 22px;
  color: var(--muted);
  font-size: 14px;
}
.about-tags li { display: inline; }
.about-tags li + li::before {
  content: "·";
  margin: 0 10px;
  color: var(--faint);
}

.about-media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.about-media img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 第 3 页 · 作品（GitHub 仓库卡片） ---------- */
.repo-grid { margin-top: 40px; }

.repo-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 170px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .3s ease, background .3s ease;
}
.repo-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.repo-head { display: flex; align-items: center; gap: 10px; }
.repo-book { color: var(--accent); flex: none; }
.repo-name {
  font-weight: 700;
  font-size: 16px;
  min-width: 0;
  overflow-wrap: anywhere; /* 长仓库名直接换行展示，不省略 */
}
.repo-desc {
  color: var(--muted);
  font-size: 14px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.repo-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}
.repo-stat { display: inline-flex; align-items: center; gap: 6px; }
.repo-stat svg { width: 15px; height: 15px; }
.repo-link { margin-left: auto; color: var(--muted); transition: color .3s ease; }
.repo-card:hover .repo-link { color: var(--accent); }

/* 加载骨架屏 */
.skeleton { pointer-events: none; }
.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk-title { height: 16px; width: 55%; }
.sk-line { height: 12px; width: 100%; }
.sk-line.short { width: 65%; }
.sk-foot { height: 12px; width: 40%; margin-top: auto; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 错误卡片 */
.repo-error {
  align-items: flex-start;
  justify-content: center;
  border-style: dashed;
  pointer-events: auto;
}
.repo-error strong { font-size: 15px; }
.repo-error p { color: var(--muted); font-size: 13px; margin: 0; }
.repo-error .btn-ghost { align-self: flex-start; margin-top: 6px; }

/* ---------- 第 4 页 · 加入我们（朴素文字条目 + QQ 群区） ---------- */
.join-grid { margin-top: 36px; }

.join-card { padding: 6px 0 18px; border-top: 1px solid var(--line); }
.join-card h3 { font-size: 16px; font-weight: 700; margin: 14px 0 4px; }
.join-card h3::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: 2px;
}
.join-card p { color: var(--muted); font-size: 14px; margin: 0; }

/* QQ 群区（无卡片托盘：与上方条目同宽对齐，直接排布） */
.qq-card {
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 28px;
}
.qq-info { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qq-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qq-label { color: var(--muted); font-size: 14px; }
/* 群号仅保留等宽字体强调，不再套内层底色/边框 */
.qq-number {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text);
}
.qq-tip { width: 100%; color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- 按钮 ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  color: var(--button-text);
  background: var(--accent);
  border: none;
  transition: background .3s ease;
}
.btn-primary:hover { background: var(--accent-strong); color: var(--button-text); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color .3s ease, color .3s ease;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-ghost.btn-sm { padding: 7px 18px; font-size: 13px; }

/* 首页主按钮旁的次级文字链接 */
.link-quiet {
  font-size: 15px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: color .3s ease, border-color .3s ease;
}
.link-quiet:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 页脚 ---------- */
.footer {
  position: relative;
  z-index: 1;
  background: var(--footer-bg);
  border-top: 1px solid var(--line);
  padding: 52px clamp(16px, 4vw, 48px) 40px;
  transition: background .5s ease, border-color .5s ease;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-logo { height: 56px; width: auto; border-radius: 12px; }
.footer-name { font-size: clamp(20px, 2.4vw, 24px); font-weight: 800; letter-spacing: .03em; }
.footer-nav { display: flex; gap: 26px; }
.footer-nav a { color: var(--muted); font-size: 15px; transition: color .3s ease; }
.footer-nav a:hover { color: var(--text); }
.footer-icp {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.footer-icp a {
  align-self: flex-end; /* flex item 默认拉伸占满整行，收缩到文字实际宽度 */
}
.footer-icp a:hover { color: var(--muted); }

/* ---------- Toast 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 200;
  transform: translate(-50%, 16px);
  background: var(--toast-bg);
  color: #ebe9e4;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease), background .5s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 进场动画（收敛的淡入位移） ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .7s var(--ease) var(--d, 0s), transform .7s var(--ease) var(--d, 0s);
}
.reveal.in-view { opacity: 1; transform: none; }

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

/* ---------- 响应式 ---------- */
@media (max-width: 991.98px) {
  .about-media { max-width: 560px; }
}
@media (max-width: 767.98px) {
  .footer-icp { text-align: left; }
  .footer-icp a { align-self: flex-start; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .qq-card { flex-direction: column; text-align: center; }
  .qq-info, .qq-actions { justify-content: center; }
}
@media (max-width: 599.98px) {
  /* 阶段 1：隐藏顶栏工作室名字，保留 Logo 图与横排导航 */
  .topbar { padding: 0 16px; }
  .topbar-right { gap: 8px; }
  .brand-name { display: none; }
  .nav-link { padding: 8px 9px; font-size: 14px; }
  .theme-toggle { width: 34px; height: 34px; }
  .hero { padding-bottom: 88px; }
  .hero-actions { margin-top: 28px; }
  .hero-eyebrow { letter-spacing: .22em; }
  .scroll-hint { display: none; }
}
@media (max-width: 449.98px) {
  /* 阶段 2：导航文字竖写，指示器同步变为竖向 */
  .nav-link {
    writing-mode: vertical-lr;
    letter-spacing: .18em;
    padding: 10px 9px;
    font-size: 13px;
  }
  .nav-indicator {
    top: 4px;
    bottom: 4px;
    height: auto;
    transform: none;
  }
}

/* ---------- 降低动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  html.native-scroll, html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero-stage, .scroll-hint, .topbar { animation: none; }
  .scroll-hint-line i, .sk { animation: none; }
}
