/* ============================================================
   ACE — Cinematic layer
   Shared material, typography and scroll-narrative system for every
   application page. Loaded after bright.css so it can refine the
   tokens that layer already established.

   Motion contract
   - Only transform (translate3d / scale / rotate) and opacity animate.
   - Everything here is inert until assets/cinematic.js adds
     `cine-active` to <body>; without JavaScript the site is unchanged.
   ============================================================ */

:root {
  --ease-cinematic: cubic-bezier(.19, 1, .22, 1);
  --ease-glide: cubic-bezier(.16, .84, .44, 1);
  --cine-tight: -.062em;
  --cine-glass: linear-gradient(148deg, rgba(228, 255, 208, .105), rgba(228, 255, 208, .028));
  --cine-glass-fill: rgba(9, 15, 11, .55);
  --cine-edge: rgba(226, 255, 208, .17);
  --cine-glow: rgba(201, 255, 130, .2);
  --cine-blur: blur(22px) saturate(150%);
}

/* ---------- 排版张力：更大的字号跨度与更紧的字距 ---------- */
body:not(.cinematic-home) .h-display {
  font-weight: 640;
  letter-spacing: var(--cine-tight);
  line-height: 1.04;
  text-wrap: balance;
}
body:not(.cinematic-home) .h-xl { font-weight: 610; letter-spacing: -.055em; }
body:not(.cinematic-home) .h-lg { font-weight: 560; letter-spacing: -.035em; }
body:not(.cinematic-home) .lede { letter-spacing: .012em; line-height: 1.95; }
body:not(.cinematic-home) .kicker { letter-spacing: .2em; }
body:not(.cinematic-home) .section { padding-block: clamp(88px, 11vw, 172px); }
body:not(.cinematic-home) .page-hero .h-display { font-size: clamp(52px, 8.4vw, 118px); }

/* ---------- 光标：反色圆圈 ---------- */
@media (pointer: fine) {
  .cursor-ring { mix-blend-mode: difference; border-color: rgba(255, 255, 255, .55); }
  .cursor-ring.is-hover { background: rgba(255, 255, 255, .08); border-color: #fff; }
  body.cine-active .cursor-dot { mix-blend-mode: exclusion; }
}

/* ---------- 滚动进度 ----------
   Self-contained on purpose: index.html loads home.css instead of
   bright.css, so the rail cannot rely on that layer to be visible. */
.site-progress {
  position: fixed; top: 0; left: 0; width: 100%; height: 2px; z-index: 218;
  background: rgba(201, 255, 130, .1);
  pointer-events: none;
}
.site-progress span {
  display: block; width: 100%; height: 100%;
  transform: scale3d(0, 1, 1); transform-origin: left;
  background: linear-gradient(90deg, #b4ef70, #e2ffb9);
  box-shadow: 0 0 12px rgba(201, 255, 130, .6);
  will-change: transform;
}

/* ---------- 磁吸：跟随即时，回弹柔顺 ---------- */
body.site-ready .btn,
body.site-ready .nav-cta,
body.site-ready .row-btn,
body.site-ready .filter-btn { transition: transform .55s var(--ease-cinematic), box-shadow .3s, background .3s, border-color .3s; }
body.site-ready .is-magnetic { transition: transform .06s linear; }

/* ---------- 材质：毛玻璃 + 渐变描边 ---------- */
.cine-glass { position: relative; }
.cine-glass::before {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg, rgba(236, 255, 220, .36), rgba(236, 255, 220, .05) 42%, rgba(140, 240, 200, .18));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
body:not(.cinematic-home) .cine-glass {
  background-image: var(--cine-glass);
  backdrop-filter: var(--cine-blur);
  -webkit-backdrop-filter: var(--cine-blur);
}
body.cine-active .cine-glass::after {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 12% -10%, rgba(255, 255, 255, .07), transparent 62%);
}

/* ---------- 按钮：色彩填充扩张 ---------- */
body:not(.cinematic-home) .btn { position: relative; overflow: hidden; isolation: isolate; }
body:not(.cinematic-home) .btn::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: inherit;
  transform: translate3d(-102%, 0, 0);
  transition: transform .62s var(--ease-cinematic);
  pointer-events: none;
}
body:not(.cinematic-home) .btn-primary::after { background: linear-gradient(135deg, #f2ffd8, #ccff86); }
body:not(.cinematic-home) .btn-ghost::after { background: linear-gradient(135deg, rgba(201, 255, 130, .2), rgba(120, 232, 255, .12)); }
body:not(.cinematic-home) .btn:hover::after,
body:not(.cinematic-home) .btn:focus-visible::after { transform: translate3d(0, 0, 0); }

/* ---------- 压缩卡片与列表的呼吸 ---------- */
body:not(.cinematic-home) .card { border-radius: 18px; }
body:not(.cinematic-home) .card h3 { letter-spacing: -.02em; }
body:not(.cinematic-home) .list-item .title { letter-spacing: -.02em; }
body:not(.cinematic-home) .stat-num { letter-spacing: -.05em; }

/* ============================================================
   粘性滚动序列：页头在滚动中完成一次三维换幕
   ============================================================ */
.cine-stage {
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
  contain: paint;
}
.cine-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
body.cine-active .cine-stage { opacity: 1; }
body.cine-active .cine-canvas { opacity: 1; transition: opacity 1.1s var(--ease-cinematic) .1s; }
.cine-veil {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse 78% 68% at 70% 46%, rgba(6, 12, 8, .72), rgba(5, 9, 6, .28) 58%, transparent 82%);
}
body.cine-active .cine-veil { opacity: .5; }
body.cine-active .page-hero { perspective: 1200px; transform-style: preserve-3d; }
body.cine-active .page-hero .container { position: relative; z-index: 2; }
body.cine-active .page-hero::after { z-index: 1; }

/* 三维换幕的基本单位 */
body.cine-active .cine-3d { will-change: transform, opacity; backface-visibility: hidden; }
body.cine-active .cine-settled .cine-3d { will-change: auto; }

/* 页头文字：逐词上升（仅在引擎接管时启用） */
body.cine-split .cine-mask { display: block; overflow: hidden; padding-block: .04em; }
body.cine-split .cine-word { display: inline-block; will-change: transform, opacity; }

/* 引擎接管时，页头内的 reveal 元素直接呈现 */
body.cine-active .page-hero .reveal,
body.cine-active .page-hero .reveal.in { opacity: 1; transform: none; transition: none; }

/* 引擎接管入场动画的全局规则（关闭 CSS 过渡，交由时间线驱动） */
body.cine-active .reveal { transition: none; }
body.cine-active .cine-revealed { will-change: auto; }

/* ---------- 区块视差与装饰 ---------- */
body.cine-active .section-head { will-change: transform; }

/* ============================================================
   首页（cinematic-home）：补齐该页缺少的通用层
   ============================================================ */
.cinematic-home .cine-mask { display: block; overflow: hidden; padding-block: .04em; }
.cinematic-home .cine-word { display: inline-block; will-change: transform, opacity; }
.cinematic-home .hero-watermark { will-change: transform; }

/* ============================================================
   无障碍与降级
   ============================================================ */
body.motion-reduced .cine-canvas,
body.motion-reduced .cine-stage { display: none; }
body.motion-reduced .cine-veil { opacity: .25; }
body.motion-reduced .cine-word { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .cine-canvas, .cine-stage { display: none; }
  .cine-word { transform: none; }
  body:not(.cinematic-home) .btn::after { transition: none; }
}
@media (max-width: 760px) {
  .cine-stage { display: none; }
  body:not(.cinematic-home) .section { padding-block: clamp(64px, 15vw, 96px); }
}

/* ============================================================
   主题切换：日 / 夜
   颜色本身由 theme-light.css 决定；这里只放开关组件与切换瞬间的过渡。
   ============================================================ */
html[data-theme="dark"] { color-scheme: dark; }
.theme-toggle {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  cursor: pointer; flex-shrink: 0;
  transition: transform .5s var(--ease-cinematic), background .3s, border-color .3s, box-shadow .3s;
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--accent); box-shadow: 0 0 24px var(--cine-glow); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-toggle__icon { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .55s var(--ease-cinematic), opacity .3s; will-change: transform, opacity; }
.theme-toggle__icon svg { width: 17px; height: 17px; }
html[data-theme="dark"] .theme-toggle__sun { opacity: 1; transform: rotate(0deg) scale(1); }
html[data-theme="dark"] .theme-toggle__moon { opacity: 0; transform: rotate(90deg) scale(.55); }
html[data-theme="light"] .theme-toggle__sun { opacity: 0; transform: rotate(-90deg) scale(.55); }
html[data-theme="light"] .theme-toggle__moon { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-toggle--floating { position: fixed; right: 22px; bottom: 22px; z-index: 90; }
@media (max-width: 1120px) { .theme-toggle { width: 36px; height: 36px; } }

/* 切换的 480ms 内做一次整页颜色交叉渐变，其余时间不干扰各组件自己的过渡。 */
.theme-transition, .theme-transition *, .theme-transition *::before, .theme-transition *::after {
  transition: background-color .4s var(--ease-cinematic), background .4s var(--ease-cinematic),
              color .4s var(--ease-cinematic), border-color .4s var(--ease-cinematic),
              fill .4s, stroke .4s, box-shadow .4s !important;
}
@media (prefers-reduced-motion: reduce) {
  .theme-transition, .theme-transition *, .theme-transition *::before, .theme-transition *::after { transition: none !important; }
}
