@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap");

/* Self-hosted fallback when the Adobe-hosted primary font is unavailable. */
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('fonts/ibm-plex-sans/IBMPlexSansVar-Roman.woff2') format('woff2');
    font-style: normal;
    font-weight: 100 700;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('fonts/ibm-plex-sans/IBMPlexSansVar-Italic.woff2') format('woff2');
    font-style: italic;
    font-weight: 100 700;
    font-display: swap;
}

:root {
    --text-color: #0a0a0a;
    --text-secondary: #525252;
    --text-tertiary: #a3a3a3;
    --text-light: #d1d5db;

    /* Enhanced color palette */
    --primary: #8e87ed;
    --primary-dark: #9c96e9;
    --primary-light: #a5b4fc;
    --primary-ultra-light: #eef2ff;

    --accent: #f2b10e;
    --accent-light: #fef3c7;

    --surface: #ffffff33;
    --surface-elevated: #f8fafc;
    --surface-subtle: #ebf0f6;
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --rule-color: #dedbe7;
    --section-title-color: var(--text-color);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Typography */
    --font-primary: 'adelle-sans', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

    --text-xs: clamp(0.85rem, 0.75rem + 0.25vw, 0.95rem);
    --text-sm: clamp(0.95rem, 0.85rem + 0.25vw, 1.05rem);
    --text-base: clamp(0.975rem, 0.875rem + 0.25vw, 1.075rem);
    --text-ll: 1.05rem;
    --text-lg: clamp(1.125rem, 1rem + 0.3vw, 1.3rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.35vw, 1.45rem);
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Give the profile room without letting the reading column grow too wide. */
    --sidebar-width: clamp(18rem, 22vw, 22rem);
    --layout-gap: clamp(2.5rem, 4.5vw, 5.5rem);
    --page-gutter: clamp(1.5rem, 4vw, 4rem);
    --content-max-width: 86rem;

    /* Spacing */
    --spacing-unit: 1.1rem;
    --section-spacing: 4rem;
    --section-gap: 6rem;

    /* Border radius */
    --radius-xs: 0.125rem;
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overscroll-behavior: none;
}

body {
    font-family: var(--font-primary);
    color: var(--text-color);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-subtle) 100%);
    margin: 0;
    padding: 0;
    font-weight: 300;
    letter-spacing: .35px;
    word-spacing: .3px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Center the sidebar and reading column as one layout. */
.container-fluid {
    width: 100%;
    max-width: calc(var(--sidebar-width) + var(--layout-gap) + var(--content-max-width) + 2 * var(--page-gutter));
    margin: 0 auto;
    padding: 0 var(--page-gutter);
}

.center {
    position: relative;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--layout-gap);
    align-items: start;
    min-height: 100vh;
    margin-inline: 0;
}

.center::after {
    content: none;
}

/* Keep the divider as tall as the page, independently of the sticky profile. */
.center::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--sidebar-width) - 1px);
    border-right: 1px solid var(--section-border-color, var(--border));
    pointer-events: none;
}

.mobile-only { display: none; }

/* A light, content-height sidebar within the centered layout. */
.left {
    margin-top: calc(var(--section-spacing) + 1rem);
    padding: 0 clamp(2rem, 3vw, 3rem) 1.5rem 0;
    position: sticky;
    top: calc(var(--section-spacing) + 1rem);
    max-height: calc(100vh - var(--section-spacing) - 3rem);
    max-height: calc(100dvh - var(--section-spacing) - 3rem);
    width: 100%;
    min-width: 0;
    background: none;
    box-shadow: none;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    z-index: 1000;
}

/* Enhanced headshot */
.headshot {
    width: 100%;
    max-width: clamp(10rem, 22vh, 14rem);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--border), 0 0 0 6px var(--primary-ultra-light);
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
    margin-bottom: 1.5rem;
}

.headshot:hover {
    transform: scale(1.02) rotate(0.5deg);
    box-shadow: 0 0 0 3px var(--primary-light), 0 0 0 6px var(--primary-ultra-light);
}

.head-svg {
    height: var(--scriptsize-font);
    width: var(--scriptsize-font);
}

/* Enhanced name styling */
#headname {
    font-size: clamp(var(--text-lg), 2vw, var(--text-xl));
    font-weight: 600;
    margin: 1rem 0;
    background-clip: text;
    line-height: 1.2;
}

/* Contact styling */
.contact-container {
    margin: 1.5rem 0;
}

.contact {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0.5rem 0;
    font-weight: 300;
}

/* Enhanced header icons */
.header-contact {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.header-icon {
    transition: transform var(--transition-fast);
}

.header-icon:hover {
    transform: translateY(-2px);
}

.icon-svg {
    width: clamp(32px, 4vw, 40px);
    height: clamp(32px, 4vw, 40px);
    transition: all var(--transition-fast);
    filter: drop-shadow(var(--shadow-sm));
}

.icon-svg:hover {
    filter: drop-shadow(var(--shadow-md));
    transform: scale(1.1);
}

/* Enhanced navigation */
#page-link-container {
    margin-top: 1rem;
    padding-top: 0;
}

.page-link {
    display: block;
    padding: 0.5rem 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-tertiary);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition-fast);
    transform: translateX(0) scale(1);
}

.page-link:hover {
    color: var(--primary);
    transform: translateX(0.25rem) scale(1.02);
    text-decoration: none;
}

/* Right content area */
.right {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    max-width: var(--content-max-width);
    margin-left: 0;
    padding: 1rem 0;
}

/* Enhanced sections */
.section {
    margin: var(--section-spacing) 0;
    padding-top: 1.5rem;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.section + .section {
    margin-top: var(--section-gap);
}

.section:nth-child(1) {
    animation-delay: 0.1s;
}

.section:nth-child(2) {
    animation-delay: 0.2s;
}

.section:nth-child(3) {
    animation-delay: 0.3s;
}

.section:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced section headers */
.section-head {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
    position: relative;
    color: var(--text-color);
}

/* Adelle Sans Semibold for the profile heading. */
.profile-name {
    font-family: var(--font-primary);
    font-weight: 600;
    font-style: normal;
    font-synthesis: none;
    text-transform: none;
    letter-spacing: inherit;
}

.section-inner {
    background: none;
    font-size: var(--text-sm);
    padding: 0;
    box-shadow: none;
    border: 0;
}

.section-inner > :last-child {
    margin-bottom: 0;
}

/* Typography enhancements */
p {
    margin: 0 0 1.5rem 0;
    font-size: var(--text-sm);
    line-height: 1.7;
    color: var(--text-color);
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

li {
    margin: .25rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: var(--text-sm);
}

li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 600;
}

/* Enhanced links with preserved dotted underline */
.normal-a {
    text-decoration: underline dotted var(--text-tertiary);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    color: inherit;
    transition: all var(--transition-normal);

    -webkit-text-decoration-line: underline !important;
    -webkit-text-decoration-style: dotted !important;
    -webkit-text-decoration-thickness: 1px !important;
    -webkit-text-decoration-color: var(--text-tertiary) !important;
}

.normal-a:hover {
    text-decoration: none;
    color: var(--primary);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    cursor: pointer;
}

.best-star {
    display: inline-block;
    margin-right: 0.45em;
    color: var(--accent);
    font-size: 0.9em;
    line-height: 1;
    animation: best-star-flash 2.4s ease-in-out infinite;
}

@keyframes best-star-flash {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .best-star { animation: none; }
}

/* Minimalist publications */
#publication {
    margin-top: var(--section-gap);
}

#projdiv {
    margin-top: 0;
}

#pubs {
    background: transparent;
    padding: 0;
    box-shadow: none;
    border: none;
    margin-top: 0;
}

.proj-outer {
    margin: 0;
    padding: 0;
    position: relative;
}

.proj-outer + .proj-outer {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
}

.proj-outer + .proj-outer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    border-top: 1px solid var(--rule-color);
}

.proj-box {
    background: none;
    padding: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    position: relative;
}

.proj-box::before {
    display: none;
}

.projtitle {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.75;
    margin-bottom: 0.75rem;
}

.projpeople {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 2;
}

.projtag {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
    align-items: baseline;
    line-height: 1.5;
}

.projtag>* {
    line-height: 1.5;
}

.proj-tag-conf {
    background: transparent;
    color: var(--primary-dark);
    padding: 0;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.5;
}

.proj-tag {
    padding: 0;
    line-height: 1.5;
}

.proj-tag a {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: var(--text-xs);
    font-weight: 400;
    transition: color var(--transition-fast);
    font-family: var(--font-mono);
    text-transform: lowercase;
    line-height: 1.5;
    display: inline-flex;
    align-items: baseline;
}

.proj-tag a:hover {
    color: var(--text-color);
}

.proj-tag a i {
    font-size: 0.85em;
    opacity: 0.6;
    margin-right: 0.2em;
    align-self: baseline;
}

.proj-dot {
    color: var(--text-tertiary);
    margin: 0 0.25rem;
    font-size: var(--text-xs);
    line-height: 1.5;
}

.awards {
    background: transparent;
    color: var(--accent);
    padding: 0;
    border-radius: 0;
    font-size: var(--text-sm);
    font-weight: 500;
    margin: 0;
    font-family: var(--font-mono);
    line-height: 1.5;
}

/* Adelle Sans uses Light (300) for body text and Semibold (600) for emphasis. */
.boldtext,
b,
strong {
    font-weight: 600;
}

.boldtext {
    color: var(--text-color);
}

.headchinese {
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

.tiny.proj.equal_contr {
    line-height: 1.5;
}

.tiny.proj.equal_contr text {
    line-height: 1.5;
}

.small-note-text {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-style: normal;
    line-height: 1.5;
    margin-top: 0;
}

.small-note-text .snowflake {
    opacity: 0.4;
    margin-right: 0.5rem;
}

/* Footer */
.footer-font {
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    line-height: 1.6;
}

/* Let wide monitors open up the column gap gradually, up to 50% more. */
@media (min-width: 1600px) {
    :root {
        --layout-gap: clamp(4.5rem, calc(18vw - 13.5rem), 8.25rem);
    }
}

@media (min-width: 2000px) {
    :root {
        --section-spacing: 5rem;
    }
}

/* Reserve space for the portrait's hover effect around the scroll boundary. */
@media (min-width: 1201px) {
    .profile-sidebar {
        --portrait-bleed: 0.75rem;
        margin-top: calc(var(--section-spacing) + 1rem - var(--portrait-bleed));
        margin-left: calc(-1 * var(--portrait-bleed));
        padding-top: var(--portrait-bleed);
        padding-left: var(--portrait-bleed);
        width: calc(100% + var(--portrait-bleed));
        max-width: none;
        top: calc(var(--section-spacing) + 1rem - var(--portrait-bleed));
        max-height: calc(100vh - var(--section-spacing) - 3rem + var(--portrait-bleed));
        max-height: calc(100dvh - var(--section-spacing) - 3rem + var(--portrait-bleed));
    }
}

/* Short laptop screens need less portrait height and a shorter navigation. */
@media (min-width: 1201px) and (max-height: 900px) {
    .profile-sidebar .headshot {
        max-width: 10rem;
        margin-bottom: 1rem;
    }

    .profile-sidebar .contact-container,
    .profile-sidebar .header-contact {
        margin-block: 1rem;
    }

    .profile-sidebar #page-link-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 1rem;
    }
}

/* Tablet and mobile responsiveness. */
@media (max-width: 1200px) {
    :root {
        --section-gap: 4rem;
    }

    .center {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        min-height: auto;
    }

    .center::before {
        content: none;
    }

    .desktop-only { display: none; }
    .mobile-only { display: block; }

    .left {
        position: relative;
        top: auto;
        left: auto;
        max-height: none;
        margin-top: 2rem;
        padding: 1.5rem 0;
        width: 100%;
        min-width: auto;
        background: none;
    }

    .right {
        grid-column: 1;
        margin-left: 0;
        max-width: 100%;
        width: 100%;
        padding: 1rem 0;
    }

    .container-fluid {
        max-width: calc(var(--content-max-width) + 2rem);
        padding: 0 1rem;
    }

    #headname {
        font-size: var(--text-2xl);
    }

    .section {
        margin: 2rem 0;
    }

    .tag-general {
        justify-content: flex-start;
    }
}

/* On tablets and small laptops, use the width above the main content. */
@media (min-width: 641px) and (max-width: 1200px) {
    .profile-sidebar {
        display: grid;
        grid-template-columns: clamp(10rem, 22vw, 14rem) minmax(0, 1fr);
        align-items: start;
        column-gap: clamp(2rem, 5vw, 4rem);
        padding-inline: clamp(1rem, 3vw, 2.5rem);
    }

    .profile-sidebar > .headshot.mobile-only {
        grid-column: 1;
        grid-row: 1 / 3;
        max-width: 100%;
        margin-bottom: 0;
    }

    .profile-sidebar > .profile-name.mobile-only {
        grid-column: 2;
    }

    .profile-sidebar > .contact-container {
        grid-column: 2;
        margin: 0.75rem 0 0;
    }

    .profile-sidebar .header-contact {
        margin-bottom: 0;
    }
}

@media (max-width: 640px) {
    :root {
        --section-gap: 2.8rem;
    }

    .section {
        margin-top: 1.4rem;
    }

    .container-fluid {
        padding: 0 1rem;
    }

    .left {
        padding: 1.5rem;
    }

    .headshot {
        max-width: 180px;
    }

    #headname {
        font-size: var(--text-xl);
    }

}

.name-style,
.figx-name-style {
    color: var(--text-color);
    font-weight: 400;
    font-style: italic;
    display: inline;
    transition: all var(--transition-fast);
    text-decoration: none;
}

/* Gallery styles - shared across baking.html, crafts.html, and memories.html */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all var(--transition-normal);
    aspect-ratio: 1;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-slow);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.section-icon {
    color: var(--primary);
    font-size: 1.1em;
}

@media (max-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
}
