/*
 * Plain-text layer: the site set like a well-kept text file.
 * One monospace family, one body size, hyperlink-blue links, square corners.
 * Loaded last on the six content pages, so it overrides the inline styles,
 * public-polish.css, and the feature stylesheets. Remove the <link> to undo.
 */

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

:root {
    --bg: #ffffff;
    --bg-alt: #f1f1f1;
    --text: #000000;
    --text-muted: #5c5c5c;
    --accent: #0000ee;
    --accent-hover: #0000ee;
    --border: #d0d0d0;
    --selection: #0000ee2e;
    --mark: #ffff66;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    --size-body: 0.76rem;
    --size-small: 0.68rem;
}

[data-theme="dark"] {
    --bg: #000000;
    --bg-alt: #161616;
    --text: #e6e6e6;
    --text-muted: #9c9c9c;
    --accent: #9d9dff;
    --accent-hover: #9d9dff;
    --border: #333333;
    --selection: #9d9dff40;
    --mark: #4a4a00;
}

/* ---- One family, square corners ---- */

*,
*::before,
*::after {
    font-family: var(--mono) !important;
    border-radius: 0 !important;
}

body {
    font-size: var(--size-body);
    line-height: 1.6;
    font-variant-ligatures: none;
    -webkit-font-smoothing: antialiased;
}

.main * {
    line-height: 1.6;
}

:focus-visible {
    outline: 2px solid var(--accent) !important;
    outline-offset: 2px;
}

/* ---- Links: blue, underlined, inverted on hover ---- */

a.link,
.nav-links a,
.project-title a,
.post-title a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    border-bottom: none;
    transition: none;
}

.side-links a,
.side-links a.ask-ai {
    color: var(--text-muted);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    transition: none;
}

a.link:hover,
.nav-links a:hover,
.project-title a:hover,
.post-title a:hover,
.side-links a:hover,
.pub-links a:hover,
.pub-authors a.link:hover {
    color: var(--bg);
    background: var(--accent);
    text-decoration: none;
    border-bottom: none;
    opacity: 1;
}

.pub-authors a.link {
    color: inherit;
    text-decoration-style: dotted;
}

.ask-ai {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
}

/* ---- Layout: fewer rules ---- */

.main {
    border-left: none;
    padding-left: 2.5rem;
    padding-bottom: 4rem;
}

.layout {
    grid-template-columns: max(170px, 9rem) minmax(0, 1fr);
}

/* ---- Sidebar: pages, then links elsewhere, then controls at the bottom ---- */

.sidebar {
    padding: 3.6rem 0 1.6rem;
    overflow-y: auto;
    scrollbar-width: none;
}

.nav-links {
    margin-bottom: 0;
}

/* Same row spacing as the grey links below; the old per-item margin made
   the page links sit further apart. */
.nav-links li {
    margin-bottom: 0;
}

.side-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 1.5rem;
}

.side-links a {
    line-height: 1.75;
    white-space: nowrap;
}

.side-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 0.55rem;
    margin-top: auto;
    padding-top: 2rem;
    color: var(--text-muted);
}

.side-controls .search-trigger {
    order: 1;
    flex: 0 0 100%;
    justify-content: flex-start;
    padding: 0.3rem 0;
    font-size: var(--size-small);
}

.side-controls .search-trigger svg {
    display: none;
}

.side-controls .search-trigger::before {
    content: 'search';
}

.side-controls .sound-toggle,
.side-controls .text-size-control,
.side-controls .theme-toggle {
    order: 2;
}

.side-controls .sound-toggle {
    width: auto;
    height: auto;
    padding: 0.35rem 0;
}

.side-controls .theme-toggle {
    padding: 0.35rem 0;
}

.side-controls .text-size-btn {
    padding: 0.35rem 0.25rem;
    border: none;
}

.side-note,
.commit-hash {
    flex: 0 0 100%;
    font-size: 0.62rem;
    line-height: 1.6;
    white-space: nowrap;
}

.side-note {
    order: 3;
    margin-top: 0.35rem;
}

.commit-hash {
    order: 4;
}

.nav-links a {
    font-size: inherit;
    line-height: 1.75;
}

.nav-links a.active,
.nav-links a.active:hover {
    color: var(--text);
    background: none;
    font-weight: 700;
    text-decoration: none;
    border-bottom: none;
}

/* ---- Headings carry weight, not size ---- */

.name,
.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.native-name {
    font-size: 0.78em;
    font-weight: 400;
}

.pub-title,
.exp-role,
.project-title,
.post-title,
.entry-title,
.course-name {
    font-size: inherit;
    font-weight: 700;
}

.section-marker {
    font-size: 0.92rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin-top: 2.2rem;
    margin-bottom: 0.8rem;
}

.section-marker::after {
    display: none;
}

/* ---- Body copy at one size ---- */

.update-item,
.exp-org,
.exp-description,
.exp-list,
.project-description,
.coming-soon {
    font-size: inherit;
}

.page-note,
.pub-authors,
.pub-venue,
.pub-context,
.pub-abstract,
.course-prof,
.entry-note,
.post-excerpt,
.handle,
.pronunciation-guide,
.update-date,
.entry-when,
.exp-period,
.semester,
.pub-number {
    font-size: var(--size-small);
}

.page-note {
    font-style: normal;
}

/* ---- Home ---- */

.profile-photo {
    width: 168px;
    height: 168px;
    box-shadow: none;
}

.pronunciation-button {
    border: none;
    background: none;
}

.update-media {
    background: none;
}

/* ---- Pixel art: three small drawings, one pixel = 3px, drawn in the text
   color through a mask so they follow light and dark mode. Sources are the
   ASCII grids inside assets/img/pixel/*.svg. ---- */

/* A wave under the name block */
.profile-copy::after {
    content: '';
    display: block;
    height: 12px;
    margin-top: 0.85rem;
    background: var(--text);
    -webkit-mask: url(../img/pixel/wave.svg) repeat-x left center / 24px 12px;
    mask: url(../img/pixel/wave.svg) repeat-x left center / 24px 12px;
}

/* Sparkles in the ring around the photo (216px box around the 168px photo) */
.profile-header {
    position: relative;
}

.profile-header::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -24px;
    width: 216px;
    height: 216px;
    margin-top: -108px;
    pointer-events: none;
    background: var(--text);
    -webkit-mask: url(../img/pixel/sparkles.svg) no-repeat center / 216px 216px;
    mask: url(../img/pixel/sparkles.svg) no-repeat center / 216px 216px;
}

/* A flower below the sidebar links */
.side-links::after {
    content: '';
    display: block;
    width: 39px;
    height: 63px;
    margin-top: 2.2rem;
    background: var(--text);
    -webkit-mask: url(../img/pixel/flower.svg) no-repeat center / 39px 63px;
    mask: url(../img/pixel/flower.svg) no-repeat center / 39px 63px;
}

/* Dates in the news and writing lists read as [Jul 2026] */

.update-date::before,
.post-date::before {
    content: '[';
}

.update-date::after,
.post-date::after {
    content: ']';
}

.update-item {
    grid-template-columns: 6.2rem minmax(0, 1fr);
}

.chatbot-bubble:hover {
    transform: none;
}

/* ---- Blue is for links only ---- */

.pub-number,
.semester,
.exp-list li::before {
    color: var(--text-muted);
}

.semester {
    text-transform: none;
    letter-spacing: 0;
}

.timeline-entry.major .entry-title,
.timeline-entry:hover .entry-title {
    color: var(--text);
}

.timeline-entry.major::before,
.timeline-entry.now::before {
    background: var(--text);
    border-color: var(--text);
}

.timeline-entry:hover::before {
    background: var(--text);
    border-color: var(--text);
}

.timeline-entry.now::before,
[data-theme="dark"] .timeline-entry.now::before {
    animation: now-blink 1.2s step-end infinite;
    box-shadow: none;
}

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

@media (prefers-reduced-motion: reduce) {
    .timeline-entry.now::before,
    [data-theme="dark"] .timeline-entry.now::before {
        animation: none;
    }
}

.era-label {
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--size-small);
    opacity: 1;
}

/* ---- Lists of things: whitespace instead of rules and chips ---- */

.pub-item,
.exp-item,
.project-item,
.post-content {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 2.1rem;
}

.pub-abstract,
.teaching-block {
    border-left: 1px solid var(--border);
}

.exp-period,
.tech-tag,
.post-tag {
    background: none;
    padding: 0;
    color: var(--text-muted);
}

.tech-tag,
.post-tag {
    font-size: var(--size-small);
}

.project-tech,
.post-tags {
    gap: 0.1rem 1rem;
}

/* Each paper: its figure on the left, the citation on the right.
   Papers without a figure keep the same text column. */

.pub-item {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    column-gap: 1.4rem;
    align-items: start;
    max-width: 820px;
}

.pub-body {
    grid-column: 2;
    min-width: 0;
}

.pub-figure {
    grid-column: 1;
    align-self: center;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    background: #ffffff;
    cursor: zoom-in;
    appearance: none;
}

.pub-figure img {
    display: block;
    width: 100%;
    height: auto;
}

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

/* Abstracts stay out of the way until asked for */

.pub-abstract.collapsed {
    display: none;
}

.pub-abstract {
    margin: 0.5rem 0 0.6rem;
}

.pub-venue {
    margin-bottom: 0.35rem;
}

/* Actions read as [bracketed] text links */

.pub-links {
    gap: 0.2rem 0.9rem;
}

.pub-links a,
.toggle-abstract,
.toggle-abstract:hover {
    font-size: var(--size-small);
    color: var(--accent);
    background: none;
    border: none;
    padding: 0;
    transition: none;
}

.pub-links a::before,
.toggle-abstract::before {
    content: '[';
}

.pub-links a::after,
.toggle-abstract::after {
    content: ']';
}

.pub-links a:hover,
.toggle-abstract:hover {
    color: var(--bg);
    background: var(--accent);
}

/* Linked-to item: highlighter instead of a glow */

.pub-item:target,
.timeline-entry:target,
.agent-anchor-highlight {
    outline: none;
    box-shadow: none;
    background: var(--mark);
    animation: none;
}

/* ---- Controls: quiet text, no boxes ---- */

.theme-toggle,
.sound-toggle,
.search-trigger,
.text-size-btn,
.text-size-btn:first-child,
.text-size-btn:last-child {
    border-color: transparent;
    background: none;
    transition: none;
}

.theme-toggle:hover,
.sound-toggle:hover,
.sound-toggle.sound-is-on,
.search-trigger:hover,
.text-size-btn:hover {
    border-color: transparent;
    color: var(--accent);
}

.commit-hash {
    opacity: 1;
}

/* ---- Overlays ---- */

/* No bottom bar to clear any more */

.chatbot-bubble {
    bottom: 1.5rem;
}

.chatbot-window {
    bottom: calc(1.5rem + var(--chatbot-bubble-size) + 10px);
}

.toast {
    bottom: 1.75rem;
}

.search-input {
    font-size: 0.8rem;
}

.search-results:empty::after,
.search-result-title {
    font-size: var(--size-body);
}

.search-result-preview {
    font-size: var(--size-small);
}

.chatbot-msg-bot,
.chatbot-msg-user,
.chatbot-msg-system,
.chatbot-input,
.chatbot-send {
    font-size: 0.72rem;
    line-height: 1.55;
}

.ai-picker-heading h2 {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0;
}

.ai-picker-heading p {
    font-size: var(--size-small);
}

.ai-picker-choice-copy strong {
    font-size: var(--size-body);
    font-weight: 700;
}

/* ---- Mobile ---- */

@media (max-width: 768px) {
    body {
        font-size: 0.8rem;
    }

    .main {
        padding-left: 0;
    }

    .nav-links a,
    .nav-links a.active {
        font-size: inherit;
        border-bottom: none;
    }

    /* Home: the photo sits centered under the name block */
    .profile-photo {
        width: 148px;
        height: 148px;
        margin: 2.6rem auto 0;
    }

    /* Room above and below the photo for its ring of sparkles */
    .profile-header {
        margin-bottom: 2.6rem;
    }

    /* Photo is centered and last in the header here, so the sparkles
       center on it from the bottom edge. The flower stays desktop-only. */
    .profile-header::after {
        top: auto;
        right: auto;
        bottom: -34px;
        left: 50%;
        margin: 0 0 0 -108px;
    }

    .side-links::after {
        display: none;
    }

    .pub-item {
        display: block;
    }

    .pub-figure {
        max-width: 18rem;
        margin: 0 0 0.8rem;
    }

    .pub-figure img {
        width: 100%;
    }

    /* The sidebar dissolves: pages on top, links and controls after the content */
    .layout {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        display: contents;
    }

    .nav-links {
        order: 0;
        padding: 2rem 0 1rem;
        border-bottom: 1px solid var(--border);
    }

    .main {
        order: 1;
        padding-bottom: 2.5rem;
    }

    .side-links {
        order: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.2rem 1rem;
        margin-top: 0;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border);
    }

    .side-controls {
        order: 3;
        justify-content: center;
        gap: 0.2rem 0.8rem;
        margin-top: 0;
        /* Leave room so the chatbot bubble never sits on top of the controls */
        padding: 1rem 0 calc(var(--chatbot-bubble-size, 82px) + 2rem);
    }

    .side-controls .search-trigger,
    .side-note,
    .commit-hash {
        flex: 0 0 auto;
        margin-top: 0;
    }

    .side-controls .search-trigger,
    .side-controls .sound-toggle,
    .side-controls .text-size-control,
    .side-controls .theme-toggle {
        order: 1;
    }

    .side-note {
        order: 2;
        flex-basis: 100%;
        text-align: center;
    }

    .commit-hash {
        order: 3;
        flex-basis: 100%;
        text-align: center;
    }

    .chatbot-bubble {
        bottom: 1rem;
    }

    .chatbot-window {
        bottom: calc(1rem + var(--chatbot-bubble-size) + 8px);
    }

    .toast {
        bottom: calc(1rem + var(--chatbot-bubble-size, 82px) + 0.75rem);
    }
}
