:root {
    color-scheme: light;
    --bs-body-color: #27343d;
    --bs-body-color-rgb: 39, 52, 61;
    --bs-body-bg: #eef5e5;
    --bs-body-bg-rgb: 238, 245, 229;
    --bs-link-color: #1b5269;
    --bs-link-color-rgb: 27, 82, 105;
    --bs-link-hover-color: #164b63;
    --bs-link-hover-color-rgb: 22, 75, 99;
    --bs-emphasis-color: #17242d;
    --bs-emphasis-color-rgb: 23, 36, 45;
    --bs-secondary-color: #3f4c55;
    --bs-secondary-color-rgb: 63, 76, 85;
    --bs-secondary-rgb: 63, 76, 85;
    --bs-border-color: #d5e1ed;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    --site-accent: #1b5269;
    --site-muted: #3f4c55;
    --site-border: #d5e1ed;
    --site-divider: #e3e8eb;
    --site-surface: #f7f9fc;
    --site-surface-hover: #edf3f9;
    --site-banner-text: #17466d;
    --site-nav-color: #27343d;
    --site-nav-active: #123b4d;
    --site-header-glass: rgba(255, 255, 255, .64);
    --site-header-border: rgba(227, 232, 235, .75);
    --site-header-shadow: rgba(39, 52, 61, .05);
    --site-toggle-hover: rgba(35, 107, 137, .09);
}
[data-bs-theme="dark"] {
    color-scheme: dark;
    --bs-body-color: #e5edf3;
    --bs-body-color-rgb: 229, 237, 243;
    --bs-body-bg: #111a22;
    --bs-body-bg-rgb: 17, 26, 34;
    --bs-link-color: #90c8e0;
    --bs-link-color-rgb: 144, 200, 224;
    --bs-link-hover-color: #bfe5f4;
    --bs-link-hover-color-rgb: 191, 229, 244;
    --bs-emphasis-color: #f5f8fa;
    --bs-emphasis-color-rgb: 245, 248, 250;
    --bs-secondary-color: #a9b7c3;
    --bs-secondary-color-rgb: 169, 183, 195;
    --bs-secondary-rgb: 169, 183, 195;
    --bs-border-color: #344957;
    --site-accent: #7bbbd8;
    --site-muted: #a9b7c3;
    --site-border: #344957;
    --site-divider: #2a3c49;
    --site-surface: #192630;
    --site-surface-hover: #223440;
    --site-banner-text: #c3e1ee;
    --site-nav-color: #f1f5f8;
    --site-nav-active: #f3f8fc;
    --site-header-glass: rgba(17, 26, 34, .64);
    --site-header-border: rgba(72, 96, 113, .65);
    --site-header-shadow: rgba(0, 0, 0, .2);
    --site-toggle-hover: rgba(144, 200, 224, .12);
}
html { scroll-padding-top: 5rem; }
body { font-size: 1.05rem; line-height: 1.75; isolation: isolate; }

/* Decorative backgrounds stay behind the content; text remains fully opaque. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}
:is([data-bs-theme="light"], [data-bs-theme="rain"]) body::before {
    background-color: var(--bs-body-bg);
    background-image: url("img/pixel-grass-tile.png?v=top-left-flower");
    background-size: 384px 384px;
    background-repeat: repeat;
    image-rendering: pixelated;
    opacity: .43;
}
[data-bs-theme="dark"] body::before {
    background-color: var(--bs-body-bg);
    background-image:
        radial-gradient(ellipse at 50% 38%, rgba(17, 26, 34, .42), rgba(17, 26, 34, .22) 50%, rgba(17, 26, 34, 0) 85%),
        url("img/hubble_n44_wfc3_new_large_1mb-jpg.webp");
    background-position: center, center 40%;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: .18;
}
@media print, (forced-colors: active), (prefers-reduced-transparency: reduce) {
    body::before { display: none; }
}

::selection { background-color: #ffe680; color: #1b2731; text-shadow: none; }
@media (forced-colors: active) {
    ::selection { background-color: Highlight; color: HighlightText; }
}
.container { max-width: 1040px; }
a { text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
.site-header { position: sticky; top: 0; z-index: 1020; background: var(--bs-body-bg); border-top: 2px solid var(--site-accent); border-bottom: 1px solid var(--site-header-border); box-shadow: 0 2px 12px var(--site-header-shadow); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .site-header { background: var(--site-header-glass); -webkit-backdrop-filter: blur(7px) saturate(120%); backdrop-filter: blur(7px) saturate(120%); }
}
@media (prefers-reduced-transparency: reduce) {
    .site-header { background: var(--bs-body-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.navbar { padding-top: .5rem; padding-bottom: .5rem; line-height: 1.5; }
.site-header .navbar { max-width: 1120px; }
.navbar-brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--site-nav-color); font-size: 1.45rem; line-height: 1.25; padding-top: .2rem; padding-bottom: .2rem; font-weight: 650; letter-spacing: -.04em; }
.navbar-brand:hover, .navbar-brand:focus { color: var(--site-nav-active); }
.brand-telescope { display: block; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; }

/* The GIF supplies the cat's motion; this layer carries it across the header. */
.header-cat { --cat-width: 5.25rem; position: absolute; inset: 0; overflow: hidden; pointer-events: none; user-select: none; z-index: 2; }
.header-cat-track { position: absolute; inset: 0; }
.header-cat.is-running .header-cat-track { animation: header-cat-cross var(--cat-duration) linear both; }
.header-cat-image { position: absolute; bottom: 0; left: 100%; display: block; width: var(--cat-width); height: auto; }
@keyframes header-cat-cross {
    from { transform: translateX(0); }
    to { transform: translateX(calc(-100% - var(--cat-width))); }
}
@media (prefers-reduced-motion: reduce), print {
    .header-cat { display: none; }
}

.navbar .nav-link { color: var(--site-nav-color); font-size: .94rem; }
/* Move the small GIF itself; its own frames supply the light pulse. */
.shooting-star { display: none; position: fixed; inset: 0; overflow: hidden; pointer-events: none; user-select: none; z-index: 1; }
[data-bs-theme="dark"] .shooting-star.is-running { display: block; }
.shooting-star img { position: absolute; left: var(--star-x); top: var(--star-y); width: var(--star-size); height: auto; animation: shooting-star-cross 2s linear both; }
@keyframes shooting-star-cross {
    from { transform: translate(0, 0); }
    to { transform: translate(calc(0px - var(--star-distance)), var(--star-distance)); }
}
@media (prefers-reduced-motion: reduce), print {
    .shooting-star { display: none !important; }
}

.navbar .nav-link.active { color: var(--site-nav-active); text-decoration: underline; text-underline-offset: .4em; }
.navbar-toggler { border-color: var(--site-border); }
.theme-toggle-item { display: flex; align-items: center; margin-left: .25rem; }
.theme-toggle { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid transparent; border-radius: 50%; color: var(--site-nav-color); background: transparent; cursor: pointer; }
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--site-nav-active); background: var(--site-toggle-hover); border-color: var(--site-border); }
.theme-toggle:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 3px; }
.theme-icon { display: block; width: 1.2rem; height: 1.2rem; }
.theme-icon--sun, .theme-icon--rain { display: none; }
:is([data-bs-theme="dark"], [data-bs-theme="rain"]) .theme-icon--moon { display: none; }
[data-bs-theme="dark"] .theme-icon--rain, [data-bs-theme="rain"] .theme-icon--sun { display: block; }
@media (min-width: 576px) {
    .site-header .navbar-nav { align-items: center; }
}
.btn-outline-primary { --bs-btn-color: var(--bs-link-color); --bs-btn-border-color: var(--bs-link-color); --bs-btn-hover-color: var(--bs-body-bg); --bs-btn-hover-bg: var(--bs-link-color); --bs-btn-hover-border-color: var(--bs-link-color); --bs-btn-focus-shadow-rgb: var(--bs-link-color-rgb); --bs-btn-active-color: var(--bs-body-bg); --bs-btn-active-bg: var(--bs-link-color); --bs-btn-active-border-color: var(--bs-link-color); --bs-btn-disabled-color: var(--bs-link-color); --bs-btn-disabled-border-color: var(--bs-link-color); }
.site-main { padding-top: 3rem; padding-bottom: 4rem; min-height: 65vh; }
/* A quiet reading surface fades into the garden along the outer edges. */
:is([data-bs-theme="light"], [data-bs-theme="rain"]) .site-main {
    --reading-surface: rgba(var(--bs-body-bg-rgb), .96);
    position: relative;
    isolation: isolate;
}
:is([data-bs-theme="light"], [data-bs-theme="rain"]) .site-main::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--reading-surface);
    box-shadow: 0 0 2rem 1.25rem var(--reading-surface);
}
/* Keep the soft edge behind the footer's text as well. */
:is([data-bs-theme="light"], [data-bs-theme="rain"]) .site-footer { position: relative; z-index: 0; }
@media (max-width: 767.98px) {
    :is([data-bs-theme="light"], [data-bs-theme="rain"]) .site-main { --reading-surface: var(--bs-body-bg); }
}

/* A sparse, faint shower drifts down and slightly right without catching clicks. */
.rain-layer { display: none; position: fixed; inset: 0; overflow: hidden; pointer-events: none; user-select: none; z-index: 2; opacity: .36; }
[data-bs-theme="rain"] .rain-layer { display: block; }
.rain-layer span {
    position: absolute;
    top: -2rem;
    left: var(--rain-x);
    width: 1.44px;
    height: var(--rain-length);
    background: linear-gradient(transparent, rgba(58, 117, 175, .8));
    background-position: bottom;
    background-repeat: no-repeat;
    animation: rain-fall var(--rain-duration) linear var(--rain-delay) infinite;
}
@keyframes rain-fall {
    from { transform: translate3d(0, 0, 0) rotate(-8deg); }
    to { transform: translate3d(14vh, calc(100vh + 4rem), 0) rotate(-8deg); }
}
.rain-layer .rain-drop--landing { animation-name: rain-land; }
.rain-drop--landing::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 5px;
    height: 1.5px;
    border: 1px solid rgba(58, 117, 175, .95);
    border-radius: 50%;
    opacity: 0;
    animation: rain-splash var(--rain-duration) linear var(--rain-delay) infinite;
}
@keyframes rain-land {
    0% { transform: translate3d(0, 0, 0) rotate(-8deg); }
    0%, 76% { background-size: 100% 100%; }
    80%, 100% {
        transform: translate3d(var(--rain-drift), calc(var(--rain-end) + 2rem - var(--rain-length)), 0) rotate(-8deg);
        background-size: 100% 0%;
    }
}
@keyframes rain-splash {
    0%, 79% { opacity: 0; transform: translate(-50%, -50%) rotate(8deg) scale(.3); }
    83% { opacity: 1; transform: translate(-50%, -50%) rotate(8deg) scale(.6); }
    89% { opacity: 1; transform: translate(-50%, -50%) rotate(8deg) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(8deg) scale(1.6); }
}
@media (prefers-reduced-motion: reduce), (forced-colors: active), print {
    .rain-layer { display: none !important; }
}
.rain-worm { display: none; position: fixed; width: 64px; height: 64px; pointer-events: none; user-select: none; z-index: 3; image-rendering: pixelated; }
[data-bs-theme="rain"] .rain-worm.is-visible { display: block; }
@media (prefers-reduced-motion: reduce), (forced-colors: active), print {
    .rain-worm { display: none !important; }
}
.page-title { margin-bottom: 2rem; font-size: 1.8rem; font-weight: 550; letter-spacing: -.035em; }
.intro-heading { font-size: 1.5rem; font-weight: 550; margin-bottom: 1.25rem; }
.profile p { margin-bottom: .65rem; }
.portrait { display: block; width: 100%; height: auto; border-radius: 3px; }
.profile-links { display: flex; flex-wrap: wrap; gap: .35rem .75rem; margin-top: .75rem; font-size: .875rem; }
.profile-links a { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.link-icon { display: inline-block; width: 1.25rem; height: 1.25rem; flex-shrink: 0; object-fit: contain; }
.profile-links .link-icon { width: 1.125rem; height: 1.125rem; }
.profile-contact { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.contact-link { display: inline-flex; align-items: center; gap: .55rem; width: fit-content; }
[data-bs-theme="dark"] .contact-link .link-icon { filter: brightness(1.85) saturate(.75); }
[data-bs-theme="dark"] .profile-links .link-icon[src$="linkedin.svg"] { filter: brightness(1.45); }
.ukraine-support { display: flex; align-items: center; gap: 1rem; margin-top: 3rem; padding: 1rem 1.25rem; border: 1px solid var(--site-border); border-radius: 4px; background: var(--site-surface); color: var(--site-banner-text); font-size: .95rem; text-decoration: none; }
.ukraine-support:hover { border-color: var(--site-accent); background: var(--site-surface-hover); color: var(--bs-link-hover-color); }
.ukraine-support:focus-visible { outline: 3px solid var(--site-accent); outline-offset: 3px; }
.ukraine-flag { flex: 0 0 2.4rem; height: 1.6rem; background: linear-gradient(to bottom, #0057b7 50%, #ffd700 50%); }
.support-arrow { margin-left: auto; font-size: 1.25rem; }
.site-footer { border-top: 3px solid var(--site-border); padding-top: 1.3rem; padding-bottom: 2rem; font-size: .85rem; color: var(--site-muted); }
.background-credit { display: none; margin: .4rem 0 0; }
[data-bs-theme="dark"] .background-credit { display: block; }
.contact-details dt { font-size: .9rem; color: var(--site-muted); font-weight: 500; margin-top: 1.5rem; }
.research-entry { margin-bottom: 2rem; }
.research-entry h3 { line-height: 1.5; }
.research-entry p { margin-bottom: .6rem; }
.research-links { font-size: .95rem; }
.paper-abstract { margin-top: .5rem; }
.paper-abstract > summary { position: relative; display: inline-flex; align-items: center; gap: .5rem; list-style: none; cursor: pointer; color: var(--bs-link-color); font-size: .95rem; }
.paper-abstract > summary::-webkit-details-marker { display: none; }
.paper-abstract > summary::before { content: ""; width: 0; height: 0; border-top: .3rem solid transparent; border-bottom: .3rem solid transparent; border-left: .45rem solid currentColor; transition: transform .18s ease; }
.paper-abstract[open] > summary::before { transform: rotate(90deg); }
.paper-abstract > summary:hover { text-decoration: underline; text-underline-offset: .2em; }
.paper-abstract > summary:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 2px; }
.abstract-text { max-width: 78ch; margin-top: .65rem; padding-left: 1rem; border-left: 2px solid var(--site-border); }
.research-entry .abstract-text p { margin-bottom: 0; text-align: justify; text-align-last: left; hyphens: auto; }

/* Keep the drawings beside the Abstract label without shifting the text. */
.paper-surprise { position: absolute; left: calc(100% + .75rem); top: 50%; transform: translateY(-50%); width: 9rem; height: 24px; z-index: 1; pointer-events: none; user-select: none; animation: surprise-fade 2s ease both; }
.surprise-stage { position: absolute; inset: 0; }
.surprise-character { position: absolute; top: 0; left: var(--slot); width: 24px; height: 24px; transform: translateX(-50%); }
.surprise-character svg { display: block; width: 100%; height: 100%; overflow: visible; animation: surprise-peek 1.8s ease-in-out both; animation-delay: var(--delay); }
.surprise-character .egg-blink { transform-box: fill-box; transform-origin: center; animation: surprise-blink 1.7s linear both; animation-delay: var(--delay); }
.surprise-character--money svg { animation-name: surprise-banknote; }
[data-bs-theme="dark"] .surprise-character--observer svg > g { stroke: #abc8d8; }
@keyframes surprise-fade {
    0% { opacity: 0; }
    12%, 74% { opacity: .9; }
    100% { opacity: 0; }
}
@keyframes surprise-peek {
    0%, 100% { transform: translateY(3px) scale(.94); }
    22%, 64% { transform: translateY(-2px) rotate(var(--tilt)); }
    43%, 82% { transform: translateY(0) rotate(calc(0deg - var(--tilt))); }
}
@keyframes surprise-blink {
    0%, 21%, 29%, 62%, 70%, 100% { transform: scaleY(1); }
    25%, 66% { transform: scaleY(.08); }
}
@keyframes surprise-banknote {
    0%, 100% { transform: translateY(2px) rotate(-8deg); }
    28%, 72% { transform: translateY(-4px) rotate(8deg); }
    50% { transform: translateY(0) rotate(-4deg); }
}
@media (prefers-reduced-motion: reduce) {
    .paper-abstract > summary::before { transition: none; }
    .paper-surprise { display: none; }
}
.cv-preview { display: block; width: 100%; height: 80vh; min-height: 28rem; border: 1px solid var(--site-border); border-radius: 4px; background: var(--site-surface); }
.cv-preview > p { padding: 1.25rem; }
.skip-link { position: absolute; z-index: 1100; background: var(--bs-body-bg); padding: .6rem 1rem; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Keep the About page compact without shrinking text or clipping content. */
body:has(.profile) { line-height: 1.6; }
.site-main:has(.profile) { padding-top: 1rem; padding-bottom: 3.75rem; min-height: 0; }
.site-main:has(.profile) .page-title { margin-bottom: .75rem; }
.profile .intro-heading { margin-bottom: .65rem; }
.profile .profile-contact { margin-bottom: 0; }
.profile .portrait { max-width: 250px; }
.site-main:has(.profile) .ukraine-support { margin-top: 1rem; padding: .65rem 1rem; }
body:has(.profile) .site-footer { padding-top: .65rem; padding-bottom: .65rem; }

@media (max-width: 575.98px) {
    html:has(.navbar-collapse.show) { scroll-padding-top: 14rem; }
    .container { padding-left: 1.4rem; padding-right: 1.4rem; }
    .site-main { padding-top: 2rem; }
    .profile .portrait { max-width: 220px; }
    .navbar-collapse { padding-top: .75rem; }
    .theme-toggle-item { margin-left: 0; margin-top: .25rem; }
}
