/*
    Cecilia Zhang — personal site
    Self-sufficient stylesheet for index.html.
    Mobile-first, fluid typography, no framework.
*/

/* ---------- Tokens ---------- */

:root {
    --accent: #f595a2;
    --accent-soft: #f7baad;
    --accent-deep: #c97470;
    --accent-tint: rgba(245, 149, 162, 0.10);
    --link: #c97470;
    --link-hover: #f595a2;

    --text: #2a2a2e;
    --text-muted: #6b6b72;
    --text-soft: #8a8a90;

    --bg: #f7f4f2;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-solid: #ffffff;

    /* Time-of-day tint. Defaults below match the daytime palette and are
       overridden by JS based on the visitor's local clock. */
    --tint-1: 245, 149, 162;
    --tint-2: 224, 147, 143;
    --tint-base-1: #fbf8f6;
    --tint-base-2: #f3eeec;
    --border: rgba(40, 40, 50, 0.08);
    --border-soft: rgba(40, 40, 50, 0.04);

    --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04);
    --shadow-md: 0 8px 24px rgba(20, 20, 30, 0.08), 0 1px 2px rgba(20, 20, 30, 0.04);
    --shadow-lg: 0 12px 32px rgba(20, 20, 30, 0.10), 0 32px 80px rgba(20, 20, 30, 0.06);
    --shadow-pop: 0 6px 18px rgba(245, 149, 162, 0.45);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Alegreya Sans SC', var(--font-sans);
    --font-cn: 'FZWangXZXSJF', 'Noto Sans SC', 'SimSun', 'Microsoft YaHei', sans-serif;

    --ease: cubic-bezier(.2, .8, .2, 1);

    /* Fluid type */
    --fs-body: clamp(15px, 0.9vw + 0.6rem, 17px);
    --fs-lead: clamp(17px, 1vw + 0.7rem, 20px);
    --fs-h1:   clamp(2rem, 1vw + 1.7rem, 3rem);
    --fs-h2:   clamp(1.4rem, 0.6vw + 1.1rem, 1.75rem);
    --fs-h3:   clamp(1.05rem, 0.3vw + 0.95rem, 1.2rem);
    --fs-small: clamp(13px, 0.4vw + 0.6rem, 14px);
}

/* ---------- Reset (lightweight) ---------- */

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

html, body { margin: 0; padding: 0; }

img, picture, video { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration: none; }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

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

/* ---------- Base ---------- */

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    font-weight: 300;
    line-height: 1.7;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 15% 0%, rgba(var(--tint-1), 0.18), transparent 60%),
        radial-gradient(ellipse 70% 60% at 95% 100%, rgba(var(--tint-2), 0.16), transparent 60%),
        linear-gradient(180deg, var(--tint-base-1) 0%, var(--tint-base-2) 100%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

@media (max-width: 736px) {
    body { background-attachment: scroll; }
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--text);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

p { margin: 0 0 1em 0; }

p:last-child { margin-bottom: 0; }

strong, b { font-weight: 500; color: var(--text); }

em, i { color: var(--text-soft); font-style: italic; }

hr {
    border: 0;
    border-top: 1px dashed var(--border);
    margin: 2.5em 0;
    width: 100%;
}

a.link {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(245, 149, 162, 0.35);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: color .2s ease, text-decoration-color .2s ease;
}

a.link:hover {
    color: var(--link-hover);
    text-decoration-color: rgba(245, 149, 162, 0.9);
}

a.muted-link {
    color: var(--text-muted);
    transition: color .2s ease;
}

a.muted-link:hover { color: var(--accent); }

.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;
}

/* ---------- Layout ---------- */

.page {
    max-width: 880px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 4rem) clamp(0.75rem, 2vw, 1.5rem) 6rem;
}

.card {
    background: var(--surface-solid);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

@media (min-width: 737px) {
    .card {
        background: var(--surface);
        -webkit-backdrop-filter: saturate(140%) blur(18px);
        backdrop-filter: saturate(140%) blur(18px);
        border: 1px solid rgba(255, 255, 255, 0.7);
        box-shadow: var(--shadow-md), var(--shadow-lg);
    }
}

.section {
    padding: clamp(1.75rem, 4vw, 4rem) clamp(1.25rem, 3vw, 3.5rem);
    scroll-margin-top: 1rem;
}

.section + .section { border-top: 1px solid var(--border); }

.section-heading {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 400;
    margin: 0 0 1.5em 0;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--border);
}

.section-heading a {
    color: var(--accent);
    transition: color .2s ease;
}

.section-heading a:hover { color: var(--accent-deep); }

.section-heading .divider {
    color: var(--text-soft);
    margin: 0 0.4em;
    font-weight: 300;
}

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

.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-bottom: 1rem;
}

@media (min-width: 737px) {
    .hero {
        grid-template-columns: 1fr auto;
        align-items: start;
    }
}

.hero__name {
    font-family: var(--font-display);
    font-size: var(--fs-h1);
    font-weight: 400;
    line-height: 1.1;
    margin: 0 0 0.4em 0;
}

.hero__name-cn {
    display: block;
    font-family: var(--font-cn);
    font-size: 0.85em;
    margin-top: 0.25em;
    color: var(--text-muted);
}

.hero__pic {
    --size: clamp(180px, 18vw, 240px);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,.06), 0 18px 40px rgba(0,0,0,.10);
    transition: transform .5s var(--ease), box-shadow .5s ease;
    justify-self: center;
}

.hero__pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero__pic:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 10px rgba(0,0,0,.08), 0 24px 50px rgba(0,0,0,.14);
}

.hero__tagline {
    color: var(--text-muted);
    font-size: 1em;
    margin: 0 0 1em;
}

.hero__tagline strong { color: var(--text); }

.hero__contact {
    margin: 0 0 1em;
    color: var(--text-muted);
    font-size: 0.95em;
}

.socials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 2rem;
}

.social {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.4em 0.85em;
    border-radius: var(--radius-pill);
    background: var(--accent-tint);
    color: var(--link);
    font-size: var(--fs-small);
    font-weight: 500;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.social:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}

.hero__cta {
    margin: 1.5em 0 1.5em;
    padding: 1em 1.25em;
    background: linear-gradient(135deg, rgba(247, 186, 173, 0.15), rgba(245, 149, 162, 0.15));
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--accent-deep);
    font-size: var(--fs-lead);
    line-height: 1.55;
    font-weight: 400;
}

.hero__cta-tag {
    display: inline-block;
    padding: 0.15em 0.7em;
    margin-right: 0.5em;
    background: var(--accent);
    color: #fff;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: var(--radius-pill);
    vertical-align: 0.15em;
    box-shadow: 0 2px 8px rgba(245, 149, 162, 0.35);
}

.hero__cta a {
    color: var(--accent-deep);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(245, 149, 162, 0.4);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: text-decoration-color .2s ease, color .2s ease;
}

.hero__cta a:hover {
    color: var(--accent);
    text-decoration-color: rgba(245, 149, 162, 0.9);
}

.bio h2 {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: 500;
    margin: 1.5em 0 0.5em;
    color: var(--text);
}

.bio p { color: var(--text-muted); }

/* ---------- Publications ---------- */

.pub-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pub {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
}

.pub__title {
    font-size: var(--fs-h3);
    font-weight: 500;
    line-height: 1.35;
    margin: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.5em;
    flex-wrap: wrap;
}

.pub__title a {
    color: var(--accent-deep);
    transition: color .2s ease;
}

.pub__title a:hover { color: var(--accent); }

.pub__icon {
    color: var(--text-soft);
    font-size: 0.8em;
    transition: color .2s ease, transform .2s ease;
}

.pub__title a:hover .pub__icon {
    color: var(--accent);
    transform: translateY(-1px);
}

.pub__authors {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.95em;
    line-height: 1.55;
}

.pub__authors .me {
    color: var(--text);
    font-weight: 500;
}

.pub__venue {
    color: var(--text-soft);
    font-style: italic;
    font-size: 0.92em;
    margin: 0;
}

/* ---------- Blog ---------- */

.blog__intro {
    color: var(--text-muted);
    margin-bottom: 1.5em;
}

.blog__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.5em 1em;
    background: linear-gradient(135deg, var(--accent-soft), var(--accent));
    color: #fff;
    font-size: var(--fs-small);
    font-weight: 500;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 8px rgba(245, 149, 162, 0.28);
    transition: transform .2s ease, box-shadow .2s ease;
}

.dropdown__btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-pop);
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 0.5em);
    left: 0;
    min-width: 200px;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    z-index: 10;
}

.dropdown:hover .dropdown__menu,
.dropdown:focus-within .dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown__menu a {
    display: block;
    padding: 0.5em 0.8em;
    border-radius: var(--radius-sm);
    font-size: var(--fs-small);
    color: var(--text);
    transition: background .15s ease, color .15s ease, padding-left .15s ease;
}

.dropdown__menu a:hover {
    background: linear-gradient(135deg, rgba(247, 186, 173, 0.18), rgba(245, 149, 162, 0.18));
    color: var(--accent-deep);
    padding-left: 1.1em;
}

.posts {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-card {
    display: block;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm), 0 8px 24px rgba(0, 0, 0, 0.06);
    transition: transform .35s var(--ease), box-shadow .35s ease;
    color: #fff;
    aspect-ratio: 16 / 9;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,.06), 0 22px 48px rgba(0,0,0,.12);
}

.post-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s var(--ease), filter .35s ease;
}

.post-card:hover .post-card__img {
    transform: scale(1.04);
    filter: brightness(0.55);
}

.post-card__date {
    position: absolute;
    top: 1em;
    left: 1em;
    z-index: 2;
    padding: 0.25em 0.7em;
    background: rgba(255, 255, 255, 0.92);
    color: var(--accent-deep);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
}

.post-card__title {
    position: absolute;
    left: 1em;
    right: 1em;
    bottom: 1em;
    z-index: 2;
    font-size: 1.1em;
    font-weight: 500;
    line-height: 1.3;
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    transition: opacity .25s ease;
}

.post-card__overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.75em;
    padding: 1.5em;
    background: linear-gradient(180deg, rgba(20,15,20,0.30) 0%, rgba(20,15,20,0.70) 100%);
    opacity: 0;
    transition: opacity .35s ease;
    text-align: center;
}

.post-card:hover .post-card__overlay { opacity: 1; }

.post-card:hover .post-card__title { opacity: 0; }

.post-card__excerpt {
    color: #fff;
    font-size: 0.9em;
    line-height: 1.5;
    margin: 0;
    max-width: 32em;
}

.post-card__cta {
    display: inline-block;
    padding: 0.4em 1em;
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent-deep);
    border-radius: var(--radius-pill);
    font-size: 0.78em;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.post-card:hover .post-card__cta {
    background: var(--accent);
    color: #fff;
}

.post-card__cta:hover {
    transform: translateY(-1px);
}

/* ---------- Photography ---------- */

.photo-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.photo {
    margin: 0;
}

.photo a {
    display: block;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.08);
    transition: transform .35s var(--ease), box-shadow .35s ease;
}

.photo a:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, .08),
        0 22px 48px rgba(var(--photo-accent, 20, 20, 30), 0.28);
}

.photo img {
    width: 100%;
    transition: transform .8s var(--ease);
}

.photo a:hover img { transform: scale(1.02); }

.photo figcaption {
    margin-top: 0.6em;
    font-family: var(--font-display);
    color: var(--text-soft);
    font-size: 0.92em;
    letter-spacing: 0.02em;
}

.photo figcaption::before {
    content: '';
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    border-radius: 50%;
    background: rgb(var(--photo-accent, 138, 138, 144));
    margin-right: 0.55em;
    vertical-align: 0.05em;
    transition: background .35s ease, transform .35s var(--ease);
}

.photo a:hover ~ figcaption::before,
.photo:hover figcaption::before {
    transform: scale(1.25);
}

/* ---------- Side nav (desktop) / Bottom nav (mobile) ---------- */

.sidenav {
    position: fixed;
    z-index: 100;
    display: flex;
    gap: 0.85rem;
}

@media (min-width: 737px) {
    .sidenav {
        flex-direction: column;
        left: max(1rem, calc(50% - 30em));
        top: 50%;
        transform: translateY(-50%);
    }
}

@media (max-width: 736px) {
    .sidenav {
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 0.5rem 0.6rem;
        background: rgba(255, 255, 255, 0.85);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        border-radius: var(--radius-pill);
        border: 1px solid rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    }
}

.sidenav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6em;
    height: 2.6em;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.95);
    color: var(--text-soft);
    font-size: 1em;
    box-shadow: var(--shadow-sm), 0 6px 18px rgba(0,0,0,.06);
    transition: background .25s ease, color .25s ease,
                transform .25s var(--ease), box-shadow .25s ease;
    position: relative;
}

@media (max-width: 736px) {
    .sidenav a {
        background: transparent;
        box-shadow: none;
        border: none;
    }
}

.sidenav a:hover,
.sidenav a.is-active {
    background: linear-gradient(135deg, var(--accent-soft), var(--accent));
    color: #fff;
    transform: translateY(-1px) scale(1.04);
    box-shadow: var(--shadow-pop);
}

/* Section-progress fill: rises bottom-up as the visitor scrolls through
   the corresponding section. JS sets --progress on each link (0–1). */
.sidenav a::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--accent-soft), var(--accent));
    opacity: 0.22;
    transform: scaleY(var(--progress, 0));
    transform-origin: bottom;
    transition: transform .25s var(--ease), opacity .2s ease;
    pointer-events: none;
}

.sidenav a > * {
    position: relative;
    z-index: 1;
}

/* When hovered or active, the link's own background already shows full
   pink — hide the partial fill to avoid stacking it on top. */
.sidenav a:hover::before,
.sidenav a.is-active::before {
    opacity: 0;
}

.sidenav a::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 0.6em);
    top: 50%;
    transform: translate(-6px, -50%);
    padding: 5px 10px;
    background: rgba(28, 24, 28, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

@media (max-width: 736px) {
    .sidenav a::after { display: none; }
}

.sidenav a:hover::after {
    opacity: 1;
    transform: translate(0, -50%);
}

/* ---------- Reveal animation ---------- */
/*
   Content is visible by default. The reveal animation is opt-in via the
   `is-revealing` class added by JS only for sections that begin below the
   fold. This way, if JS or IntersectionObserver fails for any reason,
   nothing ever stays invisible.
*/

@keyframes reveal-rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.reveal.is-revealing {
    animation: reveal-rise .7s var(--ease) both;
}

@media (prefers-reduced-motion: reduce) {
    .reveal.is-revealing { animation: none; }
}

/* ---------- Footer ---------- */

.footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-soft);
    font-size: var(--fs-small);
}

/* ---------- Mobile-specific tweaks ---------- */

@media (max-width: 736px) {
    .page { padding-bottom: 6rem; }

    .hero {
        text-align: center;
    }

    .hero__pic {
        order: -1;
        justify-self: center;
    }

    .socials { justify-content: center; }

    .blog__filters { justify-content: flex-start; }

    .dropdown__menu {
        left: 0;
        right: auto;
    }

    /* Right-edge dropdowns flip to the right */
    .dropdown:nth-last-child(-n+2) .dropdown__menu {
        left: auto;
        right: 0;
    }

    .section-heading { text-align: center; }
}

/* ---------- Tablet refinements ---------- */

@media (min-width: 737px) and (max-width: 1100px) {
    .sidenav {
        left: 1rem;
    }
}
