/* ===== Base ===== */
:root {
    --blue: #1a6db5;
    --blue-dark: #12538c;
    --text: #2b2b2b;
    --muted: #555;
    --bg: #ffffff;
    --bg-alt: #f8f8f8;
    --border: #1a6db5;
    --radius: 10px;
    --header-h: 74px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
    margin: 0;
    font-family: "Poppins", system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; }

.container {
    width: 100%;
    max-width: 1170px;
    margin: 0 auto;
    padding: 0 24px;
}

section { padding: 110px 0; }
.section-alt { background: var(--bg-alt); }

.eyebrow {
    display: block;
    color: var(--blue);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.section-head { text-align: center; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(1.4rem, 2.6vw, 1.75rem); font-weight: 700; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 26px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font: 600 1rem "Poppins", sans-serif;
    cursor: pointer;
    transition: background .2s;
}
.btn:hover { background: var(--blue-dark); }

/* ===== Header ===== */
.site-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 100;
    height: var(--header-h);
    background: #fff;
    border-bottom: 3px solid var(--blue);
}
.header-inner {
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -.02em;
}
.logo img { width: 44px; height: 44px; }

.navbar { display: flex; gap: 6px; }
.navbar a {
    padding: 6px 8px;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text);
    border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s;
}
.navbar a:hover, .navbar a.active { color: var(--blue); border-color: var(--blue); }

.menu-toggle {
    display: none;
    background: none;
    border: 0;
    font-size: 1.6rem;
    color: var(--text);
    cursor: pointer;
}

/* ===== Hero ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: calc(var(--header-h) + 40px) 0 60px;
}
.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 48px;
    align-items: center;
}
.hero-text h1 {
    font-size: clamp(2.4rem, 5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: 18px;
}
.hero-text p { font-size: 1.3rem; max-width: 34ch; margin: 0 0 22px; }
.hero-socials { display: flex; gap: 10px; font-size: 2.1rem; }
.hero-socials a { color: var(--text); transition: color .2s; }
.hero-socials a:hover { color: var(--blue); }

.hero-photo { display: flex; justify-content: center; }
.hero-photo img {
    width: min(320px, 80vw);
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: 50% 15%;
    border: 3px solid var(--blue);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: morph 8s ease-in-out infinite;
}
@keyframes morph {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    50% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
}
.scramble .word { white-space: nowrap; }
.scramble .ch { display: inline-block; text-align: center; }
.scramble .ch.bit { color: var(--blue); font-family: "Courier New", monospace; font-weight: 700; transform: scaleX(var(--sx, 1)); }
.hero-socials { align-items: center; }

/* ===== About ===== */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 64px;
    align-items: start;
}
.about-image img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    object-position: 50% 35%;
    border-radius: var(--radius);
}
.about-text h2 { font-size: clamp(1.4rem, 2.6vw, 1.75rem); font-weight: 700; margin-bottom: 18px; }
.about-text p { margin: 0 0 20px; }
.about-facts {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    display: grid;
    gap: 6px;
}
.about-facts i { color: var(--blue); width: 22px; }

.section-intro { max-width: 640px; margin: 14px auto 0; color: var(--muted); }

/* ===== Achievements ===== */
.achievement {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 36px;
    align-items: center;
    padding: 28px;
}
.achievement-media, .achievement-thumbs button, .lab-item {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: zoom-in;
}
.achievement-media img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
    transition: transform .3s;
}
.achievement-media:hover img { transform: scale(1.02); }
.achievement-body h3 { font-size: 1.55rem; margin-top: 12px; }
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
}
.stats div {
    border-left: 4px solid var(--blue);
    background: var(--bg-alt);
    border-radius: 6px;
    padding: 10px 14px;
}
.stats strong { display: block; font-size: 1.8rem; line-height: 1.1; color: var(--blue); }
.stats sup { font-size: .55em; }
.stats span { font-size: .88rem; color: var(--muted); }
.achievement-thumbs { display: flex; gap: 14px; }
.achievement-thumbs button { width: 150px; }
.achievement-thumbs img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: top;
    border-radius: 6px;
    border: 2px solid #d5dde7;
    transition: border-color .2s;
}
.achievement-thumbs button:hover img { border-color: var(--blue); }
.achievement-thumbs span { display: block; font-size: .85rem; font-weight: 500; margin-top: 4px; color: var(--blue); }

/* ===== Events ===== */
.event {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 36px;
    align-items: start;
    padding: 28px;
}
.event-media, .event-thumbs button {
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}
.event-media img { width: 100%; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); }
.event-body h3 { font-size: 1.4rem; margin-top: 12px; }
.event-body p { margin: 12px 0 0; }
.arrow-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.arrow-list li { position: relative; padding-left: 26px; }
.arrow-list li::before { content: "→"; position: absolute; left: 0; color: var(--blue); font-weight: 700; }
.event-thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 20px; }
.event-thumbs img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #d5dde7;
    transition: border-color .2s;
}
.event-thumbs button:hover img { border-color: var(--blue); }

/* ===== Case study ===== */
.case-study { padding: 28px; margin-bottom: 56px; }
.case-study > h3 { font-size: 1.6rem; margin-top: 12px; }
.case-study > p { margin-top: 8px; max-width: 760px; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.case-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-top: 8px;
}
.case-columns h4 { margin: 0 0 10px; font-size: 1.05rem; }
.case-columns h4 i { color: var(--blue); margin-right: 6px; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.check-list li { position: relative; padding-left: 26px; }
.check-list li::before { content: "✔"; position: absolute; left: 0; color: var(--blue); font-weight: 700; }
.case-thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 24px; }
.case-thumbs button { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: zoom-in; }
.case-thumbs img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: top left;
    border-radius: 6px;
    border: 2px solid #d5dde7;
    transition: border-color .2s;
}
.case-thumbs button:hover img { border-color: var(--blue); }
.case-thumbs span { display: block; font-size: .85rem; font-weight: 500; margin-top: 4px; color: var(--blue); }
.lab-subhead { font-size: 1.35rem; margin-bottom: 20px; }
.lab-grid + .lab-subhead { margin-top: 56px; }
.event + .event { margin-top: 28px; }

/* ===== Lab gallery ===== */
.lab-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.lab-item {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
    transition: box-shadow .25s, transform .25s;
}
.lab-item:hover, .lab-item:focus-visible { box-shadow: 0 10px 26px rgba(26, 109, 181, .25); transform: translateY(-3px); }
.lab-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; }
.lab-item span { display: block; padding: 12px 14px 14px; font-size: .9rem; line-height: 1.5; }

/* ===== Lightbox ===== */
.lightbox {
    border: 0;
    padding: 0;
    background: transparent;
    max-width: min(1400px, 94vw);
    max-height: 94vh;
    overflow: visible;
}
.lightbox::backdrop { background: rgba(10, 16, 26, .88); }
.lightbox img { max-width: 100%; max-height: 84vh; margin: 0 auto; border-radius: 6px; }
.lightbox p { color: #fff; text-align: center; margin: 12px 0 0; }
.lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: var(--blue);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

/* ===== Portfolio ===== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}
.project {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    aspect-ratio: 16 / 9;
    background: #0d1420;
}
.project img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s, filter .4s;
}
.project-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px 22px;
    color: #fff;
    background: linear-gradient(to top, rgba(6, 14, 26, .92) 0%, rgba(6, 14, 26, .7) 40%, rgba(6, 14, 26, .15) 80%, transparent 100%);
    transition: background .3s;
}
.project-overlay h3 { font-size: 1.6rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.project-desc {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    font-size: .92rem;
    margin: 0;
    transition: max-height .4s, opacity .3s, margin .3s;
}
.project-links { display: flex; gap: 10px; }
.project-links a {
    font-size: .9rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--blue);
}
.project-links a:hover { background: var(--blue-dark); }
.project:hover img, .project:focus-within img { transform: scale(1.05); filter: blur(2px); }
.project:hover .project-overlay, .project:focus-within .project-overlay { background: rgba(8, 20, 36, .85); }
.project:hover .project-desc, .project:focus-within .project-desc { max-height: 220px; opacity: 1; margin: 10px 0 14px; }
/* last odd card centred, like the reference */
.project-grid > .project:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: calc(50% - 16px);
    justify-self: center;
}

/* ===== Cards (services, timeline, contact) ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}
.card {
    border: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 22px 24px;
    background: #fff;
}
.card h3 { font-size: 1.6rem; font-weight: 600; margin: 8px 0 10px; }
.card p { margin: 0; }
.card-icon { font-size: 2.2rem; color: var(--blue); }

/* ===== Skills ===== */
.skill-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px 32px;
}
.skill-group {
    background: var(--bg-alt);
    border-left: 4px solid var(--blue);
    border-radius: 6px;
    padding: 18px 20px;
}
.skill-group h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }
.skill-group h3 i { color: var(--blue); width: 26px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    background: var(--blue);
    color: #fff;
    font-size: .88rem;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 4px;
}

/* ===== Timeline (education + experience) ===== */
.timeline {
    max-width: 760px;
    margin: 0 auto;
    display: grid;
    gap: 28px;
}
.timeline-card h3 { font-size: 1.5rem; margin-top: 12px; }
.timeline-card { position: relative; }
.org-logo { position: absolute; top: 20px; right: 22px; height: 64px; width: auto; }
.has-logo h3, .has-logo .org { padding-right: 150px; }
.pill {
    display: inline-block;
    background: var(--blue);
    color: #fff;
    font-size: .88rem;
    font-weight: 500;
    padding: 4px 13px;
    border-radius: 999px;
}
.org { color: var(--blue); margin-bottom: 10px !important; }
.timeline-card ul { margin: 6px 0 0; padding-left: 20px; }
.timeline-card li { margin-bottom: 4px; }

/* ===== Contact ===== */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    align-items: start;
}
.contact-links { display: grid; gap: 20px; }
.contact-item {
    display: flex;
    align-items: center;
    gap: 18px;
    transition: background .2s;
}
.contact-item:hover { background: #eef5fc; }
.contact-item h3 { font-size: 1.15rem; margin: 0 0 2px; }
.contact-item p { color: var(--muted); word-break: break-word; }
.contact-form { display: grid; gap: 16px; }
.contact-form label { display: grid; gap: 6px; font-weight: 500; }
.contact-form input, .contact-form textarea {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid #c4ccd6;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    resize: vertical;
}
.contact-form input:focus, .contact-form textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.contact-form .btn { justify-self: start; }
.contact-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-form { position: relative; }
.form-status { margin: 0; min-height: 1.5em; font-weight: 500; }
.form-status.success { color: #067647; }
.form-status.error { color: #b42318; }

/* ===== Footer ===== */
.site-footer { background: var(--text); color: #fff; padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.footer-inner p { margin: 0; }
.footer-socials { display: flex; gap: 16px; font-size: 1.4rem; }
.footer-socials a:hover { color: #7fb6e8; }

.scroll-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--blue);
    color: #fff;
    font-size: 1.4rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
    z-index: 90;
}
.scroll-top.show { opacity: 1; pointer-events: auto; }

/* ===== Reveal on scroll ===== */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .hero-photo img { animation: none; }
    .scramble .ch.bit { color: inherit; font-family: inherit; }
    html { scroll-behavior: auto; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .lab-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 980px) {
    .menu-toggle { display: block; }
    .navbar {
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background: #fff;
        border-bottom: 3px solid var(--blue);
        display: none;
    }
    .navbar.open { display: flex; }
    .navbar a { padding: 14px 24px; border-bottom: 1px solid #eee; }
    .logo { font-size: 1.35rem; }
    .logo img { width: 36px; height: 36px; }
}

@media (max-width: 860px) {
    section { padding: 80px 0; }
    .hero-grid, .about-grid, .contact-grid { grid-template-columns: 1fr; }
    .hero-grid { text-align: left; }
    .hero-photo { order: -1; }
    .project-grid, .card-grid, .skill-grid, .lab-grid, .achievement, .event { grid-template-columns: 1fr; }
    .event { padding: 18px; }
    .org-logo { position: static; height: 46px; margin-bottom: 12px; }
    .has-logo h3, .has-logo .org { padding-right: 0; }
    .event-thumbs { grid-template-columns: repeat(3, 1fr); }
    .case-study { padding: 18px; }
    .stats-4, .case-thumbs { grid-template-columns: repeat(2, 1fr); }
    .case-columns { grid-template-columns: 1fr; }
    .achievement { padding: 18px; }
    .stats strong { font-size: 1.45rem; }
    .about-image img { aspect-ratio: 4 / 3; }
    .project-grid > .project:last-child:nth-child(odd) { width: 100%; }
    .project { aspect-ratio: 4 / 3; }
    .project-overlay h3 { font-size: 1.3rem; }
    /* no hover on touch: always show the description */
    .project-overlay { background: rgba(8, 20, 36, .82); }
    .project-desc { max-height: none; opacity: 1; margin: 8px 0 12px; }
    .card h3 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    .container { padding: 0 16px; }
    .hero-text p { font-size: 1.1rem; }
    .project { aspect-ratio: auto; min-height: 340px; }
    .footer-inner { flex-direction: column; }
}
