/* ---------------- TutoLab 首页专属设计（仅 index.html 加载） ---------------- */
/* 依赖 style.css 的字体与色彩变量；本文件只作用于首页新区块 */
/* 首页由 build.py 依 tutorials/<book>/book.json + web-builder/site.json 生成 */

/* ---- 封面首屏 ----
   标题层固定铺满视口；书架层（.home-layout）从视口高度之下开始，
   向上滚动时物理覆盖封面，覆盖进度同步驱动封面淡出——退场入场严丝合缝。 */
.cover {
  position: fixed; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 20px; padding: 24px;
  will-change: opacity;
}
.cover-title {
  font-family: var(--serif); font-weight: 700; color: var(--ink);
  font-size: clamp(56px, 12vw, 100px); letter-spacing: .01em; margin: 0;
}
.cover-sub {
  font-family: var(--serif); font-size: clamp(15px, 2.6vw, 20px);
  color: var(--ink-soft); letter-spacing: .08em; margin: 0;
}
.cover-hint {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  font-size: 17px; color: #aeb6c2; line-height: 1;
  animation: cover-bob 2.6s ease-in-out infinite;
}
@keyframes cover-bob { 50% { transform: translate(-50%, 8px); } }
.cover.gone { visibility: hidden; }

/* 背景层由 build.py 注入 .site-bg（样式在 style.css）；首页专属：封面聚焦晕影，
   挂在 .cover::before 上随封面一起淡出，滚入书架后不残留 */
.cover::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(ellipse 62% 48% at 50% 46%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 72%);
}

/* 入场：标题/小字上浮显现（.fx 由脚本添加，减少动态时不播） */
@keyframes cover-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
body.fx .cover-title { animation: cover-rise .9s cubic-bezier(.2, .7, .2, 1) .08s both; }
body.fx .cover-sub { animation: cover-rise .9s cubic-bezier(.2, .7, .2, 1) .26s both; }
@keyframes cover-fade { from { opacity: 0; } }
body.fx .cover-hint {
  animation: cover-fade .8s ease .55s both, cover-bob 2.6s ease-in-out 1.4s infinite;
}

/* 封面模式下导航浮于封面（透明底），滚动后落回常规白底 */
body.home .site-header {
  position: fixed; top: 0; left: 0; right: 0;
  background: transparent; border-bottom-color: transparent; backdrop-filter: none;
}
body.home.scrolled .site-header {
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(6px);
  border-bottom-color: var(--hairline);
}

/* ---- 滚动淡入（body.fx 由脚本加；无 JS / 系统减少动态时内容直接可见） ---- */
body.fx .reveal, body.fx .home-aside .widget {
  opacity: 0; transform: translateY(18px);
  transition: opacity .7s ease, transform .7s ease;
}
body.fx .reveal.in, body.fx .home-aside .widget.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .cover-hint { animation: none; }
}

/* ---- 书架统计行（原首屏数据移到此处，小号排印） ---- */
.shelf-stats {
  display: flex; flex-wrap: wrap; gap: 4px 30px;
  margin: 0 0 24px; padding-bottom: 13px; border-bottom: 1px solid var(--hairline-soft);
}
.shelf-stats .stat { display: flex; align-items: baseline; gap: 8px; }
.shelf-stats .n {
  font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--ink);
  line-height: 1.2;
}
.shelf-stats .l { font-family: var(--sans); font-size: 12px; color: #8a94a3; letter-spacing: .06em; }

/* ---- 主区 + 侧栏 ---- */
.home-layout {
  max-width: 1140px; margin: 0 auto; padding: 26px 24px 30px;
  display: grid; grid-template-columns: minmax(0, 1fr) 264px; gap: 44px;
  align-items: start;
}
body.home .home-layout {
  position: relative; z-index: 1; background: var(--paper);
  margin-top: 100svh; min-height: 100svh;
}
@supports not (height: 100svh) { body.home .home-layout { margin-top: 100vh; } }
body.home .site-footer { position: relative; z-index: 1; }
#shelf, #about { scroll-margin-top: 70px; }
.sec-label {
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; letter-spacing: .2em; color: #8a94a3; font-weight: 700;
  margin-bottom: 22px;
}
.sec-label::after { content: ""; flex: 1; height: 1px; background: var(--hairline-soft); }

/* ---- 书架：分类块 + 书卡网格 ---- */
.cat-head {
  padding: 0 2px 10px; border-bottom: 2px solid var(--ink);
  margin: 26px 0 16px;
}
.cat-head:first-of-type { margin-top: 0; }
.cat-head h2 {
  font-family: var(--serif); font-size: 19px; margin: 0; color: var(--ink); display: inline;
}
.cat-head .cat-en {
  display: inline; font-size: 11px; color: #8a94a3; letter-spacing: .08em; margin-left: 10px;
}
.cat-head .cat-count {
  float: right; font-family: var(--sans); font-size: 12px; color: #8a94a3; margin-top: 5px;
}

.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px;
}
.bcard {
  --bc: var(--accent);
  display: flex; flex-direction: column; gap: 7px;
  padding: 16px 18px 13px;
  background: var(--paper-warm);
  border: 1px solid var(--hairline-soft);
  border-top: 3px solid var(--bc);
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.bcard:hover {
  box-shadow: 0 3px 16px rgba(29, 35, 43, .09);
  transform: translateY(-2px);
  text-decoration: none;
}
.bcard:hover .bcard-go { color: var(--bc); }
.bcard-top { display: flex; justify-content: space-between; align-items: center; }
.bcard-cat {
  font-family: var(--sans); font-size: 11px; letter-spacing: .1em;
  color: var(--bc); font-weight: 700;
}
.bcard-badge {
  font-family: var(--sans); font-size: 11px; color: #8a94a3;
  border: 1px solid var(--hairline); padding: 1px 8px; border-radius: 2px;
}
.bcard-title {
  font-family: var(--serif); font-size: 19px; font-weight: 700;
  color: var(--ink); margin: 2px 0 0; line-height: 1.35;
}
.bcard-en { font-size: 11.5px; color: #8a94a3; letter-spacing: .04em; }
.bcard-desc { font-size: 13px; line-height: 1.75; color: var(--ink-soft); margin: 2px 0 0; }
.bcard-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.bcard-tags span {
  font-family: var(--sans); font-size: 11px; color: #6b7480;
  background: #fff; border: 1px solid var(--hairline-soft);
  padding: 1px 8px; border-radius: 10px;
}
.bcard-stats {
  font-family: var(--sans); font-size: 12px; color: #6b7480;
  border-top: 1px dashed var(--hairline-soft); padding-top: 9px; margin-top: 4px;
}
.bcard-foot { display: flex; justify-content: space-between; align-items: baseline; }
.bcard-go {
  font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); font-weight: 600;
}
.bcard-date { font-family: var(--sans); font-size: 11px; color: #a7aeb8; }

.home-footnote { color: #8a94a3; font-size: 12.5px; text-align: center; margin: 26px 0 6px; }

/* ---- 侧栏组件 ---- */
.widget {
  border: 1px solid var(--hairline-soft); background: var(--paper-warm);
  padding: 15px 17px 13px; margin-bottom: 16px;
}
.widget-title {
  font-family: var(--sans); font-size: 11.5px; letter-spacing: .18em;
  color: #8a94a3; font-weight: 700; margin-bottom: 11px;
}
/* 最近更新 */
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 5px 0; border-bottom: 1px dashed var(--hairline-soft);
  font-size: 13px;
}
.recent-list li:last-child { border-bottom: none; }
.recent-list a { color: var(--ink); text-decoration: none; }
.recent-list a:hover { color: var(--accent); }
.recent-list .rd { font-family: var(--sans); font-size: 11px; color: #a7aeb8; white-space: nowrap; }
/* 分类 */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; border-bottom: 1px dashed var(--hairline-soft); font-size: 13px;
}
.cat-list li:last-child { border-bottom: none; }
.cat-list .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; vertical-align: 1px;
}
.cat-list a { color: var(--ink); text-decoration: none; }
.cat-list a:hover { color: var(--accent); }
.cat-list .cn { font-family: var(--sans); font-size: 11.5px; color: #a7aeb8; }
/* 关于 */
.widget p { font-size: 12.8px; line-height: 1.8; color: var(--ink-soft); margin: 0 0 8px; }
.widget-rss {
  display: inline-block; font-family: var(--sans); font-size: 12.5px;
  color: var(--accent); text-decoration: none; margin-top: 2px;
}
.widget-rss:hover { text-decoration: underline; }

/* ---- 响应式 ---- */
@media (max-width: 1020px) {
  .home-layout { grid-template-columns: 1fr; }
  .home-aside { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
  .home-aside .widget { margin-bottom: 0; }
}
@media (max-width: 640px) {
  .cover-sub { letter-spacing: .02em; }
  .cover-hint { bottom: 22px; }
  .shelf-stats { gap: 4px 20px; }
  .book-grid { grid-template-columns: 1fr; }
}
