/* ============================================
   Design System — jebin2.github.io
   Tokens from: stitch/man_page_minimalist/DESIGN.md
   ============================================ */

:root {
    /* Surfaces */
    --surface:          #131313;
    --surface-low:      #1c1b1b;
    --surface-high:     #2a2a2a;
    --surface-lowest:   #0e0e0e;

    /* Text */
    --on-surface:       #e5e2e1;
    --on-surface-dim:   #bcc9c7;

    /* Accents */
    --primary:          #66d8d2;
    --primary-bg:       rgba(32, 163, 158, 0.18);
    --secondary:        #b3c5ff;
    --tertiary:         #ffb3af;

    /* Borders */
    --outline:          #869392;
    --outline-variant:  #3d4948;
    --border:           #222222;

    /* Typography */
    --font:             'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Layout */
    --max-width:        60%;
    --nav-height:       65px;
    --footer-height:    50px;
}

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

html {
    font-size: 16px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--surface);
    color: var(--on-surface);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

ul, ol { list-style: none; }

button {
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
}

/* ============================================
   Layout
   ============================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

main.container {
    height: 100vh;
    overflow-y: auto;
    padding-top: calc(var(--nav-height) + 3rem);
    padding-bottom: calc(var(--footer-height) + 3rem);
}

/* ============================================
   Header & Nav
   ============================================ */
.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem;
    height: var(--nav-height);
}

.nav-logo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--on-surface);
    letter-spacing: -0.01em;
}
.nav-logo:hover {
    color: var(--primary);
    background: none;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.nav-links a {
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--on-surface-dim);
}
.nav-links a:hover {
    color: var(--primary);
    background: none;
}
.nav-links a.active {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.nav-toggle {
    display: none;
    font-size: 0.75rem;
    color: var(--on-surface-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   Footer — fixed at bottom, matches header
   ============================================ */
.site-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: var(--footer-height);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 100%;
    display: flex;
    gap: 1.25rem;
    align-items: center;
    font-size: 0.68rem;
    color: var(--on-surface-dim);
}

.footer-inner a {
    color: var(--on-surface-dim);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.footer-inner a:hover {
    color: var(--primary);
    background: none;
}

.footer-name {
    font-weight: 700;
    color: var(--on-surface-dim);
    margin-right: 0.25rem;
}

/* ============================================
   Section Labels
   ============================================ */
.section-label {
    font-size: 0.68rem;
    color: var(--on-surface-dim);
    opacity: 0.65;
    margin-bottom: 2rem;
    letter-spacing: 0.01em;
}

.group-label {
    font-size: 0.68rem;
    color: var(--on-surface-dim);
    opacity: 0.3;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 1.25rem;
    margin-top: 3rem;
}
.group-label:first-child {
    margin-top: 0;
}

/* ============================================
   Project Rows
   ============================================ */
.project-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.5rem 0;
    color: inherit;
    transition: background 0.12s;
}
.project-row:hover {
    background: var(--primary-bg);
    padding-left: 0.4rem;
    margin-left: -0.4rem;
}

.project-num {
    font-size: 0.68rem;
    color: var(--tertiary);
    min-width: 1.5rem;
    flex-shrink: 0;
}

.project-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

.project-desc {
    font-size: 0.875rem;
    color: var(--on-surface-dim);
    opacity: 0.6;
    flex-grow: 1;
    min-width: 0;
}

.project-tag {
    font-size: 0.65rem;
    color: var(--secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   Blog Rows
   ============================================ */
.blog-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.4rem 0;
    color: inherit;
    transition: background 0.12s;
}
.blog-row:hover {
    background: var(--primary-bg);
    padding-left: 0.4rem;
    margin-left: -0.4rem;
}
.blog-row:hover .blog-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.blog-title {
    color: var(--primary);
    font-size: 0.875rem;
    flex-shrink: 1;
    min-width: 0;
}

.blog-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.blog-date {
    font-size: 0.68rem;
    color: var(--on-surface-dim);
    white-space: nowrap;
}

.blog-cat {
    font-size: 0.65rem;
    color: var(--secondary);
    white-space: nowrap;
}

/* ============================================
   Filter Bar (Projects page)
   ============================================ */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 2.5rem;
    margin-top: 0.25rem;
}

.project-group {
    margin-bottom: 3rem;
}
.project-group:last-child {
    margin-bottom: 0;
}

.filter-sep {
    color: var(--on-surface-dim);
    opacity: 0.3;
    font-size: 0.75rem;
}

.filter-btn {
    font-size: 0.75rem;
    color: var(--on-surface-dim);
    padding: 0;
    transition: color 0.15s;
    text-transform: lowercase;
}
.filter-btn:hover,
.filter-btn.active {
    color: var(--primary);
}

/* ============================================
   Tags (Links page)
   ============================================ */
.links-subtitle {
    font-size: 0.8rem;
    color: var(--on-surface-dim);
    opacity: 0.45;
    margin-bottom: 2rem;
    margin-top: -1.25rem;
}
.tags-wrap {
    line-height: 2.6;
    font-size: 0.875rem;
}

.tag-link {
    color: var(--on-surface-dim);
    transition: color 0.12s;
}
.tag-link:hover {
    color: var(--primary);
    background: none;
}

.tag-sep {
    color: var(--on-surface-dim);
    opacity: 0.25;
    margin: 0 0.3rem;
    user-select: none;
}

/* ============================================
   Blog Post Body
   ============================================ */
.post-header {
    margin-bottom: 3rem;
}

.post-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.post-meta {
    font-size: 0.68rem;
    color: var(--on-surface-dim);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.post-body {
    font-size: 0.9rem;
    color: var(--on-surface-dim);
    line-height: 1.85;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
    color: var(--on-surface);
    font-weight: 600;
    margin: 2.5rem 0 1rem;
    line-height: 1.3;
}

.post-body h2::before {
    content: "## ";
    color: var(--on-surface-dim);
    opacity: 0.4;
}
.post-body h3::before {
    content: "### ";
    color: var(--on-surface-dim);
    opacity: 0.4;
}

.post-body p { margin: 1rem 0; }

.post-body a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-body ul,
.post-body ol {
    padding-left: 1.5rem;
    margin: 1rem 0;
    list-style: revert;
}
.post-body li { margin: 0.4rem 0; }

.post-body blockquote {
    border-left: 2px solid var(--outline-variant);
    padding-left: 1rem;
    margin: 1.5rem 0;
    opacity: 0.7;
}

.post-body pre {
    background: var(--surface-low);
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.8rem;
    line-height: 1.6;
}

.post-body code {
    font-family: var(--font);
    font-size: 0.85em;
}

.post-body :not(pre) > code {
    color: var(--primary);
    background: var(--surface-low);
    padding: 0.1em 0.35em;
}

.post-body img,
.post-body svg {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

/* Post navigation */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
}

.post-nav a {
    color: var(--on-surface-dim);
}
.post-nav a:hover {
    color: var(--primary);
    background: none;
}

/* ============================================
   Skeleton Loading
   ============================================ */
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50%       { opacity: 0.2; }
}

.skeleton {
    background: var(--surface-low);
    animation: pulse 1.6s ease-in-out infinite;
    display: inline-block;
    height: 0.875rem;
}

.skeleton-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

/* ============================================
   Error / Empty States
   ============================================ */
.state-msg {
    font-size: 0.8rem;
    color: var(--on-surface-dim);
    opacity: 0.5;
    padding: 2rem 0;
}

/* ============================================
   Intro Block (Homepage)
   ============================================ */
.intro {
    margin-bottom: 4rem;
}

.intro-line {
    font-size: 1.1rem;
    line-height: 1.5;
}

.intro-line.primary-text {
    color: var(--primary);
}

.intro-line.dim-text {
    color: var(--on-surface-dim);
}

/* ============================================
   Sections spacing
   ============================================ */
.section {
    margin-bottom: 4rem;
}

/* ============================================
   View All Link
   ============================================ */
.view-all {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--on-surface-dim);
    opacity: 0.6;
    transition: color 0.15s, opacity 0.15s;
}
.view-all:hover {
    color: var(--primary);
    opacity: 1;
    background: none;
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 640px) {
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 1rem;
        position: absolute;
        top: var(--nav-height);
        left: 0; right: 0;
        background: var(--surface);
        padding: 1.5rem 1.25rem;
        border-bottom: 1px solid var(--border);
    }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }

    .project-desc { display: none; }

    .post-title { font-size: 1.1rem; }

    .blog-row {
        flex-direction: column;
        gap: 0.2rem;
    }
    .blog-meta { flex-direction: row; }
}

/* ============================================
   Back link (blog post)
   ============================================ */
.back-link {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--on-surface-dim);
    margin-bottom: 2.5rem;
    transition: color 0.15s;
}
.back-link:hover {
    color: var(--primary);
    background: none;
}

/* ============================================
   Syntax highlight overrides (highlight.js)
   — keeps bg consistent with design system
   ============================================ */
.hljs {
    background: var(--surface-low) !important;
    color: var(--on-surface-dim) !important;
}

/* ============================================
   Scrollbar — dark theme
   ============================================ */

/* Firefox */
main.container {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-high) var(--surface);
}

/* Chrome / Safari / Edge */
main.container::-webkit-scrollbar {
    width: 6px;
}
main.container::-webkit-scrollbar-track {
    background: var(--surface);
}
main.container::-webkit-scrollbar-thumb {
    background: var(--surface-high);
    border-radius: 0;
}
main.container::-webkit-scrollbar-thumb:hover {
    background: var(--outline);
}

/* ============================================
   Accessibility
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 1px solid var(--primary);
    outline-offset: 2px;
}
