/* Aesthetic polish — ink & paper, math-forward
   Overrides style.css tokens without fighting page structure */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    --primary-color: #1a2b3c;
    --secondary-color: #1f6f78;
    --text-color: #2c3540;
    --text-muted: #5a6570;
    --background-color: #eef2f4;
    --card-background: rgba(255, 255, 255, 0.82);
    --shadow-color: rgba(26, 43, 60, 0.08);
    --hover-color: rgba(31, 111, 120, 0.08);
    --border-color: rgba(26, 43, 60, 0.1);
    --input-background: rgba(255, 255, 255, 0.9);
    --animation-primary: #1a2b3c;
    --animation-secondary: #1f6f78;
    --animation-background: rgba(31, 111, 120, 0.08);

    --primary-blue: #1f6f78;
    --primary-blue-dark: #16555c;
    --primary-blue-light: #c5e4e6;

    --heading-color: #1a2b3c;
    --accent-color: #1f6f78;
    --card-bg: rgba(255, 255, 255, 0.88);

    --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
    --font-body: "Source Sans 3", "Segoe UI", sans-serif;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 14px;
}

[data-theme="dark"] {
    --primary-color: #e8eef2;
    --secondary-color: #7eb8b5;
    --text-color: #c8d0d6;
    --text-muted: #8a969e;
    --background-color: #0b1015;
    --card-background: rgba(22, 30, 38, 0.88);
    --shadow-color: rgba(0, 0, 0, 0.45);
    --hover-color: rgba(126, 184, 181, 0.1);
    --border-color: rgba(232, 238, 242, 0.1);
    --input-background: rgba(22, 30, 38, 0.95);
    --animation-primary: #7eb8b5;
    --animation-secondary: #9fd0cd;
    --animation-background: rgba(126, 184, 181, 0.12);

    --primary-blue: #7eb8b5;
    --primary-blue-dark: #5a9a97;
    --primary-blue-light: #1a3332;

    --heading-color: #e8eef2;
    --accent-color: #7eb8b5;
    --card-bg: rgba(22, 30, 38, 0.9);
    --card-bg-dark: rgba(18, 24, 30, 0.95);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    letter-spacing: 0.01em;
    background-color: var(--background-color);
    background-image:
        radial-gradient(ellipse 90% 60% at 10% -10%, rgba(31, 111, 120, 0.14), transparent 55%),
        radial-gradient(ellipse 70% 50% at 95% 15%, rgba(180, 140, 90, 0.1), transparent 50%),
        radial-gradient(ellipse 60% 40% at 50% 100%, rgba(31, 111, 120, 0.07), transparent 55%);
    background-attachment: fixed;
    transition:
        background-color 0.45s var(--ease-soft),
        color 0.45s var(--ease-soft);
}

[data-theme="dark"] body {
    background-image:
        radial-gradient(ellipse 90% 60% at 10% -10%, rgba(126, 184, 181, 0.12), transparent 55%),
        radial-gradient(ellipse 70% 50% at 95% 20%, rgba(90, 110, 140, 0.1), transparent 50%),
        radial-gradient(ellipse 50% 40% at 40% 100%, rgba(126, 184, 181, 0.06), transparent 55%);
}

/* —— Header —— */
header {
    background: color-mix(in srgb, var(--card-background) 78%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 0 var(--border-color), 0 8px 24px transparent;
    transition: box-shadow 0.35s var(--ease-soft), background 0.35s var(--ease-soft);
}

header.is-scrolled {
    box-shadow: 0 8px 28px var(--shadow-color);
}

.logo {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.55rem;
    letter-spacing: 0.02em;
    transition: color 0.3s var(--ease-soft);
}

.logo-link {
    text-decoration: none;
}

.header-profile {
    border-color: color-mix(in srgb, var(--secondary-color) 55%, transparent);
    transition: transform 0.4s var(--ease-out), border-color 0.3s ease, box-shadow 0.3s ease;
}

.header-profile:hover {
    transform: scale(1.05);
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--secondary-color) 25%, transparent);
}

.nav-links a {
    position: relative;
    padding: 0.55rem 0.9rem;
    font-size: 1.05rem;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.25s var(--ease-soft), background 0.25s var(--ease-soft);
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0.9rem;
    right: 0.9rem;
    bottom: 0.35rem;
    height: 2px;
    background: var(--secondary-color);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.35s var(--ease-out);
}

.nav-links a:hover {
    background-color: transparent;
    color: var(--secondary-color);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    transform: scaleX(1);
}

.nav-links a.active {
    color: var(--secondary-color);
    background: transparent;
    font-weight: 600;
}

.theme-toggle {
    border-radius: 50%;
    transition: color 0.3s ease, transform 0.45s var(--ease-out), background 0.3s ease;
}

.theme-toggle:hover {
    background: var(--hover-color);
    transform: rotate(20deg) scale(1.08);
}

/* —— Hero —— */
.hero {
    min-height: calc(100vh - 100px);
    isolation: isolate;
}

.hero-content {
    position: relative;
    z-index: 2;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 2.5rem 1.25rem 3.5rem;
    max-width: 42rem;
}

.profile-image {
    width: 168px;
    height: 168px;
    border-width: 3px;
    border-color: color-mix(in srgb, var(--secondary-color) 70%, white);
    box-shadow:
        0 12px 40px var(--shadow-color),
        0 0 0 8px color-mix(in srgb, var(--secondary-color) 12%, transparent);
    animation: heroPortraitIn 1s var(--ease-out) both;
}

.profile-image:hover img {
    transform: scale(1.06);
}

.hero h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.6rem, 6vw, 3.75rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.65rem;
    animation: none;
    text-shadow: 0 1px 24px color-mix(in srgb, var(--background-color) 80%, transparent);
}

.hero-content > p:not(.hero-bio) {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--secondary-color);
    letter-spacing: 0.04em;
    text-transform: none;
    margin-bottom: 1rem;
    animation: none;
}

.hero-bio {
    color: var(--text-muted) !important;
    font-size: 1.15rem !important;
    line-height: 1.65 !important;
    margin-bottom: 1.75rem !important;
    animation: none !important;
}

/* Hero entrance — never hide content; only subtle rise */
.js-ready .hero-content > * {
    animation: fadeRiseSoft 0.7s var(--ease-out) both;
}

.js-ready .hero-content > *:nth-child(1) { animation-delay: 0.05s; }
.js-ready .hero-content > *:nth-child(2) { animation-delay: 0.12s; }
.js-ready .hero-content > *:nth-child(3) { animation-delay: 0.18s; }
.js-ready .hero-content > *:nth-child(4) { animation-delay: 0.24s; }
.js-ready .hero-content > *:nth-child(5) { animation-delay: 0.3s; }
.js-ready .hero-content > *:nth-child(6) { animation-delay: 0.36s; }

.social-links {
    margin-top: 0.5rem;
    animation: none;
    gap: 0.75rem;
}

.social-links a {
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--primary-color);
    background: color-mix(in srgb, var(--card-background) 70%, transparent);
    border: 1px solid var(--border-color);
    transition:
        transform 0.35s var(--ease-out),
        color 0.25s ease,
        background 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.35s ease;
}

.social-links a:hover {
    color: #fff;
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-4px);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--secondary-color) 35%, transparent);
}

/* —— Buttons —— */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.85rem 1.65rem;
    background: var(--secondary-color);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--secondary-color) 28%, transparent);
    transition:
        transform 0.35s var(--ease-out),
        background 0.25s ease,
        box-shadow 0.35s ease,
        color 0.25s ease;
}

.btn:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-3px);
    box-shadow: 0 12px 28px color-mix(in srgb, var(--secondary-color) 35%, transparent);
}

.btn:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-outline {
    background: transparent;
    color: var(--secondary-color);
    border: 1.5px solid color-mix(in srgb, var(--secondary-color) 65%, transparent);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

/* —— Page content —— */
.page-content {
    padding-top: 2.5rem;
    padding-bottom: 4rem;
}

.about-section h1,
.projects-section h1,
.achievements-page h1,
.contact-section h1 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: -0.02em;
    font-size: clamp(2.2rem, 4vw, 3rem);
}

.about-section > p {
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1.7;
}

.education h2,
.experience h2,
.achievement-section h2,
.section-title {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: -0.01em;
}

.card,
.project-card,
.achievement-card,
.contact-info.card,
.contact-form.card,
.latex-card,
.github-card {
    background: var(--card-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px var(--shadow-color);
    transition:
        transform 0.45s var(--ease-out),
        box-shadow 0.45s var(--ease-out),
        border-color 0.3s ease,
        background 0.35s ease;
}

.card:hover,
.project-card:hover,
.achievement-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px var(--shadow-color);
    border-color: color-mix(in srgb, var(--secondary-color) 35%, var(--border-color));
}

.project-card h3,
.experience-item h4,
.card h3 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: -0.01em;
}

.project-card h3::after {
    background: var(--secondary-color);
    transition: width 0.45s var(--ease-out);
}

.duration {
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
}

.tech-tag {
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.82rem;
    background: color-mix(in srgb, var(--secondary-color) 14%, transparent);
    color: var(--primary-color);
    border: 1px solid color-mix(in srgb, var(--secondary-color) 22%, transparent);
    transition: transform 0.3s var(--ease-out), background 0.25s ease;
}

.project-card:hover .tech-tag {
    transform: translateY(-2px);
}

.tech-tag.python,
.tech-tag.qgis,
.tech-tag.or-tools,
.tech-tag.matlab,
.tech-tag.javascript,
.tech-tag.html,
.tech-tag.css,
.tech-tag.react,
.tech-tag.node,
.tech-tag.sql,
.tech-tag.gis,
.tech-tag.statistics,
.tech-tag.research {
    color: #fff;
    border-color: transparent;
}

/* —— Scroll reveal —— */
.reveal {
    opacity: 1;
    transform: translateY(0);
}

.js-ready .reveal:not(.is-visible) {
    opacity: 0;
    transform: translateY(22px);
}

.js-ready .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.7s var(--ease-out),
        transform 0.7s var(--ease-out);
    transition-delay: var(--reveal-delay, 0s);
}

/* —— Canvas / footer —— */
#graphCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.28;
    transition: opacity 0.5s ease;
}

[data-theme="dark"] #graphCanvas {
    opacity: 0.22;
}

main {
    position: relative;
    z-index: 1;
}

footer {
    border-top: 1px solid var(--border-color);
    background: transparent;
    padding: 1.75rem 0;
    margin-top: 2rem;
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

/* —— Forms —— */
.form-group input,
.form-group textarea {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--secondary-color) 22%, transparent);
}

.contact-item {
    transition: transform 0.3s var(--ease-out), color 0.25s ease;
}

.contact-item:hover {
    transform: translateX(4px);
    color: var(--secondary-color);
}

/* —— Keyframes —— */
@keyframes fadeRise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeRiseSoft {
    from {
        opacity: 0.35;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heroPortraitIn {
    from {
        opacity: 0;
        transform: scale(0.92);
        box-shadow: 0 0 0 0 transparent;
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .reveal,
    .js-ready .reveal:not(.is-visible),
    .js-ready .reveal.is-visible,
    .js-ready .hero-content > * {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        transition: none !important;
    }
}

/* Home page — fill space without feeling sparse */
.hero.hero-compact {
    min-height: auto;
    padding: 1.75rem 1rem 2.5rem;
    align-items: flex-start;
}

.hero.hero-compact .hero-content {
    max-width: 52rem;
    padding: 1rem 1rem 2rem;
}

.hero.hero-compact .profile-image {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.hero.hero-compact h1 {
    font-size: clamp(2.2rem, 5vw, 3rem);
    margin-bottom: 0.35rem;
}

.hero-role {
    color: var(--secondary-color) !important;
    font-weight: 500 !important;
    font-size: 1.05rem !important;
    margin-bottom: 1.25rem !important;
}

.hero-summary {
    text-align: left;
    max-width: 40rem;
    margin: 0 auto 1.5rem;
}

.hero-summary p {
    color: var(--text-muted) !important;
    font-size: 1.05rem !important;
    line-height: 1.65 !important;
    margin: 0 0 0.9rem !important;
    animation: none !important;
}

.hero-summary p:last-child {
    margin-bottom: 0 !important;
}

.hero-now {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    text-align: left;
    margin: 0 auto 1.35rem;
    max-width: 40rem;
}

.hero-now-item {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--card-background) 75%, transparent);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.hero-now-item .now-label {
    margin-bottom: 0.15rem;
}

.hero-now-item strong {
    color: var(--heading-color);
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.05rem;
}

.hero-now-item > span:last-child {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.hero-tags {
    justify-content: center;
    margin: 0 auto 1.25rem;
    max-width: 40rem;
}

.hero.hero-compact .social-links {
    margin-top: 0.25rem;
}

.hero.hero-compact .button-group {
    margin-top: 1rem;
}

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

    .hero-summary {
        text-align: center;
    }
}

.home-section {
    position: relative;
    z-index: 2;
    padding: 3.25rem 0;
}

.home-section .section-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.85rem, 3vw, 2.35rem);
    letter-spacing: -0.02em;
    color: var(--heading-color);
    margin: 0 0 1.75rem;
    text-align: left;
}

.home-summary .summary-panel {
    max-width: 46rem;
    padding: 2rem 2.25rem;
    height: auto;
}

.home-summary .summary-panel p {
    color: var(--text-muted);
    font-size: 1.12rem;
    line-height: 1.75;
    margin: 0 0 1.15rem;
}

.home-summary .summary-panel p:last-of-type {
    margin-bottom: 1.35rem;
}

.text-link {
    color: var(--secondary-color);
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: letter-spacing 0.3s var(--ease-out), color 0.25s ease;
}

.text-link:hover {
    letter-spacing: 0.04em;
    color: var(--primary-blue-dark);
}

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

.now-card {
    padding: 1.5rem 1.6rem;
    height: auto;
}

.now-label {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--secondary-color);
    margin-bottom: 0.55rem;
}

.now-card h3 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.35rem;
    margin: 0 0 0.45rem;
    color: var(--heading-color);
}

.now-card p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.55;
    font-size: 0.98rem;
}

.home-projects {
    margin-bottom: 2rem;
}

.home-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    justify-content: flex-start;
}

.interest-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.interest-tags span {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--card-background) 80%, transparent);
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    transition: transform 0.3s var(--ease-out), border-color 0.25s ease, background 0.25s ease;
}

.interest-tags span:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--secondary-color) 45%, var(--border-color));
    background: color-mix(in srgb, var(--secondary-color) 10%, transparent);
}

.connect-panel {
    text-align: center;
    padding: 2.5rem 2rem;
    max-width: 40rem;
    margin: 0 auto;
    height: auto;
}

.connect-panel h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2rem;
    margin: 0 0 0.65rem;
    color: var(--heading-color);
    border: none;
    padding: 0;
}

.connect-panel p {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    font-size: 1.08rem;
}

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

@media (max-width: 768px) {
    .nav-links a::after {
        display: none;
    }

    .profile-image {
        width: 140px;
        height: 140px;
    }

    .card:hover,
    .project-card:hover,
    .achievement-card:hover {
        transform: translateY(-3px);
    }

    .home-section {
        padding: 2.5rem 0;
    }

    .home-summary .summary-panel {
        padding: 1.5rem 1.35rem;
    }
}
