/* =========================================================================
   Portfolio — modern-minimal design system
   只用 CSS 变量做主题，方便整体改色。下面 :root 改一个 --accent 即可换主题色。
   ========================================================================= */

:root {
    color-scheme: light;

    --bg: #ffffff;
    --bg-alt: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #f2f5fa;
    --text: #0f172a;
    --text-soft: #475569;
    --text-muted: #64748b;
    --border: #e6e9f0;
    --border-strong: #d3d9e4;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: #f4f1fe;
    --accent-contrast: #ffffff;
    --highlight: #059669;
    --highlight-soft: #ecfdf5;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, .06), 0 14px 32px rgba(15, 23, 42, .08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, .14);

    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 22px;

    --container: 1120px;
    --header-h: 68px;
    --ease: cubic-bezier(.2, .7, .2, 1);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC",
        Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #0b0f17;
        --bg-alt: #0d1320;
        --surface: #121826;
        --surface-2: #1a2233;
        --text: #f1f5f9;
        --text-soft: #c2cbda;
        --text-muted: #8c98ac;
        --border: #20283a;
        --border-strong: #2c3650;

        --accent: #8b5cf6;
        --accent-hover: #a78bfa;
        --accent-soft: #221a3a;
        --accent-contrast: #ffffff;
        --highlight: #34d399;
        --highlight-soft: #0e2a22;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 8px 30px rgba(0, 0, 0, .45);
        --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
    }
}

/* ----- reset & base ----- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 18px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.02em; color: var(--text); font-weight: 700; }
button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent); color: #fff; }

.icon { display: inline-block; vertical-align: middle; flex: none; }

/* ----- layout ----- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 24px; }
.section { padding-block: clamp(64px, 9vw, 112px); }
.section-alt { background: var(--bg-alt); }
main { display: block; }

/* ----- buttons ----- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    font-weight: 600; font-size: .975rem; line-height: 1;
    padding: .8rem 1.25rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer; white-space: nowrap;
    transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:hover .icon { transform: translateX(3px); }
.btn-primary .icon { transition: transform .2s var(--ease); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-lg { padding: 1rem 1.6rem; font-size: 1.05rem; }

/* ----- tags ----- */
.tag-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag {
    font-size: .85rem; font-weight: 500; color: var(--text-soft);
    background: var(--surface-2); border: 1px solid var(--border);
    padding: .34rem .7rem; border-radius: 999px; line-height: 1.2; white-space: nowrap;
}
.tag-sm { font-size: .78rem; padding: .28rem .6rem; }

/* ----- header / nav ----- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color .25s, box-shadow .25s, background .25s;
}
.site-header.is-scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }
.header-inner { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }

.nav { display: flex; align-items: center; gap: .25rem; }
.nav-link { padding: .5rem .8rem; border-radius: 8px; font-weight: 500; font-size: .95rem; color: var(--text-soft); transition: color .2s, background .2s; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }

.header-actions { display: flex; align-items: center; gap: .6rem; }

.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-option { display: inline-grid; place-items: center; min-width: 32px; height: 28px; padding: 0 .45rem; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--text-muted); transition: .2s; }
.lang-option:hover { color: var(--text); }
.lang-option.is-active { background: var(--accent); color: #fff; }

.menu-toggle { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.menu-toggle .icon-close { display: none; }

/* ----- hero ----- */
.hero {
    position: relative; text-align: center; overflow: hidden;
    padding-top: calc(var(--header-h) + clamp(48px, 9vw, 92px));
    padding-bottom: clamp(64px, 10vw, 116px);
}
.hero-bg {
    position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(58% 48% at 50% 0%, var(--accent-soft) 0%, transparent 72%),
        radial-gradient(40% 38% at 84% 18%, color-mix(in srgb, var(--highlight) 14%, transparent) 0%, transparent 70%);
}
.hero-inner { max-width: 820px; display: flex; flex-direction: column; align-items: center; }
.hero-avatar { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; border: 4px solid var(--surface); box-shadow: var(--shadow-md); margin-bottom: 1.25rem; }
.hero-eyebrow { color: var(--accent); font-weight: 600; font-size: 1rem; margin-bottom: .5rem; }
.hero-name { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 800; letter-spacing: -.03em; }
.hero-title { font-size: clamp(1.1rem, 2.4vw, 1.5rem); color: var(--text); font-weight: 600; margin-top: .7rem; }
.hero-tagline { max-width: 640px; color: var(--text-soft); font-size: clamp(1rem, 1.6vw, 1.18rem); margin-top: 1.1rem; line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; margin-top: 1.9rem; }
.hero-scroll { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); color: var(--text-muted); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }

/* ----- section heading ----- */
.section-heading { max-width: 720px; margin-bottom: clamp(32px, 5vw, 56px); }
.section-heading.is-center { margin-inline: auto; text-align: center; }
.section-eyebrow { display: inline-block; color: var(--accent); font-weight: 600; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .7rem; }
.section-title { font-size: clamp(1.7rem, 3.6vw, 2.5rem); font-weight: 800; }
.section-subtitle { color: var(--text-soft); font-size: 1.075rem; margin-top: .9rem; line-height: 1.7; }

/* ----- about ----- */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: clamp(32px, 5vw, 64px); align-items: start; }
.about-text p { color: var(--text-soft); font-size: 1.075rem; line-height: 1.8; }
.about-text p + p { margin-top: 1.1rem; }
.about-meta { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1.7rem; }
.about-meta-item { display: inline-flex; align-items: center; gap: .5rem; color: var(--text-soft); font-weight: 500; font-size: .97rem; transition: color .2s; }
.about-meta-item .icon { color: var(--accent); }
a.about-meta-item:hover { color: var(--accent); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.2rem; box-shadow: var(--shadow-sm); }
.stat-value { display: block; font-size: 1.9rem; font-weight: 800; color: var(--highlight); letter-spacing: -.02em; line-height: 1; }
.stat-label { display: block; margin-top: .45rem; color: var(--text-muted); font-size: .92rem; font-weight: 500; }

/* ----- skills ----- */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.skill-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.skill-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.skill-card-head { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.15rem; }
.skill-card-head h3 { font-size: 1.12rem; font-weight: 700; }
.skill-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }

/* ----- projects (自动滚动展示 / auto-scrolling marquee) ----- */
/* 页面左侧留白：让第一张卡片与标题对齐 */
.projects-marquee {
    --page-gutter: max(24px, calc((100vw - var(--container)) / 2 + 24px));
    margin-top: clamp(28px, 4vw, 44px);
    padding-left: var(--page-gutter);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    /* 左右边缘渐隐，强化“横向流动”的观感 */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}
.projects-marquee::-webkit-scrollbar { display: none; }
/* 自动滚动时隐藏滚动条、交给动画驱动 */
.projects-marquee[data-running] { overflow: hidden; }
/* 键盘聚焦时取消边缘渐隐遮罩，避免落在边缘的卡片焦点框被淡化看不见 */
.projects-marquee:focus-within { -webkit-mask-image: none; mask-image: none; }

.projects-track { display: flex; gap: 22px; width: max-content; padding-block: 10px 30px; }

@media (prefers-reduced-motion: no-preference) {
    .projects-marquee[data-running] .projects-track {
        will-change: transform;
        animation: project-marquee var(--marquee-duration, 40s) linear infinite;
    }
    /* 悬停 / 键盘聚焦 / 触摸按住时暂停，方便阅读 */
    .projects-marquee[data-running]:hover .projects-track,
    .projects-marquee[data-running]:focus-within .projects-track,
    .projects-marquee[data-running].is-paused .projects-track { animation-play-state: paused; }
    @keyframes project-marquee {
        from { transform: translateX(0); }
        to   { transform: translateX(calc(-1 * var(--marquee-shift, 0px))); }
    }
}

.project-card { position: relative; flex: 0 0 clamp(280px, 80vw, 400px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; transition: transform .2s var(--ease), box-shadow .25s, border-color .2s; }
.project-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.project-card.is-featured { border-color: color-mix(in srgb, var(--highlight) 38%, var(--border)); }

.project-media { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--accent-soft), var(--highlight-soft)); overflow: hidden; }
.project-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.project-card:hover .project-media img { transform: scale(1.04); }
.project-media-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--accent); opacity: .45; }
.project-tag { position: absolute; top: .8rem; left: .8rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); padding: .3rem .6rem; border-radius: 6px; box-shadow: var(--shadow-sm); }
.project-card.is-featured .project-tag { color: var(--highlight); }

.project-body { display: flex; flex-direction: column; flex: 1; padding: 1.4rem 1.5rem 1.5rem; }
.project-title { font-size: 1.18rem; font-weight: 700; margin-bottom: .55rem; }
.project-summary { color: var(--text-soft); font-size: .96rem; line-height: 1.7; margin-bottom: 1.1rem; flex: 1; }
.project-more { display: inline-flex; align-items: center; gap: .35rem; margin-top: auto; color: var(--accent); font-weight: 600; font-size: .9rem; }
.project-more .icon { transition: transform .2s var(--ease); }
.project-card:hover .project-more .icon { transform: translateX(4px); }

/* 整张卡片可点击：铺满卡片的隐形链接（保留 <article> 语义，且兼容跑马灯克隆） */
.project-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.project-card-link:focus-visible { outline-offset: -3px; }

/* 仅供读屏使用、视觉隐藏 */
.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; }

/* ----- project detail page (/projects/{slug}) ----- */
.project-detail { padding-top: calc(var(--header-h) + clamp(32px, 6vw, 60px)); padding-bottom: clamp(64px, 9vw, 112px); }
.project-detail .container { max-width: 980px; }
.project-back { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-muted); font-weight: 500; font-size: .95rem; margin-bottom: 1.6rem; transition: color .2s, gap .2s; }
.project-back:hover { color: var(--accent); gap: .55rem; }

.project-detail-head { max-width: 760px; margin-bottom: clamp(28px, 4vw, 44px); }
.project-detail-tag { display: inline-block; color: var(--accent); background: var(--accent-soft); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: .34rem .72rem; border-radius: 999px; margin-bottom: 1.05rem; }
.project-detail-title { font-size: clamp(2rem, 4.6vw, 3rem); font-weight: 800; letter-spacing: -.03em; }
.project-detail-summary { color: var(--text-soft); font-size: clamp(1.05rem, 1.8vw, 1.25rem); line-height: 1.7; margin-top: 1rem; }
.project-detail-tech { margin-top: 1.5rem; }

.project-detail-body { max-width: 760px; margin-bottom: clamp(32px, 5vw, 56px); }
.project-detail-body p { color: var(--text-soft); font-size: 1.075rem; line-height: 1.85; }
.project-detail-body p + p { margin-top: 1.1rem; }

.project-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 18px; }
.project-gallery-item { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.project-gallery-item img { width: 100%; height: auto; }

.project-detail-actions { margin-top: 1.8rem; }
.project-detail--missing { padding-top: calc(var(--header-h) + clamp(48px, 9vw, 96px)); }

/* ----- footer ----- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg); padding-block: 1.8rem; }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--text-muted); font-size: .88rem; }

/* ----- motion: entrance + scroll reveal ----- */
@media (prefers-reduced-motion: no-preference) {
    .hero-scroll { animation: bob 2s var(--ease) infinite; }
    @keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 6px); } }

    .hero-inner > * { animation: hero-in .7s var(--ease) both; }
    .hero-inner > *:nth-child(1) { animation-delay: .02s; }
    .hero-inner > *:nth-child(2) { animation-delay: .08s; }
    .hero-inner > *:nth-child(3) { animation-delay: .14s; }
    .hero-inner > *:nth-child(4) { animation-delay: .20s; }
    .hero-inner > *:nth-child(5) { animation-delay: .26s; }
    .hero-inner > *:nth-child(6) { animation-delay: .32s; }
    .hero-inner > *:nth-child(7) { animation-delay: .38s; }
    @keyframes hero-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

    /* 滚动进入时淡入（纯 CSS，不支持的浏览器直接显示，不会隐藏内容） */
    @supports (animation-timeline: view()) {
        .reveal { opacity: 0; animation: reveal-in linear both; animation-timeline: view(); animation-range: entry 0% entry 42%; }
        @keyframes reveal-in { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* ----- responsive ----- */
@media (max-width: 860px) {
    .menu-toggle { display: inline-flex; }
    .nav {
        position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: .15rem;
        background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md);
        padding: .8rem 24px 1.2rem;
        opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-12px);
        max-height: calc(100dvh - var(--header-h)); overflow: auto;
        transition: opacity .2s, transform .2s, visibility .2s;
    }
    .site-header.nav-open { border-bottom-color: var(--border); }
    .site-header.nav-open .nav { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
    .site-header.nav-open .menu-toggle .icon-menu { display: none; }
    .site-header.nav-open .menu-toggle .icon-close { display: inline-block; }
    .nav-link { padding: .8rem .6rem; font-size: 1rem; border-radius: 10px; }

    .about-grid { grid-template-columns: 1fr; gap: 36px; }
    .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 600px) {
    .container { padding-inline: 18px; }
    .nav { padding-inline: 18px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: .4rem; }
    .btn { flex: 1; justify-content: center; }
    .hero-actions { width: 100%; }
}

/* ----- Blazor diagnostics (保留模板默认) ----- */
.blazor-error-boundary {
    background: #b32121; padding: 1rem 1rem 1rem 1rem; color: #fff;
}
.blazor-error-boundary::after { content: "发生了一个错误 / An error has occurred."; }
.validation-message { color: #e50000; }
