/* ===========================================================
   Homepage (index.html) page styles — light source of truth.
   Dark overrides live in css/theme.css, loaded after this.
   =========================================================== */

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

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
}

/* --- Dot field ------------------------------------------------
   Same ground the notes use (writing/shared/plain.css), scoped to
   this page via body.home. Two tokens, so it can be retuned or
   switched off without hunting through rules: set --grain and
   --dot to `none` / `transparent` and the page is flat again. */
body.home {
    --dot: rgba(104, 116, 140, 0.10);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='0.04'/%3E%3C/svg%3E");
    background-image:
        radial-gradient(circle at 1px 1px, var(--dot) 0 1.3px, transparent 1.7px),
        var(--grain);
    background-size: 22px 22px, 200px 200px;
    background-position: 8px 12px, left top;
}

/* Restated at (0,2,1): css/theme.css carries
   [data-theme="dark"] body { background: ... } — a shorthand at
   (0,1,1) that resets background-image. The field has to be
   re-declared above that weight to survive in dark. */
[data-theme="dark"] body.home {
    --dot: rgba(173, 186, 199, 0.065);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='0.055'/%3E%3C/svg%3E");
    background-color: var(--dk-bg);
    background-image:
        radial-gradient(circle at 1px 1px, var(--dot) 0 1.3px, transparent 1.7px),
        var(--grain);
    background-size: 22px 22px, 200px 200px;
    background-position: 8px 12px, left top;
}

/* --- Hero: photo + intro, two columns ----------------------- */
.name {
    margin: 0.35em 0 0.25em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
}

.alias {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 1.7rem;
    font-weight: 300;
    line-height: 1;
    color: #b9b3c7;
    letter-spacing: -0.02em;
}

.alias img {
    height: 0.82em;
    width: auto;
    display: block;
}

.hero {
    display: grid;
    grid-template-columns: 61fr 39fr;
    column-gap: 32px;
    align-items: center;
    max-width: 1140px;
    margin: 12px auto 0;
}

.hero-intro {
    padding: 2.5%;
}

.hero-photo {
    padding: 2.5%;
}

.social-row {
    text-align: center;
}

/* --- Hidden gallery button on profile photo --- */
.profile-photo-wrap {
    position: relative;
    display: inline-block;
    width: 100%;
}

.profile-photo-wrap>a>img {
    width: 100%;
    border-radius: 4px;
    display: block;
}

.gallery-peek {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
    text-decoration: none;
}

.profile-photo-wrap:hover .gallery-peek,
.profile-photo-wrap:focus-within .gallery-peek {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.gallery-peek:hover {
    background: rgba(110, 70, 190, 0.6);
    color: #fff;
    text-decoration: none;
}

/* --- Section headings --- */
h2 {
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.8rem;
    font-weight: 600;
    text-align: center;
}

/* --- Experience Grid --- */
.exp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 16px;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.exp-card {
    text-align: center;
}

.exp-card img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    margin-bottom: 8px;
}

.exp-card .exp-role {
    font-size: 13px;
    line-height: 1.4;
}

.exp-card .exp-org {
    font-weight: 700;
    font-size: 13px;
}

.exp-card .exp-date {
    font-size: 12px;
    color: #666;
}

/* --- News & Highlights --- */
.news-section {
    max-width: 1140px;
    margin: 0 auto 20px;
    padding: 0 20px;
}

.news-heading {
    font-size: 1.8rem;
    color: #222;
    margin: 40px 0 14px;
    text-align: center;
}

.news-card {
    padding: 8px 0 0;
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.news-card::-webkit-scrollbar {
    width: 4px;
}

.news-card::-webkit-scrollbar-track {
    background: transparent;
}

.news-card::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 8px;
}

.news-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.news-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 5px 0;
}

.news-date {
    width: 76px;
    min-width: 76px;
    font-size: 0.78rem;
    color: #737373;
    white-space: nowrap;
    font-weight: 400;
    flex-shrink: 0;
}

.news-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    width: 62px;
    min-width: 62px;
    padding: 2px 0;
    border-radius: 999px;
    text-transform: capitalize;
    letter-spacing: 0.4px;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}

.news-badge.paper {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.news-badge.position {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.news-badge.intern {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.news-badge.award {
    background: rgba(168, 85, 247, 0.12);
    color: #7c3aed;
}

.news-badge.talk {
    background: rgba(236, 72, 153, 0.12);
    color: #db2777;
}

.news-desc {
    font-size: 0.82rem;
    color: #444;
    line-height: 1.5;
    font-weight: 400;
    flex: 1;
}

.news-desc a {
    color: var(--brand);
    font-weight: 500;
}

/* --- Research cards --- */
.research-grid {
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

.research-card {
    display: grid;
    grid-template-columns: 25% 75%;
    background: #cac4db;
}

.research-media,
.research-body {
    padding: 20px;
    overflow: hidden;
    overflow-wrap: break-word;
}

.research-media {
    text-align: center;
    align-self: center;
}

.research-media img {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
}

.research-body {
    align-self: center;
    text-align: left;
}

.research-body p {
    margin: 0.6em 0 0;
}

/* --- Reading --- */
.reading-section {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

.reading-intro {
    max-width: 780px;
    margin: -6px auto 0;
    text-align: center;
    font-size: 0.88rem;
    line-height: 1.65;
    color: #555;
}

.reading-intro a {
    white-space: nowrap;
}

/* --- Footer --- */
.footer-mark {
    display: block;
    width: 84px;
    height: auto;
    margin: 0 auto 16px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.footer-mark:hover {
    opacity: 0.85;
}

#footer {
    margin-top: 60px;
    padding: 30px 0;
    text-align: center;
    font-size: 0.9rem;
    color: #555;
}

/* --- The Loop — Möbius strip ornament --- */
#visual-canvas {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 118px;
    height: 118px;
    z-index: 40;
    cursor: pointer;
    opacity: 0;
    transition: opacity 1.4s ease, transform 0.35s ease;
}

#visual-canvas.ornament-ready {
    opacity: 0.9;
}

#visual-canvas:hover,
#visual-canvas:focus-visible {
    opacity: 1;
    transform: scale(1.05);
}

#visual-canvas:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 4px;
    border-radius: 50%;
}

#visual-canvas canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- Responsive tweaks (≤768px) --- */
@media (max-width: 768px) {
    body {
        font-size: 15px;
        -webkit-text-size-adjust: 100%;
    }

    .name {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.4rem;
        margin-top: 30px;
        margin-bottom: 14px;
    }

    /* Hero: photo on top, text below */
    .hero {
        display: flex;
        flex-direction: column-reverse;
        align-items: center;
        margin-top: 0;
    }

    .hero-intro {
        width: 100%;
        padding: 10px 16px;
    }

    .hero-intro p,
    .hero-intro ul {
        text-align: left;
    }

    .hero-photo {
        display: flex;
        justify-content: center;
        width: 100%;
        padding: 10px 8px 0;
    }

    .profile-photo-wrap {
        width: 160px;
        max-width: 160px;
    }

    .profile-photo-wrap>a>img {
        border-radius: 50%;
    }

    /* Experience Grid: 2 columns on mobile */
    .exp-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px 12px;
        padding: 0 20px;
    }

    .exp-card img {
        width: 44px;
        height: 44px;
    }

    .exp-card .exp-role {
        font-size: 12px;
    }

    .exp-card .exp-org {
        font-size: 12px;
    }

    .exp-card .exp-date {
        font-size: 11px;
    }

    /* Research cards: image on top, description below */
    .research-card {
        display: flex;
        flex-direction: column;
    }

    .research-media,
    .research-body {
        width: 100%;
        padding: 14px 16px;
        display: block;
    }

    .research-media {
        padding-bottom: 0;
    }

    .research-media img {
        width: 70%;
        max-width: 280px;
        border-radius: 8px;
    }

    .research-body {
        text-align: left;
    }

    /* News */
    .news-section {
        padding: 0 16px;
    }

    .news-card {
        max-height: 320px;
    }

    .news-item {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 0;
    }

    .news-date {
        min-width: 70px;
        font-size: 0.75rem;
    }

    .news-badge {
        font-size: 0.6rem;
    }

    #footer {
        padding: 20px 20px;
        margin-top: 30px;
    }

    #visual-canvas {
        display: none;
    }
}

/* --- Extra small devices (below 400px) --- */
@media (max-width: 400px) {
    .name {
        font-size: 1.4rem;
    }

    body,
    p,
    a {
        font-size: 13px;
    }

    strong {
        font-size: 13px;
    }

    .profile-photo-wrap {
        width: 130px;
        max-width: 130px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #visual-canvas {
        transition: opacity 0.2s ease;
    }
}
