:root {
    --cream: #FFFDF8;
    --cream-dark: #F5F3ED;
    --ink: #111111;
    --ink-medium: #333333;
    --ink-light: #666666;
    --accent: #B8342A;
    --rule: #D4D2CB;
}

/* Dark theme */
[data-theme="dark"] {
    --cream: #1a1a1a;
    --cream-dark: #252525;
    --ink: #f0f0f0;
    --ink-medium: #d0d0d0;
    --ink-light: #999999;
    --accent: #e05a4f;
    --rule: #3a3a3a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    min-height: 100vh;
    background: var(--cream);
    color: var(--ink);
}

/* Top rule */
.top-rule {
    height: 3px;
    background: var(--ink);
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--rule);
}

.masthead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}

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

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

.nav-links a {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-medium);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--accent);
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--ink-medium);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--accent);
}

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

/* Main content */
main {
    padding: 4rem 0;
}

.intro {
    max-width: 540px;
}

.intro h1 {
    font-size: 2.75rem;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

.intro h1 em {
    font-style: italic;
}

.intro .lede,
.lede {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--ink-medium);
    margin-bottom: 2.5rem;
}

/* Divider */
.divider {
    width: 3rem;
    height: 1px;
    background: var(--rule);
    margin: 2.5rem 0;
}

/* Links section */
.elsewhere {
    padding-top: 0.5rem;
}

.elsewhere h2 {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    margin-bottom: 1rem;
}

.link-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.link-list a {
    font-size: 1.05rem;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

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

.link-list .arrow {
    font-size: 0.85rem;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s ease;
}

.link-list a:hover .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Footer */
footer {
    border-top: 1px solid var(--rule);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.colophon {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    color: var(--ink-light);
}

.issue-number {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-light);
    background: var(--cream-dark);
    padding: 0.35rem 0.75rem;
    border-radius: 2px;
}

/* Animations */
.intro h1,
.intro .lede,
.divider,
.elsewhere {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeIn 0.6s ease-out forwards;
}

.intro h1 { animation-delay: 0.1s; }
.intro .lede { animation-delay: 0.2s; }
.divider { animation-delay: 0.3s; }
.elsewhere { animation-delay: 0.4s; }

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: 0 1.25rem;
    }

    .masthead {
        flex-direction: column;
        gap: 1rem;
    }

    .intro h1 {
        font-size: 2.25rem;
    }

    main {
        padding: 3rem 0;
    }

    footer {
        margin-top: 3rem;
    }

    .footer-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Selection */
::selection {
    background: var(--accent);
    color: var(--cream);
}

/* =====================
   Blog Styles
   ===================== */

/* Blog listing styles */
.post-list {
    list-style: none;
}

.post-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--rule);
}

.post-item:last-child {
    border-bottom: none;
}

.post-title {
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.post-title a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: var(--accent);
}

.post-meta {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    color: var(--ink-light);
    letter-spacing: 0.01em;
}

.post-excerpt {
    margin-top: 0.75rem;
    color: var(--ink-medium);
    line-height: 1.6;
}

/* Blog post content styles */
.post-header {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--rule);
}

.post-header h1 {
    font-size: 2.5rem;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.post-content {
    line-height: 1.75;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.post-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--ink-medium);
}

.post-content code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.9em;
    background: var(--cream-dark);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.post-content pre {
    background: var(--cream-dark);
    padding: 1.25rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.post-content a:hover {
    text-decoration-thickness: 2px;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1.5rem 0;
}

/* Back link */
.back-link {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

.back-link a {
    color: var(--ink-light);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

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

/* Page header for blog index */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.25rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

/* =====================
   GitHub Contributions Widget
   ===================== */

.github-activity {
    padding-top: 0.5rem;
}

.github-activity h2 {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    margin-bottom: 1rem;
}

.contributions-widget {
    margin-bottom: 1rem;
}

.contributions-count {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    color: var(--ink-medium);
    margin-bottom: 0.75rem;
}

.contributions-grid {
    margin-bottom: 0.5rem;
}

.contributions-grid .month-labels {
    display: grid;
    grid-template-columns: 24px repeat(53, 9px);
    gap: 3px;
    margin-bottom: 3px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.65rem;
    color: var(--ink-light);
}

.contributions-grid .month-label {
    white-space: nowrap;
}

.contributions-grid .grid-container {
    display: flex;
    gap: 3px;
}

.contributions-grid .day-labels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-right: 3px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.6rem;
    color: var(--ink-light);
}

.contributions-grid .day-label {
    height: 9px;
    line-height: 9px;
    width: 21px;
    text-align: right;
}

.contributions-grid .cells {
    display: flex;
    gap: 3px;
}

.contributions-grid .week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.contributions-grid .cell {
    width: 9px;
    height: 9px;
    border-radius: 2px;
}

.contributions-grid .cell.level-0,
.contributions-grid .cell.level-empty {
    background-color: #ebedf0;
}

.contributions-grid .cell.level-1 {
    background-color: #9be9a8;
}

.contributions-grid .cell.level-2 {
    background-color: #40c463;
}

.contributions-grid .cell.level-3 {
    background-color: #30a14e;
}

.contributions-grid .cell.level-4 {
    background-color: #216e39;
}

.contributions-legend {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-end;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.65rem;
    color: var(--ink-light);
}

.contributions-legend .legend-cells {
    display: flex;
    gap: 2px;
}

.contributions-legend .cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.contributions-legend .cell.level-0 {
    background-color: #ebedf0;
}

.contributions-legend .cell.level-1 {
    background-color: #9be9a8;
}

.contributions-legend .cell.level-2 {
    background-color: #40c463;
}

.contributions-legend .cell.level-3 {
    background-color: #30a14e;
}

.contributions-legend .cell.level-4 {
    background-color: #216e39;
}

/* Dark mode: contribution grid empty cells */
[data-theme="dark"] .contributions-grid .cell.level-0,
[data-theme="dark"] .contributions-grid .cell.level-empty,
[data-theme="dark"] .contributions-legend .cell.level-0 {
    background-color: #2d333b;
}

/* Mobile: horizontal scroll with larger cells like GitHub */
@media (max-width: 600px) {
    .contributions-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .contributions-grid .month-labels {
        grid-template-columns: 28px repeat(53, 10px);
    }

    .contributions-grid .day-label {
        height: 10px;
        line-height: 10px;
        width: 25px;
    }

    .contributions-grid .cell {
        width: 10px;
        height: 10px;
    }
}

/* Custom tooltip for contributions */
.contrib-tooltip {
    position: absolute;
    background: var(--ink);
    color: var(--cream);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
