/* ==========================================================
   Ryan · 个人主页
   纸与墨：宣纸质感 + 全衬线排版 + 极细分割线，夜间为墨底
   ========================================================== */

/* ---------- 变量：白天（宣纸） ---------- */
:root {
    --ground: #e3e2de;
    --ink: #22211f;
    --quiet: #6f6c66;
    --faint: #9a968f;
    --rule: rgba(34, 33, 31, 0.14);
    --line: rgba(34, 33, 31, 0.32);
    --wash: rgba(34, 33, 31, 0.045);
    --nav-bg: rgba(227, 226, 222, 0.82);
    --dot: #5f6b57;
    --serif: "Noto Serif SC", "Noto Serif", "Songti SC", "STSong", "SimSun", Georgia, serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --measure: 1120px;
    --weight: 500;
    --transition: all 0.2s ease;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeColorMatrix values='2.2 0 0 0 -.6 0 2.2 0 0 -.6 0 0 2.2 0 -.6 0 0 0 0 .13'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
    color-scheme: light;
}

/* ---------- 变量：夜晚（墨底） ---------- */
[data-theme="dark"] {
    --ground: #1d1d1b;
    --ink: #dddad3;
    --quiet: #9a968e;
    --faint: #6e6b65;
    --rule: rgba(221, 218, 211, 0.14);
    --line: rgba(221, 218, 211, 0.32);
    --wash: rgba(221, 218, 211, 0.05);
    --nav-bg: rgba(29, 29, 27, 0.82);
    --dot: #8d9c82;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeColorMatrix values='2.2 0 0 0 -.6 0 2.2 0 0 -.6 0 0 2.2 0 -.6 0 0 0 0 .07'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
    color-scheme: dark;
}

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

html {
    font-size: 112.5%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--serif);
    font-weight: var(--weight);
    font-size: 1rem;
    line-height: 1.9;
    letter-spacing: 0.02em;
    color: var(--ink);
    background-color: var(--ground);
    background-image: var(--grain);
    background-attachment: fixed;
    overflow-x: hidden;
    transition: background-color 0.35s ease, color 0.35s ease;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

ul {
    list-style: none;
}

::selection {
    background: var(--ink);
    color: var(--ground);
}

.container {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 48px;
}

/* ---------- 导航 ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 18px 0;
    background: var(--nav-bg);
    backdrop-filter: blur(14px) saturate(120%);
    border-bottom: 1px solid var(--rule);
    transition: background-color 0.35s ease, border-color 0.35s ease;
}

.nav-container {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.nav-logo {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--ink);
}

.nav-logo:hover {
    color: var(--quiet);
}

.nav-menu {
    display: flex;
    gap: 30px;
    margin-left: auto;
}

.nav-link {
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    color: var(--quiet);
    position: relative;
    padding-bottom: 2px;
}

.nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--ink);
}

.nav-link.active::after,
.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--rule);
    background: transparent;
    color: var(--quiet);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--line);
    color: var(--ink);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 6px 0;
}

.hamburger span {
    width: 20px;
    height: 1px;
    background: var(--ink);
    transition: var(--transition);
}

/* ---------- 英雄区 ---------- */
.hero {
    padding: 170px 0 100px;
    border-bottom: 1px solid var(--rule);
}

.hero-bg {
    display: none;
}

.hero-content {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 48px;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 72px;
    align-items: center;
    animation: fadeInUp 0.9s ease-out;
}

/* 英雄区插画：昼夜各一张，随主题切换 */
.hero-figure {
    position: relative;
}

.hero-img {
    display: none;
    width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}

[data-theme="dark"] .hero-img-night {
    display: block;
}

:root:not([data-theme="dark"]) .hero-img-day {
    display: block;
}

.hero-text {
    min-width: 0;
}

.hero-greeting {
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    color: var(--faint);
    text-transform: uppercase;
    margin-bottom: 18px;
}

.hero-title {
    font-size: 3.6rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.08em;
    color: var(--ink);
    margin-bottom: 18px;
}

.gradient-text {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--ink);
}

.hero-subtitle {
    font-size: 1.05rem;
    font-weight: var(--weight);
    letter-spacing: 0.12em;
    color: var(--quiet);
    margin-bottom: 26px;
}

.hero-desc {
    font-size: 1rem;
    color: var(--quiet);
    max-width: 44em;
    line-height: 1.95;
    margin-bottom: 36px;
}

.hero-links {
    display: flex;
    gap: 34px;
    flex-wrap: wrap;
}

.hero-link {
    font-size: 0.88rem;
    letter-spacing: 0.1em;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding-bottom: 3px;
}

.hero-link:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.scroll-indicator {
    display: none;
}

/* ---------- 区域通用 ---------- */
section {
    padding: 92px 0;
    border-bottom: 1px solid var(--rule);
    transition: border-color 0.35s ease;
}

.section-header {
    margin-bottom: 46px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.section-tag {
    order: 2;
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--faint);
}

.section-title {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--ink);
    order: 1;
}

.section-desc {
    flex-basis: 100%;
    order: 3;
    font-size: 0.92rem;
    color: var(--quiet);
    max-width: 46em;
    line-height: 1.9;
    margin-top: 10px;
}

/* ---------- 关于 ---------- */
.about-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 64px;
    align-items: start;
}

.about-image {
    display: flex;
    justify-content: flex-start;
    padding-top: 6px;
}

.avatar-placeholder {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 600;
    color: var(--quiet);
    letter-spacing: 0;
}

.about-text .about-lead {
    font-size: 1.15rem;
    line-height: 1.9;
    color: var(--ink);
    margin-bottom: 20px;
}

.about-text p {
    color: var(--quiet);
    font-size: 0.98rem;
    line-height: 1.95;
    margin-bottom: 16px;
    max-width: 40em;
}

.about-stats {
    display: flex;
    gap: 56px;
    margin-top: 40px;
    padding-top: 26px;
    border-top: 1px solid var(--rule);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-number {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--ink);
}

.stat-label {
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    color: var(--faint);
}

/* ---------- 技能 ---------- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
}

.skill-card {
    border-bottom: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    padding: 34px 44px 34px 0;
    transition: var(--transition);
}

.skill-card:nth-child(2n) {
    border-right: none;
    padding-right: 0;
    padding-left: 44px;
}

.skill-card:nth-last-child(-n+2) {
    border-bottom: none;
}

.skill-card:hover {
    background: var(--wash);
}

.skill-icon {
    color: var(--quiet);
    margin-bottom: 18px;
    display: flex;
    transition: var(--transition);
}

.skill-icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 1.4;
}

.skill-card:hover .skill-icon {
    color: var(--ink);
}

.skill-card h3 {
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    color: var(--ink);
}

.skill-card p {
    font-size: 0.9rem;
    color: var(--quiet);
    line-height: 1.85;
    max-width: 30em;
}

/* ---------- 项目：索引式列表 ---------- */
.project-list {
    display: flex;
    flex-direction: column;
}

.project-row {
    display: grid;
    grid-template-columns: 56px 1fr 168px;
    gap: 28px;
    align-items: start;
    padding: 28px 20px 28px 0;
    border-bottom: 1px solid var(--rule);
    transition: var(--transition);
}

.project-row:first-child {
    border-top: 1px solid var(--rule);
}

.project-row:hover {
    background: var(--wash);
}

.project-index {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: var(--faint);
    padding-top: 5px;
}

.project-body h3 {
    font-size: 1.12rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--ink);
    margin-bottom: 6px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.project-arrow {
    font-size: 0.9rem;
    color: var(--faint);
    opacity: 0;
    transform: translateX(-3px);
    transition: var(--transition);
}

.project-row:hover .project-arrow {
    opacity: 1;
    transform: translateX(0);
}

.project-body p {
    font-size: 0.92rem;
    color: var(--quiet);
    line-height: 1.9;
    max-width: 42em;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0 14px;
    margin-top: 10px;
}

.project-tags span {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    color: var(--faint);
}

.project-tags span::before {
    content: "·";
    margin-right: 14px;
    color: var(--faint);
}

.project-tags span:first-child::before {
    content: none;
    margin: 0;
}

.project-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    padding-top: 4px;
}

.project-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    color: var(--quiet);
}

.project-status .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--dot);
}

.project-status.is-idle .dot {
    background: transparent;
    border: 1px solid var(--faint);
}

.project-port {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--faint);
}

.project-row-static {
    cursor: default;
}

.project-row-static:hover {
    background: transparent;
}

/* 基础设施 */
.infra-note {
    margin-top: 44px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--faint);
    line-height: 1.9;
}

.infra-note .infra-label {
    font-size: 0.68rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--quiet);
}

/* ---------- 联系 ---------- */
.contact-desc {
    font-size: 0.96rem;
    color: var(--quiet);
    max-width: 40em;
    margin-bottom: 34px;
    line-height: 1.95;
}

.contact-links {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
}

.contact-card {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    font-size: 0.92rem;
    letter-spacing: 0.1em;
    color: var(--ink);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.contact-card:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.contact-icon {
    color: var(--quiet);
    display: flex;
    align-self: center;
}

.contact-icon svg {
    width: 16px;
    height: 16px;
}

.contact-card:hover .contact-icon {
    color: var(--ink);
}

/* ---------- 页脚 ---------- */
.footer {
    padding: 52px 0 64px;
    text-align: left;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    color: var(--faint);
}

.footer-text,
.footer-copy {
    color: var(--faint);
}

/* ---------- 动画 ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

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

    .reveal,
    .hero-content {
        animation: none;
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .container,
    .nav-container,
    .hero-content {
        padding: 0 32px;
    }

    .hero-content {
        grid-template-columns: 220px 1fr;
        gap: 44px;
    }

    .project-row {
        grid-template-columns: 40px 1fr;
        gap: 16px;
    }

    .project-side {
        grid-column: 2;
        flex-direction: row;
        align-items: center;
        gap: 14px;
        padding-top: 2px;
    }

    .about-content {
        grid-template-columns: 1fr;
        gap: 36px;
    }

    .avatar-placeholder {
        width: 112px;
        height: 112px;
        font-size: 2.3rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 106%;
    }

    .nav-menu {
        position: fixed;
        top: 67px;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: flex-start;
        padding: 26px 32px 30px;
        gap: 18px;
        border-bottom: 1px solid var(--rule);
        transform: translateY(-140%);
        transition: var(--transition);
    }

    .nav-menu.open {
        transform: translateY(0);
    }

    .hamburger {
        display: flex;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(4px, 4px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(4px, -4px);
    }

    .hero {
        padding: 140px 0 72px;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 36px;
    }

    .hero-figure {
        max-width: 240px;
    }

    .hero-title {
        font-size: 2.6rem;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .skill-card,
    .skill-card:nth-child(2n) {
        border-right: none;
        padding-left: 0;
        padding-right: 0;
    }

    .skill-card:nth-last-child(-n+2) {
        border-bottom: 1px solid var(--rule);
    }

    .skill-card:last-child {
        border-bottom: none;
    }

    .about-stats {
        gap: 32px;
    }

    section {
        padding: 68px 0;
    }

    .hero-links {
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .container,
    .nav-container,
    .hero-content {
        padding: 0 22px;
    }

    .nav-menu {
        padding: 24px 22px 28px;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .project-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 22px 0;
    }

    .project-index {
        padding-top: 0;
    }

    .project-side {
        grid-column: 1;
    }
}
