/* ===== 设计令牌 (Design Tokens) ===== */
:root {
    --bg-deep: #f5f7fa;
    --bg-titanium: #ffffff;
    --dot-color: #c8d6e5;
    --accent-glow: #2563eb;
    --accent-purple: #7c3aed;
    --text-main: #1a1a2e;
    --text-sub: #64748b;
    --glass-border: rgba(37, 99, 235, 0.12);
    --glass-surface: rgba(255, 255, 255, 0.7);
    --footer-bar-height: 64px;
    --nav-height: 80px;
    --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out-back: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===== 基础重置 ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
                 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-deep);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== 导航栏 ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 100;
    background: rgba(245, 247, 250, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(37, 99, 235, 0.06);
    opacity: 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
}

.logo-symbol {
    width: 36px;
    height: 36px;
    color: var(--text-main);
    flex-shrink: 0;
}

.logo-symbol svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-main);
}

/* 艺术渐变 Logo */
.logo-text-art {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1.35rem;
    font-weight: 950;
    letter-spacing: 4px;
    -webkit-text-stroke: 0.5px rgba(37, 99, 235, 0.3);
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.25));
    transition: filter 0.3s ease;
}

.nav-logo:hover .logo-text-art {
    filter: drop-shadow(0 0 12px rgba(124, 58, 237, 0.4));
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: color 0.2s ease;
    position: relative;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 1.5px;
    background: var(--accent-glow);
    transform: scaleX(0);
    transition: transform 0.25s var(--ease-out-expo);
    transform-origin: left;
}

.nav-item:hover {
    color: var(--accent-glow);
}

.nav-item:hover::after {
    transform: scaleX(1);
}

/* ===== 页面主体 ===== */
.page-main {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: calc(var(--nav-height) + 80px) 40px calc(var(--footer-bar-height) + 60px);
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
}

/* ===== Hero 区域 ===== */
.hero-section {
    text-align: center;
    opacity: 0;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-main) 0%, #2563eb 60%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-sub);
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* ===== 搜索框 ===== */

/* 用 @property 让 conic-gradient 中的角度值可以被 transition/animation 直接驱动 */
@property --glow-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes border-light-travel {
    to { --glow-angle: 360deg; }
}

@keyframes outer-glow-pulse {
    0%, 100% { opacity: 0.55; }
    50%       { opacity: 0.85; }
}

.search-shell {
    position: relative;
    width: 100%;
    max-width: 640px;
    height: 58px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1.5px solid rgba(37, 99, 235, 0.15);
    border-radius: 100px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.4s ease, border-color 0.4s ease,
                max-width 0.4s var(--ease-out-expo);
    opacity: 0;
    overflow: visible;
    z-index: 20;
}

/*
 * ::before — 边框光带本体
 * 原理：伪元素比父级略大（inset: -2px），背景是一个亮点在旋转的 conic-gradient。
 * 用 mask 把中间区域挖空，只露出 2px 宽的边框圆环，
 * 这样旋转的渐变就只在边框轨道上流动，不会显示在内部。
 */
.search-shell::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 100px;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;

    background: conic-gradient(
        from var(--glow-angle),
        transparent        0%,
        transparent       30%,
        #06b6d4           45%,
        #2563eb           50%,
        #7c3aed           55%,
        transparent       70%,
        transparent      100%
    );

    /* mask 挖空内部：只保留 2px 宽的边框环 */
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 2px;

    animation: border-light-travel 2.4s linear infinite;
}

/* ::after — 边框外侧柔光晕 */
.search-shell::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 100px;
    z-index: -2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;

    background: conic-gradient(
        from var(--glow-angle),
        transparent        0%,
        transparent       30%,
        rgba(6,182,212,0.5)  45%,
        rgba(37,99,235,0.6)  50%,
        rgba(124,58,237,0.5) 55%,
        transparent       70%,
        transparent      100%
    );

    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 6px;

    filter: blur(6px);
    animation: border-light-travel 2.4s linear infinite,
               outer-glow-pulse 2s ease-in-out infinite;
}

/* 聚焦时只改 opacity，动画始终在跑不会卡住 */
.search-shell:focus-within::before,
.search-shell:focus-within::after {
    opacity: 1;
}

.search-shell:focus-within {
    border-color: transparent;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.13);
    max-width: 720px;
}

.search-shell.expanded {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 6px 30px rgba(37, 99, 235, 0.12);
    max-width: 720px;
}

/* ===== 引擎选择器 ===== */
.engine-select {
    position: relative;
    height: 100%;
    width: auto;
    min-width: 80px;
    max-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    margin-left: 2px;
    border-radius: 100px;
    background: transparent;
    border: none;
    box-shadow: none;
    outline: none;
    color: var(--text-main);
    cursor: pointer;
    gap: 6px;
    transition: background 0.2s ease;
}

.engine-select:hover,
.engine-select.open {
    background: rgba(37, 99, 235, 0.04);
}

.engine-select::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(37, 99, 235, 0.1);
}

.engine-current {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.engine-caret {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s, color 0.2s;
    stroke-width: 2.5px;
}

.engine-select.open .engine-caret {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--accent-glow);
}

/* 下拉菜单 */
.engine-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    width: 160px;
    padding: 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(37, 99, 235, 0.15);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.2s;
    z-index: 100;
    visibility: hidden;
}

.engine-menu::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

.engine-select.open .engine-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

.engine-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-sub);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}

.engine-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent-glow);
}

.engine-item.active {
    color: var(--accent-glow);
    background: rgba(37, 99, 235, 0.06);
    font-weight: 700;
}

/* 搜索输入 */
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    height: 100%;
    padding: 0 16px;
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.search-input::placeholder {
    color: #94a3b8;
}

/* 搜索按钮 */
.search-btn {
    height: calc(100% - 8px);
    padding: 0 22px;
    margin: 4px 4px 4px 0;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
    transition: all 0.3s cubic-bezier(0.2, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.search-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.search-btn:active {
    transform: scale(0.96) translateY(0);
}

/* ===== 卡片阵列 ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    width: 100%;
    perspective: 1200px;
}

.info-card {
    position: relative;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(37, 99, 235, 0.1);
    backdrop-filter: blur(12px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.4s var(--ease-out-back),
                background 0.4s var(--ease-out-back),
                box-shadow 0.4s var(--ease-out-back);
    opacity: 0;
    backface-visibility: hidden;
    animation-fill-mode: both;
    will-change: transform;
}

.card-image-wrapper {
    width: 100%;
    height: 180px;
    position: relative;
    overflow: hidden;
}

.card-image-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, #fff);
    z-index: 1;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

.info-card:hover .card-img {
    transform: scale(1.1);
    opacity: 1;
}

.info-card:hover {
    border-color: rgba(37, 99, 235, 0.25);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.08);
}

.card-icon {
    width: 48px;
    height: 48px;
    margin: -24px 0 15px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-glow);
    border-radius: 12px;
    position: relative;
    z-index: 2;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
}

.card-title {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 10px;
    padding: 0 24px;
    color: var(--text-main);
    position: relative;
    z-index: 2;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.6;
    padding: 0 24px 30px;
    position: relative;
    z-index: 2;
}

/* ===== 背景 Canvas ===== */
#dotCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.ambient-glow {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.06), transparent 50%);
}

/* ===== 页脚 ===== */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-bar-height);
    padding: 0 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-sub);
    z-index: 5;
    opacity: 0;
    transform: translateY(8px);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(37, 99, 235, 0.08);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body.footer-visible .site-footer {
    opacity: 1;
    transform: translateY(0);
}

.footer-links {
    display: flex;
    gap: 25px;
}

.footer-links a {
    color: var(--text-sub);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-glow);
}

/* ===== SPA 过渡遮罩 ===== */
.spa-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--bg-deep);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.spa-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* ===== Logo 亮色适配 ===== */
.logo-symbol {
    color: #1a1a2e;
}

/* ===== 动画系统 ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* 首次访问：渐进入场 */
.first-visit .navbar         { animation: fadeInDown 1.2s var(--ease-out-expo) forwards; }
.first-visit .hero-section    { animation: fadeInUp 1.4s var(--ease-out-expo) 0.2s forwards; }
.first-visit .search-shell    { animation: fadeInUp 1.4s var(--ease-out-expo) 0.4s forwards; }
.first-visit .info-card       { animation: fadeInUp 1.5s var(--ease-out-expo) forwards; }
.first-visit .info-card:nth-child(1) { animation-delay: 0.6s; }
.first-visit .info-card:nth-child(2) { animation-delay: 0.8s; }
.first-visit .info-card:nth-child(3) { animation-delay: 1.0s; }

/* 后续访问：快速入场 */
.subsequent-visit .navbar         { animation: fadeIn 0.6s ease-out forwards; }
.subsequent-visit .hero-section    { animation: fadeIn 0.6s ease-out 0.1s forwards; }
.subsequent-visit .search-shell    { animation: fadeIn 0.6s ease-out 0.15s forwards; }
.subsequent-visit .info-card       { animation: fadeIn 0.5s ease-out 0.2s forwards; }

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    :root {
        --nav-height: 64px;
        --footer-bar-height: 56px;
    }

    .nav-container { padding: 0 20px; }
    .nav-links { gap: 16px; }
    .nav-item { font-size: 0.85rem; }

    .page-main {
        padding: calc(var(--nav-height) + 48px) 20px calc(var(--footer-bar-height) + 40px);
        gap: 32px;
    }

    .search-shell {
        height: 52px;
        max-width: 100%;
    }

    .search-shell.expanded { max-width: 100%; }

    .search-btn { padding: 0 18px; font-size: 0.85rem; }

    .card-grid { grid-template-columns: 1fr; gap: 16px; }

    .site-footer { padding: 0 20px; }
}

@media (max-width: 480px) {
    .nav-links { gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav-item { white-space: nowrap; font-size: 0.8rem; }
    .engine-select { min-width: 60px; padding: 0 10px; }
    .engine-current { font-size: 0.8rem; }
}