/* 字体：改成放在本地 resources/static/fonts/ 里自托管。
   原来这里是从 fonts.googleapis.com @import 的，那是「渲染阻塞」的：
   网一慢或连不上，浏览器会一直等这个 CSS 才肯画第一帧，
   结果就是整页空白（连文字都没有）。自托管以后完全不依赖网络。 */
@font-face {
  font-family: 'Pacifico';
  font-style: normal;
  font-weight: 400;
  font-display: swap;              /* 字体没到时先用后备字体显示文字，不挡渲染 */
  src: url('fonts/pacifico-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Pacifico';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/pacifico-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

html, body {
  margin: 0;
  min-height: 100%;

  /* 默认字体。不写这条的话，中文会落到各浏览器自己的默认字体上：
     Safari 用宋体、Chrome 用苹方，同一个页面两个浏览器长得完全不一样。
     这里显式点名 —— 拉丁字母走系统 UI 字体，中文走苹方（就是你要的那个样子）。
     换成微软雅黑是为了 Windows 上也不掉回宋体。 */
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #99a2cd 0%, #acc9e0 100%);
  background-attachment: fixed; /* 可选：滚动时渐变固定 */
}

.titleBar {
  display: flex;
  align-items: center;      /* 垂直居中 */
  justify-content: center;  /* 水平居中 */
  height: 56px;
  padding: 0 16px;
  background: #44c6982f;
  border-bottom: 3px solid #51c5d72c;
  box-sizing: border-box;

  /* 钉在顶部：页面往下滚时标题栏不跟着上去，一直贴在窗口最上面 */
  position: sticky;
  top: 0;
  z-index: 10;                        /* 盖住下面滚上来的内容 */
  backdrop-filter: blur(8px);         /* 底色是半透明的，不模糊的话下面的字会透出来 */
  -webkit-backdrop-filter: blur(8px); /* Safari 要加前缀 */
}

.titleBar_title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #3649db;
  font-family: 'Pacifico', cursive;
}

.titleBar_sidebar {
  width: 240px;          /* 栏宽 */
  flex: 0 0 240px;       /* 固定宽度，不伸缩 */
  height: 100vh;         /* 满屏高 */
  background: #6026e8;
  padding: 16px;
  box-sizing: border-box;

  position: sticky;      /* 页面滚动时侧栏固定 */
  top: 0;
}

.titleBar_back {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);   /* 和标题栏文字对齐到同一条中线上 */
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  color: #3649db;
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Heiti SC', sans-serif;
  font-weight: 400;              /* 站酷快乐体只有一档字重，写 bold 会被伪加粗 */
  font-size: 16px;
  line-height: 1;
  text-decoration: none;         /* 链接默认的下划线不要 */
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}

.titleBar_content {
  flex: 1;               /* 占满剩余宽度 */
  padding: 16px;
}

.title {
  font-weight: bold;
  color: #fff;
  letter-spacing: 4px;
  animation: riseUp 1.2s ease-out both;
}

@keyframes riseUp {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rUp {
  animation: riseUp 1.8s ease-out both;
}

.fontPac {
  font-family: 'Pacifico', cursive;
}

.card {
  background: #b2d6fc;                        /* 浅蓝底 */
  border: 1px solid #8ac4ff;                  /* 稍深一点的浅蓝描边 */
  border-radius: 12px;
  padding: 16px;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(31, 31, 31, 0.12);

  /* 和标题一样的入场动画，延迟 0.5s 后开始。
     这里用 backwards 而不是 both：等待期间一样是透明的，
     但动画结束后不会再用 forwards 锁死 transform，hover 的位移才能生效 */
  animation: riseUp 1.2s ease-out 0.5s backwards;
}

/* 可点击的卡片：<a class="card" href="..."> */
a.card {
  display: block;              /* 撑满整个网格格子 */
  color: inherit;              /* 不要链接默认的蓝色/下划线 */
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

a.card:hover {
  background: #c3dffd;                          /* 悬停稍微亮一点 */
  box-shadow: 0 6px 16px rgba(31, 31, 31, 0.18);
  transform: translateY(-4px);                  /* 浮起来 */
}

a.card:active {
  transform: translateY(-1px) scale(0.99);      /* 按下去 */
  box-shadow: 0 2px 6px rgba(31, 31, 31, 0.12);
}

/* 键盘 Tab 选中时给个可见的框 */
a.card:focus-visible {
  outline: 3px solid #3649db;
  outline-offset: 2px;
}

/* 一行里第二张卡片再晚 0.15s，两张依次出场 */
.cardRow .card:nth-child(2) {
  animation-delay: 0.65s;
}

/* 卡片容器：一行放两个 */
.cardRow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));  /* 两列，等宽 */
  gap: 16px;                                         /* 卡片间距 */
  align-items: stretch;                              /* 同一行等高 */

  max-width: 960px;      /* 太宽的屏幕上不让卡片拉得过宽 */
  margin: 0 auto;        /* 整行水平居中 */
  padding: 0 16px;       /* 两边留点空隙，不贴屏幕边 */
  box-sizing: border-box;
}

/* 窄屏（手机）时自动变成一行一个 */
@media (max-width: 640px) {
  .cardRow {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 返回链接 */
.backRow {
  text-align: center;
  margin: 24px 0;
}

.backLink {
  color: #3649db;
  font-weight: bold;
  text-decoration: none;
}

.backLink:hover {
  text-decoration: underline;
}

/* ============================================================
   打字机（多句循环）
   逐字打印 → 停一下 → 逐字删除 → 换下一句 → 循环
   ------------------------------------------------------------
   用法：把要轮播的句子用 | 隔开写进 data-words，
   元素里的文字写第一句，作为 JS 没跑起来时的兜底：

       <h2 class="typewriter"
           data-words="自研架构|自研对比学习|自研 DRNN"> 自研架构 </h2>

   为什么不用纯 CSS：CSS 改不了元素里的文字内容，也就没法在每一轮换一句话。
   所以“逐字改文字”交给 indexScript.js，这里只负责光标和排版。
   想换句子只改 data-words，不用碰 JS。

   可选参数（写在 data-* 上，单位毫秒）：
     data-type-speed    每个字打出来的时间，默认 140
     data-delete-speed  每个字删掉的时间，默认 80
     data-hold          一句话打完停多久，默认 1600
     data-gap           删完到下一句开始空多久，默认 400
   ============================================================ */
.typewriter {
  display: inline-block;
  white-space: nowrap;         /* 打字过程中别换行 */

  /* 固定行高。line-height: normal 的高度是按「这一行里实际有哪些字」算的：
     有一个汉字时是 33px，删空以后只剩光标和西文的 strut，就只有 28px。
     于是每轮删到最后一个字，<h2> 会突然矮 5px，下面的内容整体往上跳。
     写死行高以后，空句和满句一样高，下面就不会动了。 */
  line-height: 1.4;
}

/* 光标：跟在文字屁股后面。用 ::after 而不是右边框，
   这样元素宽度随文字长短变化，光标始终贴着最后一个字 */
.typewriter::after {
  content: '';
  display: inline-block;
  width: 0.08em;
  height: 1em;
  margin-left: 0.12em;
  vertical-align: -0.12em;
  background: currentColor;
  animation: typewriterCaret 1s step-end infinite;
}

/* 光标：亮一半时间、灭一半时间。step-end 让它是「跳」而不是渐隐 */
@keyframes typewriterCaret {
  0%, 50%       { opacity: 1; }
  50.01%, 100%  { opacity: 0; }
}

/* ============================================================
   首页背景文字
   ------------------------------------------------------------
   把标题下面那几句（data-words 里那些）复制成三行巨大的半透明文字，
   斜着铺在整屏背后，一行往左、一行往右地慢慢流，像远处掠过的标语。
   只在 index.html 里有这一层，其它页面没有。

   实现要点：
   - position: fixed + z-index: -1：钉在视口上、滚动时不动，
     负层级让它待在渐变背景之上、所有正文之下（正文不用改自己的 z-index）。
   - 每行内容由 JS 复制成两份（.bgWords_group），整条轨道平移 -50%，
     正好走过一份的长度，回到原点时无缝，看不出循环的接缝。
   - 动画只改 transform / opacity，交给合成层跑，不触发重排，滚动不受影响。
   ============================================================ */
.bgWords {
  position: fixed;
  inset: 0;
  z-index: -1;                 /* 在渐变背景之上、正文之下 */
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;  /* 三行均匀铺满整屏，不留一大片空底 */
  padding: 6vh 0;                 /* 上下留点边，别顶到标题栏和屏幕底 */
  box-sizing: border-box;
  overflow: hidden;            /* 超宽的文字裁在视口里，不产生横向滚动条 */
  pointer-events: none;        /* 别挡住点击 */
  user-select: none;
  transform: skewY(-6deg);     /* 整体斜一点，比水平摆着有速度感 */
}

.bgWords_row {
  display: flex;
  width: 100%;
  overflow: hidden;

  /* 两头淡出，文字不会在屏幕边缘被硬生生切断 */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);

  /* 呼吸：淡入淡出，让静止的画面也在动 */
  animation: bgBreathe 9s ease-in-out infinite alternate;
}

.bgWords_row--2 { animation-delay: -3s; }
.bgWords_row--3 { animation-delay: -6s; }

/* 轨道：两份内容并排，整体平移 */
.bgWords_track {
  display: flex;
  flex: none;
  will-change: transform;
  animation: bgDriftLeft 70s linear infinite;
}

/* 三行速度、方向都不一样，看起来才不像同一条在复制 */
.bgWords_row--1 .bgWords_track { animation-duration: 70s; }
.bgWords_row--2 .bgWords_track { animation-name: bgDriftRight; animation-duration: 95s; }
.bgWords_row--3 .bgWords_track { animation-duration: 120s; }

.bgWords_group {
  display: flex;
  flex: none;
  align-items: center;
  white-space: nowrap;         /* 一句话不许折行 */
}

.bgWords_word {
  padding: 0 0.35em;
  font-size: clamp(2.25rem, 7vw, 6.5rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.14);
  text-shadow: 0 10px 40px rgba(54, 73, 219, 0.10);
}

/* 中间一行用深蓝，和上下两行的白色错开，层次多一点 */
.bgWords_row--2 .bgWords_word {
  color: rgba(54, 73, 219, 0.09);
  text-shadow: none;
}

.bgWords_row--3 .bgWords_word {
  color: rgba(255, 255, 255, 0.11);
}

/* 句子之间的分隔点 */
.bgWords_dot {
  font-size: clamp(1.5rem, 4.5vw, 4rem);
  color: rgba(255, 255, 255, 0.20);
  line-height: 1;
}

.bgWords_row--2 .bgWords_dot {
  color: rgba(54, 73, 219, 0.12);
}

/* 往左流：从 0 平移到 -50%，也就是走过一份内容的宽度，正好接回开头 */
@keyframes bgDriftLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* 往右流：反过来 */
@keyframes bgDriftRight {
  from { transform: translateX(-50%); }
  to   { transform: translateX(0); }
}

@keyframes bgBreathe {
  from { opacity: 0.75; }
  to   { opacity: 1; }
}

/* 保险：页面上所有文字都套着 riseUp 动画，而它的第一帧是 opacity: 0。
   万一系统开了「减少动态效果」导致动画不跑，文字就会永远看不见，
   所以这里直接关掉动画、让内容正常显示。 */
@media (prefers-reduced-motion: reduce) {
  .title,
  .card {
    animation: none;
  }

  /* 打字机同理：JS 会直接显示第一句，光标也别闪了 */
  .typewriter::after {
    animation: none;
    opacity: 0;
  }

  /* 背景文字：不流动、不呼吸，只留一层静止的淡字当纹理 */
  .bgWords_row,
  .bgWords_track {
    animation: none;
  }
}
