/* ============================================================
   CSS Variables — Light theme (default)
   ============================================================ */
:root {
    --color-bg: #ffffff;
    --color-bg-secondary: #f5f5f5;
    --color-text: #1a1a1a;
    --color-text-secondary: #6b6b6b;
    --color-border: #e0e0e0;
    --color-primary: hsl(185, 53%, 37%);
    --color-primary-subtle: hsl(185, 53%, 94%);

    --header-height: 3.5rem;
    --z-header: 100;

    --text-xs: 0.25rem;
    --text-sm: 0.5rem;
    --text-base: 0.75rem;
    --text-md: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2rem;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    --radius-md: 0.375rem;

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;

    --max-width: 680px;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Monaco, Consolas, monospace;
}

/* Dark theme — explicit toggle */
[data-theme="dark"] {
    --color-bg: #0f0f0f;
    --color-bg-secondary: #1a1a1a;
    --color-text: #e8e8e8;
    --color-text-secondary: #888888;
    --color-border: #2a2a2a;
    --color-primary: hsl(185, 53%, 63%);
    --color-primary-subtle: hsl(185, 53%, 12%);
}


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

html {
    font-size: 16px;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-base), color var(--transition-base);
}

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

/* ============================================================
   Container
   ============================================================ */
.container {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 var(--space-8);
}

/* ============================================================
   Gradient text — disabled for blog, plain color used instead
   ============================================================ */
.gradient-text {
    color: var(--color-text);
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    height: var(--header-height);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(8px);
    background-color: color-mix(in srgb, var(--color-bg) 90%, transparent);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.site-logo {
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    flex-shrink: 0;
}

.site-logo:hover .gradient-text {
    color: var(--color-primary);
}

.site-logo:hover {
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

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

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* Show sun in dark mode, moon in light mode */
[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

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

/* For system default (no data-theme set yet) */
:root:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .icon-moon {
        display: none;
    }

    :root:not([data-theme]) .theme-toggle .icon-sun {
        display: block;
    }
}

/* ============================================================
   Main layout
   ============================================================ */
main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem var(--space-8);
}

/* ============================================================
   Index page — post list
   ============================================================ */
.page-title {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2.5rem;
}

.post-list {
    list-style: none;
}

.post-list li {
    margin-bottom: 40px;
}

.post-list a {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--color-text);
}

.post-list .entry-title {
    white-space: nowrap;
    font-size: var(--text-md);
}

.post-list .entry-leaders {
    flex: 1;
    border-bottom: 2px dotted var(--color-border);
    margin-bottom: 0.25em;
    min-width: 2rem;
}

.post-list .entry-date {
    white-space: nowrap;
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

.post-list a:hover .entry-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Load more */
.load-more {
    margin-top: 2rem;
    background: none;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.load-more:hover {
    background-color: var(--color-primary-subtle);
}

/* ============================================================
   Post page
   ============================================================ */
.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

.post-subtitle {
    font-size: var(--text-md);
    color: var(--color-text-secondary);
    margin-top: 0.35rem;
    margin-bottom: 0.75rem;
    font-style: italic;
}

.post-meta {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-bottom: 1.25rem;
}

.post-separator {
    border: none;
    border-top: 1px solid var(--color-border);
}

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

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

.post-content h2,
.post-content h3,
.post-content h4 {
    margin-top: 2em;
    margin-bottom: 0.75em;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.post-content h2 {
    font-size: var(--text-xl);
}

.post-content h3 {
    font-size: var(--text-lg);
}

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

.post-content li {
    margin-bottom: 0.4em;
}

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

.post-content blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: 1em;
    color: var(--color-text-secondary);
    margin: 1.5em 0;
}

.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em auto;
}

.post-content .image-caption {
    text-align: center;
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-top: -1.25em;
    margin-bottom: 2em;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-bg-secondary);
    padding: 0.15em 0.35em;
    border-radius: var(--radius-md);
}

.post-content pre {
    margin: 1.5em 0;
    border-radius: var(--radius-md);
    overflow-x: auto;
    padding-inline: var(--space-4);
}

.post-content pre code {
    background: none;
    font-size: var(--text-base);
}

.post-content .shiki code {
    background: none;
}

/* ============================================================
   Footnotes
   ============================================================ */
.post-content .footnotes {
    margin-top: 3em;
    padding-top: 1.5em;
    border-top: 1px solid var(--color-border);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

.post-content .footnotes ol {
    padding-left: 1.5em;
}

.post-content .footnotes li {
    margin-bottom: var(--space-2);
    line-height: 1.6;
}

.post-content .footnotes li p {
    display: inline;
    margin: 0;
}

.post-content .footnotes a[href^="#fnref"] {
    text-decoration: none;
    margin-left: var(--space-1);
    color: var(--color-text-secondary);
}

.post-content .footnotes a[href^="#fnref"]:hover {
    color: var(--color-primary);
}

.post-content sup a {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
}

.post-content sup a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================================
   Tables
   ============================================================ */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: var(--text-base);
    line-height: 1.5;
}

.post-content th,
.post-content td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.post-content thead th {
    background-color: var(--color-bg-secondary);
    font-weight: 600;
}

.post-content tbody tr:nth-child(even) {
    background-color: var(--color-bg-secondary);
}

.post-content tbody tr:hover {
    background-color: color-mix(in srgb, var(--color-primary-subtle) 60%, transparent);
    transition: background-color var(--transition-fast);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    background-color: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding-block: var(--space-10);
    transition: background-color var(--transition-base);
}

.footer-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-8);
    align-items: stretch;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.footer-brand-name {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.footer-brand-name:hover {
    color: var(--color-primary);
}

.footer-tagline {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

.footer-right {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    align-items: flex-end;
    justify-content: space-between;
}

.footer-socials {
    display: flex;
    gap: var(--space-3);
}

.footer-social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    transition: color var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
    text-decoration: none;
}

.footer-social-link:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background-color: var(--color-primary-subtle);
}

.footer-copyright {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

/* ============================================================
   Mobile (≤640px)
   ============================================================ */
@media (max-width: 640px) {
    .container {
        padding: 0 1.25rem;
    }

    main {
        padding: 2rem 1.25rem;
    }

    .post-header h1 {
        font-size: 1.6rem;
    }

    /* Dot leaders hidden on mobile */
    .post-list .entry-leaders {
        display: none;
    }

    /* Date below title on mobile */
    .post-list a {
        flex-wrap: wrap;
    }

    .post-list .entry-date {
        flex-basis: 100%;
        font-size: var(--text-base);
        margin-top: 0.2em;
    }

    /* Tables scroll on mobile */
    .post-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Footer stacks on mobile */
    .footer-inner {
        grid-template-columns: 1fr;
    }

    .footer-right {
        align-items: flex-start;
    }
}
