/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Dark (default) */
    --bg:        #0d1117;
    --bg-alt:    #161b22;
    --bg-card:   #1c2128;
    --text:      #e6edf3;
    --text-dim:  #8b949e;
    --accent:    #58a6ff;
    --accent-bg: #58a6ff1a;
    --border:    #30363d;
    --code-bg:   #161b22;
    --shadow:    rgba(0,0,0,0.4);
}

[data-theme="light"] {
    --bg:        #ffffff;
    --bg-alt:    #f6f8fa;
    --bg-card:   #ffffff;
    --text:      #1f2328;
    --text-dim:  #656d76;
    --accent:    #0969da;
    --accent-bg: #0969da1a;
    --border:    #d0d7de;
    --code-bg:   #f6f8fa;
    --shadow:    rgba(0,0,0,0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 16px;
    transition: background 0.2s, color 0.2s;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.container {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-wide {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Header ───────────────────────────────────────────────────────────── */
header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.logo span {
    color: var(--accent);
}

nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

nav a:hover,
nav a.active {
    color: var(--text);
    background: var(--bg-alt);
}

nav a.active {
    color: var(--accent);
    background: var(--accent-bg);
}

/* ── Theme toggle ─────────────────────────────────────────────────────── */
.theme-toggle {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--bg-card);
}

/* ── Hero / Home ──────────────────────────────────────────────────────── */
.hero {
    padding: 4rem 0 3rem;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.hero h1 span {
    color: var(--accent);
}

.hero p {
    color: var(--text-dim);
    font-size: 1.05rem;
    max-width: 540px;
    margin-bottom: 2rem;
}

.hero-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}

.hero-links a:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

/* ── Section ──────────────────────────────────────────────────────────── */
.section {
    padding: 3rem 0;
    border-top: 1px solid var(--border);
}

.section h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

.section h2 span {
    color: var(--accent);
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--shadow);
}

/* Clickable project card (whole card is a link) */
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-link h3,
.card-link p,
.card-link .tags span {
    color: inherit;
}

.card-link h3 {
    color: var(--text);
}

.card-link p {
    color: var(--text-dim);
}

.card-link .tags span {
    color: var(--accent);
}

/* Pin colors on hover so the browser's default link-hover (purple) doesn't bleed through */
.card-link:hover {
    color: inherit;
}

.card-link:hover h3 {
    color: var(--text);
}

.card-link:hover p {
    color: var(--text-dim);
}

.card-link:hover .tags span {
    color: var(--accent);
}

.card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.5;
}

.card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.card .tags span {
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 500;
}

/* ── Article list ─────────────────────────────────────────────────────── */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.article-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.article-item:hover {
    border-color: var(--accent);
}

.article-item .date {
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 90px;
    padding-top: 0.1rem;
}

.article-item .content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.article-item .content p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ── Article body ─────────────────────────────────────────────────────── */
.article-header {
    padding: 3rem 0 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.article-header .meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.article-header .meta span {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.article-header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.article-body {
    padding-bottom: 3rem;
}

.article-body h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
    letter-spacing: -0.01em;
}

.article-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

.article-body p {
    margin-bottom: 1rem;
}

.article-body ul,
.article-body ol {
    margin: 0 0 1rem 1.5rem;
}

.article-body li {
    margin-bottom: 0.35rem;
}

.article-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1.25rem;
    margin: 1rem 0;
    background: var(--accent-bg);
    border-radius: 0 6px 6px 0;
    color: var(--text-dim);
}

.article-body code {
    font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.article-body pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.article-body pre code {
    background: none;
    border: none;
    padding: 0;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.article-body th,
.article-body td {
    border: 1px solid var(--border);
    padding: 0.6rem 0.85rem;
    text-align: left;
}

.article-body th {
    background: var(--bg-alt);
    font-weight: 600;
}

/* ── Resume timeline ──────────────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding: 0 0 2rem 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
}

.timeline-item .role {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.timeline-item .company {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.timeline-item .dates {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.timeline-item ul {
    list-style: none;
    padding: 0;
}

.timeline-item ul li {
    color: var(--text-dim);
    font-size: 0.9rem;
    padding-left: 1rem;
    position: relative;
    margin-bottom: 0.35rem;
}

.timeline-item ul li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ── Skills ───────────────────────────────────────────────────────────── */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.skill-category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.skill-category h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.skill-category ul {
    list-style: none;
    padding: 0;
}

.skill-category li {
    font-size: 0.85rem;
    color: var(--text-dim);
    padding: 0.15rem 0;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
}

footer p {
    color: var(--text-dim);
    font-size: 0.85rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-dim);
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* ── Table wrapper (mobile scroll) ───────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: 8px;
}

.table-wrap table {
    margin: 0;
    min-width: 100%;
}

/* ── Mobile responsive ───────────────────────────────────────────────── */
@media (max-width: 720px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    nav {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.15rem;
    }

    nav a {
        font-size: 0.8rem;
        padding: 0.35rem 0.55rem;
    }

    .hero h1 {
        font-size: 1.7rem;
    }

    .hero {
        padding: 2.5rem 0 2rem;
    }

    .hero-links {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-links a {
        justify-content: center;
    }

    .article-item {
        flex-direction: column;
        gap: 0.4rem;
    }

    .article-item .date {
        min-width: 0;
    }

    .container-wide,
    .container {
        padding: 0 1rem;
    }
}
