:root {
    --primary-color: #2c596b;
    --primary-hover: #2a9d8f;
    --link-color: #e76f51;
    --link-hover: #f4a261;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #737373;
    --text-subtitle: #50666f;
    --border-color: #e0e3e7;
    --white: #ffffff;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        system-ui, sans-serif;
    line-height: 1.55;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 16px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: "Raleway", -apple-system, system-ui, sans-serif;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    line-height: 1.3;
}

h1 {
    font-size: clamp(1.6rem, 4vw, 1.75rem);
}
h2 {
    font-size: clamp(1.35rem, 3vw, 1.5rem);
}
h3 {
    font-size: clamp(1.15rem, 2vw, 1.25rem);
}
h4 {
    font-size: clamp(1.05rem, 2vw, 1.125rem);
}
h5 {
    font-size: clamp(1rem, 2vw, 1.0625rem);
}
h6 {
    font-size: clamp(1rem, 2vw, 1rem);
}

ul,
ol {
    padding-left: 1.5rem;
}
li {
    margin-bottom: 0.5rem;
}
hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

a {
    color: var(--link-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
}

/* Site Header */
.site-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
}

.site-header .container {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-title {
    font-size: clamp(1.3rem, 5vw, 1.75rem);
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-color);
    font-family: "Raleway", system-ui, sans-serif;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.site-title:hover {
    color: var(--primary-hover);
}

header nav {
    display: flex;
    gap: clamp(0.75rem, 2vw, 1.25rem);
    flex-wrap: wrap;
}

header nav a,
.nav-link {
    font-size: clamp(0.9rem, 2vw, 1rem);
    text-decoration: none;
    color: var(--primary-color);
}

header nav a:hover,
.nav-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Main Content */
.main-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1rem 1rem;
}

/* Articles & Posts */
article {
    margin-bottom: 2rem;
    padding: clamp(1rem, 3vw, 1.5rem);
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.post-preview {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
    .post-preview:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }
}

article h2 a,
.title {
    color: var(--primary-color);
    text-decoration: none;
    line-height: 1.3;
    display: block;
    transition: color 0.2s ease;
    margin-top: 0;
}

article h2 a:hover {
    color: var(--primary-hover);
}

.subtitle {
    color: var(--text-subtitle);
    font-weight: 400;
    margin: 0.5rem 0;
}

.meta {
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    color: var(--text-secondary);
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem);
    align-items: center;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

/* Code Blocks */
code {
    background: var(--bg-color);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas,
        monospace;
    border: 1px solid var(--border-color);
    word-wrap: break-word;
}

pre {
    overflow-x: auto;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin: 1.5rem 0;
    -webkit-overflow-scrolling: touch;
}

pre code {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
}

/* Blockquotes */
blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--primary-color);
    background: var(--bg-color);
    border-radius: 0 4px 4px 0;
}

blockquote p {
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

blockquote cite {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: normal;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-narrow {
    width: clamp(280px, 75%, 100%);
    margin: 1.5rem auto;
}

figure {
    margin: 2rem 0;
}

figcaption {
    text-align: center;
    font-style: italic;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin: 0.5rem auto 0;
    max-width: 640px;
}

figcaption p {
    margin: 0;
}

/* Footnotes */
sup {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
}

sup a {
    text-decoration: none;
    position: relative;
}

.footnote-popup {
    display: none;
    position: absolute;
    background: var(--white);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 6px;
    max-width: min(300px, calc(100vw - 2rem));
    font-size: 0.9em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.footnote-popup.show {
    opacity: 1;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    color: var(--text-secondary);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .site-header {
        padding: 0.75rem 0.5rem;
    }
    .site-header .container {
        padding: 0 0.5rem;
    }
    .main-content {
        padding: 1.5rem 0.75rem 0.75rem;
    }

    article {
        border-radius: 6px;
        margin-bottom: 1.5rem;
    }

    pre {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    blockquote {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-radius: 0 4px 4px 0;
    }
}
