/* ============================================
   Custom Mini — Minimalist Blog Theme for Grav
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Light mode (default) */
    --color-bg: #fafaf8;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-secondary: #555;
    --color-text-muted: #888;
    --color-border: #e0e0e0;
    --color-accent: #2a5a8a;
    --color-accent-hover: #1d3f61;
    --color-tag-bg: #f0f0ee;
    --color-tag-text: #555;
    --color-code-bg: #f4f4f2;
    --color-blockquote-border: #d0d0d0;

    /* Typography */
    --font-body: 'Lora', Georgia, 'Times New Roman', serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Sizing */
    --max-width: 680px;
    --header-height: 60px;
}

/* Dark mode */
[data-theme="dark"] {
    --color-bg: #161618;
    --color-surface: #1e1e21;
    --color-text: #e0e0e0;
    --color-text-secondary: #aaa;
    --color-text-muted: #777;
    --color-border: #333;
    --color-accent: #6aafe6;
    --color-accent-hover: #8fc5f0;
    --color-tag-bg: #2a2a2e;
    --color-tag-text: #aaa;
    --color-code-bg: #1e1e21;
    --color-blockquote-border: #444;
}

/* Auto dark mode for users without JS / before toggle is used */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #161618;
        --color-surface: #1e1e21;
        --color-text: #e0e0e0;
        --color-text-secondary: #aaa;
        --color-text-muted: #777;
        --color-border: #333;
        --color-accent: #6aafe6;
        --color-accent-hover: #8fc5f0;
        --color-tag-bg: #2a2a2e;
        --color-tag-text: #aaa;
        --color-code-bg: #1e1e21;
        --color-blockquote-border: #444;
    }
}

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

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.3s ease;
}

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

.site-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

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

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

.nav-link {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.nav-active {
    color: var(--color-text);
}

/* --- Theme Toggle --- */
.theme-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

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

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

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

/* --- Main Content --- */
.site-main {
    flex: 1;
    padding: 2.5rem 0;
}

/* --- Page Content (default template) --- */
.page-content h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

/* --- Blog Listing --- */
.blog-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.blog-description {
    color: var(--color-text);
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 1rem;
    line-height: 1.8;
}

.blog-description p {
    margin-bottom: 0.8rem;
}

.blog-description p:last-child {
    margin-bottom: 0;
}

.blog-description a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.post-card {
    border-bottom: 1px solid var(--color-border);
}

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

.post-card-link {
    display: block;
    padding: 1.5rem 0;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.post-card-link:hover {
    opacity: 0.75;
}

.post-card .post-date {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-card .post-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0.3rem 0 0.4rem;
    line-height: 1.3;
    color: var(--color-text);
}

.post-summary {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* --- Tags --- */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.tag {
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--color-tag-bg);
    color: var(--color-tag-text);
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

/* --- Blog Post (item template) --- */
.post-header {
    margin-bottom: 2rem;
}

.post-header .post-date {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-header .post-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin: 0.4rem 0 0.6rem;
}

/* --- Post Body Typography --- */
.post-body {
    font-size: 1rem;
    line-height: 1.8;
}

.post-body h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 2.5rem 0 0.8rem;
    line-height: 1.3;
}

.post-body h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem 0 0.6rem;
    line-height: 1.4;
}

.post-body p {
    margin-bottom: 1.3rem;
}

.post-body a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

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

.post-body ul,
.post-body ol {
    margin: 0 0 1.3rem 1.5rem;
}

.post-body li {
    margin-bottom: 0.4rem;
}

.post-body blockquote {
    border-left: 3px solid var(--color-blockquote-border);
    padding-left: 1.2rem;
    margin: 1.5rem 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

.post-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--color-code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

.post-body pre {
    background: var(--color-code-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1.2rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.post-body pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

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

.post-body hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* --- Post Navigation --- */
.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.post-nav-link {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s;
    max-width: 45%;
}

.post-nav-link:hover {
    color: var(--color-accent-hover);
}

.post-nav-older {
    margin-left: auto;
    text-align: right;
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: auto;
}

.site-footer p {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* --- Responsive --- */

/* Tablets */
@media (max-width: 768px) {
    html {
        font-size: 17px;
    }

    .container {
        padding: 0 1.25rem;
    }

    .blog-title,
    .page-content h1 {
        font-size: 1.7rem;
    }

    .post-header .post-title {
        font-size: 1.8rem;
    }

    .post-card .post-title {
        font-size: 1.15rem;
    }
}

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

    .container {
        padding: 0 1rem;
    }

    .header-inner {
        height: 52px;
    }

    .site-title {
        font-size: 1rem;
    }

    .site-nav {
        gap: 0.8rem;
    }

    .nav-link {
        font-size: 0.8rem;
    }

    .site-main {
        padding: 1.5rem 0;
    }

    .blog-title,
    .page-content h1 {
        font-size: 1.5rem;
    }

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

    .post-card-link {
        padding: 1.2rem 0;
    }

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

    .post-body h2 {
        font-size: 1.3rem;
    }

    .post-body h3 {
        font-size: 1.1rem;
    }

    .post-nav {
        flex-direction: column;
    }

    .post-nav-link {
        max-width: 100%;
    }

    .post-nav-older {
        text-align: left;
    }
}
