/* =========================================================
   Base tokens
   ========================================================= */

 :root {
    --max: 980px;
    --pad: 20px;
    --radius: 16px;
    --radius-sm: 12px;
    --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    --t: 160ms;
    /* Light theme (default) */
    --bg: #ffffff;
    --surface: #f6f7fb;
    --surface-2: #ffffff;
    --text: #0b1020;
    --muted: #5a657a;
    --line: #e4e8f2;
    --shadow: 0 10px 30px rgba(14, 20, 38, 0.08);
    --link: #1d4ed8;
    --link-hover: #173ea9;
    --chip: rgba(29, 78, 216, 0.08);
    --chip-text: #173ea9;
    --focus: rgba(29, 78, 216, 0.35);
    /* shared sizing */
    --ctrl-h: 40px;
    --ctrl-r: 14px;
    --pill-r: 12px;
}

 :root[data-theme="dark"] {
    --bg: #0b0c10;
    --surface: #11131a;
    --surface-2: #0f1117;
    --text: #e8eaf0;
    --muted: #a7adbe;
    --line: #222636;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    --link: #cdd6ff;
    --link-hover: #ffffff;
    --chip: rgba(205, 214, 255, 0.12);
    --chip-text: #e8eaf0;
    --focus: rgba(205, 214, 255, 0.28);
}


/* =========================================================
     Reset / global
     ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    text-rendering: optimizeLegibility;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

 :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 10px;
}


/* =========================================================
     Layout primitives
     ========================================================= */

.container {
    width: min(var(--max), calc(100% - 2 * var(--pad)));
    margin: 0 auto;
}

.section {
    padding: 26px 0 46px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}


/* =========================================================
     Shared UI primitives (refactor targets)
     ========================================================= */


/* Card shell used by many components */

 :where(.panel, .card, .pcard, .xp-card, .edu-card) {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 16px;
}


/* Clickable controls: unify menu/theme/button */

 :where(.btn, .theme-toggle, .menu-toggle) {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: var(--ctrl-h);
    padding: 0 12px;
    border-radius: var(--ctrl-r);
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    transition: transform var(--t) ease, border-color var(--t) ease, background var(--t) ease;
}

 :where(.btn, .theme-toggle, .menu-toggle):hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--line) 55%, var(--text));
    text-decoration: none;
}

 :where(.btn, .theme-toggle, .menu-toggle):active {
    transform: translateY(0);
}

.btn {
    justify-content: center;
    padding: 0 14px;
    background: var(--surface-2);
}

.btn.primary {
    background: color-mix(in srgb, var(--link) 12%, var(--surface-2));
    border-color: color-mix(in srgb, var(--link) 25%, var(--line));
}

.btn.btn-icon {
    gap: 10px;
}

.btn.btn-icon i {
    font-size: 16px;
    color: var(--muted);
}


/* Pill-like links used in multiple places */

 :where(.r-links a, .plinks a) {
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--pill-r);
    background: var(--surface-2);
    border: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
}

 :where(.r-links a, .plinks a):hover {
    text-decoration: none;
}


/* Chips */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--chip);
    color: var(--chip-text);
    border: 1px solid color-mix(in srgb, var(--chip-text) 18%, transparent);
    font-size: 13px;
}


/* Bullets */

.bullets {
    margin: 8px 0 0;
    padding-left: 18px;
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

.bullets li {
    margin: 4px 0;
}


/* =========================================================
     Topbar + nav
     ========================================================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--text);
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.navwrap {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* Desktop default */

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}

.nav a {
    padding: 8px 10px;
    border-radius: 12px;
    color: var(--muted);
    border: 1px solid transparent;
}

.nav a:hover {
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border-color: var(--line);
}

.nav a.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}


/* Mobile menu toggle */

.menu-toggle {
    display: none;
    background: var(--surface);
}

.menu-text {
    font-size: 13px;
    color: var(--muted);
}

.menu-icon {
    width: 18px;
    height: 12px;
    position: relative;
    display: inline-block;
}

.menu-icon::before,
.menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.menu-icon::before {
    top: 0;
}

.menu-icon::after {
    bottom: 0;
}


/* Theme toggle specifics */

.theme-toggle {
    background: var(--surface);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .label {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.theme-toggle.icon-only {
    width: 40px;
    padding: 0;
    justify-content: center;
}

.theme-toggle.icon-only svg {
    width: 20px;
    height: 20px;
}


/* Mobile behavior */

@media (max-width: 720px) {
    .menu-toggle {
        display: inline-flex;
    }
    .nav {
        display: none;
        position: absolute;
        left: var(--pad);
        right: var(--pad);
        top: 58px;
        padding: 10px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        flex-direction: column;
        gap: 4px;
    }
    .nav.is-open {
        display: flex;
    }
    .nav a {
        padding: 10px 12px;
        border-radius: 12px;
    }
}


/* =========================================================
     Typography
     ========================================================= */

h1 {
    font-size: clamp(28px, 3.4vw, 40px);
    margin: 0;
    line-height: 1.15;
}

h2 {
    font-size: 18px;
    margin: 0 0 8px;
}

p {
    margin: 0;
}

.lede {
    color: var(--muted);
    margin-top: 8px;
    max-width: 70ch;
}


/* =========================================================
     Hero
     ========================================================= */

.hero {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 22px;
    align-items: center;
    padding: 18px;
}

@media (max-width: 720px) {
    .hero {
        grid-template-columns: 1fr;
        text-align: left;
    }
}

.avatar {
    width: 200px;
    height: 200px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    object-fit: cover;
    box-shadow: var(--shadow);
}

@media (max-width: 720px) {
    .avatar {
        width: 160px;
        height: 160px;
    }
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    align-items: center;
}

.inline-links {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    margin-left: 6px;
}

.inline-links a {
    font-size: 14px;
}

.hero-meta {
    margin-top: 12px;
}

.hero-meta-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 12px;
    align-items: start;
}

.hero-meta-row.no-label {
    display: block;
}

.hero-meta-label {
    font-size: 13px;
    color: var(--muted);
    padding-top: 3px;
}

.hero-meta-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lang-pill {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    font-size: 13px;
    color: color-mix(in srgb, var(--text) 90%, var(--muted));
}


/* =========================================================
     Research / Projects (square thumbs)
     ========================================================= */

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 860px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.meta {
    font-size: 13px;
    color: var(--muted);
}

.r-desc {
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

.r-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}


/* =========================================================
     Footer
     ========================================================= */

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
    padding-top: 10px;
}


/* =========================================================
     Projects: image-first grids (standalone variants)
     ========================================================= */

.pgrid-3,
.pgrid-4 {
    display: grid;
    gap: 14px;
}

.pgrid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pgrid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
    .pgrid-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .pgrid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .pgrid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .pgrid-3,
    .pgrid-4 {
        grid-template-columns: 1fr;
    }
}

.pcard {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pthumb {
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.pthumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Thumb aspect variants */

.thumb-square {
    aspect-ratio: 1 / 1;
}

.thumb-rect {
    aspect-ratio: 3 / 2;
}

.pthumb-square {
    aspect-ratio: 1 / 1;
}

.pthumb-wide {
    aspect-ratio: 2 / 1;
}

.pbody {
    padding: 12px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ptitle {
    margin: 0;
    font-size: 16px;
    line-height: 1.25;
}

.pmeta {
    font-size: 13px;
    color: var(--muted);
    margin-top: -4px;
}

.plinks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 2px;
}


/* Page header panel */

.page-header {
    padding: 16px;
}

.page-title {
    margin: 0;
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.2;
}

.page-subtitle {
    margin-top: 8px;
}


/* =========================================================
     Education
     ========================================================= */

.edu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 980px) {
    .edu-grid {
        grid-template-columns: 1fr;
    }
}

.edu-card {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.edu-card h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.25;
}

.edu-top {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edu-degree {
    font-weight: 650;
}

.edu-place {
    color: var(--muted);
    font-size: 13px;
}

.edu-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.edu-tags .chip {
    height: 26px;
    font-size: 12px;
}


/* Timeline list for courses/programs */

.edu-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.edu-item {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
}

.edu-year {
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    padding-top: 2px;
}

.edu-item-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
}

.edu-item-meta {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.edu-item-desc {
    margin-top: 6px;
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
}


/* Collapsible sections */

details.edu-details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

details.edu-details>summary {
    list-style: none;
    cursor: pointer;
    padding: 14px;
    font-weight: 650;
}

details.edu-details>summary::-webkit-details-marker {
    display: none;
}

details.edu-details .edu-details-body {
    padding: 0 14px 14px;
}

.uni-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 980px) {
    .uni-grid {
        grid-template-columns: 1fr;
    }
}


/* Embedded achievements */

.achievements {
    margin-top: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.achievements--nested {
    margin-top: 10px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.ach {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
    font-size: 14px;
}

.ach-icon {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    margin-top: 1px;
    color: var(--muted);
    font-size: 14px;
}

details.ach-more>summary {
    cursor: pointer;
    user-select: none;
    padding: 8px 2px;
}


/* Group headers */

.edu-group {
    margin-top: 18px;
}

.edu-group:first-of-type {
    margin-top: 12px;
}

.edu-group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.edu-group-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.edu-group-title i {
    color: var(--muted);
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.edu-group-meta {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}


/* Badges */

.edu-badges {
    display: flex;
    justify-content: flex-end;
    align-items: start;
}

.pill {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    background: transparent;
}

.pill--upcoming {
    color: var(--text);
    border-color: color-mix(in srgb, var(--line) 60%, var(--text));
}

.edu-item--upcoming {
    border-style: dashed;
}


/* Optional thumb variant */

.edu-item.edu-item--thumb {
    grid-template-columns: 70px 140px 1fr auto;
    align-items: center;
}

.edu-thumb {
    aspect-ratio: 2 / 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.edu-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 720px) {
    .edu-item.edu-item--thumb {
        grid-template-columns: 70px 1fr;
    }
    .edu-thumb {
        display: none;
    }
}

.edu-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 860px) {
    .edu-grid-2 {
        grid-template-columns: 1fr;
    }
}

.edu-card-row {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* =========================================================
     Experience
     ========================================================= */

.xp-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 980px) {
    .xp-grid {
        grid-template-columns: 1fr;
    }
}

.xp-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.xp-thumb {
    border-bottom: 1px solid var(--line);
}

.xp-body {
    padding: 12px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.xp-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.25;
}

.xp-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: -4px;
}

.xp-bullets {
    margin: 6px 0 0;
}

.xp-card--compact .xp-body {
    padding: 12px;
}

.xp-grid--vol .xp-bullets li {
    margin: 3px 0;
}


/* =========================================================
     Carousel (3-card)
     ========================================================= */

.c3 {
    margin-top: 10px;
}

.c3-viewport {
    position: relative;
    overflow: hidden;
    padding: 0;
}

.c3-track {
    display: flex;
    gap: 14px;
    transition: transform 360ms ease;
    will-change: transform;
    position: relative;
    z-index: 1;
}

.c3-card {
    flex: 0 0 calc((100% - 28px) / 3);
}

@media (max-width: 980px) {
    .c3-card {
        flex-basis: calc((100% - 14px) / 2);
    }
}

@media (max-width: 640px) {
    .c3-card {
        flex-basis: 100%;
    }
}


/* Edge shading */

.c3-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 72px;
    z-index: 2;
    pointer-events: none;
}

.c3-fade--left {
    left: 0;
    background: linear-gradient(to right, var(--bg), transparent);
}

.c3-fade--right {
    right: 0;
    background: linear-gradient(to left, var(--bg), transparent);
}


/* Arrows */

.c3-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 3;
    display: grid;
    place-items: center;
}

.c3-btn--prev {
    left: 10px;
}

.c3-btn--next {
    right: 10px;
}

.c3-btn::before {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(135deg);
    margin-left: 2px;
}

.c3-btn--next::before {
    transform: rotate(-45deg);
    margin-left: 0;
    margin-right: 2px;
}

.c3-btn:disabled {
    opacity: 0.35;
    cursor: default;
}


/* Dots */

.c3-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.c3-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.c3-dot[aria-current="true"] {
    background: var(--text);
    border-color: var(--text);
}


/* =========================================================
     Languages (grid)
     ========================================================= */

.lang-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

@media (max-width: 860px) {
    .lang-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.lang-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.lang-name {
    font-weight: 650;
}

.lang-level {
    color: var(--muted);
    font-size: 13px;
}


/* =========================================================
     Selected projects (home)
     ========================================================= */

.home-proj-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 10px;
}

@media (max-width: 860px) {
    .home-proj-grid {
        grid-template-columns: 1fr;
    }
}

.home-proj {
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
    transition: transform var(--t) ease, border-color var(--t) ease;
}

.home-proj:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--line) 55%, var(--text));
    text-decoration: none;
}

.home-proj-title {
    font-weight: 650;
    line-height: 1.2;
}

.home-proj-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: -2px;
}

.home-proj-desc {
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
}