/*
 * Campus Circle Base Layer
 * Quiet, precise, keyboard-safe defaults.
 */

/* Manrope：拉丁字母与数字，自托管（中文回退至系统中文黑体） */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/manrope-400.woff2") format("woff2");
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/manrope-500.woff2") format("woff2");
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/manrope-600.woff2") format("woff2");
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/manrope-700.woff2") format("woff2");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: auto;
  scroll-padding-top: calc(var(--header-h) + 20px);
  text-size-adjust: 100%;
}

html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  /* 四团极淡的彩光铺在纸面上：蓝 / 亮蓝 / 紫 / 青。
     不用 background-attachment: fixed——它会强制每次滚动整幅重绘，
     是滚动卡顿的经典元凶；光随内容滚，视觉几乎无差。 */
  background-image:
    radial-gradient(880px 520px at 0% -12%, var(--wash-1), transparent 64%),
    radial-gradient(820px 520px at 100% -6%, var(--wash-2), transparent 64%),
    radial-gradient(900px 560px at 58% 118%, var(--wash-3), transparent 66%),
    radial-gradient(760px 480px at 26% 56%, var(--wash-4), transparent 68%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Micro-noise base: barely-there matte grain, no color drift */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.035'/></svg>");
  background-size: 140px 140px;
}

img,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
[role="button"],
input,
textarea,
select,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
p,
dl,
dd,
dt,
ul,
ol,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4,
h5 {
  text-wrap: balance;
  letter-spacing: var(--tracking-tight);
}

p,
li,
dd {
  text-wrap: pretty;
}

/* 数据型数字等宽，避免计数跳动 */
.tabular,
.stat-value,
.metric,
.badge,
.tag,
.pagination,
.post-stats {
  font-variant-numeric: tabular-nums;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--accent);
  color: #fff;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid var(--bg);
  border-radius: var(--r-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
}

input,
textarea,
select {
  caret-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: calc(var(--z-toast) + 1);
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--dur-3) var(--ease-out);
}

.skip-link:focus {
  transform: none;
}

.container {
  width: min(var(--container), calc(100% - var(--content-pad) * 2));
  margin-inline: auto;
}

.container.narrow {
  width: min(var(--container-narrow), calc(100% - var(--content-pad) * 2));
}

.page-main {
  min-height: calc(100dvh - var(--header-h));
  padding: 32px 0 72px;
}

.flex {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.gap-sm {
  gap: var(--sp-2);
}

.mt-16 {
  margin-top: var(--sp-4);
}

.mt-20 {
  margin-top: var(--sp-5);
}

.mt-24 {
  margin-top: var(--sp-6);
}

.mb-16 {
  margin-bottom: var(--sp-4);
}

.mb-24 {
  margin-bottom: var(--sp-6);
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: var(--text-sm);
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: var(--text-xs);
  line-height: 1.5;
}

.title-mt {
  margin-top: var(--sp-4);
}

.pre-line {
  white-space: pre-line;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

/* The old index redirect card, kept graceful */
.error-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--sp-6);
  background: var(--bg);
}

.error-page > div {
  width: min(440px, 100%);
  padding: var(--sp-8);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.error-copy {
  margin: var(--sp-4) 0 var(--sp-6);
  color: var(--muted);
}

.error-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- 页面背景：视频层 + 玻璃雾罩（替代旧版五层浪 + 上浮气泡）----------
   结构由 p_layout.php 的 renderPageFx() 输出一次（fixed、aria-hidden、pointer-events:none）。
   视频等 window load 之后再 play()，不跟首屏抢带宽；加载失败 / 省流量模式 / 减少动态效果时
   自动只剩底部两团极光，页面照样好看。
   层级顺序：极光（兜底底色）→ 视频 → 雾罩，卡片浮在雾罩之上。 */
.page-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
  --fx-veil-a: rgba(246, 250, 255, 0.8);
  --fx-veil-b: rgba(246, 250, 255, 0.34);
  --fx-veil-c: rgba(246, 250, 255, 0.36);
  --fx-veil-d: rgba(246, 250, 255, 0.5);
  --fx-video-opacity: 0.95;
  /* 中央柔光斑的颜色（洗掉原片正中的金色圆桌）。
     必须跟随主题：浅色用白雾提亮，深色必须换成暗雾压暗 ——
     否则切深色后这里会留一团突兀的白光。 */
  --fx-bloom: rgba(246, 250, 255, 0.66);
  --fx-bloom-end: rgba(246, 250, 255, 0);
}

.page-fx i {
  display: block;
  position: absolute;
}

/* 两团极光：紫 / 青，缓慢漂移。视频没出来时它们就是底色，出来了就被压在最底下。
   性能要点：不用 filter: blur（大范围 blur 是最贵的 CSS 效果，合成层重光栅化会拖垮帧率），
   用四段透明度递减的 radial-gradient 直接画出软边；keyframes 只动 translate 不动 scale
   （缩放同样会触发重光栅化）。 */
.page-fx .pf-b1,
.page-fx .pf-b2 {
  border-radius: 50%;
  opacity: 0.26;
  will-change: transform;
}

.page-fx .pf-b1 {
  width: 50vw;
  height: 54vh;
  left: -6vw;
  top: -16vh;
  background: radial-gradient(closest-side, rgba(122, 92, 255, 0.95), rgba(122, 92, 255, 0.5) 42%, rgba(122, 92, 255, 0.18) 64%, transparent 80%);
  animation: pfAur1 46s ease-in-out infinite alternate;
}

.page-fx .pf-b2 {
  width: 46vw;
  height: 52vh;
  right: -8vw;
  top: -4vh;
  background: radial-gradient(closest-side, rgba(0, 194, 168, 0.95), rgba(0, 194, 168, 0.5) 42%, rgba(0, 194, 168, 0.18) 64%, transparent 80%);
  animation: pfAur2 56s ease-in-out infinite alternate;
}

/* 视频层：唯一持续重绘的元素，只动 opacity，尺寸交给 object-fit 处理 */
.page-fx .pf-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 46%;
  /* 微放大 + 上移：把画面里的陈设（金桌、金环）推到画面边缘，只留天空、雪山和水面的柔和纹理 */
  transform: scale(1.08) translateY(-13%);
  opacity: 0;
  /* 降饱和 + 轻模糊：原片是 3D 渲染的客厅（沙发、金桌、金环都在里面运镜），
     降饱和压掉暖金，轻模糊把陈设化成柔和色块 —— 任何一帧都不会冒出扎眼的家具。
     blur 只作用在这一个 video 合成层上，成本可控。 */
  filter: saturate(0.62) brightness(1.05) blur(2px);
  transition: opacity 1.4s var(--ease-out);
  will-change: opacity;
}

.page-fx .pf-video.is-ready {
  opacity: var(--fx-video-opacity);
}

/* 雾罩：把画面压成氛围底，正文对比度不受影响。
   中间补一块柔光斑——原片正中是那张金色圆桌，正好落在 hero 卡片文字区后面，
   用局部柔光把它洗掉，两侧的天空、雪山、水面继续透出来。 */
.page-fx .pf-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(26% 24% at 42% 32%, var(--fx-bloom), var(--fx-bloom-end) 74%),
    linear-gradient(180deg, var(--fx-veil-a) 0%, var(--fx-veil-b) 26%, var(--fx-veil-c) 64%, var(--fx-veil-d) 100%);
}

@keyframes pfAur1 {
  from { transform: translate(0, 0); }
  to { transform: translate(16%, 10%); }
}

@keyframes pfAur2 {
  from { transform: translate(0, 0); }
  to { transform: translate(-14%, 8%); }
}

/* 深色模式：视频压暗、雾罩换成深色雾，卡片靠自身的玻璃层保持可读。
   柔光斑同步换成暗雾：位置不变（继续洗视频正中的圆桌），只是颜色由白转暗，
   不再在深色页面里发光。 */
[data-theme="dark"] .page-fx {
  --fx-veil-a: rgba(11, 16, 32, 0.94);
  --fx-veil-b: rgba(11, 16, 32, 0.58);
  --fx-veil-c: rgba(11, 16, 32, 0.66);
  --fx-veil-d: rgba(11, 16, 32, 0.96);
  --fx-video-opacity: 0.42;
  --fx-bloom: rgba(11, 16, 32, 0.55);
  --fx-bloom-end: rgba(11, 16, 32, 0);
}

[data-theme="dark"] .page-fx .pf-video {
  filter: saturate(0.72) brightness(0.72);
}

[data-theme="dark"] .page-fx .pf-b1,
[data-theme="dark"] .page-fx .pf-b2 {
  opacity: 0.32;
}

/* 手机：不播视频（背景视频不值得为移动流量买单），极光层顶上，页面照样有氛围 */
@media (max-width: 640px) {
  .page-fx .pf-video {
    display: none;
  }
}

/* 「减少动态效果」用户：视频不播，光斑停在静态一帧 */
@media (prefers-reduced-motion: reduce) {
  .page-fx .pf-b1,
  .page-fx .pf-b2 {
    animation: none;
  }
  .page-fx .pf-video {
    display: none;
  }
  .page-fx .pf-b1 { opacity: 0.2; }
  .page-fx .pf-b2 { opacity: 0.2; }
}
