/* ---------- tokens ---------- */
:root {
    --bg: #fcfbf8;
    --surface: #ffffff;
    --ink: #1f1d1a;
    --muted: #6d675d;
    --line: #e7e0d4;
    --accent: #5d4531;
    --accent-soft: #efe8de;
    --title-color: #7c3aed;
    --radius: 14px;
    --font-display: "Newsreader", Georgia, serif;
    --font-title: "Instrument Serif", Georgia, serif;
    --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
}

/* Dark theme: follows the system by default… */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #222222;
        --surface: #2c2c2c;
        --ink: #eae8e4;
        --muted: #a5a19a;
        --line: #3d3d3d;
        --accent: #dcc7ad;
        --accent-soft: #40382e;
        --title-color: #b794f4;
    }
}

/* …and the toggle wins in both directions. */
:root[data-theme="dark"] {
    --bg: #222222;
    --surface: #2c2c2c;
    --ink: #eae8e4;
    --muted: #a5a19a;
    --line: #3d3d3d;
    --accent: #dcc7ad;
    --accent-soft: #40382e;
    --title-color: #b794f4;
}

/* ---------- base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.7;
    max-width: 62rem;
    margin: 0 auto;
    padding: 0 1.5rem;
    transition: background 0.25s ease, color 0.25s ease;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-thickness: 2px;
}

em {
    font-style: normal;
    font-weight: 600;
}

strong {
    /* Source Serif 4 is loaded at 400/600; pin to the real 600 face. */
    font-weight: 600;
}

/* Visually hidden but present for crawlers and assistive tech. */
.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;
}

/* ---------- nav ---------- */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 1.75rem 0;
}

.nav-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--ink);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9375rem;
}

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

.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--ink);
    cursor: pointer;
    align-self: center;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(15deg);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- hero ---------- */
.hero {
    display: flex;
    align-items: flex-start;
    gap: 2.75rem;
    text-align: left;
    padding: 3rem 0 4rem;
}

.hero-figure {
    flex-shrink: 0;
    text-align: center;
    width: 220px;
}

.avatar-button {
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    display: inline-block;
    line-height: 0;
    transition: transform 0.2s ease;
}

.avatar-button:hover {
    transform: rotate(-3deg) scale(1.04);
}

.avatar-button:active {
    transform: scale(0.96);
}

.avatar-button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

.avatar {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--surface);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    background: var(--accent-soft);
}

.avatar.swapping {
    animation: pop 0.35s ease;
}

@keyframes pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.88) rotate(4deg); }
    100% { transform: scale(1); }
}

.avatar-hint {
    color: var(--muted);
    font-size: 0.8125rem;
    margin-top: 0.625rem;
    font-family: var(--font-display);
    font-style: italic;
    transition: opacity 0.4s ease;
}

.avatar-hint.hidden {
    opacity: 0;
}

/* On mouse devices the hint follows the cursor instead. */
@media (hover: hover) {
    .avatar-hint {
        display: none;
    }
}

.cursor-hint {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    padding: 0.2rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    color: var(--ink);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.875rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.cursor-hint.visible {
    opacity: 1;
}

.hero-title {
    font-family: var(--font-title);
    font-style: italic;
    /* Instrument Serif ships only a 400 weight; 700 makes the browser synthesize a heavier face. */
    font-weight: 700;
    font-size: clamp(2.5rem, 6.5vw, 3.5rem);
    letter-spacing: 0.005em;
    color: var(--title-color);
    min-height: 1.2em;
}

.caret {
    display: inline-block;
    width: 0.06em;
    height: 0.82em;
    margin-left: 0.06em;
    background: var(--title-color);
    vertical-align: -0.04em;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

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

.hero-sub {
    color: var(--muted);
    margin-top: 0.875rem;
}

.hero-text p + p {
    margin-top: 1rem;
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1rem;
}

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-link svg {
    width: 0.9375rem;
    height: 0.9375rem;
    fill: currentColor;
}

.icon-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

/* ---------- side cards (under the icons) ---------- */
.side-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
    text-align: left;
}

.status-line {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.55;
    text-align: center;
}

.status-guess {
    font-style: italic;
    transition: opacity 0.3s ease;
}

.status-guess.fading {
    opacity: 0;
}

.side-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.55;
}

.side-card-title {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.currently-list {
    list-style: none;
}

.currently-list em {
    font-style: italic;
    font-weight: 400;
    color: var(--ink);
}


/* ---------- sections ---------- */
.section {
    padding: 2.5rem 0;
    border-top: 1px solid var(--line);
}

.section-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.625rem;
    margin-bottom: 1.25rem;
}

.section p + p {
    margin-top: 1rem;
}

/* ---------- projects ---------- */
.project {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.15s ease;
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.project:hover {
    border-color: var(--accent);
}

.pub-body {
    flex: 1;
    min-width: 0;
}

.project h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1875rem;
    margin-bottom: 0.375rem;
}

.project p {
    color: var(--muted);
    font-size: 0.9375rem;
}

.pub-fig {
    width: 280px;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 4px;
    align-self: center;
}

.pub-abstract {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.pub-abstract summary {
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent);
    user-select: none;
}

.pub-abstract summary:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.pub-abstract[open] summary {
    margin-bottom: 0.375rem;
}

.pub-links {
    display: flex;
    gap: 1rem;
    margin-top: 0.625rem;
}

.pub-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
}

.pub-btn svg {
    width: 0.875rem;
    height: 0.875rem;
    fill: currentColor;
}

.pub-btn:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.project h3 a {
    color: var(--ink);
    text-decoration: none;
}

.project h3 a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.pub-authors .me {
    font-weight: 600;
    color: var(--ink);
}

.pub-note {
    font-size: 0.8125rem;
    font-style: italic;
}

.pub-meta {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-style: italic;
}

.pub-meta em {
    font-weight: 400;
}


/* ---------- gallery: salon wall ---------- */
.gallery-wall {
    display: grid;
    grid-template-columns: 1fr 1.55fr 1fr;
    gap: 1.125rem;
    align-items: start;
}

.wall-col {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
}

/* Varied frame sizes and offsets — no two neighbors share a width,
   so the wall reads as hung prints rather than a grid. */
.wall-side .gallery-item:nth-child(3n + 1) {
    width: 100%;
}

.wall-side .gallery-item:nth-child(3n + 2) {
    width: 78%;
    align-self: flex-end;
}

.wall-side .gallery-item:nth-child(3n) {
    width: 88%;
    align-self: flex-start;
}

.wall-center .gallery-item:nth-child(odd) {
    width: 100%;
}

.wall-center .gallery-item:nth-child(2) {
    width: 74%;
    align-self: center;
}

.wall-center .gallery-item:nth-child(4) {
    width: 84%;
    align-self: flex-end;
}

/* Framed prints: matte, shadow, and a slightly crooked hang. */
.gallery-item {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.wall-col .gallery-item:nth-child(odd) {
    transform: rotate(-0.7deg);
}

.wall-col .gallery-item:nth-child(even) {
    transform: rotate(0.7deg);
}

.gallery-item:hover,
.gallery-item:focus {
    transform: rotate(0deg);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 2px;
    transition: filter 0.3s ease;
}

.gallery-item figcaption {
    position: absolute;
    inset: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    color: #fff;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover img,
.gallery-item:focus img {
    filter: brightness(0.4);
}

.gallery-item:hover figcaption,
.gallery-item:focus figcaption {
    opacity: 1;
}

.gallery-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Narrow screens: dissolve the three wall columns into one two-column flow. */
@media (max-width: 800px) {
    .gallery-wall {
        display: block;
        column-count: 2;
        column-gap: 0.875rem;
    }

    .wall-col {
        display: contents;
    }

    .gallery-item {
        break-inside: avoid;
        margin-bottom: 0.875rem;
    }

    /* Reset the staggered widths — small screens need the density back. */
    .wall-side .gallery-item,
    .wall-center .gallery-item {
        width: 100%;
    }
}

/* ---------- footer ---------- */
.footer-aside {
    font-size: 0.75rem;
    margin-top: 0.375rem;
    opacity: 0.75;
}

.footer {
    border-top: 1px solid var(--line);
    padding: 2rem 0 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
    font-family: var(--font-display);
    font-style: italic;
}


/* ---------- small screens ---------- */
@media (max-width: 640px) {
    .project {
        flex-direction: column;
    }

    .pub-fig {
        width: 100%;
        align-self: stretch;
    }

    .hero {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        text-align: center;
        padding-top: 2rem;
    }

    /* The "currently" card doesn't earn its space on small screens. */
    .side-card {
        display: none;
    }

    .hero-links {
        justify-content: center;
    }

    .avatar {
        width: 180px;
        height: 180px;
    }
}

@media (max-width: 480px) {
    .nav {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
}
