/* ==========================================================
   Yufeng Wang — site styles
   ========================================================== */

:root {
    --ink: #eef1f7;
    --ink-2: rgba(232, 236, 245, 0.72);
    --ink-3: rgba(232, 236, 245, 0.56);
    --line: rgba(255, 255, 255, 0.12);
    --line-2: rgba(255, 255, 255, 0.22);
    --accent: #f5b08c;          /* nebula peach */
    --accent-2: #8fd3e8;        /* nebula teal  */
    --bg: #05070f;

    --serif: "Newsreader", "Times New Roman", Times, serif;
    --sans: var(--serif);

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --gutter: clamp(20px, 3vw, 48px);
    --max: 90vw;

    /* driven by js: 0 at top, 1 after one viewport of scroll */
    --s: 0;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 72px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.6;
    font-weight: 400;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }

::selection { background: rgba(245, 176, 140, 0.35); color: #fff; }

:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* ---------- Galaxy backdrop ----------
   .nebula  – nebula, spiral galaxy and dense stars, rendered once with WebGL (js/site.js)
   .stars   – a lighter layer of bright stars that twinkle and move with depth
   The gradient on .sky is what shows if WebGL is unavailable. */

.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background:
        radial-gradient(ellipse 60% 50% at 76% 50%, rgba(70, 90, 150, 0.22) 0%, rgba(70, 90, 150, 0) 70%),
        radial-gradient(ellipse 70% 40% at 60% 75%, rgba(150, 80, 100, 0.12) 0%, rgba(150, 80, 100, 0) 70%),
        linear-gradient(160deg, #060914 0%, #03050c 100%);
}

.sky-drift {
    position: absolute;
    inset: -4%;
    transform: translate3d(var(--mx, 0px), calc(var(--my, 0px) + var(--s) * -48px), 0);
    transition: transform 1.2s var(--ease-out);
    will-change: transform;
}

.nebula,
.stars {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.nebula { animation: sky-in 2.8s var(--ease-out) both; }
.stars { animation: fade 2.4s ease .3s both; }

@keyframes sky-in {
    from { opacity: 0; transform: scale(1.14); }
    to   { opacity: 1; transform: scale(1.04); }
}

/* Readability: dark on the left where the text sits, open on the right where
   the galaxy is; deepens uniformly as the page scrolls. */
.sky-shade {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(5, 7, 15, 0.86) 0%, rgba(5, 7, 15, 0.62) 38%, rgba(5, 7, 15, 0.12) 72%, rgba(5, 7, 15, 0.05) 100%),
        linear-gradient(0deg, rgba(5, 7, 15, 0.55) 0%, rgba(5, 7, 15, 0) 40%);
}

.sky-shade::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 15, 0.7);
    opacity: var(--s);
}

.hero-inner { position: relative; z-index: 1; }

/* ---------- Navigation ---------- */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px var(--gutter);
    font-size: 16px;
    letter-spacing: 0.01em;
    transition: background-color .5s ease, padding .5s var(--ease-out), border-color .5s ease;
    border-bottom: 1px solid transparent;
    animation: fade 1.2s ease 1.8s both;
}

.nav.is-solid {
    padding-top: 14px;
    padding-bottom: 14px;
    background: rgba(5, 7, 15, 0.55);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border-bottom-color: var(--line);
}

.nav-name {
    font-family: var(--serif);
    font-size: 21px;
    letter-spacing: 0;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .5s ease, transform .5s var(--ease-out);
    pointer-events: none;
}

.nav.is-solid .nav-name { opacity: 1; transform: none; pointer-events: auto; }

.nav-links { display: flex; gap: clamp(18px, 3vw, 36px); }

.nav-links a {
    color: var(--ink-2);
    position: relative;
    padding: 4px 0;
    transition: color .25s ease;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform .4s var(--ease-out);
}

.nav-links a:hover,
.nav-links a.is-active { color: var(--ink); }

.nav-links a:hover::after,
.nav-links a.is-active::after { transform: scaleX(1); transform-origin: left; }

@media (max-width: 560px) {
    .nav-name { display: none; }
    .nav { justify-content: flex-end; }
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding: 100px var(--gutter) 84px;
}

.hero-inner {
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
}

.hero-name {
    font-family: var(--serif);
    font-weight: 300;
    font-size: clamp(52px, 8vw, 100px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.hero-fields {
    margin-top: 22px;
    font-size: 14px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-2);
}

.hero-fields i {
    display: inline-block;
    margin: 0 0.7em;
    font-style: normal;
    color: var(--accent);
}

/* Trajectories: industry + academia side by side */

.tracks {
    margin-top: clamp(36px, 6vh, 56px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 420px));
    column-gap: clamp(32px, 4vw, 72px);
    row-gap: 40px;
}

.track-label {
    padding-left: 31px;
    margin-bottom: 16px;
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.track {
    position: relative;
    display: grid;
    gap: 22px;
}

/* the line that connects the stops — draws top → bottom on load */
.track::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 9px;
    bottom: 9px;
    width: 1px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--line-2) 40%, var(--line) 100%);
    transform-origin: top;
    animation: draw-y 1.5s var(--ease-out) .6s both;
}

@keyframes draw-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.stop {
    position: relative;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr);
    column-gap: 22px;
    align-items: baseline;
    animation: rise 1.1s var(--ease-out) var(--d, 0s) both;
}

.stop-dot {
    position: relative;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--ink-3);
    grid-row: 1;
    align-self: start;
    margin-top: 6px;
}

.stop.is-now .stop-dot {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(245, 176, 140, 0.8);
}

.stop.is-now .stop-dot::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    animation: pulse 2.8s ease-out 2.2s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1); opacity: .9; }
    100% { transform: scale(3.2); opacity: 0; }
}

.stop-when {
    grid-column: 2;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
}

.stop.is-now .stop-when { color: var(--accent); }

.stop-body {
    grid-column: 2;
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stop-body > div { min-width: 0; }

.logo {
    flex: none;
    width: 52px;
    height: 52px;
    margin-top: 2px;
    border-radius: 12px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 6px 18px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo.is-wide { padding: 7px; }
.logo.is-wordmark { padding: 8px; }

.stop-body h2 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(22px, 2vw, 25px);
    line-height: 1.15;
    letter-spacing: 0.002em;
}

.stop-org {
    margin-top: 3px;
    font-size: 16.5px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--ink);
}

.stop-note {
    margin-top: 3px;
    font-size: 15px;
    font-style: italic;
    color: var(--ink-3);
}

.stop-org a,
.stop-note a {
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size .4s var(--ease-out), color .25s ease;
}

.stop-org a:hover,
.stop-note a:hover { background-size: 100% 1px; color: var(--accent); }

/* Profile icons */

.social {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.hero .social { margin-top: clamp(36px, 6vh, 56px); }

.social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 20px;
    color: var(--ink-2);
    border: 1px solid var(--line-2);
    background: rgba(5, 7, 15, 0.3);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: color .3s ease, background-color .3s ease, border-color .3s ease,
                transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}

.social a:hover {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(245, 176, 140, 0.32);
}

.social a:active { transform: translateY(-1px) scale(0.96); }

/* Scroll cue */

.scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 28px;
    width: 1px;
    height: 48px;
    background: var(--line);
    overflow: hidden;
    transform: translateX(-50%);
    animation: fade 1s ease 2.2s both;
}

.scroll-cue span {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--ink);
    animation: cue 2.4s var(--ease-out) 2.4s infinite;
    transform: translateY(-100%);
}

@keyframes cue {
    0%   { transform: translateY(-100%); }
    60%  { transform: translateY(100%); }
    100% { transform: translateY(100%); }
}

/* Load-in */

.rise { animation: rise 1.2s var(--ease-out) var(--d, 0s) both; }

@keyframes rise {
    from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
    to   { opacity: 1; transform: none; filter: blur(0); }
}

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

/* ---------- Content blocks ---------- */

.block {
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(80px, 12vw, 140px) var(--gutter) 0;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: 48px;
}

.block-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(34px, 3.4vw, 44px);
    line-height: 1;
    letter-spacing: -0.005em;
    align-self: start;
    position: sticky;
    top: 96px;
}

@media (max-width: 860px) {
    .block { grid-template-columns: minmax(0, 1fr); }
    .block-title { position: static; margin-bottom: 28px; }
}

.work::before {
    content: "";
    position: absolute;
    left: 0;
    top: -1px;
    height: 1px;
    width: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .7s var(--ease-out);
}

.work:hover::before { transform: scaleX(1); }

/* Research: themes → works */

/* wide screens: year | venue + title | summary */
@media (min-width: 1200px) {
    .works .work {
        grid-template-columns: 48px minmax(0, 1.05fr) minmax(0, 0.95fr);
        grid-template-rows: auto auto 1fr;
        column-gap: 40px;
        align-items: start;
    }
    .work > div { display: contents; }
    .works .work > .logo { grid-row: 1 / span 3; }
    .work .venue { grid-column: 2; grid-row: 1; }
    .works .work h4 { grid-column: 2; grid-row: 2; }
    .works .work-note { grid-column: 3; grid-row: 1 / span 3; margin-top: 0; padding-top: 1px; }
}

.theme-name {
    font-family: var(--serif);
    font-weight: 400;
    font-style: italic;
    font-size: 21px;
    color: var(--ink-2);
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-2);
}

.work {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 24px;
    padding: 24px 0 26px;
    border-bottom: 1px solid var(--line);
}

.works { border-top: 1px solid var(--line); }

.work .logo { width: 48px; height: 48px; border-radius: 10px; margin-top: 0; }
.logo.is-full { padding: 0; }

.venue {
    font-size: 12.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.venue.is-pending { color: var(--ink-3); }
.venue.is-project { color: var(--accent-2); }

.work h4 {
    margin-top: 7px;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(20px, 1.9vw, 23px);
    line-height: 1.3;
    max-width: 34em;
}

.work h4 a {
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size .5s var(--ease-out);
}

.work h4 a:hover { background-size: 100% 1px; }

.work-note {
    margin-top: 8px;
    font-size: 16.5px;
    line-height: 1.6;
    color: var(--ink-2);
    max-width: 44em;
}

.more {
    grid-column: 2;
    justify-self: start;
    margin-top: 32px;
    font-size: 16px;
    font-style: italic;
    color: var(--ink-2);
    transition: color .25s ease;
}

.more span { display: inline-block; transition: transform .35s var(--ease-out); }
.more:hover { color: var(--ink); }
.more:hover span { transform: translateX(4px); }

@media (max-width: 860px) {
    .more { grid-column: 1; }
}

/* Service & Awards */

.award {
    display: grid;
    grid-template-columns: 44px auto minmax(0, 1fr);
    column-gap: 28px;
    align-items: baseline;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.award .fa {
    font-size: 14px;
    color: var(--ink-3);
}

.award-name {
    font-family: var(--serif);
    font-size: 19px;
    color: var(--ink);
}

.award-venue {
    margin-left: -10px;
    font-size: 12.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.reviewing { margin-top: 48px; }

.venues {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 0;
    padding-top: 18px;
}

.venues li {
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink-2);
}

.venues li + li::before {
    content: "·";
    margin: 0 0.7em;
    color: var(--ink-3);
}

/* Footer */

.foot {
    max-width: var(--max);
    margin: clamp(100px, 14vw, 160px) auto 0;
    padding: 28px var(--gutter) 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    font-size: 14px;
    color: var(--ink-3);
    border-top: 1px solid var(--line);
}

.social.is-small { gap: 10px; }
.social.is-small a { width: 38px; height: 38px; font-size: 16px; }

/* ---------- Scroll reveal ---------- */

.js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
    transition-delay: var(--rd, 0s);
}

.js .reveal.is-in { opacity: 1; transform: none; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
    .tracks { grid-template-columns: minmax(0, 1fr); }
}


@media (max-width: 560px) {
    .hero { align-items: flex-end; padding-top: 104px; }
    .hero-fields { letter-spacing: 0.12em; line-height: 1.9; }
    .hero-fields span { display: block; }
    .hero-fields i { display: none; }
    .sky-shade {
        background:
            linear-gradient(90deg, rgba(5, 7, 15, 0.82) 0%, rgba(5, 7, 15, 0.55) 70%, rgba(5, 7, 15, 0.35) 100%),
            linear-gradient(0deg, rgba(5, 7, 15, 0.6) 0%, rgba(5, 7, 15, 0) 45%);
    }
    .stop-note { color: var(--ink-2); }
    .stop { column-gap: 18px; }
    .venues { gap: 8px 1.1em; }
    .venues li + li::before { content: none; }
    .foot { flex-direction: column; align-items: flex-start; gap: 16px; }
    .social.is-small { flex-wrap: nowrap; }
    .track-label { padding-left: 27px; }
    .scroll-cue { display: none; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
    html { scroll-behavior: auto; }
    .scroll-cue { display: none; }
}
