/* =========================================================
   Portfolio stylesheet
   1. Tokens & themes   2. Base   3. Header / nav / hero
   4. Sections & cards  5. Publications   6. Contact & footer
   7. Popups            8. Responsive     9. Motion
   ========================================================= */

/* ---------- 1. Tokens & themes ---------- */
:root {
    --primary-dark: #3E5902;
    --primary: #556B2F;
    --primary-light: #8F9779;
    --secondary: #795548;
    --light: #F5F5DC;
    --soil-brown: #8D6E63;
    --water-blue: #2196F3;

    --bg: #f9f9f5;
    --bg-alt: #eaefe0;
    --surface: #fff;
    --border: #f0f0f0;
    --divider: #e5e8df;
    --text: #333;
    --text-muted: #555;
    --text-soft: #666;
    --heading: var(--primary-dark);
    --link: var(--primary);
    --accent: var(--primary);
    --accent-soft: var(--primary-light);
    --chip-bg: #eef2e7;
    --chip-text: var(--primary-dark);
    --input-bg: #fff;
    --input-border: #e0e0e0;
    --shadow: 0 5px 20px rgba(0, 0, 0, .06);
    --shadow-hover: 0 12px 25px rgba(0, 0, 0, .11);
    --ok: #245b2a;

    --section-y: clamp(1.75rem, 2.8vw, 2.5rem);
    --gap: clamp(1rem, 1.6vw, 1.5rem);
}

body.dark-mode {
    --bg: #0f1411;
    --bg-alt: #172019;
    --surface: #19201c;
    --border: rgba(220, 235, 224, .10);
    --divider: #354238;
    --text: #dfe7e1;
    --text-muted: #b8c4bc;
    --text-soft: #a3b0a8;
    --heading: #edf3ee;
    --link: #a9c978;
    --accent: #9fbe70;
    --accent-soft: #9fb882;
    --chip-bg: #29352d;
    --chip-text: #c8dda9;
    --input-bg: #222b26;
    --input-border: rgba(220, 235, 224, .15);
    --shadow: 0 8px 28px rgba(0, 0, 0, .25);
    --shadow-hover: 0 12px 30px rgba(0, 0, 0, .4);
    --ok: #a8d08a;
    --light: #e7eee9;
    --water-blue: #63aee8;
}

/* Prevents a light flash while the saved dark theme is applied. */
html.dark-mode-preload,
html.dark-mode-preload body { background: #0f1411; }

/* ---------- 2. Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    overflow-x: hidden;
    transition: background-color .3s ease, color .3s ease;
}

h1, h2, h3, h4 {
    font-family: 'Merriweather', serif;
    color: var(--heading);
    margin-bottom: 1rem;
}

a:focus-visible,
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.container {
    width: min(94%, 1600px);
    margin: 0 auto;
    padding: 0 clamp(8px, 2vw, 24px);
}

section {
    padding: var(--section-y) 0;
    background-color: var(--bg);
    scroll-margin-top: 96px;
}
/* Alternate shades: education, publications, skills, contact use --bg; projects, interests, connect use --bg-alt */
#projects, #interests, #connect { background-color: var(--bg-alt); }

.section-title {
    position: relative;
    text-align: center;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    margin-bottom: 2rem;
}
.section-title:after {
    content: '';
    position: absolute;
    width: 80px;
    height: 4px;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    border-radius: 2px;
}

.section-intro, .projects-intro, .interests-intro {
    max-width: 900px;
    margin: 0 auto 1.75rem;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- 3. Header, navigation, hero ---------- */
header {
    position: relative;
    overflow: hidden;
    padding: 1rem 0 0;
    color: #fff;
    background:
        linear-gradient(rgba(62, 89, 2, .9), rgba(85, 107, 47, .85)),
        repeating-linear-gradient(45deg, rgba(62, 89, 2, .1) 0 10px, rgba(85, 107, 47, .1) 10px 20px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}
body.dark-mode header {
    background:
        radial-gradient(circle at 75% 35%, rgba(78, 109, 58, .2), transparent 34%),
        linear-gradient(135deg, #101612 0%, #172019 52%, #0d120f 100%);
    box-shadow: 0 5px 25px rgba(0, 0, 0, .35);
}
header > .container { position: relative; z-index: 1; }

/* Decorative plants */
.plant-animation { position: absolute; bottom: 0; width: 100%; height: 150px; }
.plant { position: absolute; bottom: 0; opacity: .7; animation: grow 8s ease-in-out infinite; }
.plant:nth-child(1) { left: 10%; height: 80px;  animation-delay: 0s; }
.plant:nth-child(2) { left: 30%; height: 100px; animation-delay: 1s; }
.plant:nth-child(3) { left: 50%; height: 120px; animation-delay: 2s; }
.plant:nth-child(4) { left: 70%; height: 90px;  animation-delay: 3s; }
.plant:nth-child(5) { left: 90%; height: 70px;  animation-delay: 4s; }
@keyframes grow {
    0%, 100% { transform: scaleY(.8); opacity: .6; }
    50% { transform: scaleY(1.1); opacity: .9; }
}

/* Navigation: sits in the header, floats after scrolling (see theme-navigation.js) */
nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-height: 64px;
    padding: 1rem 0;
    border: 1px solid transparent;
    transition: background-color .3s ease, box-shadow .3s ease;
}
nav.nav-floating {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: min(94%, 1540px);
    padding: .65rem 1rem;
    z-index: 9000;
    border-radius: 18px;
    background: rgba(42, 61, 18, .94);
    border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
}
body.dark-mode nav.nav-floating {
    background: rgba(18, 24, 20, .94);
    border-color: rgba(185, 210, 185, .16);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .42);
}

.logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--light);
    white-space: nowrap;
}
.logo i { margin-right: 10px; }

.nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(.7rem, 1.2vw, 1.5rem);
    margin-left: auto;
    list-style: none;
}
.nav-links a {
    position: relative;
    color: var(--light);
    text-decoration: none;
    font-weight: 600;
    font-size: clamp(.85rem, 1vw, 1rem);
    white-space: nowrap;
}
.nav-links a:after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 0;
    height: 2px;
    background: var(--light);
    transition: width .3s ease;
}
.nav-links a:hover:after { width: 100%; }

.theme-toggle,
.mobile-menu-btn {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .08);
    transition: background-color .3s ease, color .3s ease, transform .3s ease;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .18); transform: rotate(10deg); }
body.dark-mode .theme-toggle { color: #f4d66d; border-color: rgba(255, 255, 255, .22); }
.mobile-menu-btn { display: none; }

/* Hero */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    min-height: 50vh;
    padding: 2.5rem 0 4.5rem;
    text-align: left;
}
.hero-content { max-width: 850px; }
.hero h1 {
    color: #fff;
    font-size: clamp(2.2rem, 5vw, 5rem);
    margin-bottom: .8rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
    animation: fadeInDown 1s ease;
}
.hero-tagline {
    margin-bottom: 1.2rem;
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    font-weight: 600;
    color: var(--light);
    animation: fadeInUp 1s ease;
}
body.dark-mode .hero-tagline { color: #c4d7ad; }
.hero-about {
    max-width: 800px;
    margin-bottom: 1.5rem;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.8;
    color: var(--light);
    animation: fadeInUp 1s ease;
}
body.dark-mode .hero-about { color: #c1cbc4; }

.hero-document-buttons { display: flex; flex-wrap: wrap; gap: .9rem; }
.hero .btn {
    display: inline-block;
    width: fit-content;
    padding: .9rem 2.5rem;
    border: none;
    border-radius: 30px;
    background: var(--primary-light);
    color: #fff;
    font: 600 1.1rem 'Open Sans', sans-serif;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, .2);
    transition: background-color .3s ease, transform .3s ease, box-shadow .3s ease;
}
.hero .btn:hover { background: var(--primary-dark); transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0, 0, 0, .15); }

.hero-research-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 24px;
    background: rgba(255, 255, 255, .06);
}
body.dark-mode .hero-research-panel { background: rgba(255, 255, 255, .035); border-color: rgba(210, 230, 215, .14); }
.research-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    min-height: 100px;
    padding: 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .9);
    text-align: center;
    transition: background-color .3s ease, transform .3s ease;
}
.research-item:hover { background: rgba(255, 255, 255, .12); transform: translateY(-3px); }
body.dark-mode .research-item { background: rgba(255, 255, 255, .045); color: #dfe8e1; }
.research-item i { font-size: 1.7rem; color: var(--light); }
body.dark-mode .research-item i { color: #b6d48b; }
.research-item span { font-size: .9rem; font-weight: 600; }

/* ---------- 4. Sections & cards ---------- */
.animate-on-scroll { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.animate-on-scroll.visible { opacity: 1; transform: none; }

/* Shared card look */
.education-item, .project-card, .interest-card, .skill-card, .profile-card,
.contact-info, .contact-form, .pw-metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    transition: transform .3s ease, box-shadow .3s ease, background-color .3s ease;
}
.education-item:hover, .project-card:hover, .interest-card:hover,
.skill-card:hover, .profile-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }

/* Card grids: rows are centred, so a short last row stays in the middle. */
.projects-grid, .interests-grid, .skills-container, .connect-container {
    --cols: 4;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--gap);
}
.projects-grid > *, .interests-grid > *, .skills-container > *, .connect-container > * {
    flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
    min-width: 0;
}
.connect-container { --cols: 3; }
.projects-grid > .projects-empty { flex: 1 1 100%; }

/* Education */
#education .container { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
#education .section-title { grid-column: 1 / -1; margin-bottom: 1.25rem; }
.education-item {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.6rem 1.8rem;
    border-left: 5px solid var(--primary);
}
.education-item:before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.education-item h3 { font-size: 1.3rem; }
.education-item .date { display: flex; align-items: center; margin-bottom: .8rem; color: var(--accent-soft); font-weight: 700; }
.education-item .date i { margin-right: 8px; }
.education-item p { max-width: 850px; color: var(--text-muted); }
.education-item .date, .education-item .thesis-link { max-width: 850px; }
.thesis-link {
    display: inline-flex;
    align-items: center;
    margin-top: auto;
    padding-top: .8rem;
    color: var(--link);
    font-weight: 600;
    text-decoration: none;
}
.thesis-link i { margin-left: 6px; transition: transform .3s ease; }
.thesis-link:hover i { transform: translateX(4px); }

/* Projects (cards are rendered by github-projects.js) */
.projects-status { margin: 0 0 1.5rem; text-align: center; font-size: .95rem; color: var(--accent-soft); }
.project-card {
    display: flex;
    flex-direction: column;
    padding: 1.6rem;
    border-top: 4px solid var(--primary);
}
.project-card h3 { margin-bottom: .7rem; font-size: 1.25rem; word-break: break-word; }
.project-card h3 a { color: var(--link); text-decoration: none; }
.project-card h3 a:hover { text-decoration: underline; }
.project-description { margin-bottom: 1rem; color: var(--text-muted); }
.project-topics { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.project-topic { padding: .3rem .65rem; border-radius: 20px; background: var(--chip-bg); color: var(--chip-text); font-size: .78rem; }
.project-meta { display: flex; flex-wrap: wrap; gap: .6rem 1.1rem; margin-bottom: 1rem; color: var(--text-soft); font-size: .9rem; }
.project-meta span { display: inline-flex; align-items: center; gap: .35rem; }
.project-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: auto; }
.project-language { color: var(--accent-soft); font-size: .85rem; font-weight: 600; }
.project-btn, .profile-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--primary);
    color: #fff;
    border-radius: 25px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .3s ease, transform .3s ease;
}
.project-btn { padding: .65rem 1rem; font-size: .88rem; }
.profile-btn { justify-content: center; margin-top: 1rem; padding: .8rem 1.6rem; box-shadow: 0 4px 8px rgba(0, 0, 0, .15); }
.project-btn:hover, .profile-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }
.projects-all-btn { display: flex; width: max-content; max-width: 100%; margin: 1.75rem auto 0; }
.projects-empty { padding: 2rem; text-align: center; color: var(--text-soft); background: var(--surface); border-radius: 10px; }

/* Research interests */
.research-statement-request { margin: 0 auto 1.75rem; text-align: center; }
.interest-card { overflow: hidden; }
.interest-img {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    overflow: hidden;
    color: #fff;
    font-size: 3.2rem;
}
.interest-img:after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .2); }
.interest-img i { z-index: 1; text-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
.soil-water-bg { background: linear-gradient(45deg, rgba(141, 110, 99, .85), rgba(33, 150, 243, .85)); }
.interest-content { padding: 1.4rem 1.6rem; }
.interest-content h3 { margin-bottom: .6rem; font-size: 1.2rem; line-height: 1.4; }
.interest-content p, .skill-card p, .profile-card p { color: var(--text-muted); }

/* Skills */
.skill-card { padding: 1.6rem 1.4rem; text-align: center; }
.skill-icon { margin-bottom: 1rem; font-size: 3rem; color: var(--accent); transition: transform .3s ease; }
.skill-card:hover .skill-icon { transform: scale(1.1); }
.water-skill { color: var(--water-blue); }
.skill-card h3 { margin-bottom: .6rem; font-size: 1.2rem; }

/* Cards that open the detail popup */
.clickable-card { cursor: pointer; }
.clickable-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Connect */
.profile-card { padding: 2rem; text-align: center; }
.profile-icon { margin-bottom: 1rem; font-size: 4rem; color: var(--accent); }

/* ---------- 5. Publications (markup is generated by scholar-publications.js) ---------- */
#google-scholar-publications { width: 100%; }
.pw-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 1.75rem; }
.pw-metric { display: flex; align-items: center; gap: 1.1rem; min-width: 0; padding: 1.4rem; border-top: 4px solid var(--primary); overflow-wrap: anywhere; }
.pw-metric-icon {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--accent);
    font-size: 1.5rem;
}
.pw-metric:nth-child(2) .pw-metric-icon { background: rgba(141, 110, 99, .15); color: var(--soil-brown); }
.pw-metric-label { margin: 0 0 3px; color: var(--text-soft); font-size: .95rem; font-weight: 600; }
.pw-metric-value { margin: 0; color: var(--heading); font: 700 clamp(1.6rem, 2.6vw, 2.5rem)/1.15 'Merriweather', serif; }
.pw-metric:nth-child(2) .pw-metric-value { color: var(--soil-brown); }

.pw-list { padding-top: .5rem; border-top: 1px solid var(--divider); }
.pw-publication {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: clamp(8px, 1.2vw, 16px);
    padding: 1rem 0;
    border-bottom: 1px solid var(--divider);
}
.pw-publication:last-child { border-bottom: 0; }
.pw-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--heading);
    font-weight: 700;
}
.pw-reference { min-width: 0; line-height: 1.8; overflow-wrap: anywhere; }
.pw-reference strong { color: var(--heading); }
.pw-author-self { font-weight: 700; }
.pw-paper-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--link);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}
.pw-paper-link:hover { text-decoration: underline; }
.pw-status { padding: 14px 0; color: var(--text-soft); }
.pw-scholar-action { display: flex; justify-content: center; margin-top: 1.5rem; }
.pw-scholar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 50px;
    padding: 12px 28px;
    border-radius: 999px;
    background: var(--primary-dark);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: background-color .2s ease, transform .2s ease;
}
.pw-scholar-button:hover { background: var(--primary); transform: translateY(-2px); }
body.dark-mode .pw-scholar-button { background: #405b31; }

/* ---------- 6. Contact & footer ---------- */
.contact-container { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 2rem; align-items: start; }
.contact-info, .contact-form { padding: 2rem; }
.contact-item { display: flex; align-items: flex-start; margin-bottom: 1.3rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.contact-icon { flex: 0 0 50px; width: 50px; margin-right: 1rem; text-align: center; font-size: 1.8rem; color: var(--accent); }
.contact-item-content h4 { margin-bottom: .3rem; font-size: 1.15rem; }
.contact-item-content a { color: var(--link); }

.form-group { margin-bottom: 1.2rem; }
.form-control {
    width: 100%;
    padding: .9rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    transition: border-color .3s ease, box-shadow .3s ease;
}
.form-control::placeholder { color: #89978f; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(85, 107, 47, .15); }
textarea.form-control { min-height: 140px; resize: vertical; }

.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .9rem 2.2rem;
    border: none;
    border-radius: 30px;
    background: var(--primary);
    color: #fff;
    font: 600 1.05rem 'Open Sans', sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, .15);
    transition: background-color .3s ease, transform .3s ease, box-shadow .3s ease;
}
.submit-btn:hover { background: var(--primary-dark); transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0, 0, 0, .2); }
.submit-btn:disabled { opacity: .7; cursor: not-allowed; transform: none; }

.contact-status { display: none; margin-top: 1rem; padding: .9rem 1rem; border-radius: 8px; font-size: .95rem; }
.contact-status.success { display: block; background: #edf7ed; color: #2e6b2e; border: 1px solid #b8d8b8; }
.contact-status.error { display: block; background: #fff0f0; color: #9b2c2c; border: 1px solid #e4b5b5; }

footer { padding: 2.25rem 0; background: var(--primary-dark); color: #fff; text-align: center; transition: background-color .3s ease; }
body.dark-mode footer { background: #080c0a; }
footer h3 { color: #fff; }
.footer-content { max-width: 900px; margin: 0 auto; }
.social-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 1.2rem 0; list-style: none; }
.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 1.35rem;
    transition: background-color .3s ease, transform .3s ease;
}
.social-links a:hover { background: var(--primary); transform: translateY(-5px); }
.copyright { margin-top: 1rem; font-size: .9rem; opacity: .8; }

/* Floating "Schedule a Meeting" button */
.meeting-dial {
    position: fixed;
    right: 25px;
    bottom: 25px;
    z-index: 9999;
    display: flex;
    align-items: center;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border-radius: 50px;
    background: #d4a017;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, .25);
    transition: width .35s ease;
    animation: pulse 2.5s infinite;
}
body.dark-mode .meeting-dial { background: #a77d16; }
.meeting-dial:hover { width: 240px; animation: none; }
.meeting-dial .icon { min-width: 64px; text-align: center; font-size: 28px; }
.meeting-dial .label { white-space: nowrap; opacity: 0; font-weight: 600; font-size: 15px; transition: opacity .2s ease; }
.meeting-dial:hover .label { opacity: 1; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- 7. Popups ---------- */
/* Request modals (CV / research statement) */
.cv-modal { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(0, 0, 0, .65); }
.cv-modal.active { display: flex; }
.cv-modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2.25rem;
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    animation: popIn .25s ease;
}
.cv-modal-close { position: absolute; top: 12px; right: 18px; width: 36px; height: 36px; border: none; background: transparent; color: var(--text-soft); font-size: 2rem; cursor: pointer; }
.cv-modal-close:hover { color: var(--heading); }
.cv-modal-header { margin-bottom: 1.5rem; text-align: center; }
.cv-modal-header i { margin-bottom: 1rem; font-size: 2.5rem; color: var(--accent); }
.cv-modal-header h2 { margin-bottom: .5rem; }
.cv-modal-header p { color: var(--text-soft); }
.cv-modal label { display: block; margin-bottom: .5rem; font-weight: 600; color: var(--text); }
.cv-modal .submit-btn { width: 100%; }
@keyframes popIn { from { opacity: 0; transform: translateY(-20px) scale(.98); } to { opacity: 1; transform: none; } }

/* Message-sent confirmation */
.request-confirmation-overlay {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem; background: rgba(15, 23, 42, .58);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .45s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .45s;
}
.request-confirmation-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.request-confirmation-overlay.closing { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .55s ease, visibility 0s linear .55s; }
.request-confirmation-card {
    width: min(420px, 100%);
    padding: 2.25rem 1.75rem;
    border-radius: 18px;
    background: var(--surface);
    text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .25);
    opacity: 0;
    transform: translateY(16px) scale(.965);
    transition: transform .5s cubic-bezier(.22, 1, .36, 1), opacity .45s ease;
}
.request-confirmation-overlay.active .request-confirmation-card { opacity: 1; transform: none; }
.request-confirmation-overlay.closing .request-confirmation-card { opacity: 0; transform: translateY(-8px) scale(.98); transition: transform .45s ease, opacity .45s ease; }
.confirmation-check {
    display: flex; align-items: center; justify-content: center;
    width: 76px; height: 76px; margin: 0 auto 1.1rem;
    border-radius: 50%; background: #2e7d32; color: #fff; font-size: 2.1rem;
    box-shadow: 0 8px 24px rgba(46, 125, 50, .25);
    animation: confirmationPop .6s cubic-bezier(.2, .8, .2, 1) .05s both;
}
.confirmation-check i { animation: confirmationCheck .4s cubic-bezier(.2, .8, .2, 1) .22s both; }
.request-confirmation-card h3 { margin: 0 0 .45rem; color: var(--ok); font-size: 1.35rem; }
.request-confirmation-card p { margin: 0; color: var(--text-muted); }
@keyframes confirmationPop { 0% { transform: scale(.72); opacity: 0; } 65% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes confirmationCheck { 0% { transform: scale(0) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Skill / research-interest detail popup (see card-details-modal.js) */
.detail-modal { display: none; position: fixed; inset: 0; z-index: 2147483646; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(0, 0, 0, .7); }
.detail-modal.active { display: flex; animation: fadeIn .2s ease; }
.detail-modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
    animation: fadeInUp .25s ease;
}
.detail-modal-close { position: absolute; top: .6rem; right: .9rem; border: none; background: none; color: inherit; font-size: 2rem; line-height: 1; cursor: pointer; }
.detail-modal-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; padding-right: 1.5rem; }
.detail-modal-icon { flex: 0 0 56px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1.5rem; }
.detail-modal-type { display: block; color: var(--accent); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.detail-modal-header h2 { margin: .15rem 0 0; font-size: 1.4rem; line-height: 1.25; }
.detail-overview { margin-bottom: 1.25rem; line-height: 1.7; }
.detail-section { margin-bottom: 1.1rem; }
.detail-section h4 { margin-bottom: .5rem; font-size: .95rem; color: var(--accent); }
.detail-list { padding-left: 1.2rem; line-height: 1.7; }
.detail-tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-tag { padding: .25rem .75rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-text); font-size: .85rem; }

/* ---------- 8. Responsive ---------- */
@media (min-width: 1600px) {
    .projects-grid, .interests-grid { --cols: 4; }
}
@media (max-width: 1599px) {
    .projects-grid, .interests-grid { --cols: 3; }
    .skills-container { --cols: 4; }
}
@media (max-width: 1199px) {
    .skills-container { --cols: 3; }
}

/* Tablet: menu collapses, hero stacks */
@media (max-width: 992px) {
    .projects-grid, .interests-grid, .skills-container, .connect-container { --cols: 2; }
    .hero { grid-template-columns: 1fr; min-height: 0; padding: 1.5rem 0 4rem; text-align: center; }
    .hero-content { margin: 0 auto; }
    .hero-about { margin-left: auto; margin-right: auto; }
    .hero-document-buttons { justify-content: center; }
    .hero-research-panel { max-width: 640px; width: 100%; margin: 0 auto; }
    .contact-container { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: .5rem;
        border-radius: 14px;
        background: rgba(42, 61, 18, .98);
        box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
    }
    body.dark-mode .nav-links { background: rgba(18, 24, 20, .98); }
    nav.nav-open .nav-links { display: flex; }
    .nav-links a { display: block; padding: .8rem 1rem; font-size: 1rem; }
    .nav-links a:after { display: none; }
    .nav-links a:hover { background: rgba(255, 255, 255, .08); border-radius: 8px; }
    .theme-toggle { margin-left: auto; }
    .mobile-menu-btn { display: inline-flex; }
}

@media (max-width: 768px) {
    section { scroll-margin-top: 78px; }
    .logo { font-size: 1.5rem; }
    nav.nav-floating { top: 8px; width: calc(100% - 20px); min-height: 58px; padding: .5rem .7rem; border-radius: 15px; }
    #education .container { grid-template-columns: 1fr; }
    .education-item { padding: 1.4rem; }
    .plant { height: 60px !important; }
    .meeting-dial { right: 15px; bottom: 15px; }
    .meeting-dial:hover { width: 210px; }
}

@media (max-width: 900px) {
    .pw-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pw-metric:last-child { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
    .projects-grid, .interests-grid, .skills-container, .connect-container { --cols: 1; }
    .pw-metrics { grid-template-columns: 1fr; }
    .pw-metric { padding: 1rem; gap: .9rem; }
    .pw-metric-icon { flex-basis: 46px; width: 46px; height: 46px; font-size: 1.15rem; }
    .pw-publication { grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
    .pw-number { width: 30px; height: 30px; font-size: .9rem; }
    .pw-scholar-button { width: 100%; padding: 12px 16px; }
    .hero-document-buttons { flex-direction: column; align-items: stretch; }
    .hero .btn { width: 100%; text-align: center; }
    .contact-info, .contact-form, .profile-card { padding: 1.3rem; }
    .cv-modal-content { padding: 1.75rem 1.25rem; }
    .detail-modal-content { padding: 1.5rem 1.25rem; }
}

@media (max-width: 420px) {
    .container { width: 96%; padding: 0 6px; }
    .hero h1 { font-size: 2rem; }
    .section-title { font-size: 1.6rem; }
    .hero-research-panel { grid-template-columns: 1fr 1fr; padding: .75rem; gap: .6rem; }
    .project-footer { flex-wrap: wrap; }
}

/* ---------- 9. Motion ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: none; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .animate-on-scroll { opacity: 1; transform: none; }
}
