/* ===== Dark theme (default) — "Deep Space" ===== */
:root {
    --bg: #060912;
    --text: #e8edf5;
    --text-body: #cbd5e1;
    --text-dim: #8b98ad;
    --accent: #38bdf8;
    --accent-2: #a78bfa;
    --accent-contrast: #06131f;
    --card: rgba(17, 24, 39, 0.6);
    --border: #1c2739;
    --border-hover: #31415c;
    --glow: rgba(56, 189, 248, 0.12);
    --h1-from: #ffffff;
    --h1-mid: #38bdf8;
    --h1-to: #a78bfa;
    --tag-color: #a78bfa;
    --tag-border: rgba(167, 139, 250, 0.35);
    --ctrl-bg: rgba(13, 19, 32, 0.75);
    --btn-bg: rgba(30, 41, 59, .8);
    --shadow-card: 0 0 30px rgba(56,189,248,.07);
    --mono: "JetBrains Mono", ui-monospace, monospace;
}
/* ===== Light theme — "Academic Paper" ===== */
html[data-theme="light"] {
    --bg: #faf8f4;
    --text: #1c1917;
    --text-body: #44403c;
    --text-dim: #78716c;
    --accent: #1e40af;
    --accent-2: #7c3aed;
    --accent-contrast: #ffffff;
    --card: #ffffff;
    --border: #e7e2d9;
    --border-hover: #cbc2b2;
    --glow: rgba(30, 64, 175, 0.10);
    --h1-from: #1c1917;
    --h1-mid: #1e40af;
    --h1-to: #4338ca;
    --tag-color: #7c3aed;
    --tag-border: rgba(124, 58, 237, 0.35);
    --ctrl-bg: rgba(255, 255, 255, 0.85);
    --btn-bg: #f5f2ec;
    --shadow-card: 0 4px 16px rgba(28,25,23,.08);
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    margin: 0;
    transition: background .4s ease, color .4s ease;
}
h1, h2, .subtitle, .project-name { font-family: "Exo 2", sans-serif; }

/* ===== Backdrops: stars for dark, constellation for light ===== */
.bg-glow {
    position: fixed; inset: 0; z-index: -3; pointer-events: none;
    background:
        radial-gradient(ellipse 60% 40% at 75% -5%, var(--glow), transparent 60%),
        radial-gradient(ellipse 50% 35% at 15% 10%, var(--glow), transparent 65%);
    transition: opacity .4s;
}
.stars {
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,.7), transparent 50%),
        radial-gradient(1px 1px at 35% 65%, rgba(255,255,255,.5), transparent 50%),
        radial-gradient(1.5px 1.5px at 60% 12%, rgba(255,255,255,.65), transparent 50%),
        radial-gradient(1px 1px at 82% 42%, rgba(255,255,255,.45), transparent 50%),
        radial-gradient(1px 1px at 22% 88%, rgba(255,255,255,.5), transparent 50%),
        radial-gradient(1.5px 1.5px at 92% 78%, rgba(255,255,255,.6), transparent 50%),
        radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,.35), transparent 50%),
        radial-gradient(1px 1px at 70% 92%, rgba(255,255,255,.45), transparent 50%);
    background-size: 550px 550px;
    animation: twinkle 6s ease-in-out infinite alternate;
    transition: opacity .5s;
}
.stars-2 { z-index: -1; background-size: 350px 350px; opacity: .5; animation-duration: 9s; animation-delay: -3s; }
@keyframes twinkle { from { opacity: .9; } to { opacity: .45; } }
html[data-theme="light"] .stars { opacity: 0; animation: none; }
html[data-theme="light"] .stars-2 { opacity: 0; animation: none; }

/* Sparse constellation layer, both themes */
.sky {
    position: fixed; inset: 0; width: 100%; height: 100%;
    z-index: -1; pointer-events: none;
    opacity: .3; transition: opacity .5s;
}
html[data-theme="light"] .sky { opacity: .45; }
.sky line { stroke: var(--border-hover); stroke-width: 1; }
.sky circle { fill: var(--accent); opacity: .6; }
.sky .lone { opacity: .25; }

/* Deep-sky objects — muted, slightly blurred, pure backdrop.
   The dark theme needs noticeably more opacity than the light one:
   thin cyan strokes sink into the near-black background. */
.deep-objects {
    position: fixed; inset: 0; width: 100%; height: 100%;
    z-index: -1; pointer-events: none;
    filter: blur(1.6px);
    opacity: .25; transition: opacity .5s;
}
html[data-theme="light"] .deep-objects { opacity: .13; filter: blur(1.8px); }
.deep-objects .stroke { stroke: var(--accent); fill: none; }
.deep-objects .glow { fill: var(--accent); }
.deep-objects .glow-pulse { animation: sourcePulse 9s ease-in-out infinite; }
@keyframes sourcePulse { 0%, 100% { opacity: .3; } 50% { opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
    .deep-objects .glow-pulse { animation: none; opacity: .4; }
}

.container { max-width: 680px; margin: 0 auto; padding: 88px 20px 60px; }

/* ===== Top-right controls: theme toggle + language menu ===== */
.controls {
    position: fixed; top: 18px; right: 18px; z-index: 20;
    display: flex; gap: 8px; align-items: center;
}
.ctrl-btn {
    display: flex; align-items: center; gap: 7px;
    background: var(--ctrl-bg); border: 1px solid var(--border);
    color: var(--text); border-radius: 999px; cursor: pointer;
    padding: 7px 12px; backdrop-filter: blur(8px);
    font-family: var(--mono); font-size: .8rem; font-weight: 600;
    transition: border-color .25s, transform .15s;
}
.ctrl-btn:hover { border-color: var(--accent); }
.ctrl-btn:active { transform: scale(.95); }
.ctrl-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .icon-sun { display: none; }
html[data-theme="light"] .theme-btn .icon-sun { display: block; }
html[data-theme="light"] .theme-btn .icon-moon { display: none; }
.lang-flag { font-size: 1rem; line-height: 1; }
.lang-chevron { width: 12px !important; height: 12px !important; transition: transform .2s; }
.lang-wrap { position: relative; }
.lang-wrap.open .lang-chevron { transform: rotate(180deg); }
.lang-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--ctrl-bg); border: 1px solid var(--border); border-radius: 12px;
    backdrop-filter: blur(10px); padding: 5px; min-width: 150px;
    box-shadow: 0 12px 30px rgba(0,0,0,.25);
    opacity: 0; transform: translateY(-6px); pointer-events: none;
    transition: opacity .18s, transform .18s;
}
.lang-wrap.open .lang-dropdown { opacity: 1; transform: none; pointer-events: auto; }
.lang-option {
    display: flex; align-items: center; gap: 9px; width: 100%;
    background: none; border: none; color: var(--text); cursor: pointer;
    padding: 8px 12px; border-radius: 8px; font-size: .85rem; text-align: left;
    transition: background .15s;
}
.lang-option:hover { background: var(--btn-bg); }
.lang-option.active { color: var(--accent); font-weight: 600; }
.lang-option .check { margin-left: auto; opacity: 0; }
.lang-option.active .check { opacity: 1; }

/* ===== Header ===== */
.header-grid {
    display: grid; grid-template-columns: 1fr 150px;
    gap: 32px; align-items: center; margin-bottom: 44px;
}
h1 {
    font-size: 2.6rem; font-weight: 700; margin: 0 0 8px; letter-spacing: -1px;
    background: linear-gradient(120deg, var(--h1-from) 40%, var(--h1-mid) 85%, var(--h1-to));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle { font-size: 1.15rem; color: var(--text-dim); font-weight: 400; }

.profile-photo-container { display: flex; justify-content: flex-end; }
.profile-photo-wrapper {
    width: 150px; height: 150px; border-radius: 50%; overflow: hidden;
    padding: 3px;
    background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--border) 40%, var(--border) 60%, var(--accent));
    box-shadow: 0 10px 35px rgba(0,0,0,.3), 0 0 30px var(--glow);
    transition: transform .35s ease, box-shadow .35s ease;
}
.profile-photo-wrapper:hover { transform: scale(1.03) rotate(1deg); }
.profile-photo {
    width: 100%; height: 100%; object-fit: cover; object-position: center 22%;
    border-radius: 50%; display: block;
}

/* ===== Contacts ===== */
.grid-contacts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px; margin-bottom: 12px;
}

/* Academic profile links (ORCID, ADS) under the contact cards */
.links-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.link-pill {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--mono); font-size: .75rem; font-weight: 600;
    color: var(--text); text-decoration: none;
    background: var(--card); border: 1px solid var(--border); border-radius: 999px;
    padding: 6px 14px; transition: all .25s;
}
.link-pill:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.link-pill .orcid-dot {
    width: 15px; height: 15px; border-radius: 50%; background: #a6ce39;
    color: #fff; font-size: .55rem; font-weight: 700; font-style: normal;
    display: inline-flex; align-items: center; justify-content: center;
}
.link-pill .ads-dot {
    width: 15px; height: 15px; border-radius: 50%; background: #1c459b;
    display: inline-flex; align-items: center; justify-content: center;
}
.link-pill .ads-dot::after {
    content: ""; width: 5px; height: 5px; border-radius: 50%;
    background: #fff; box-shadow: 0 -4px 0 -1.5px #fff, 4px 2px 0 -1.5px #fff;
}
.link-pill .dl-icon {
    width: 14px; height: 14px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.contact-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 16px; position: relative; backdrop-filter: blur(4px);
    transition: border-color .25s, transform .25s, background .4s;
}
.contact-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.contact-label {
    font-family: var(--mono); font-size: 0.68rem; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px;
}
.contact-row { display: flex; align-items: center; justify-content: space-between; }
.contact-value a {
    color: var(--text); text-decoration: none; font-weight: 600;
    font-family: var(--mono); font-size: 0.9rem; transition: color .2s;
}
.contact-value a:hover { color: var(--accent); }
.copy-btn {
    background: none; border: none; color: var(--text-dim); cursor: pointer;
    padding: 5px; border-radius: 6px; display: flex; transition: all .2s;
}
.copy-btn:hover { color: var(--accent); background: var(--glow); }
.copy-btn svg { width: 15px; height: 15px; fill: currentColor; }
.tooltip {
    position: absolute; right: 14px; top: 9px;
    background: #10b981; color: #fff; font-size: .68rem; font-weight: 600;
    padding: 2px 8px; border-radius: 5px; opacity: 0;
    transition: opacity .2s; pointer-events: none;
}

/* ===== Sections ===== */
h2 {
    display: flex; align-items: center; gap: 14px;
    font-size: 0.92rem; font-weight: 600; color: var(--accent);
    margin: 60px 0 22px; text-transform: uppercase; letter-spacing: 2.5px;
}
h2::after {
    content: ""; flex: 1; height: 1px;
    background: linear-gradient(90deg, var(--border-hover), transparent);
}
p { color: var(--text-body); font-size: 1rem; }

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 28px; display: flex; flex-direction: column; gap: 26px; }
.timeline::before {
    content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2) 60%, transparent);
    opacity: .45; border-radius: 2px;
}
.timeline-item { position: relative; }
.timeline-item::before {
    content: ""; position: absolute; left: -28px; top: 7px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--bg); border: 2px solid var(--accent);
    box-shadow: 0 0 10px var(--glow);
    transition: background .4s;
}
.timeline-date {
    font-family: var(--mono); color: var(--accent); font-weight: 600;
    font-size: .82rem; letter-spacing: .5px; margin-bottom: 2px;
}
.timeline-content strong { color: var(--text); font-weight: 600; font-size: 1.05rem; }
.timeline-sub { color: var(--text-dim); font-size: .93rem; margin-top: 2px; }

/* ===== Cards ===== */
.research-card, .publication-item, .project-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 26px; backdrop-filter: blur(4px);
    transition: border-color .3s, box-shadow .3s, transform .3s, background .4s;
}
.research-card:hover, .publication-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-card);
}
.research-card strong { color: var(--text); }
.publication-title { font-weight: 700; color: var(--text); font-size: 1.1rem; line-height: 1.4; }
.publication-journal { font-style: italic; color: var(--text-dim); font-size: .93rem; margin: 8px 0 18px; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
    background: var(--btn-bg); border: 1px solid var(--border); color: var(--text);
    padding: 7px 16px; border-radius: 8px; font-size: .85rem; font-weight: 500;
    text-decoration: none; transition: all .25s;
}
.btn:hover {
    background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
    font-weight: 600;
}

/* ===== Conferences (fully clickable rows) ===== */
.conferences-list { display: flex; flex-direction: column; gap: 12px; }
.conf-item {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 15px 20px; display: flex; justify-content: space-between; align-items: center;
    text-decoration: none; transition: all .25s;
}
.conf-item:hover {
    border-color: var(--accent); transform: translateX(4px);
    box-shadow: -4px 0 0 -1px var(--accent), var(--shadow-card);
}
.conf-name { font-weight: 600; color: var(--text); flex: 1; }
.conf-type {
    font-family: var(--mono); font-size: .65rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px;
    padding: 2px 10px; white-space: nowrap;
}
.conf-link { color: var(--accent); font-size: .88rem; font-weight: 500; }

/* ===== Scientific code note ===== */
.code-note { color: var(--text-dim); font-size: .95rem; margin: 0; }

/* ===== Pet projects (separate, slightly playful) ===== */
.side-intro { color: var(--text-dim); font-size: .92rem; margin: -8px 0 16px; }
.project-card { display: block; text-decoration: none; }
.project-card:hover {
    border-color: #2aabee;
    box-shadow: 0 8px 30px rgba(42,171,238,.15);
    transform: translateY(-3px);
}
.project-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.project-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2aabee, #1d93d2);
    box-shadow: 0 4px 14px rgba(42,171,238,.35);
}
.project-icon svg { width: 22px; height: 22px; fill: #fff; }
.project-name { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.project-handle { font-family: var(--mono); font-size: .82rem; color: #2aabee; }
.project-tag {
    font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--tag-color); border: 1px solid var(--tag-border); border-radius: 999px;
    padding: 2px 10px;
}
.project-arrow { margin-left: auto; color: var(--accent); font-size: 1.2rem; transition: transform .25s; }
.project-card:hover .project-arrow { transform: translateX(5px); }
.project-desc { margin: 14px 0 0; font-size: .95rem; }

footer {
    margin-top: 90px; border-top: 1px solid var(--border); padding-top: 24px;
    text-align: center; font-size: .85rem; color: var(--text-dim);
}

/* ===== Reveal on scroll ===== */
body.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
body.js .reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    body.js .reveal { opacity: 1; transform: none; transition: none; }
    .stars, .stars-2 { animation: none; }
}

@media (max-width: 640px) {
    .container { padding: 80px 16px 40px; }
    .header-grid { grid-template-columns: 1fr; text-align: center; gap: 20px; margin-bottom: 28px; }
    .profile-photo-container { justify-content: center; order: -1; }
    .grid-contacts { grid-template-columns: 1fr; }
    h1 { font-size: 2.1rem; }
    .conf-item { flex-direction: column; align-items: flex-start; gap: 6px; }
    .project-arrow { display: none; }
    .sky { opacity: .2; }
    html[data-theme="light"] .sky { opacity: .3; }
    .deep-objects { opacity: .15; }
    html[data-theme="light"] .deep-objects { opacity: .08; }
}