/* ============================================
   Premium aesthetic overhaul v2
   ============================================ */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- Custom Properties ---- */
:root {
    --accent: #4f46e5;
    --accent-light: #818cf8;
    --accent-subtle: rgba(79, 70, 229, 0.08);
    --accent-glow: rgba(79, 70, 229, 0.25);
    --surface: rgba(255, 255, 255, 0.6);
    --surface-hover: rgba(255, 255, 255, 0.9);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
    --shadow-xl: 0 24px 60px rgba(0,0,0,0.12), 0 8px 20px rgba(0,0,0,0.08);
    --gradient-accent: linear-gradient(135deg, #4f46e5, #7c3aed, #ec4899);
    --gradient-subtle: linear-gradient(135deg, rgba(79,70,229,0.05), rgba(124,58,237,0.05), rgba(236,72,153,0.03));
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

.dark {
    --accent: #818cf8;
    --accent-light: #a5b4fc;
    --accent-subtle: rgba(129, 140, 248, 0.1);
    --accent-glow: rgba(129, 140, 248, 0.2);
    --surface: rgba(46, 46, 51, 0.6);
    --surface-hover: rgba(46, 46, 51, 0.9);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.35);
    --shadow-xl: 0 24px 60px rgba(0,0,0,0.45);
    --gradient-subtle: linear-gradient(135deg, rgba(129,140,248,0.06), rgba(124,58,237,0.04), rgba(236,72,153,0.03));
}

/* ---- Base ---- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em;
}

html {
    scroll-behavior: smooth;
}

/* Subtle noise texture overlay for depth */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--noise);
    background-size: 256px 256px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.4;
}

/* Subtle animated gradient background for homepage */
body.list {
    background: var(--code-bg);
    position: relative;
}

body.list::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(124, 58, 237, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.03) 0%, transparent 50%);
    animation: bgShift 25s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

.dark.list::before {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(129, 140, 248, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(124, 58, 237, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.03) 0%, transparent 50%);
}

@keyframes bgShift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, -3%) rotate(3deg); }
}

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow), var(--shadow-lg); }
    50% { box-shadow: 0 0 40px var(--accent-glow), var(--shadow-xl); }
}

main.main {
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Selection ---- */
::selection {
    background: var(--accent-glow);
    color: var(--primary);
}

/* ---- Header ---- */
.header {
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(255, 255, 255, 0.72);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow var(--transition-med), background var(--transition-med);
}

.dark .header {
    background: rgba(29, 30, 32, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Logo */
.logo a {
    font-weight: 800;
    letter-spacing: -0.04em;
    font-size: 1.1em;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: opacity var(--transition-fast);
}

.logo a:hover {
    opacity: 0.8;
}

/* Nav links */
#menu {
    gap: 2px;
}

#menu a {
    position: relative;
    transition: color var(--transition-fast);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

#menu a:hover {
    background: var(--accent-subtle);
}

#menu a span {
    position: relative;
    font-weight: 500;
    font-size: 0.9em;
}

#menu a span::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: width var(--transition-med);
}

#menu a:hover span::after,
#menu a span.active::after {
    width: 100%;
}

#menu a:hover span {
    color: var(--accent);
}

#menu .active {
    border-bottom: none;
    color: var(--accent);
}

/* Theme toggle */
button#theme-toggle {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

button#theme-toggle:hover {
    background: var(--accent-subtle);
    transform: rotate(20deg) scale(1.1);
}

/* ---- Profile / Hero ---- */
.profile {
    padding: 2rem 0 1rem;
    display: flex;
    justify-content: center;
}

.profile .profile_inner {
    padding: 3.5rem 3rem 2.5rem;
    position: relative;
    text-align: center;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    transition: box-shadow var(--transition-med), transform var(--transition-med);
}

.profile .profile_inner:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

/* Avatar with gradient ring */
.profile img {
    border-radius: 50%;
    border: none !important;
    padding: 4px;
    background: var(--gradient-accent);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-med), box-shadow var(--transition-med);
    animation: scaleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    width: 140px !important;
    height: 140px !important;
}

.profile img:hover {
    transform: scale(1.08) rotate(2deg);
    box-shadow: var(--shadow-xl), 0 0 40px var(--accent-glow);
}

/* Welcome text */
.profile .profile_inner > span {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.03em;
    margin-top: 1rem;
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

/* ---- Social Icons ---- */
.social-icons {
    padding: 24px 0 8px;
    display: flex;
    justify-content: center;
    gap: 10px;
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    transition: all var(--transition-med);
    margin: 0 !important;
}

.social-icons a svg {
    height: 18px;
    width: 18px;
    transition: all var(--transition-med);
}

/* Individual icon hover colors */
.social-icons a[title="Linkedin"]:hover {
    background: #0077b5;
    border-color: #0077b5;
    box-shadow: 0 8px 24px rgba(0, 119, 181, 0.3);
    transform: translateY(-4px) scale(1.05);
}

.social-icons a[title="Googlescholar"]:hover {
    background: #4285f4;
    border-color: #4285f4;
    box-shadow: 0 8px 24px rgba(66, 133, 244, 0.3);
    transform: translateY(-4px) scale(1.05);
}

.social-icons a[title="CV"]:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    box-shadow: 0 8px 24px rgba(231, 76, 60, 0.3);
    transform: translateY(-4px) scale(1.05);
}

.social-icons a[title="GitHub"]:hover {
    background: #333;
    border-color: #333;
    box-shadow: 0 8px 24px rgba(51, 51, 51, 0.3);
    transform: translateY(-4px) scale(1.05);
}

.dark .social-icons a[title="GitHub"]:hover {
    background: #f0f0f0;
    border-color: #f0f0f0;
}

.dark .social-icons a[title="GitHub"]:hover svg {
    stroke: #333;
}

.social-icons a:hover svg {
    stroke: #fff;
}

/* ---- Post Pages ---- */
.post-single {
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Page title */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.post-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 80px;
    height: 2px;
    background: var(--gradient-accent);
    border-radius: 2px;
}

.post-header .post-title {
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    font-size: 2.8rem;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Content styling */
.post-content {
    line-height: 1.8;
    letter-spacing: -0.005em;
    font-size: 17px;
    color: var(--content);
}

.post-content p {
    margin-bottom: 1.4em;
}

/* Headings in content */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--primary);
    scroll-margin-top: 5rem;
}

.post-content h2 {
    font-size: 1.6rem;
    margin: 3rem auto 1.2rem;
    padding-bottom: 0.5rem;
    display: block;
    position: relative;
}

.post-content h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 48px;
    height: 3px;
    background: var(--gradient-accent);
    border-radius: 3px;
}

/* H3 — timeline-style for work experience sections */
.post-content h3 {
    font-size: 1.25rem;
    margin: 2.5rem 0 1rem;
    padding: 0.8rem 0 0.8rem 1.2rem;
    border-left: 3px solid var(--accent);
    position: relative;
    transition: border-color var(--transition-med);
}

.post-content h3::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--theme);
}

.post-content h3 a.anchor {
    display: none;
}

/* Lists */
.post-content ul {
    list-style: none;
    padding-inline-start: 0;
}

.post-content ul li {
    position: relative;
    padding-left: 1.6em;
    margin-top: 0.6em;
}

.post-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.post-content ol li {
    padding-left: 0.4em;
    margin-top: 0.6em;
}

/* Strong text accent */
.post-content strong {
    color: var(--primary);
    font-weight: 600;
}

/* Links */
.post-content a {
    color: var(--accent);
    text-decoration: none;
    box-shadow: none;
    border-bottom: 1.5px solid rgba(79, 70, 229, 0.2);
    transition: border-color var(--transition-fast), color var(--transition-fast);
    font-weight: 500;
}

.post-content a:hover {
    border-bottom-color: var(--accent);
    opacity: 1;
    box-shadow: none;
}

.dark .post-content a {
    border-bottom-color: rgba(129, 140, 248, 0.2);
}

.dark .post-content a:hover {
    border-bottom-color: var(--accent);
}

/* Images — elegant figure treatment */
.post-content img {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-slow);
    margin: 2rem auto;
    display: block;
    border: 1px solid var(--border);
}

.post-content img:hover {
    box-shadow: var(--shadow-xl);
    transform: scale(1.3);
    border-color: var(--accent-glow);
}

/* Blockquotes */
.post-content blockquote {
    border-inline-start: 3px solid var(--accent);
    padding: 1.2em 1.6em;
    background: var(--gradient-subtle);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    margin: 1.5em 0;
}

/* Code */
.post-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--accent-subtle);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    color: var(--accent);
}

.post-content pre code {
    color: #d5d5d6;
    background: var(--hljs-bg) !important;
    border-radius: var(--radius-md);
    padding: 1.2em 1.4em;
    font-size: 0.85em;
    box-shadow: var(--shadow-md);
}

/* Tables */
.post-content table {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.post-content table th {
    background: var(--accent-subtle);
    font-weight: 600;
}

/* ---- Cards for post entries ---- */
.post-entry {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(8px);
    transition: all var(--transition-med);
    box-shadow: var(--shadow-sm);
}

.post-entry:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-glow);
    transform: translateY(-3px);
}

.post-entry:active {
    transform: translateY(0) scale(0.99);
}

/* ---- Footer ---- */
.footer {
    border-top: 1px solid var(--border);
    font-size: 13px;
    letter-spacing: 0.01em;
    opacity: 0.5;
    transition: opacity var(--transition-med);
    padding: 2rem 0;
}

.footer:hover {
    opacity: 0.8;
}

.footer a {
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.footer a:hover {
    border-bottom-color: var(--secondary);
    color: var(--accent);
}

/* ---- Top Link ---- */
.top-link {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: var(--accent) !important;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: visibility 0.5s, opacity 0.8s linear, transform var(--transition-fast), box-shadow var(--transition-fast);
    border: none;
    border-radius: 50% !important;
    width: 44px;
    height: 44px;
}

.top-link svg {
    filter: brightness(10) !important;
}

.top-link:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 28px var(--accent-glow);
}

/* ---- TOC ---- */
.toc {
    border-radius: var(--radius-md);
    background: var(--gradient-subtle);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.toc .inner ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.toc .inner > ul > li {
    margin: 0.3em 0;
}

.toc .inner ul ul {
    padding-left: 1.4em;
    margin: 0.15em 0 0.3em;
}

.toc .inner ul ul li {
    position: relative;
    padding-left: 1em;
    margin: 0.15em 0;
    font-size: 0.92em;
    opacity: 0.85;
}

.toc .inner ul ul li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 600;
}

/* ---- Tags ---- */
.post-tags a {
    border-radius: 99px;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid var(--border);
}

.post-tags a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---- Pagination ---- */
.paginav {
    border-radius: var(--radius-md);
}

.paginav a {
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--tertiary);
    border: 2px solid var(--theme);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-light);
}

.list:not(.dark)::-webkit-scrollbar-thumb {
    border-color: var(--code-bg);
}

/* ---- Responsive ---- */
@media screen and (max-width: 768px) {
    .profile .profile_inner {
        padding: 2.5rem 1.5rem 2rem;
        margin: 0 1rem;
        border-radius: var(--radius-lg);
    }

    .profile .profile_inner > span {
        font-size: 1.25rem;
    }

    .profile img {
        width: 120px !important;
        height: 120px !important;
    }

    .social-icons a {
        width: 42px;
        height: 42px;
    }

    .social-icons a svg {
        height: 16px;
        width: 16px;
    }

    .post-header .post-title {
        font-size: 2rem;
    }

    .post-content {
        font-size: 16px;
    }

    .post-content h2 {
        font-size: 1.35rem;
    }

    .post-content h3 {
        font-size: 1.1rem;
    }

    .post-content img {
        border-radius: var(--radius-md);
        margin: 1.5rem auto;
    }
}

/* ---- Publication entries ---- */
.pub-entry {
    padding: 1.4rem 1.6rem;
    margin-bottom: 1.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--gradient-subtle);
    transition: border-color var(--transition-med), box-shadow var(--transition-med);
}

.pub-entry:hover {
    border-color: var(--accent-glow);
    box-shadow: var(--shadow-md);
}

.pub-entry h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.02em;
    color: var(--primary);
}

.pub-entry p {
    margin-bottom: 0.5em;
    font-size: 0.95em;
    line-height: 1.6;
}

.pub-entry p:last-child {
    margin-bottom: 0;
}

.pub-links {
    margin-top: 0.4rem !important;
}

.pub-links a {
    font-weight: 600;
    font-size: 0.88em;
    letter-spacing: 0.01em;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    body.list::before {
        animation: none;
    }
}

/* ---- KaTeX Math ---- */
.katex-display {
    margin: 1.2em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.4em 0;
}

.katex {
    font-size: 1.1em;
}
