/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0e17;
    --bg-alt: #0e1524;
    --panel: #131c30;
    --text: #e6edf3;
    --muted: #8b98ab;
    --blue: #4B8BBE;
    --dark-blue: #306998;
    --yellow: #FFD43B;
    --yellow-soft: #FFE873;
    --purple: #a371f7;
    --radius: 14px;
}

html { scroll-behavior: smooth; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    padding-bottom: 40px; /* 给固定备案条留位置 */
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

pre, code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; }

::selection { background: rgba(255, 212, 59, .3); }

/* ===== 导航 ===== */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(10, 14, 23, .8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo-py {
    display: inline-block; margin-right: 6px; padding: 2px 8px;
    background: linear-gradient(135deg, var(--blue), var(--dark-blue));
    color: var(--yellow); border-radius: 8px;
    animation: logo-pulse 3s ease-in-out infinite;
}
@keyframes logo-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(75, 139, 190, .6); }
    50% { box-shadow: 0 0 16px 4px rgba(75, 139, 190, .4); }
}
.nav-links { display: flex; gap: 28px; list-style: none; }
.nav-links a {
    position: relative; color: var(--muted); text-decoration: none;
    font-size: 15px; transition: color .25s;
}
.nav-links a::after {
    content: ""; position: absolute; left: 0; bottom: -6px;
    width: 0; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--blue), var(--yellow));
    transition: width .3s ease;
}
.nav-links a:hover { color: var(--yellow); }
.nav-links a:hover::after { width: 100%; }

/* ===== 首屏 ===== */
.hero {
    position: relative; padding: 120px 0 100px; overflow: hidden;
    background:
        radial-gradient(ellipse 60% 50% at 20% 10%, rgba(75, 139, 190, .15), transparent),
        radial-gradient(ellipse 50% 40% at 80% 80%, rgba(255, 212, 59, .08), transparent),
        var(--bg);
}
#particleCanvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none;
}

/* 漂浮代码符号 */
.float-symbols { position: absolute; inset: 0; pointer-events: none; }
.float-symbol {
    position: absolute; left: var(--x); top: -40px;
    font-family: Consolas, monospace; font-size: var(--s);
    color: rgba(75, 139, 190, .35);
    text-shadow: 0 0 12px rgba(75, 139, 190, .5);
    animation: float-down 9s linear infinite;
    animation-delay: var(--d);
}
.float-symbol:nth-child(even) { color: rgba(255, 212, 59, .28); text-shadow: 0 0 12px rgba(255, 212, 59, .45); }
@keyframes float-down {
    0% { top: -40px; opacity: 0; transform: rotate(-10deg); }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 110%; opacity: 0; transform: rotate(15deg); }
}

.hero-inner { position: relative; display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.hero-text { flex: 1 1 420px; }

/* 标题逐字弹入 */
.hero-title { font-size: 52px; line-height: 1.25; }
.title-line { display: block; }
.title-word {
    display: inline-block;
    opacity: 0; transform: translateY(40px) scale(.6);
    animation: word-in .7s cubic-bezier(.22, 1.4, .36, 1) forwards;
}
.title-line:nth-child(1) .title-word:nth-child(1) { animation-delay: .1s; }
.title-line:nth-child(1) .title-word:nth-child(2) { animation-delay: .2s; }
.title-line:nth-child(2) .title-word:nth-child(1) { animation-delay: .35s; }
.title-line:nth-child(2) .title-word:nth-child(2) { animation-delay: .42s; }
.title-line:nth-child(2) .title-word:nth-child(3) { animation-delay: .49s; }
.title-line:nth-child(2) .title-word:nth-child(4) { animation-delay: .56s; }
.title-line:nth-child(2) .title-word:nth-child(5) { animation-delay: .63s; }
.title-line:nth-child(2) .title-word:nth-child(6) { animation-delay: .7s; }
.title-line:nth-child(3) .title-word:nth-child(1) { animation-delay: .85s; }
.title-line:nth-child(3) .title-word:nth-child(2) { animation-delay: .93s; }
.title-line:nth-child(3) .title-word:nth-child(3) { animation-delay: 1.01s; }
.title-line:nth-child(3) .title-word:nth-child(4) { animation-delay: 1.09s; }
@keyframes word-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.hl-word .title-word {
    background: linear-gradient(120deg, var(--blue) 20%, var(--yellow) 80%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    background-size: 200% 100%;
    animation: word-in .7s cubic-bezier(.22, 1.4, .36, 1) forwards,
               gradient-flow 4s linear 1.5s infinite;
}
@keyframes gradient-flow {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

.typing-wrap {
    margin-top: 26px; font-family: Consolas, monospace; font-size: 19px;
    color: var(--yellow-soft); min-height: 32px;
    opacity: 0; animation: fade-in .8s ease 1.3s forwards;
}
@keyframes fade-in { to { opacity: 1; } }
.prompt { color: var(--blue); margin-right: 8px; }
.cursor {
    display: inline-block; width: 10px; height: 22px; margin-left: 3px;
    background: var(--yellow); vertical-align: -3px;
    box-shadow: 0 0 10px var(--yellow);
    animation: blink .8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-sub {
    margin-top: 14px; color: var(--muted); font-size: 17px;
    opacity: 0; animation: fade-in .8s ease 1.5s forwards;
}

/* 发光按钮 */
.btn {
    display: inline-block; margin-top: 30px; padding: 13px 34px;
    background: linear-gradient(135deg, var(--blue), var(--dark-blue));
    color: #fff; text-decoration: none; font-size: 16px; font-weight: 600;
    border: none; border-radius: 999px; cursor: pointer;
    transition: transform .25s, box-shadow .25s;
    opacity: 0; animation: fade-in .8s ease 1.7s forwards;
}
.btn-glow {
    position: relative;
    box-shadow: 0 0 20px rgba(75, 139, 190, .5), 0 0 60px rgba(75, 139, 190, .2);
    animation: fade-in .8s ease 1.7s forwards, btn-breathe 2.4s ease-in-out 2s infinite;
}
@keyframes btn-breathe {
    0%, 100% { box-shadow: 0 0 20px rgba(75, 139, 190, .5), 0 0 60px rgba(75, 139, 190, .2); }
    50% { box-shadow: 0 0 30px rgba(75, 139, 190, .8), 0 0 90px rgba(255, 212, 59, .3); }
}
.btn:hover { transform: translateY(-3px) scale(1.04); }
.btn-ghost { background: transparent; border: 1px solid var(--blue); box-shadow: none; opacity: 1; animation: none; }
.btn-ghost:hover { background: rgba(75, 139, 190, .12); box-shadow: 0 0 20px rgba(75, 139, 190, .3); }

/* 蛇形装饰：双环旋转 + 悬浮 */
.hero-snake { position: relative; flex: 1 1 280px; display: flex; align-items: center; justify-content: center; min-height: 240px; }
.snake-ring {
    position: absolute; width: 200px; height: 200px; border-radius: 50%;
    border: 2px dashed rgba(75, 139, 190, .5);
    animation: spin 12s linear infinite;
}
.snake-ring.ring2 {
    width: 150px; height: 150px;
    border-color: rgba(255, 212, 59, .4);
    animation: spin 8s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }
.snake-core {
    position: relative; z-index: 2; font-size: 72px;
    animation: hover-float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(255, 212, 59, .45));
}
@keyframes hover-float {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-18px) rotate(4deg); }
}

/* 滚动提示 */
.scroll-hint {
    position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
    width: 26px; height: 44px;
    border: 2px solid rgba(139, 152, 171, .5); border-radius: 14px;
}
.scroll-hint-arrow {
    position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
    width: 4px; height: 10px; border-radius: 2px; background: var(--yellow);
    animation: hint-scroll 1.6s ease-in-out infinite;
}
@keyframes hint-scroll {
    0% { top: 8px; opacity: 1; }
    70% { top: 24px; opacity: 0; }
    100% { top: 8px; opacity: 0; }
}

/* ===== 区块 ===== */
.section { position: relative; padding: 90px 0; text-align: center; overflow: hidden; }
.section-alt { background: var(--bg-alt); }
.section-title { font-size: 34px; }
.section-title::after {
    content: ""; display: block; margin: 12px auto 0;
    width: 70px; height: 4px; border-radius: 3px;
    background: linear-gradient(90deg, var(--blue), var(--yellow), var(--purple), var(--blue));
    background-size: 300% 100%;
    animation: title-line-flow 3s linear infinite;
}
@keyframes title-line-flow {
    0% { background-position: 0% 0; }
    100% { background-position: 300% 0; }
}
.accent { color: var(--yellow); text-shadow: 0 0 18px rgba(255, 212, 59, .4); }
.section-desc { margin-top: 12px; color: var(--muted); }

/* ===== 搭积木 ===== */
.blocks-stage-wrap {
    margin-top: 50px;
    display: flex; justify-content: center; align-items: flex-end;
    gap: 60px; flex-wrap: wrap;
}
.blocks-stage { position: relative; width: 280px; }
.explosion-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.spark {
    position: absolute; width: 8px; height: 8px; border-radius: 50%;
    pointer-events: none;
    animation: spark-fly .8s ease-out forwards;
}
@keyframes spark-fly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); }
}

.blocks-tower {
    display: flex; flex-direction: column-reverse; align-items: center;
    min-height: 372px;
}
.block {
    position: relative;
    width: calc(120px + var(--i) * 24px);
    padding: 12px 0; margin-bottom: 8px;
    background: var(--c); color: #0a0e17;
    font-weight: 700; font-size: 16px;
    border-radius: 10px;
    box-shadow: 0 6px 0 rgba(0, 0, 0, .4), 0 0 0 rgba(255, 212, 59, 0);
    opacity: 0; transform: translateY(-460px) rotate(10deg) scale(.8);
}
.block.dropped {
    animation: drop .55s cubic-bezier(.28, .84, .42, 1) forwards,
               block-shine 4s ease-in-out calc(var(--i) * .6s + 2s) infinite;
    animation-delay: calc(var(--i) * .6s), calc(var(--i) * .6s + 2s);
}
@keyframes drop {
    0% { opacity: 0; transform: translateY(-460px) rotate(10deg) scale(.8); }
    60% { opacity: 1; transform: translateY(16px) rotate(0) scale(1.03); }
    80% { transform: translateY(-7px) scale(1); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes block-shine {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.18); }
}
.blocks-ground { position: relative; height: 10px; border-radius: 6px; overflow: visible; }
.blocks-ground::before {
    content: ""; position: absolute; inset: 0; border-radius: 6px;
    background: linear-gradient(90deg, var(--blue), var(--yellow), var(--blue));
    background-size: 200% 100%;
    animation: ground-flow 3s linear infinite;
}
@keyframes ground-flow {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}
.ground-glow {
    position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
    width: 90%; height: 26px; border-radius: 50%;
    background: radial-gradient(ellipse, rgba(255, 212, 59, .35), transparent 70%);
    animation: glow-pulse 2.4s ease-in-out infinite;
}
@keyframes glow-pulse {
    0%, 100% { opacity: .5; transform: translateX(-50%) scaleX(1); }
    50% { opacity: 1; transform: translateX(-50%) scaleX(1.1); }
}

/* 代码窗口：流动渐变边框 */
.code-window {
    position: relative;
    width: 400px; max-width: 100%;
    background: var(--panel); border-radius: var(--radius);
    text-align: left;
    border: 1px solid transparent;
    background-image: linear-gradient(var(--panel), var(--panel)),
                      linear-gradient(120deg, var(--blue), var(--yellow), var(--purple), var(--blue));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    background-size: 100% 100%, 300% 300%;
    animation: border-flow 6s linear infinite;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
@keyframes border-flow {
    0% { background-position: 0 0, 0% 50%; }
    100% { background-position: 0 0, 300% 50%; }
}
.code-titlebar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: rgba(255, 255, 255, .04);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.code-filename { margin-left: 8px; font-size: 13px; color: var(--muted); }
.code-body { padding: 18px 20px; font-size: 15px; line-height: 2; min-height: 216px; }
.code-line {
    display: block; opacity: 0; transform: translateX(-16px) scale(.96);
    transition: opacity .4s, transform .4s;
}
.code-line.show {
    opacity: 1; transform: translateX(0) scale(1);
    animation: line-flash .5s ease;
}
@keyframes line-flash {
    0% { text-shadow: 0 0 16px rgba(255, 212, 59, .9); }
    100% { text-shadow: none; }
}
.kw { color: #ff7b72; } .fn { color: #d2a8ff; } .str { color: #a5d6a7; }
.num { color: #79c0ff; } .op { color: #ff9e64; } .cm { color: #7d8590; }

/* ===== 语法卡片 ===== */
.card-grid {
    margin-top: 50px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px;
}
.card {
    position: relative;
    background: var(--panel); border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, .08);
    padding: 24px; text-align: left;
    transition: transform .3s ease, border-color .3s, box-shadow .3s;
    transform-style: preserve-3d;
    will-change: transform;
}
.card:hover {
    border-color: var(--blue);
    box-shadow: 0 18px 50px rgba(75, 139, 190, .28);
}
.card::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%),
                rgba(75, 139, 190, .15), transparent 40%);
    opacity: 0; transition: opacity .3s; pointer-events: none;
}
.card:hover::before { opacity: 1; }
.card h3 { color: var(--yellow-soft); font-size: 18px; }
.card-code {
    margin: 14px 0; padding: 14px;
    background: #070b12; border-radius: 10px;
    font-size: 13px; line-height: 1.8; overflow-x: auto; white-space: pre;
    border: 1px solid rgba(255, 255, 255, .05);
}
.card-note { color: var(--muted); font-size: 14px; }

/* ===== 函数调用动画 ===== */
.fn-stage { margin-top: 50px; }
.fn-code {
    display: inline-block; padding: 16px 26px;
    background: var(--panel); border-radius: 12px;
    font-family: Consolas, monospace; font-size: 17px; text-align: left; line-height: 1.9;
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.fn-code .indent { display: block; padding-left: 2em; }
.fn-machine {
    position: relative; margin: 50px auto 0;
    width: 640px; max-width: 100%; height: 200px;
}
.fn-chip {
    position: absolute; top: 70px; padding: 10px 20px;
    border-radius: 10px; font-family: Consolas, monospace; font-weight: 700;
    opacity: 0; z-index: 3;
}
.arg-a { left: 0; background: var(--blue); color: #fff; box-shadow: 0 0 18px rgba(75, 139, 190, .5); }
.arg-b { left: 0; top: 126px; background: var(--dark-blue); color: #fff; box-shadow: 0 0 18px rgba(48, 105, 152, .5); }
.result { right: 0; background: var(--yellow); color: #0a0e17; box-shadow: 0 0 26px rgba(255, 212, 59, .6); }

.fn-stage.play .arg-a { animation: feed 1s ease-in .2s forwards; }
.fn-stage.play .arg-b { animation: feed 1s ease-in .7s forwards; }
.fn-stage.play .result { animation: pop-out .8s cubic-bezier(.22, 1.4, .36, 1) 2.5s forwards; }
@keyframes feed {
    0% { opacity: 0; transform: translateX(0) scale(1); }
    30% { opacity: 1; }
    85% { opacity: 1; transform: translateX(200px) scale(.65); }
    100% { opacity: 0; transform: translateX(225px) scale(.4); }
}
@keyframes pop-out {
    0% { opacity: 0; transform: translateX(-50px) scale(.4) rotate(-12deg); }
    60% { opacity: 1; transform: translateX(8px) scale(1.12) rotate(3deg); }
    100% { opacity: 1; transform: translateX(0) scale(1) rotate(0); }
}

.fn-box {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 190px; height: 120px;
    display: flex; align-items: center; justify-content: center;
    background: var(--panel); border: 2px dashed var(--blue); border-radius: 18px;
    font-family: Consolas, monospace; font-size: 17px; color: var(--yellow-soft);
    z-index: 2;
}
.fn-box-ring {
    position: absolute; inset: -14px; border-radius: 26px;
    border: 1px solid rgba(75, 139, 190, .35);
    animation: ring-spin 6s linear infinite;
}
.fn-box-ring.ring2 {
    inset: -26px; border-radius: 34px;
    border-style: dashed; border-color: rgba(255, 212, 59, .22);
    animation: ring-spin 10s linear infinite reverse;
}
@keyframes ring-spin { to { transform: rotate(360deg); } }
.fn-stage.play .fn-box { animation: digest .7s ease 1.9s; }
@keyframes digest {
    0%, 100% { transform: translate(-50%, -50%) scale(1); border-color: var(--blue); box-shadow: none; }
    40% { transform: translate(-50%, -50%) scale(1.15) rotate(-2deg); border-color: var(--yellow);
          box-shadow: 0 0 44px rgba(255, 212, 59, .55); }
    70% { transform: translate(-50%, -50%) scale(.96) rotate(1deg); }
}

/* 爆炸光环（JS 注入粒子） */
.fn-burst { position: absolute; left: 50%; top: 50%; z-index: 4; pointer-events: none; }
.burst-particle {
    position: absolute; left: 0; top: 0;
    width: 10px; height: 10px; border-radius: 2px;
    animation: burst-fly .9s cubic-bezier(.16, .84, .44, 1) forwards;
}
@keyframes burst-fly {
    0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.3); }
}

.fn-caption { margin-top: 26px; color: var(--muted); font-family: Consolas, monospace; font-size: 17px; }
.fn-stage.play .fn-caption { animation: caption-in .5s ease 3s both; opacity: 0; }
@keyframes caption-in { to { opacity: 1; } }

/* ===== 日记时间线 ===== */
.timeline { margin-top: 50px; max-width: 680px; margin-left: auto; margin-right: auto; text-align: left; }
.timeline-item {
    position: relative; padding: 0 0 34px 34px;
    border-left: 2px solid rgba(75, 139, 190, .4);
}
.timeline-item::before {
    content: ""; position: absolute; left: -9px; top: 6px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 0 4px rgba(255, 212, 59, .2), 0 0 16px rgba(255, 212, 59, .5);
    animation: dot-pulse 2.2s ease-in-out infinite;
}
@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 212, 59, .2), 0 0 10px rgba(255, 212, 59, .4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 212, 59, .08), 0 0 24px rgba(255, 212, 59, .7); }
}
.timeline-item time { font-size: 13px; color: var(--blue); font-family: Consolas, monospace; }
.timeline-item h3 { margin: 4px 0 6px; font-size: 19px; }
.timeline-item p { color: var(--muted); font-size: 15px; }

/* 滚动出现 */
.reveal { opacity: 0; transform: translateY(36px) scale(.97); transition: opacity .7s ease, transform .7s cubic-bezier(.22, 1, .36, 1); }
.reveal.visible { opacity: 1; transform: translateY(0) scale(1); }

/* ===== 页脚 ===== */
.site-footer {
    padding: 44px 0 36px; text-align: center;
    border-top: 1px solid rgba(255, 255, 255, .06);
    background: var(--bg-alt);
}
.footer-slogan { color: var(--muted); }

/* ===== 固定备案号 ===== */
.fixed-icp {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    padding: 10px 16px;
    text-align: center;
    background: rgba(10, 14, 23, .88);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.fixed-icp a {
    color: #6e7b8d; font-size: 13px; text-decoration: none;
    transition: color .25s, text-shadow .25s;
}
.fixed-icp a:hover {
    color: var(--yellow);
    text-shadow: 0 0 12px rgba(255, 212, 59, .5);
}

@media (max-width: 720px) {
    .hero-title { font-size: 36px; }
    .nav-links { gap: 14px; }
    .fn-machine { height: 250px; }
    .hero-snake { min-height: 190px; }
    .snake-ring { width: 160px; height: 160px; }
    .snake-ring.ring2 { width: 118px; height: 118px; }
    .snake-core { font-size: 56px; }
}
