/* ==========================================================================
   BlogFlow — Default Theme Stylesheet
   Responsive, accessible, dark-mode-aware. No JavaScript required.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom Properties (Light Mode)
   -------------------------------------------------------------------------- */
:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --text: #1a1a2e;
    --text-secondary: #555770;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e4e9;
    --code-bg: #f1f3f5;
    --code-text: #c2255c;
    --blockquote-border: #2563eb;
    --blockquote-bg: #f0f4ff;
    --tag-bg: #e8edff;
    --tag-text: #2563eb;
    --shadow: rgba(0, 0, 0, 0.06);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro",
        Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

/* --------------------------------------------------------------------------
   2. Dark Mode
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16161a;
        --bg-secondary: #1e1e24;
        --text: #ececf1;
        --text-secondary: #a0a0b0;
        --accent: #60a5fa;
        --accent-hover: #93c5fd;
        --border: #2e2e38;
        --code-bg: #1e1e24;
        --code-text: #f0a8c0;
        --blockquote-border: #60a5fa;
        --blockquote-bg: #1a1f2e;
        --tag-bg: #1e2a40;
        --tag-text: #60a5fa;
        --shadow: rgba(0, 0, 0, 0.3);
    }
}

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

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   4. Accessibility
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 0 0 0.25rem 0.25rem;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

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

/* --------------------------------------------------------------------------
   5. Layout
   -------------------------------------------------------------------------- */
.site-header,
main,
.site-footer {
    width: 100%;
    max-width: 48rem;
    margin-inline: auto;
    padding-inline: 1.5rem;
}

main {
    flex: 1;
    padding-block: 2rem;
}

/* --------------------------------------------------------------------------
   6. Header
   -------------------------------------------------------------------------- */
.site-header {
    padding-block: 1.25rem;
    border-bottom: 1px solid var(--border);
}

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

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

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

/* --------------------------------------------------------------------------
   7. Footer
   -------------------------------------------------------------------------- */
.site-footer {
    padding-block: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.site-footer a {
    color: var(--accent);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. Post Content
   -------------------------------------------------------------------------- */
.post-content,
.page-content {
    max-width: 65ch;
}

.post-content > * + *,
.page-content > * + * {
    margin-top: 1.25rem;
}

.post-content h2,
.page-content h2 {
    font-size: 1.5rem;
    margin-top: 2.5rem;
    margin-bottom: 0.5rem;
}

.post-content h3,
.page-content h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.post-content h4,
.page-content h4 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

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

.post-content a:hover,
.page-content a:hover {
    color: var(--accent-hover);
}

/* Lists */
.post-content ul,
.post-content ol,
.page-content ul,
.page-content ol {
    padding-left: 1.5rem;
}

.post-content li + li,
.page-content li + li {
    margin-top: 0.25rem;
}

/* Blockquotes */
.post-content blockquote,
.page-content blockquote {
    border-left: 3px solid var(--blockquote-border);
    background: var(--blockquote-bg);
    padding: 0.75rem 1rem;
    border-radius: 0 0.25rem 0.25rem 0;
    color: var(--text-secondary);
}

/* Inline code */
.post-content code,
.page-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.125em 0.375em;
    border-radius: 0.25rem;
}

/* Code blocks */
.post-content pre,
.page-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    line-height: 1.5;
}

.post-content pre code,
.page-content pre code {
    background: none;
    color: var(--text);
    padding: 0;
    font-size: 0.875rem;
}

/* Images */
.post-content img,
.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

/* Horizontal rules */
.post-content hr,
.page-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin-block: 2rem;
}

/* Tables */
.post-content table,
.page-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.post-content th,
.post-content td,
.page-content th,
.page-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

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

/* --------------------------------------------------------------------------
   9. Post Header & Metadata
   -------------------------------------------------------------------------- */
.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

.post-meta-sep {
    color: var(--border);
}

/* --------------------------------------------------------------------------
   10. Tags
   -------------------------------------------------------------------------- */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.tag {
    display: inline-block;
    font-size: 0.8125rem;
    padding: 0.125rem 0.625rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 1rem;
    text-decoration: none;
    transition: opacity 0.15s;
}

.tag:hover {
    opacity: 0.8;
}

/* --------------------------------------------------------------------------
   11. Post List / Summaries
   -------------------------------------------------------------------------- */
.post-list h1 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.post-summary {
    padding-block: 1.25rem;
    border-bottom: 1px solid var(--border);
}

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

.post-summary h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.post-summary h2 a {
    color: var(--text);
    text-decoration: none;
}

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

.post-summary .summary {
    margin-top: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* --------------------------------------------------------------------------
   12. Pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9375rem;
}

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

.pagination a:hover {
    text-decoration: underline;
}

.pagination-next {
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   13. Error Page
   -------------------------------------------------------------------------- */
.error-page {
    text-align: center;
    padding-block: 4rem;
}

.error-page h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.error-page a {
    color: var(--accent);
    text-decoration: none;
}

.error-page a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   14. Chroma Syntax Highlighting
   Compatible with goldmark-highlighting / Chroma output classes
   -------------------------------------------------------------------------- */

/* Background */
.chroma { background-color: var(--code-bg); color: var(--text); }

/* Keyword */
.chroma .k,
.chroma .kc,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr { color: #7c3aed; font-weight: 600; }

/* Name */
.chroma .n  { color: var(--text); }
.chroma .na { color: #0d9488; }
.chroma .nb { color: #2563eb; }
.chroma .nc { color: #2563eb; font-weight: 600; }
.chroma .nf { color: #2563eb; }

/* String */
.chroma .s,
.chroma .sa,
.chroma .sb,
.chroma .sc,
.chroma .dl,
.chroma .sd,
.chroma .s2,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx,
.chroma .sr,
.chroma .s1,
.chroma .ss { color: #047857; }

/* Number */
.chroma .m,
.chroma .mb,
.chroma .mf,
.chroma .mh,
.chroma .mi,
.chroma .il,
.chroma .mo { color: #b45309; }

/* Comment */
.chroma .c,
.chroma .ch,
.chroma .cm,
.chroma .c1,
.chroma .cs,
.chroma .cp,
.chroma .cpf { color: var(--text-secondary); font-style: italic; }

/* Operator */
.chroma .o,
.chroma .ow { color: #be185d; }

/* Punctuation */
.chroma .p { color: var(--text-secondary); }

/* Generic */
.chroma .gd { color: #dc2626; }
.chroma .gi { color: #16a34a; }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 700; }

@media (prefers-color-scheme: dark) {
    .chroma .k,
    .chroma .kc,
    .chroma .kd,
    .chroma .kn,
    .chroma .kp,
    .chroma .kr { color: #a78bfa; }

    .chroma .na { color: #5eead4; }
    .chroma .nb { color: #60a5fa; }
    .chroma .nc { color: #60a5fa; }
    .chroma .nf { color: #60a5fa; }

    .chroma .s,
    .chroma .sa,
    .chroma .sb,
    .chroma .sc,
    .chroma .dl,
    .chroma .sd,
    .chroma .s2,
    .chroma .se,
    .chroma .sh,
    .chroma .si,
    .chroma .sx,
    .chroma .sr,
    .chroma .s1,
    .chroma .ss { color: #34d399; }

    .chroma .m,
    .chroma .mb,
    .chroma .mf,
    .chroma .mh,
    .chroma .mi,
    .chroma .il,
    .chroma .mo { color: #fbbf24; }

    .chroma .c,
    .chroma .ch,
    .chroma .cm,
    .chroma .c1,
    .chroma .cs,
    .chroma .cp,
    .chroma .cpf { color: #8e8e99; }

    .chroma .o,
    .chroma .ow { color: #f472b6; }

    .chroma .gd { color: #fca5a5; }
    .chroma .gi { color: #86efac; }
}

/* --------------------------------------------------------------------------
   15. Print Stylesheet
   -------------------------------------------------------------------------- */
@media print {
    body {
        color: #000;
        background: #fff;
        font-size: 12pt;
    }

    .site-header,
    .site-footer,
    .pagination,
    .skip-link,
    .post-tags {
        display: none;
    }

    main {
        max-width: none;
        padding: 0;
    }

    .post-content a,
    .page-content a {
        color: #000;
        text-decoration: underline;
    }

    .post-content a[href^="http"]::after,
    .page-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.875em;
        color: #555;
    }

    pre {
        white-space: pre-wrap;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* --------------------------------------------------------------------------
   16. Mermaid Diagrams
   -------------------------------------------------------------------------- */
.mermaid {
    text-align: center;
    margin: 1.5rem 0;
}
.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   17. Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .tag { transition: none; }
}
