/* ==============================================
   Zhang Ziqi — Parchment & Wireframe Design
   Design System: 羊皮紙 + 線框終端美學
   ============================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    --parchment: #F3EAD5;
    --parchment-shaded: #E3D4BB;
    --parchment-deeper: #D5C4A6;
    --text-primary: #4A3B2C;
    --text-secondary: rgba(74, 59, 44, 0.86);
    --text-light: rgba(74, 59, 44, 0.68);
    --text-faint: rgba(74, 59, 44, 0.52);
    --border: #4A3B2C;
    --border-light: rgba(74, 59, 44, 0.25);
    --shadow: rgba(74, 59, 44, 0.15);
    --sidebar-width: 300px;
    --content-max-width: 720px;
    --max-layout-width: 1040px;
    --font-serif-cn: 'Noto Serif SC', 'Songti SC', 'SimSun', 'Times New Roman', serif;
    --font-serif: 'Times New Roman', Georgia, serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 110%; }
body {
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--parchment);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-weight: 400;
    position: relative;
    overflow-x: hidden;
}
::selection {
    background: var(--text-primary);
    color: var(--parchment);
}

/* ==============================================
   Parchment Texture (full-page, fixed)
   ============================================== */
.parchment-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: var(--parchment);
}
/* Layer 1 — Fractal stains / cloud unevenness */
.parchment-stains {
    position: absolute;
    inset: 0;
    opacity: 0.25;
    mix-blend-mode: color-burn;
    width: 100%;
    height: 100%;
}
/* Layer 2 — Fine fiber / grain noise */
.parchment-grain {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    mix-blend-mode: multiply;
    width: 100%;
    height: 100%;
}
/* Layer 3 — Laid paper weave (vertical + horizontal) */
.parchment-weave-v {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        var(--text-primary) 2px,
        var(--text-primary) 4px
    );
}
.parchment-weave-h {
    position: absolute;
    inset: 0;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 16px,
        var(--text-primary) 16px,
        var(--text-primary) 18px
    );
}
/* Layer 4 — Aged edge oxidation & vignette */
.parchment-vignette-outer {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 150px rgba(74, 59, 44, 0.30);
}
.parchment-vignette-inner {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 40px rgba(74, 59, 44, 0.10);
}

/* ==============================================
   Wireframe Box (core card component)
   ============================================== */
.wireframe-box {
    position: relative;
    border: 1.5px solid var(--border);
    padding: 2.5px;
    box-shadow: 2px 2px 0px var(--shadow);
    background: var(--parchment);
}
.wireframe-box > .wireframe-inner {
    border: 0.5px solid var(--border);
    width: 100%;
    height: 100%;
    position: relative;
    background: var(--parchment);
}
.wireframe-box.shaded {
    background: var(--parchment-shaded);
}
.wireframe-box.shaded > .wireframe-inner {
    background: var(--parchment-shaded);
}

/* ---------- Section Title with Diamonds ---------- */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    color: var(--text-primary);
    opacity: 0.85;
}
.section-header .diamond {
    font-size: 6px;
    line-height: 1;
    flex-shrink: 0;
}
.section-header .rule {
    height: 1px;
    background: var(--border);
    flex: 1;
    opacity: 0.5;
}
.section-header h2 {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 0 2px;
}
.section-number {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.15em;
    margin-right: 2px;
}

/* ---------- Diamond Divider ---------- */
.diamond-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 4px 0;
    color: var(--text-faint);
}
.diamond-divider .diamond {
    font-size: 5px;
    line-height: 1;
}
.diamond-divider .rule {
    height: 0.5px;
    background: var(--border);
    flex: 1;
    max-width: 60px;
    opacity: 0.3;
}

/* ==============================================
   Layout
   ============================================== */
.layout {
    display: flex;
    min-height: 100vh;
    width: calc(100% - 64px);
    max-width: 1080px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ==============================================
   Sidebar — shaded parchment panel
   ============================================== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    background: transparent;
    border-right: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}
.sidebar-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px 28px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    width: 100%;
}
.sidebar-inner::-webkit-scrollbar {
    display: none;
}

/* Avatar — wireframe framed */
.sidebar-avatar-wrap {
    position: relative;
    margin-bottom: 22px;
    flex-shrink: 0;
}
.sidebar-avatar-outer {
    width: 150px;
    height: 150px;
    border: 1.5px solid var(--border);
    padding: 3px;
    box-shadow: 2px 2px 0px var(--shadow);
    background: var(--parchment);
    border-radius: 50%;
}
.sidebar-avatar-inner {
    border: 0.5px solid var(--border);
    border-radius: 50%;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--parchment-shaded);
}
.sidebar-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Name & Tagline */
.sidebar-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    color: var(--text-primary);
    text-transform: uppercase;
}
.sidebar-tagline {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
    font-style: italic;
}

/* Meta fields (monospace system labels) */
.sidebar-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
    width: 100%;
    padding-top: 14px;
}
.sidebar-meta p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.3;
}
.sidebar-meta p .label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-faint);
    margin-bottom: 2px;
}

/* Links */
.sidebar-links {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.9rem;
    margin-bottom: 4px;
    white-space: nowrap;
}
.sidebar-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    display: inline-block;
}
.sidebar-links a:hover {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.sidebar-links .dot {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

/* Status indicator */
.sidebar-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    padding: 3px 10px;
    margin-top: auto;
    opacity: 0.7;
}
.sidebar-status .led {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-primary);
    animation: ledPulse 2s ease-in-out infinite;
}
.sidebar-status span {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
@keyframes ledPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Bottom version label */
.sidebar-version {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-faint);
    margin-top: 8px;
}
.easter-egg-link {
    margin-top: 20px;
    padding-top: 0;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-decoration: none;
    transition: color 0.2s ease;
}
.easter-egg-link:hover,
.easter-egg-link:focus-visible {
    color: var(--text-primary);
}

/* Language switch and fixed section navigation */
.language-toggle {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 20;
    border: 1px solid var(--border);
    background: rgba(243, 234, 213, 0.92);
    color: var(--text-secondary);
    padding: 6px 9px;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
}
.language-toggle span { opacity: 0.55; }
.language-toggle .language-toggle-active { opacity: 1; color: var(--text-primary); }
.language-toggle-separator { margin: 0 5px; }

.side-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    width: 160px;
    align-self: center;
    margin-top: 28px;
}
.side-nav a {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 8px;
    color: var(--text-light);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.side-nav a span { opacity: 0.65; }
.side-nav a b { font-weight: 700; }
.side-nav a:hover { color: var(--text-primary); }


/* ==============================================
   Content Area
   ============================================== */
.content {
    flex: 1;
    max-width: none;
    padding: 36px 0 48px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: relative;
    z-index: 1;
}

/* ==============================================
   Section Cards (wireframe-box wrappers)
   ============================================== */
.section-card {
    width: min(var(--content-max-width), calc(100% - 64px));
    margin: 0 auto;
}
.section-card .card-pad {
    padding: 24px 28px 28px;
}

/* Bio text */
.content-bio {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.72;
    white-space: pre-line;
}

/* ==============================================
   Education
   ============================================== */
.edu-item {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.edu-year {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.08em;
    min-width: 105px;
    padding-top: 1px;
}
.edu-detail h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: -0.2px;
}
.edu-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.edu-secondary {
    display: inline-block;
    margin-top: 3px;
}
.edu-extra {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ==============================================
   Publications
   ============================================== */
.pub-item {
    padding: 18px 0;
    border-bottom: 0.5px solid var(--border-light);
}
.pub-item:first-of-type {
    padding-top: 0;
}
.pub-item:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}
.pub-venue {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-light);
    margin-bottom: 4px;
}
.pub-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 3px;
    line-height: 1.4;
}
.pub-content h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}
.pub-content h3 a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.pub-authors {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}
.pub-authors strong {
    color: var(--text-primary);
    font-weight: 600;
    font-style: italic;
}

/* ==============================================
   Projects
   ============================================== */
.project-item {
    padding: 20px 0;
    border-bottom: 0.5px solid var(--border-light);
}
.project-item:first-of-type {
    padding-top: 0;
}
.project-item:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}
.project-tags {
    display: flex;
    gap: 7px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.project-tags span {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    padding: 2px 9px;
    border: 1px solid var(--border);
    background: var(--parchment);
}
.project-item h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}
.project-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.62;
}
.project-role {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.08em;
    margin-top: 10px;
}

/* ==============================================
   Activities (Beyond Research)
   ============================================== */
.activity-item {
    display: flex;
    gap: 0;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 0.5px solid var(--border-light);
    font-size: 0.87rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.activity-item:first-of-type {
    padding-top: 0;
}
.activity-item:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}
.activity-item strong {
    color: var(--text-primary);
    font-weight: 600;
}
.activity-emoji {
    font-size: 1.1rem;
    line-height: 1;
    margin-top: 1px;
    flex-shrink: 0;
}
.activity-detail {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.06em;
    margin-top: 2px;
}

/* ==============================================
   Footer
   ============================================== */
footer {
    text-align: center;
    padding: 14px 0;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.1em;
}

/* ==============================================
   Scroll Animations
   ============================================== */
.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================================
   Responsive
   ============================================== */
@media (max-width: 768px) {
    .language-toggle { top: 10px; right: 10px; }
    .side-nav { display: none; }
    .layout {
        flex-direction: column;
        min-height: auto;
        width: 100%;
    }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1.5px solid var(--border);
        box-shadow: 0px 2px 0px var(--shadow);
    }
    .sidebar-inner {
        padding: 36px 24px 28px;
        overflow-y: visible;
    }
    .sidebar-avatar-outer {
        width: 110px;
        height: 110px;
    }

    .content {
        max-width: 100%;
        padding: 24px 0 36px;
        gap: 20px;
    }
    .section-card {
        width: auto;
        margin: 0 16px;
    }
    .section-card .card-pad {
        padding: 20px 18px 22px;
    }

    .edu-item {
        flex-direction: column;
        gap: 4px;
    }
    .edu-year {
        min-width: auto;
    }
}

@media (max-width: 600px) {
    .section-card {
        margin: 0 8px;
    }
    .section-card .card-pad {
        padding: 18px 14px 20px;
    }
    .section-header h2 {
        font-size: 0.7rem;
        letter-spacing: 0.15em;
    }
    .sidebar-avatar-outer {
        width: 90px;
        height: 90px;
    }
    .sidebar-name {
        font-size: 1.05rem;
    }
    footer {
        padding: 10px 0;
    }
}
