/*
  追加样式 —— 官网内容需要的部分。

  ★ 这里不覆盖 style.css 里的任何原有规则 ★
  style.css 是模板原版，标题动效、按钮 hover、配色过渡、跟随鼠标的光标
  都由它和 script.js 提供，原样保留。

  这个文件只做三件模板没考虑过的事：
    1. 模板是单屏的（body overflow:hidden），官网要能往下滚；
    2. three.js 的 canvas 原本在文档流里，滚走就没背景了，这里固定成背景；
    3. 滚离首屏后让模板那几个 fixed 元素淡出，免得压在正文上。
*/

/* ---- 0. 移动端基础设施 ---- */
html {
  /* iOS 横屏时不要自作主张放大正文字号 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 让浏览器自带的滚动条、下拉刷新圈等跟随深色 */
  color-scheme: dark;
  scroll-behavior: smooth;
  /* 首屏预留高度。
     优先用 svh —— 它是「地址栏还在」时的高度，正文永远不会被地址栏挡掉；
     老浏览器（Chrome < 108 / Safari < 15.4）回退到 100vh。 */
  --first-screen: 100vh;
}

@supports (height: 100svh) {
  html {
    --first-screen: 100svh;
  }
}

/* ---- 1. 放开滚动 ---- */
body {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: var(--first-screen);
}

/* ---- 2. 渐变背景固定在视口 ---- */
body > canvas {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
}

/* ---- 2.5 修掉模板大标题的换行 bug（全局，不放进任何 @media） ----

   模板是 left:50% + translateX(-50%) 居中的。对 fixed 元素来说，
   只给 left 不给 right，可用宽度就只剩视口的一半 —— 390px 的屏上
   只有 195px，而「极速互传」在 58.5px 字号下要 234px，于是被折成
   「极速互 / 传」。

   ⚠ 这条必须放在全局而不是 @media (max-width:700px), (pointer:coarse) 里：
   放进媒体查询后，一旦查询没命中（桌面模式、奇怪的 WebView、旧浏览器
   不认 pointer:coarse……），标题就又会折行。改成整宽居中在任何浏览器、
   任何宽度下都成立，而且对桌面是零视觉差异（模板本来就是 text-align:center，
   只是盒子从「半屏收缩包裹」变成「整屏」而已）。                        */
.heading {
  left: 0;
  right: 0;
  width: auto;
  transform: translateY(-50%);
  /* 模板的 white-space:nowrap 被它自己后面那句 text-wrap:auto 覆盖了
     （text-wrap 是 text-wrap-mode 的简写，写在后面会重置换行模式），
     这里两种写法都补上，支持的用后者、不支持的用前者 */
  white-space: nowrap;
  text-wrap: nowrap;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* 模板那几个 fixed 元素加一层淡出过渡（只加 opacity，不碰它们的 transform，
   否则 .heading / .footer 的居中会歪掉） */
.heading,
.footer {
  transition: opacity .45s ease;
}

/* ---- 3. 滚离首屏后让位 ---- */
body.site-scrolled .heading,
body.site-scrolled .footer {
  opacity: 0;
  pointer-events: none;
}

/* ==================== 官网内容 ==================== */

.site {
  position: relative;
  z-index: 5;
  /* 首屏整屏留给上面那套模板动效（100svh，见文件顶部） */
  margin-top: var(--first-screen);
  padding: 0 24px 72px;
  background: linear-gradient(to bottom,
      rgba(6, 8, 20, 0) 0%,
      rgba(6, 8, 20, .82) 12%,
      rgba(6, 8, 20, .95) 30%,
      rgba(6, 8, 20, .97) 100%);
  color: #fff;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    sans-serif;
}

.site-block {
  max-width: 1000px;
  margin: 0 auto;
  padding: 56px 0;
}

.site-eyebrow {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .6);
}

.site-title {
  margin: 0;
  font-family: "Syne", "Inter", sans-serif;
  font-weight: 800;
  font-size: clamp(30px, 5.2vw, 56px);
  line-height: 1.05;
  letter-spacing: -.02em;
}

.site-heading {
  margin: 0 0 24px;
  font-size: clamp(22px, 3.2vw, 32px);
  font-weight: 700;
  letter-spacing: -.01em;
}

.site-lede {
  margin: 18px 0 0;
  max-width: 40em;
  font-size: 17px;
  line-height: 1.7;
  color: rgba(255, 255, 255, .82);
}

.site-lede strong {
  color: #fff;
}

.site-muted {
  color: rgba(255, 255, 255, .58);
  font-size: 14px;
  margin: 6px 0 0;
}

.site-actions {
  margin-top: 30px;
}

/* 按钮沿用模板那套圆角 + hover 上浮的手感 */
.site-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform .25s ease, background .25s ease, border-color .25s ease;
}

/* 主按钮（白底实心）。当前页面上没有在用它 —— 首屏的 GitHub 入口
   还没上线所以走 .site-btn-ghost；等仓库建好、链接能点了，把那个
   span 换成 <a class="site-btn site-btn-primary"> 就会变成这版样式。 */
.site-btn-primary {
  background: #fff;
  color: #0a0c18;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .32);
}

.site-btn-primary:hover {
  transform: translateY(-2px);
  background: #eef0f7;
}

/* GitHub 占位按钮：仓库还没建，先给个「半透明描边」的样式，
   建好后把 <span> 换成 <a href="...">，这里不用动 */
.site-btn-ghost {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.site-btn-ghost:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .36);
}

/* 还没上线的东西不要假装能点 */
.site-btn.is-pending {
  cursor: default;
  opacity: .82;
}

.site-btn.is-pending:hover {
  transform: none;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
}

.site-gh-icon {
  width: 19px;
  height: 19px;
  flex: none;
  fill: currentColor;
}

.site-btn-meta {
  font-weight: 500;
  font-size: 12px;
  opacity: .55;
}

.site-fineprint {
  margin: 18px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, .55);
}

/* ---- 卡片 ---- */
.site-grid {
  display: grid;
  gap: 14px;
  /* 老浏览器（Chrome < 79）不认 min()，下面这条会被整条丢弃，
     所以先给一版普通写法兜底 —— 否则 grid-template-columns 没了，
     卡片会退化成一列自动宽度 */
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  /* min(250px, 100%) 而不是裸 250px：320px 以下的窄屏（折叠屏外屏、
     词典笔）上裸 250px 会把卡片顶出容器 */
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}

.site-card {
  padding: 22px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .05);
  /* iOS Safari 只认带前缀的写法，少了这行 iPhone 上完全没有毛玻璃 */
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform .25s ease, border-color .25s ease, background .25s ease;
}

.site-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .09);
}

.site-card h3 {
  margin: 0 0 8px;
  font-size: 16.5px;
  font-weight: 650;
}

.site-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.65;
  color: rgba(255, 255, 255, .72);
}

/* ---- 步骤 ---- */
.site-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.site-steps li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 22px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .05);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.site-step-no {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: #fff;
  color: #0a0c18;
}

.site-steps h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
}

.site-steps p {
  margin: 0;
  font-size: 14.5px;
  color: rgba(255, 255, 255, .72);
}

.site code {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 13.5px;
  background: rgba(255, 255, 255, .14);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- 收尾 ---- */
.site-foot {
  padding-top: 40px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .5);
  font-size: 13.5px;
}

.site-foot p {
  margin: 0 0 6px;
}

/* ==================== 4. 手机竖屏适配 ====================
   模板本身一个 @media 都没有（纯桌面单屏 demo），下面全是补的。
================================================================ */

/* ---- 触屏设备 ---- */
@media (hover: none), (pointer: coarse) {

  /* 模板那个圆环光标是靠 mousemove 定位的，手机上没有鼠标，
     它会停在文档左上角变成一个白圈 —— 直接藏掉。 */
  .custom-cursor {
    display: none !important;
  }

  body {
    cursor: auto;
  }

  a,
  button {
    -webkit-tap-highlight-color: transparent;
  }

  /* 触屏没有 hover，把 hover 的效果挪到 :active 上做点击反馈 */
  .site-btn-primary:active {
    transform: translateY(-2px);
    background: #eef0f7;
  }

  .site-card:active {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .09);
  }

  .site-steps li:active {
    border-color: rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .09);
  }

  /* 页脚避开 iPhone 底部手势条，同时允许窄屏换行 */
  .footer {
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 32px);
    white-space: normal;
  }
}

/* ---- 首屏下滑提示（桌面端不显示） ---- */
.site-scroll-hint {
  display: none;
  position: fixed;
  left: 50%;
  top: calc(50% + 3.8rem);
  transform: translateX(-50%);
  z-index: 11;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, .7);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: .16em;
  pointer-events: none;
  transition: opacity .45s ease;
}

.site-scroll-hint i {
  display: block;
  width: 9px;
  height: 9px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  animation: site-hint-bounce 1.9s ease-in-out infinite;
}

@keyframes site-hint-bounce {

  0%,
  100% {
    transform: rotate(45deg) translate(0, 0);
    opacity: .45;
  }

  50% {
    transform: rotate(45deg) translate(3px, 3px);
    opacity: 1;
  }
}

body.site-scrolled .site-scroll-hint {
  opacity: 0;
}

@media (max-width: 700px), (pointer: coarse) {
  .site-scroll-hint {
    display: flex;
  }
}
/* 注：大标题的整宽居中在文件靠上的「2.5」一节，是全局规则，这里不再重复 */

/* 手机竖屏（含 6.7" 大屏机）：正文排版整体收紧一档 */
@media (max-width: 640px) {
  .site {
    padding-top: 0;
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .site-block {
    padding: 34px 0;
  }

  .site-title {
    font-size: clamp(26px, 8.6vw, 38px);
    line-height: 1.14;
    text-wrap: balance;
  }

  .site-heading {
    font-size: clamp(19px, 6vw, 26px);
    margin-bottom: 18px;
    text-wrap: balance;
  }

  .site-lede {
    font-size: 15.5px;
    line-height: 1.72;
  }

  .site-eyebrow {
    font-size: 11.5px;
    letter-spacing: .14em;
    margin-bottom: 10px;
  }

  .site-card {
    padding: 18px;
    border-radius: 16px;
  }

  .site-card h3 {
    font-size: 16px;
  }

  .site-card p,
  .site-steps p {
    font-size: 14px;
  }

  .site-steps li {
    padding: 16px 18px;
    gap: 12px;
    border-radius: 16px;
  }

  .site-btn {
    width: 100%;
    justify-content: center;
    padding: 15px 22px;
  }

  .site-foot {
    padding-top: 30px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    font-size: 12.5px;
  }

  .site code {
    font-size: 12.5px;
    word-break: break-all;
  }
}

/* 窄竖屏：小屏机、折叠屏外屏、词典笔那类 320px 上下的宽度。
   标题现在是整宽单行了，可以把字放大一档。 */
@media (max-width: 400px) and (orientation: portrait) {
  .heading {
    font-size: clamp(2.6rem, 15vw, 3.8rem);
    letter-spacing: -0.03em;
  }

  .site {
    padding-left: max(15px, env(safe-area-inset-left, 0px));
    padding-right: max(15px, env(safe-area-inset-right, 0px));
  }

  .site-title {
    font-size: clamp(23px, 8.4vw, 31px);
  }

  .site-scroll-hint {
    font-size: 11px;
    letter-spacing: .12em;
  }
}

/* 竖屏手机上地址栏可见时，小视口比大视口矮，
   把标题和下滑提示对齐到预留的那一屏的正中间 */
@supports (height: 100svh) {

  @media (hover: none), (pointer: coarse) {
    .heading {
      top: 50svh;
    }

    .site-scroll-hint {
      top: calc(50svh + 3.8rem);
    }
  }
}

/* 说明：横屏矮视口（手机横过来只有 390px 高）不做特殊处理。
   试过把首屏压到 76vh，结果正文跑到页脚上面去重叠了 —— 固定页脚在
   bottom:2rem，比 76vh 更靠下。横屏整屏本来就只有 390px，白滚一屏
   比元素重叠好，所以统一用 100svh。 */

@media (prefers-reduced-motion: reduce) {

  html {
    scroll-behavior: auto;
  }

  .site-btn,
  .site-card,
  .heading,
  .footer,
  .site-scroll-hint {
    transition: none;
  }

  .site-scroll-hint i {
    animation: none;
  }
}
