/* ===========================================
   SAMMIE CHAN — PORTFOLIO
   Clean single-page resume, zero JS frameworks
   =========================================== */

/* ---------- Fonts ---------- */
@font-face {
    font-family: 'Montserrat';
    src: url('./assets/Montserrat-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* ---------- Custom properties ---------- */
:root {
    --c-bg:      #0e0e10;
    --c-surface: #18181b;
    --c-card:    #1e1e22;
    --c-border:  #2a2a2e;
    --c-text:    #e4e4e7;
    --c-muted:   #a1a1aa;
    --c-accent:  #6366f1;
    --c-accent2: #38bdf8;
    --c-accent3: #a78bfa;
    --c-accent4: #fb923c;
    --c-heading: #ffffff;
    --c-hero-grad-start: #fff;
    --c-header-bg: rgba(14,14,16,.85);
    --c-overlay-bg: rgba(14,14,16,.96);
    --c-tech-hover: rgba(255,255,255,.04);
    --c-job-hover-border: rgba(99,102,241,.4);
    --c-edu-icon-bg: rgba(99,102,241,.1);
    --c-cert-icon-bg: rgba(251,146,60,.1);
    --c-tag-bg: rgba(251,146,60,.1);
    --c-hero-grad1: rgba(99,102,241,.12);
    --c-hero-grad2: rgba(56,189,248,.08);
    --radius:    12px;
    --header-h:  64px;
}

html.light {
        --c-bg:      #f8f9fa;
        --c-surface: #ffffff;
        --c-card:    #ffffff;
        --c-border:  #e2e4e9;
        --c-text:    #1e1e2e;
        --c-muted:   #5c5f6e;
        --c-accent:  #4f46e5;
        --c-accent2: #0284c7;
        --c-accent3: #7c3aed;
        --c-accent4: #ea580c;
        --c-heading: #111118;
        --c-hero-grad-start: #111118;
        --c-header-bg: rgba(248,249,250,.9);
        --c-overlay-bg: rgba(248,249,250,.97);
        --c-tech-hover: rgba(0,0,0,.04);
        --c-job-hover-border: rgba(79,70,229,.3);
        --c-edu-icon-bg: rgba(79,70,229,.08);
        --c-cert-icon-bg: rgba(234,88,12,.08);
        --c-tag-bg: rgba(234,88,12,.08);
        --c-hero-grad1: rgba(79,70,229,.06);
        --c-hero-grad2: rgba(2,132,199,.05);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }
body {
    font-family: 'Montserrat', system-ui, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ---------- Utilities ---------- */
.container { width: 90%; max-width: 1120px; margin: 0 auto; }

/* =============================================
   HEADER
   ============================================= */
#header {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 clamp(1rem, 4vw, 2.5rem);
    z-index: 100;
    background: transparent;
    transition: background .3s, box-shadow .3s;
}
#header.scrolled {
    background: var(--c-header-bg);
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 var(--c-border);
}
html.light #header.scrolled { box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.logo {
    font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

#desktop-nav {
    display: flex; gap: 2rem;
    position: absolute; left: 50%; transform: translateX(-50%);
}
#desktop-nav a {
    font-size: .85rem; font-weight: 500; letter-spacing: .04em;
    text-transform: uppercase; color: var(--c-muted);
    transition: color .25s;
}
#desktop-nav a:hover { color: var(--c-heading); }

.header-right { display: flex; align-items: center; gap: 1rem; }
.header-social { display: flex; gap: 1rem; }
.header-social a {
    color: var(--c-muted); font-size: 1.1rem;
    transition: color .25s;
}
.header-social a:hover { color: var(--c-accent2); }

/* Hamburger */
#menu-toggle {
    display: none; background: none; border: none; cursor: pointer;
    width: 28px; height: 20px; position: relative; z-index: 110;
}

/* Theme toggle */
#theme-toggle {
    background: none; border: 1px solid var(--c-border); cursor: pointer;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-muted); font-size: 1rem;
    transition: color .25s, border-color .25s;
}
#theme-toggle:hover { color: var(--c-accent2); border-color: var(--c-accent2); }
#theme-toggle .fa-sun  { display: none; }
#theme-toggle .fa-moon { display: inline; }
html.light #theme-toggle .fa-sun  { display: inline; }
html.light #theme-toggle .fa-moon { display: none; }
#menu-toggle span {
    display: block; width: 100%; height: 2px; background: var(--c-text);
    border-radius: 2px; position: absolute; left: 0;
    transition: transform .3s, opacity .3s;
}
#menu-toggle span:nth-child(1) { top: 0; }
#menu-toggle span:nth-child(2) { top: 50%; transform: translateY(-50%); }
#menu-toggle span:nth-child(3) { bottom: 0; }
#menu-toggle.open span:nth-child(1) { top: 50%; transform: translateY(-50%) rotate(45deg); }
#menu-toggle.open span:nth-child(2) { opacity: 0; }
#menu-toggle.open span:nth-child(3) { bottom: 50%; transform: translateY(50%) rotate(-45deg); }

/* Mobile nav overlay */
#mobile-nav {
    position: fixed; inset: 0; z-index: 105;
    background: var(--c-overlay-bg); backdrop-filter: blur(20px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem;
    opacity: 0; pointer-events: none; transition: opacity .35s;
}
#mobile-nav.open { opacity: 1; pointer-events: auto; }
#mobile-nav a {
    font-size: 1.5rem; font-weight: 600; color: var(--c-muted);
    transition: color .2s;
}
#mobile-nav a:hover { color: var(--c-heading); }
.mobile-nav-social { display: flex; gap: 1.5rem; margin-top: 1rem; }
.mobile-nav-social a { font-size: 1.3rem; }

/* =============================================
   HERO
   ============================================= */
#hero {
    position: relative; min-height: 100vh; display: flex; align-items: center;
    overflow: hidden; padding: calc(var(--header-h) + 2rem) 0 4rem;
}
.hero-bg {
    position: absolute; inset: 0; z-index: 0;
    background:
        radial-gradient(ellipse 80% 60% at 70% 40%, var(--c-hero-grad1) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 20% 80%, var(--c-hero-grad2) 0%, transparent 60%);
}

.hero-grid {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center;
}

.hero-text { max-width: 560px; }
.hero-label {
    display: inline-block;
    font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
    color: var(--c-accent2);
    margin-bottom: 1rem;
}
#hero h1 {
    font-size: clamp(2.6rem, 5vw, 4rem); font-weight: 700;
    line-height: 1.1; letter-spacing: -.03em;
    background: linear-gradient(135deg, var(--c-hero-grad-start) 30%, var(--c-accent2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.25rem;
}
.hero-text p {
    font-size: 1.05rem; color: var(--c-muted); max-width: 480px;
    margin-bottom: 2rem;
}

.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn-primary, .btn-outline {
    display: inline-flex; align-items: center; padding: .75rem 1.5rem;
    font-size: .9rem; font-weight: 600; border-radius: 8px;
    transition: transform .2s, box-shadow .2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent2));
    color: #fff; /* always white on gradient */
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(99,102,241,.3); }
.btn-outline {
    border: 1px solid var(--c-border); color: var(--c-text);
    background: transparent;
}
.btn-outline:hover {
    border-color: var(--c-accent2); color: var(--c-accent2);
    transform: translateY(-2px);
}

.hero-portrait {
    display: flex; justify-content: center; align-items: center;
}
.hero-portrait img {
    width: clamp(180px, 25vw, 380px);
    height: clamp(180px, 25vw, 380px);
    filter: grayscale(20%) brightness(1.05);
    border-radius: 50%;
    border: 3px solid var(--c-border);
    box-shadow: 0 0 60px rgba(99,102,241,.15);
    object-fit: cover;
}
html.light .hero-portrait img {
    filter: grayscale(10%) brightness(1);
    box-shadow: 0 8px 30px rgba(0,0,0,.1);
}

/* =============================================
   SECTION SHARED
   ============================================= */
section { padding: 6rem 0; }
.section-heading {
    font-size: clamp(1.75rem, 3vw, 2.25rem); font-weight: 700;
    text-align: center; margin-bottom: 3.5rem;
    position: relative;
}
.section-heading::after {
    content: ''; display: block; width: 48px; height: 3px;
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent2));
    margin: .75rem auto 0; border-radius: 2px;
}

/* reveal-on-scroll */
.skill-group, .job, .edu-card {
    opacity: 0; transform: translateY(24px);
    transition: opacity .6s ease, transform .6s ease;
}
.skill-group.visible, .job.visible, .edu-card.visible {
    opacity: 1; transform: translateY(0);
}

/* =============================================
   SKILLS
   ============================================= */
#skills { background: var(--c-surface); }

.skills-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}

.skill-group {
    background: var(--c-card); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 1.75rem;
    transition: opacity .6s ease, transform .6s ease, border-color .3s;
}
.skill-group:hover { border-color: var(--c-accent); }

.skill-group[data-accent="blue"]  { border-top: 3px solid var(--c-accent); }
.skill-group[data-accent="cyan"]  { border-top: 3px solid var(--c-accent2); }
.skill-group[data-accent="violet"]{ border-top: 3px solid var(--c-accent3); }
.skill-group[data-accent="orange"]{ border-top: 3px solid var(--c-accent4); }

.skill-group h3 {
    font-size: .95rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--c-muted); margin-bottom: 1.25rem;
}

.tech-icons {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem;
}

.tech {
    display: flex; flex-direction: column; align-items: center;
    gap: .4rem; padding: .75rem .5rem; border-radius: 8px;
    transition: background .25s, transform .25s;
}
.tech:hover { background: var(--c-tech-hover); transform: translateY(-3px); }
.tech img { width: 36px; height: 36px; object-fit: contain; }
.tech span { font-size: .72rem; color: var(--c-muted); text-align: center; }
.invert-icon { filter: brightness(0) invert(1); }
html.light .invert-icon { filter: none; }

/* =============================================
   EXPERIENCE (TIMELINE)
   ============================================= */
#experience { background: var(--c-bg); }

.timeline {
    position: relative; max-width: 760px; margin: 0 auto;
    padding-left: 36px;
}
.timeline::before {
    content: ''; position: absolute; left: 7px; top: 8px; bottom: 0;
    width: 2px; background: var(--c-border);
}

.job {
    position: relative; margin-bottom: 2.5rem;
}
.job:last-child { margin-bottom: 0; }

.job-marker {
    position: absolute; left: -36px; top: 6px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--c-accent); border: 3px solid var(--c-bg);
    z-index: 2;
    transition: box-shadow .3s;
}
.job:hover .job-marker { box-shadow: 0 0 12px var(--c-accent); }

.job:nth-child(2) .job-marker { background: var(--c-accent2); }
.job:nth-child(2):hover .job-marker { box-shadow: 0 0 12px var(--c-accent2); }
.job:nth-child(3) .job-marker { background: var(--c-accent3); }
.job:nth-child(3):hover .job-marker { box-shadow: 0 0 12px var(--c-accent3); }
.job:nth-child(4) .job-marker { background: var(--c-accent4); }
.job:nth-child(4):hover .job-marker { box-shadow: 0 0 12px var(--c-accent4); }
.job:nth-child(5) .job-marker { background: #34d399; }
.job:nth-child(5):hover .job-marker { box-shadow: 0 0 12px #34d399; }

.job-card {
    background: var(--c-card); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 1.5rem 1.75rem;
    transition: border-color .3s, transform .3s;
}
.job:hover .job-card {
    border-color: var(--c-job-hover-border);
    transform: translateY(-3px);
}

.job-date {
    display: inline-block; font-size: .78rem; font-weight: 500;
    color: var(--c-accent2); margin-bottom: .5rem;
    letter-spacing: .03em;
}

.job-card h3 {
    font-size: 1.15rem; font-weight: 700; color: var(--c-heading);
    margin-bottom: .15rem;
}
.job-card h4 {
    font-size: .9rem; font-weight: 500; color: var(--c-muted);
    margin-bottom: .85rem;
}
.job-card ul {
    padding-left: 1.1rem; list-style: disc;
}
.job-card li {
    font-size: .88rem; color: var(--c-muted); margin-bottom: .45rem;
    line-height: 1.55;
}
.job-card li::marker { color: var(--c-accent); }

/* =============================================
   EDUCATION
   ============================================= */
#education { background: var(--c-surface); }

.edu-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
    max-width: 960px; margin: 0 auto;
}

.edu-card {
    background: var(--c-card); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 2rem;
    display: flex; gap: 1.25rem;
    transition: opacity .6s ease, transform .6s ease, border-color .3s;
}
.edu-card:hover { border-color: var(--c-job-hover-border); }
.edu-card.cert { border-top: 3px solid var(--c-accent4); }
.edu-card:not(.cert) { border-top: 3px solid var(--c-accent3); }

.edu-icon {
    flex-shrink: 0; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--c-edu-icon-bg); border-radius: 50%;
    font-size: 1.3rem; color: var(--c-accent3);
}
.edu-card.cert .edu-icon { background: var(--c-cert-icon-bg); }
.edu-icon img { width: 28px; height: 28px; object-fit: contain; }

.edu-body { flex: 1; }
.edu-date {
    display: inline-block; font-size: .76rem; font-weight: 500;
    color: var(--c-accent2); margin-bottom: .4rem; letter-spacing: .03em;
}
.edu-body h3 {
    font-size: 1.1rem; font-weight: 700; color: var(--c-heading);
    margin-bottom: .35rem;
}
.edu-degree {
    font-size: .92rem; font-weight: 600; color: var(--c-text);
    margin-bottom: .6rem;
}
.edu-body p {
    font-size: .85rem; color: var(--c-muted); line-height: 1.6;
}

.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.tag {
    font-size: .72rem; font-weight: 600;
    padding: .3rem .7rem; border-radius: 20px;
    background: var(--c-tag-bg); color: var(--c-accent4);
}

.card-link {
    display: inline-flex; align-items: center; gap: .4rem;
    margin-top: .75rem; font-size: .82rem; font-weight: 600;
    color: var(--c-accent4); transition: gap .25s;
}
.card-link:hover { gap: .7rem; }

/* =============================================
   FOOTER
   ============================================= */
footer {
    border-top: 1px solid var(--c-border);
    padding: 2rem 0; background: var(--c-bg);
}
.footer-inner {
    display: flex; align-items: center; justify-content: space-between;
    font-size: .82rem; color: var(--c-muted);
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a {
    color: var(--c-muted); font-size: 1rem;
    transition: color .25s;
}
.footer-links a:hover { color: var(--c-accent2); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
    #desktop-nav, .header-social { display: none; }
    #menu-toggle { display: block; }

    .hero-grid { grid-template-columns: 1fr; text-align: center; }
    .hero-text { max-width: 100%; margin: 0 auto; }
    .hero-text p { margin-left: auto; margin-right: auto; }
    .hero-actions { justify-content: center; }
    .hero-portrait { order: -1; }
    .hero-portrait img { width: clamp(180px, 45vw, 260px); height: clamp(180px, 45vw, 260px); }

    .skills-grid { grid-template-columns: 1fr; }
    .edu-grid   { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    :root { --header-h: 56px; }
    section { padding: 4rem 0; }

    #hero h1 { font-size: 2.2rem; }
    .hero-portrait img { width: clamp(150px, 40vw, 200px); height: clamp(150px, 40vw, 200px); }

    .tech-icons { grid-template-columns: repeat(3, 1fr); }

    .timeline { padding-left: 28px; }
    .job-marker { left: -28px; width: 14px; height: 14px; }
    .timeline::before { left: 5px; }

    .job-card { padding: 1.25rem; }

    .edu-card { flex-direction: column; }

    .footer-inner { flex-direction: column; gap: .75rem; text-align: center; }
}