/* IFaster —— 动效语言参考 RhineLabUI（白底开场 / 终端逐字 / 圆环绕行 /
   解密式揭示 / 滚动数字），实现为无依赖的原生 CSS + JS。不使用任何游戏素材。 */

:root {
  --wrap: 1060px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "MiSans", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
}

/* =========================================================================
   配色一 · 乐正绫（红 · 白 · 黑）—— 默认
   ========================================================================= */
:root,
[data-palette="ling"][data-theme="dark"] {
  --bg: #120f11;
  --bg-2: #0a0809;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --text: #f4f1ee;
  --muted: #a89f9c;
  --line: #3c3134;
  --accent: #e02330;
  --accent-2: #ff6f7a;
  --accent-soft: rgba(224, 35, 48, 0.16);
  --boot-bg: #fbfaf9;
  --boot-ink: #141011;
  --boot-dim: #6d6264;
  --boot-ring: #c8102e;
  --boot-ok: #8a6a2f;
}

[data-palette="ling"][data-theme="light"] {
  --bg: #f8f6f5;
  --bg-2: #ffffff;
  --panel: rgba(17, 17, 17, 0.028);
  --panel-strong: rgba(17, 17, 17, 0.055);
  --text: #121011;
  --muted: #6f6462;
  --line: #ded7d4;
  --accent: #c8102e;
  --accent-2: #e02330;
  --accent-soft: rgba(200, 16, 46, 0.1);
  --boot-bg: #ffffff;
  --boot-ink: #121011;
  --boot-dim: #6f6462;
  --boot-ring: #c8102e;
  --boot-ok: #7d6230;
}

/* =========================================================================
   配色二 · 竹林（黑 · 白 · 深绿）
   ========================================================================= */
[data-palette="bamboo"][data-theme="dark"] {
  --bg: #0c1210;
  --bg-2: #070c0a;
  --panel: rgba(232, 237, 230, 0.035);
  --panel-strong: rgba(232, 237, 230, 0.07);
  --text: #e9eee7;
  --muted: #93a398;
  --line: #2f4238;
  --accent: #4e8c6a;
  --accent-2: #9cc3a6;
  --accent-soft: rgba(78, 140, 106, 0.18);
  --boot-bg: #f3f1e7;
  --boot-ink: #131a15;
  --boot-dim: #67766b;
  --boot-ring: #2f6b4a;
  --boot-ok: #4e7d4a;
}

[data-palette="bamboo"][data-theme="light"] {
  --bg: #f3f1e7;
  --bg-2: #fbfaf4;
  --panel: rgba(19, 26, 21, 0.03);
  --panel-strong: rgba(19, 26, 21, 0.055);
  --text: #101713;
  --muted: #5f6e63;
  --line: #cbd2c4;
  --accent: #2f6b4a;
  --accent-2: #4e8c6a;
  --accent-soft: rgba(47, 107, 74, 0.12);
  --boot-bg: #fbfaf4;
  --boot-ink: #101713;
  --boot-dim: #5f6e63;
  --boot-ring: #2f6b4a;
  --boot-ok: #3f6b3c;
}

/* 切配色时整体平滑过渡 */
body, .topbar, .footer, .section, .card, .row, .spec li, .tags span,
.icon-btn, .brand-mark, .st, .kicker, .index-table, .hero-meta {
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease),
              border-color 0.45s var(--ease);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.8 var(--sans);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 45% at 12% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(55% 45% at 88% 8%, rgba(83, 97, 102, 0.28), transparent 72%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  transition: background 0.8s var(--ease);
}

.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 96px 96px;
  opacity: 0.1;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 20%, transparent 78%);
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

[data-theme="light"] .scanline { display: none; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0.06em; }
.muted { color: var(--muted); }

/* ============================== 开场：白底终端 ============================== */
.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--boot-bg);
  color: var(--boot-ink);
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.72s var(--ease);
}

.boot.done { clip-path: inset(0 0 100% 0); }
.boot.gone { display: none; }

.boot-stage {
  position: relative;
  width: min(560px, 84vw);
  min-height: 300px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  animation: bootIn 0.5s var(--ease) both;
}

@keyframes bootIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.boot-ring { position: absolute; top: -34px; width: 260px; height: 260px; opacity: 0.9; }
.ring-track { fill: none; stroke: color-mix(in srgb, var(--boot-ink) 12%, transparent); stroke-width: 1.2; }
.ring-draw {
  fill: none;
  stroke: var(--boot-ring);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 578;
  stroke-dashoffset: 578;
  transform: rotate(-90deg);
  transform-origin: 110px 110px;
  animation: ringDraw 1.9s var(--ease) 0.25s forwards;
}
.ring-dot { fill: var(--boot-ring); opacity: 0; animation: dotIn 0.4s var(--ease) 2.1s forwards; }

@keyframes ringDraw { to { stroke-dashoffset: 0; } }
@keyframes dotIn { to { opacity: 1; } }

.boot-mark {
  font: 700 40px/1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--boot-ink);
  opacity: 0;
  animation: markIn 0.5s var(--ease) 1.75s forwards;
}

@keyframes markIn {
  from { opacity: 0; letter-spacing: 0.4em; filter: blur(4px); }
  to { opacity: 1; letter-spacing: 0.06em; filter: none; }
}

.boot-log {
  margin-top: 18px;
  width: 100%;
  min-height: 118px;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--boot-dim);
  letter-spacing: 0.08em;
  white-space: pre-wrap;
}
.boot-log .ok { color: var(--boot-ok); }
.boot-log .hl { color: var(--boot-ring); }
.boot-log .cursor::after {
  content: "▌";
  margin-left: 2px;
  animation: blink 0.9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.boot-bar {
  width: 100%;
  height: 2px;
  background: color-mix(in srgb, var(--boot-ink) 12%, transparent);
  overflow: hidden;
}
.boot-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--boot-ring);
  transition: width 0.3s linear;
}

.boot-foot {
  margin-top: 12px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  letter-spacing: 0.24em;
  color: var(--boot-dim);
}
.boot-skip { opacity: 0.72; }

.boot-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.boot.flash .boot-flash { animation: flash 0.4s ease-out; }
@keyframes flash { 0% { opacity: 0; } 35% { opacity: 0.9; } 100% { opacity: 0; } }

/* 开场期间正文压暗等待 */
body.booting .topbar,
body.booting main,
body.booting .footer { opacity: 0; }

.topbar, main, .footer { transition: opacity 0.6s var(--ease); }

/* 首屏逐行出现 */
.reveal-line {
  opacity: 0;
  transform: translateY(10px);
  filter: blur(6px);
}
body.ready .reveal-line {
  animation: lineIn 0.75s var(--ease) forwards;
}
body.ready .reveal-line:nth-child(1) { animation-delay: 0.05s; }
body.ready .reveal-line:nth-child(2) { animation-delay: 0.14s; }
body.ready .reveal-line:nth-child(3) { animation-delay: 0.23s; }
body.ready .reveal-line:nth-child(4) { animation-delay: 0.32s; }
body.ready .reveal-line:nth-child(5) { animation-delay: 0.41s; }
body.ready .reveal-line:nth-child(6) { animation-delay: 0.5s; }

@keyframes lineIn {
  to { opacity: 1; transform: none; filter: none; }
}

/* ============================== 顶部栏 ============================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 700 12px/1 var(--mono);
  letter-spacing: 0;
}
.brand-name { font-size: 14px; letter-spacing: 0.22em; }
.brand-sep { color: var(--line); }
.brand-sub { color: var(--muted); }
.nav-links { display: flex; gap: 22px; margin-left: auto; font-size: 12.5px; color: var(--muted); }
.nav-links a { padding-bottom: 2px; border-bottom: 1px solid transparent; transition: color 0.18s ease, border-color 0.18s ease; }
.nav-links a:hover { color: var(--text); border-color: var(--accent); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ============================== 首屏 ============================== */
.hero { padding: 108px 0 74px; }
.kicker { margin: 0 0 22px; color: var(--accent); font-size: 12.5px; }
.hero-title { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.hero-title .line {
  font-size: clamp(42px, 8vw, 82px);
  line-height: 1.06;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.hero-title .thin {
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: 0.5em;
  color: var(--muted);
  font-weight: 300;
}
.hero-sub { max-width: 560px; margin: 26px 0 0; color: var(--muted); font-size: 16.5px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: 500 14.5px/1 var(--sans);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.btn-solid { background: var(--accent); border-color: var(--accent); color: #10171a; }
.btn-solid:hover { background: var(--text); border-color: var(--text); color: var(--bg); }

.hero-meta {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 40px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}
.hero-meta li { display: flex; align-items: center; gap: 8px; }
.dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ============================== 滚动数字 ============================== */
.roll { display: inline-flex; }
.roller {
  display: inline-block;
  height: 1em;
  overflow: hidden;
  line-height: 1;
  vertical-align: baseline;
}
.roller .strip {
  display: block;
  transform: translateY(calc(var(--d, 0) * -1em));
  transition: transform 0.46s var(--ease);
}
.roller .strip span { display: block; height: 1em; line-height: 1; }

/* ============================== 章节 ============================== */
.section { padding: 66px 0; border-top: 1px solid var(--line); }
.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 30px;
  font-size: 13px;
  letter-spacing: 0.14em;
  font-weight: 400;
}
.section-title .num { color: var(--accent); }
.section-title .en { color: var(--muted); font-size: 12px; letter-spacing: 0.28em; }
.section-note { margin: -14px 0 26px; color: var(--muted); font-size: 15px; }
.section-foot { margin: 22px 0 0; color: var(--muted); font-size: 12.5px; }

.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 44px; }
.prose p { margin: 0 0 18px; }

.spec { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.spec li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.spec .k { width: 74px; color: var(--accent); font-size: 11.5px; }
.spec .v { color: var(--muted); font-size: 14.5px; }

/* ============================== 解密式揭示 ============================== */
.decrypt { position: relative; }
.decrypt::before {
  content: "";
  position: absolute;
  inset: -10px -14px;
  z-index: 2;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 55%, color-mix(in srgb, var(--bg) 60%, var(--line)) 100%);
  clip-path: inset(0 0 calc(var(--p, 0) * 100%) 0);
  transition: clip-path 0.95s var(--ease);
  pointer-events: none;
}
.decrypt::after {
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  z-index: 3;
  top: calc(var(--p, 0) * 100%);
  height: 1px;
  background: var(--accent);
  opacity: calc(1 - var(--p, 0));
  box-shadow: 0 0 14px var(--accent);
  pointer-events: none;
}
.decrypt > * {
  filter: blur(calc((1 - var(--p, 0)) * 6px));
  opacity: calc(0.25 + var(--p, 0) * 0.75);
  transition: filter 0.95s var(--ease), opacity 0.95s var(--ease);
}

/* 无 JS 时不要藏内容 */
html:not(.js) .decrypt::before,
html:not(.js) .decrypt::after { display: none; }
html:not(.js) .decrypt > * { filter: none; opacity: 1; }
html:not(.js) .reveal-line { opacity: 1; transform: none; filter: none; }

/* 进入视口后逐项错开（按行列延迟） */
.card, .row:not(.head) { --stagger-delay: calc(var(--stagger, 0) * 90ms); }
.card, .row:not(.head) {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), border-color 0.2s ease, background 0.2s ease;
}
.decrypt.in .card,
.decrypt.in .row:not(.head) {
  opacity: 1;
  transform: none;
  transition-delay: var(--stagger-delay);
}
html:not(.js) .card, html:not(.js) .row:not(.head) { opacity: 1; transform: none; }

/* ============================== 卡片 ============================== */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card {
  position: relative;
  padding: 26px 22px 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.card:hover { border-color: var(--accent); background: var(--panel-strong); transform: translateY(-2px); }
.card:hover::before, .card:hover::after { opacity: 1; }
.card .sweep {
  position: absolute;
  top: 0;
  left: -60%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, var(--accent-soft), transparent);
  opacity: 0;
}
.card:hover .sweep { animation: sweep 0.85s var(--ease); }
@keyframes sweep {
  0% { left: -60%; opacity: 0.9; }
  100% { left: 110%; opacity: 0; }
}

.card-code { display: block; color: var(--accent); font-size: 11.5px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 17.5px; font-weight: 500; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tags span {
  padding: 3px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ============================== 索引表 ============================== */
.index-table { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 1.6fr;
  gap: 16px;
  align-items: center;
  padding: 15px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  position: relative;
}
.row.head { color: var(--muted); font-size: 11px; letter-spacing: 0.24em; padding-bottom: 10px; }
a.row { transition: background 0.18s ease, color 0.18s ease; }
a.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.24s var(--ease);
}
a.row:hover { background: var(--panel-strong); color: var(--accent); }
a.row:hover::before { transform: scaleY(1); }
.row .note { color: var(--muted); font-family: var(--sans); font-size: 14px; letter-spacing: 0.01em; }
.row.is-planned { opacity: 0.6; }
.st { font-size: 11px; letter-spacing: 0.16em; color: var(--muted); }
.st-on { color: var(--accent); }

/* ============================== 联系 / 页脚 ============================== */
.contact-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.footer { border-top: 1px solid var(--line); padding: 26px 0 34px; color: var(--muted); font-size: 11.5px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* ============================== 减少动效 ============================== */
@media (prefers-reduced-motion: reduce) {
  .boot { display: none; }
  .reveal-line, .card, .row:not(.head) { opacity: 1; transform: none; filter: none; animation: none; }
  .decrypt::before, .decrypt::after { display: none; }
  .decrypt > * { filter: none; opacity: 1; }
  .dot { animation: none; }
  html { scroll-behavior: auto; }
}

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 26px; }
  .row { grid-template-columns: 1fr; gap: 4px; }
  .row.head { display: none; }
  .nav-links { display: none; }
  .hero { padding: 76px 0 56px; }
}
