/* =============================================================
   layout.css
   职责：页面骨架与区块布局 —— 容器、导航栏、Hero、
        筛选栏、文章网格、关于、页脚、模态框框架
   ============================================================= */

/* -------------------------------------------------------------
   1. 通用容器
   ------------------------------------------------------------- */
.section {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: 0 var(--page-pad) 72px;
  scroll-margin-top: calc(var(--nav-h) + 32px);
}

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section__title {
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -0.03em;
}

.section__sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-2);
}
.section__sub strong { color: var(--text-1); font-weight: 650; }

/* -------------------------------------------------------------
   2. 顶部悬浮玻璃导航
   ------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px var(--page-pad);
  /* 说明：不使用 mask 渐隐，避免裁切移动端展开的导航抽屉；
     滚上去的卡片由 backdrop-filter 自然模糊，本身就是液态玻璃的效果 */
}

.navbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: var(--page-max);
  height: var(--nav-h);
  margin-inline: auto;
  padding: 0 12px 0 16px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}

/* 品牌区 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--accent);
}
.brand__mark .icon { width: 18px; height: 18px; }

.brand__text { font-size: 17px; }

/* 导航面板（桌面横排 / 移动抽屉） */
.nav-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: space-between;
  min-width: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.nav-link {
  position: relative;
  display: block;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 14.5px;
  font-weight: 520;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.nav-link:hover { color: var(--text-1); background: var(--glass-bg); }
.nav-link.is-active { color: var(--text-1); background: var(--glass-bg-strong); }

/* 导航操作区 */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.nav-burger { display: none; }

/* -------------------------------------------------------------
   3. Hero
   ------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: 48px;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: clamp(48px, 8vw, 96px) var(--page-pad) clamp(40px, 6vw, 80px);
  scroll-margin-top: calc(var(--nav-h) + 24px);
}

.hero__copy { min-width: 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}
.eyebrow .icon { width: 14px; height: 14px; color: var(--accent); }

.hero__title {
  margin-top: 20px;
  font-size: clamp(34px, 5.6vw, 60px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.hero__desc {
  margin-top: 20px;
  max-width: 52ch;
  font-size: clamp(15px, 1.5vw, 17px);
  color: var(--text-2);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero__stats {
  display: flex;
  gap: 34px;
  margin-top: 40px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}
.stat dt {
  font-size: 12.5px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.stat dd {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Hero 装饰：玻璃卡片堆叠 */
.hero__visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 340px;
}

.stack {
  position: relative;
  width: min(100%, 380px);
  aspect-ratio: 1 / 0.92;
  transform-style: preserve-3d;
  perspective: 1200px;
}

.stack__card {
  position: absolute;
  padding: 18px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  animation: float var(--dur-slow) var(--ease) infinite alternate;
}

.stack__card:nth-child(1) {
  top: 6%;
  right: 8%;
  bottom: auto;
  left: auto;
  width: 74%;
  animation-duration: 7s;
  animation-delay: -1s;
  transform: rotate(-4deg);
}
.stack__card:nth-child(2) {
  top: auto;
  right: auto;
  bottom: 4%;
  left: 2%;
  width: 72%;
  animation-duration: 8.5s;
  animation-delay: -3s;
  transform: rotate(3deg);
}
.stack__card:nth-child(3) {
  top: 34%;
  right: 2%;
  bottom: auto;
  left: auto;
  width: 46%;
  animation-duration: 6.5s;
  animation-delay: -2s;
  transform: rotate(6deg);
}

@keyframes float {
  from { translate: 0 0; }
  to   { translate: 0 -14px; }
}

.stack__top { display: flex; gap: 6px; margin-bottom: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hairline); }
.dot--r { background: #ff5f57; }
.dot--y { background: #febc2e; }
.dot--g { background: #28c840; }

.stack__line {
  height: 8px;
  margin-bottom: 9px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--hairline), transparent);
}
.stack__line--title { width: 62%; height: 12px; background: linear-gradient(90deg, var(--accent), transparent); }
.stack__line--short { width: 42%; }

.stack__bars { display: flex; align-items: flex-end; gap: 6px; height: 48px; margin-top: 18px; }
.stack__bars i {
  flex: 1;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.55;
}
.stack__bars i:nth-child(1) { height: 40%; }
.stack__bars i:nth-child(2) { height: 70%; }
.stack__bars i:nth-child(3) { height: 52%; }
.stack__bars i:nth-child(4) { height: 92%; }
.stack__bars i:nth-child(5) { height: 64%; }

.stack__code {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.9;
  color: var(--text-2);
  white-space: nowrap;
}
/* Hero 装饰代码块里的假 token */
.tk { color: var(--text-2); }
.tk--k { color: var(--tok-keyword); }
.tk--f { color: var(--tok-fn); }
.tk--n { color: var(--tok-number); }
.tk--s { color: var(--tok-string); }

.stack__chip {
  display: inline-block;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd-soft);
}
.stack__ring {
  width: 58px;
  height: 58px;
  margin: 14px auto 4px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px));
}

.hero__glow {
  position: absolute;
  inset: 12% 8%;
  z-index: -1;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  background: radial-gradient(circle, var(--accent), transparent 65%);
}

/* -------------------------------------------------------------
   4. 筛选栏
   ------------------------------------------------------------- */
.filterbar {
  margin-bottom: 26px;
  scroll-margin-top: calc(var(--nav-h) + 32px);
}

.filterbar__scroller {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.filterbar__scroller::-webkit-scrollbar { display: none; }

/* -------------------------------------------------------------
   5. 文章网格
   ------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}
.grid[hidden] { display: none; }

/* 网格项外壳：承载 hover 位移与入场动画，
   与内部 .glass 分离，避免 transform 影响 backdrop-filter 的采样 */
.card-shell {
  display: flex;
  /* 必须显式带上 opacity：本规则加载在 .reveal 之后，
     单属性 transition 会整体覆盖 .reveal 的过渡，
     导致卡片入场时 opacity 直接跳变、丢失 stagger 淡入。 */
  transition:
    transform var(--dur) var(--ease),
    opacity var(--dur-slow) var(--ease-out);
}
.card-shell:hover { transform: translate3d(0, -6px, 0); }

/* -------------------------------------------------------------
   6. 关于区
   ------------------------------------------------------------- */
.about {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 26px;
  padding: 30px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  scroll-margin-top: calc(var(--nav-h) + 32px);
}

.about__avatar {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  flex: none;
  border-radius: 28px;
  font-size: 36px;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-1);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  object-fit: cover;          /* 作为头像图片时裁切居中 */
  object-position: center;
}

.about__body p {
  margin-top: 14px;
  color: var(--text-2);
  font-size: 15px;
}

/* -------------------------------------------------------------
   7. 页脚
   ------------------------------------------------------------- */
.site-footer {
  padding: 0 var(--page-pad) 40px;
}

.footer-inner {
  max-width: var(--page-max);
  margin-inline: auto;
  padding: 30px;
  border-radius: var(--r-xl);
  text-align: center;
  box-shadow: var(--shadow-1);
}

/* 页脚：三行居中堆叠的徽章 / 链接行，行间距 10px */
.footer__rows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* 行内容器：图标 + 文字，间距 6px；窄屏允许文字换行 */
.footer__row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
}
.footer__row > span { min-width: 0; }

/* 胶囊徽章（版权 / 公网安备）：先给纯色兜底，再用 color-mix 按主题降饱和 */
.footer__pill {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.footer__pill--purple {
  background-color: #6d28d9;
  background-color: color-mix(in oklab, #7c3aed 84%, var(--bg-base));
}

/* ICP 备案行：浅灰文字 + 橙色小图标，hover 有玻璃高亮 */
.footer__icp {
  padding: 4px 10px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.footer__icp:hover {
  background-color: var(--glass-bg-hover);
  color: var(--text-1);
}
.footer__icon--orange { color: #ff7a45; }

/* 备案官方徽标：PNG 本身已是透明底，不加白色底托、不加圆角/投影，
   避免透明 PNG 边缘在部分浏览器里产生白边错觉 */
.footer__badge {
  height: 18px;
  width: auto;
  flex: none;
  vertical-align: -3px;
  object-fit: contain;
}
.footer__icp .footer__badge { height: 20px; }

/* 胶囊型链接（公网安备）的 hover 微反馈 */
a.footer__pill {
  transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
a.footer__pill:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* 页脚图标统一 16px，并随 currentColor 变色 */
.footer__rows .icon { width: 16px; height: 16px; }

/* -------------------------------------------------------------
   8. 模态框框架
   ------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: end center;
  padding: 0;
  /* 关闭动画（约 320ms）期间容器仍在 DOM 中且铺满全屏，
     若不禁用指针事件会吞掉这一段时间内的所有点击。 */
  pointer-events: none;
}
/* 仅打开状态接收交互，关闭瞬间即失效。 */
.modal.is-open { pointer-events: auto; }
.modal[hidden] { display: none; }

.modal__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  backdrop-filter: blur(6px) saturate(120%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.modal.is-open .modal__scrim { opacity: 1; }

.modal__panel {
  position: relative;
  width: min(920px, 100%);
  height: min(92vh, 100%);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translate3d(0, 4%, 0);
  opacity: 0;
  transition:
    transform var(--dur-slow) var(--ease-out),
    opacity var(--dur-slow) var(--ease-out);
}
.modal.is-open .modal__panel {
  transform: none;
  opacity: 1;
}

/* 说明：这两个元素是 .glass 面板的直接子元素，
   components.css 里的 .glass > * 会把 position / z-index 覆盖成 relative / 2，
   因此这里用 .modal__panel > 提升特异性，确保定位与层级不被吃掉 */
.modal__panel > .modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-1);
  box-shadow: var(--shadow-1);
}

.modal__panel > .modal__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  height: 3px;
  background: transparent;
}
.modal__progress i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent);
  transition: width 80ms linear;
}

.modal__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
