/* ============================================================
   Chirpy-style theme for The Software Factory
   Color tokens per DESIGN.md are preserved.
   ============================================================ */

:root {
    --c-sidebar-bg: #2c3e50;
    --c-sidebar-fg: #ffffff;
    --c-sidebar-muted: #a0a9b4;
    --c-body: #333333;
    --c-heading: #2c3e50;
    --c-link: #3498db;
    --c-link-hover: #2980b9;
    --c-page-bg: #f9f9f9;
    --c-card-bg: #ffffff;
    --c-meta: #7f8c8d;
    --c-tag-bg: #ecf0f1;
    --c-border: #ecf0f1;
    --c-shadow: rgba(44, 62, 80, 0.08);

    --sidebar-w: 260px;
    --panel-w: 240px;
    --content-max: 800px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--c-page-bg);
    color: var(--c-body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Oxygen-Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
    font-size: 16px;
}

a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-link-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    color: var(--c-heading);
    line-height: 1.25;
    margin: 1.25em 0 0.5em;
    font-weight: 600;
}

code, pre {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

pre {
    background: #f4f6f8;
    border-radius: 6px;
    padding: 1em;
    overflow-x: auto;
    font-size: 0.9em;
}

code {
    background: var(--c-tag-bg);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
}

pre code {
    background: transparent;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* ============================================================
   Layout: three-column (sidebar | main | panel)
   ============================================================ */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
    min-height: 100vh;
}

.layout.no-panel {
    grid-template-columns: var(--sidebar-w) 1fr;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    background: var(--c-sidebar-bg);
    color: var(--c-sidebar-fg);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2em 1em 1em;
    height: 100%;
}

.avatar-link { display: block; margin-bottom: 1em; }

.avatar {
    width: 7em;
    height: 7em;
    object-fit: contain;
    display: block;
}

.site-title {
    color: var(--c-sidebar-fg);
    font-size: 1.25em;
    margin: 0.25em 0 0;
    text-align: center;
    font-weight: 600;
}
.site-title a { color: var(--c-sidebar-fg); }
.site-title a:hover { text-decoration: none; color: var(--c-link); }

.site-tagline {
    color: var(--c-sidebar-muted);
    text-align: center;
    font-size: 0.85em;
    margin: 0.5em 0 1.5em;
    font-style: italic;
}

.site-nav {
    width: 100%;
    flex-grow: 1;
}
.site-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}
.site-nav .nav-item { margin: 0; }
.site-nav .nav-item a {
    color: var(--c-sidebar-fg);
    display: flex;
    align-items: center;
    gap: 0.75em;
    padding: 0.7em 1em;
    border-radius: 999px;
    font-size: 0.95em;
    transition: background 0.15s ease, color 0.15s ease;
}
.site-nav .nav-item a:hover {
    background: rgba(52, 152, 219, 0.15);
    color: var(--c-link);
    text-decoration: none;
}
.site-nav .nav-item.active a {
    background: var(--c-link);
    color: #fff;
}
.site-nav .nav-item i {
    width: 1.25em;
    text-align: center;
}

.sidebar-bottom {
    width: 100%;
    margin-top: auto;
    padding-top: 1em;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.social-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75em;
    display: flex;
    justify-content: center;
    gap: 0.9em;
}
.social-list a { color: var(--c-sidebar-muted); font-size: 1.1em; }
.social-list a:hover { color: var(--c-link); text-decoration: none; }

.sidebar-copyright {
    color: var(--c-sidebar-muted);
    font-size: 0.75em;
    margin: 0;
}

/* ============================================================
   Main content
   ============================================================ */

.main { min-width: 0; padding: 2em 2em; }
.main-inner { max-width: var(--content-max); margin: 0 auto; }

/* ============================================================
   Post cards (homepage + list pages)
   ============================================================ */

.page-heading {
    font-size: 1.5em;
    margin: 0 0 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--c-border);
}

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

.post-card {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 1.5em;
    box-shadow: 0 2px 6px var(--c-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    gap: 1.25em;
    align-items: stretch;
}
.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px var(--c-shadow);
}
.post-card-body { flex: 1; min-width: 0; }
.post-card-thumb {
    flex: 0 0 140px;
    align-self: stretch;
    border-radius: 6px;
    overflow: hidden;
    background: var(--c-tag-bg);
    display: block;
    min-height: 140px;
}
.post-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}
.post-card-thumb--placeholder {
    background: var(--c-sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.post-card-thumb--placeholder img {
    width: 60%;
    height: auto;
    object-fit: contain;
    opacity: 0.85;
}

.post-card h2 { margin: 0 0 0.4em; font-size: 1.4em; }
.post-card h2 a { color: var(--c-heading); }
.post-card h2 a:hover { color: var(--c-link); text-decoration: none; }

.post-card .post-summary { color: var(--c-body); margin: 0.5em 0; }

.post-meta {
    color: var(--c-meta);
    font-size: 0.85em;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75em;
    align-items: center;
}
.post-meta .sep { color: var(--c-border); }
.post-meta i { margin-right: 0.25em; }

.post-category {
    display: inline-block;
    background: var(--c-link);
    color: #fff;
    font-size: 0.8em;
    padding: 0.15em 0.7em;
    border-radius: 15px;
}
.post-category a { color: #fff; }

.post-tags { margin-top: 0.75em; }
.post-tag {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-heading);
    font-size: 0.8em;
    padding: 0.2em 0.7em;
    border-radius: 12px;
    margin: 0.15em 0.2em 0.15em 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.post-tag:hover { background: var(--c-link); color: #fff; text-decoration: none; }

/* ============================================================
   Article page
   ============================================================ */

.article {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 2em 2.25em;
    box-shadow: 0 2px 6px var(--c-shadow);
    line-height: 1.8;
}

.article-title { margin-top: 0; font-size: 2em; }

.article-content img { display: block; margin: 1em auto; border-radius: 6px; }
.article-content h2,
.article-content h3,
.article-content h4 { scroll-margin-top: 1em; }

.article-content blockquote {
    border-left: 4px solid var(--c-link);
    margin: 1em 0;
    padding: 0.25em 1em;
    color: var(--c-meta);
    background: #f4f6f8;
    border-radius: 4px;
}

.article-footer { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--c-border); }

/* Video embeds */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 1.5em 0;
    border-radius: 6px;
}
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================================
   Right panel (TOC + trending tags)
   ============================================================ */

.panel {
    padding: 2em 1em;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.panel-block {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 1em 1.25em;
    margin-bottom: 1em;
    box-shadow: 0 2px 6px var(--c-shadow);
}

.panel-heading {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-meta);
    margin: 0 0 0.75em;
    font-weight: 700;
}

.panel .toc ul { list-style: none; padding-left: 1em; margin: 0.25em 0; }
.panel .toc > ul { padding-left: 0; }
.panel .toc a {
    display: block;
    padding: 0.2em 0;
    color: var(--c-body);
    font-size: 0.88em;
    border-left: 2px solid transparent;
    padding-left: 0.5em;
}
.panel .toc a:hover {
    color: var(--c-link);
    border-left-color: var(--c-link);
    text-decoration: none;
}

.trending-tags a {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-heading);
    font-size: 0.8em;
    padding: 0.2em 0.7em;
    border-radius: 12px;
    margin: 0.15em 0.2em 0.15em 0;
}
.trending-tags a:hover { background: var(--c-link); color: #fff; text-decoration: none; }

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2em 0 0;
    font-size: 0.9em;
}
.pagination a, .pagination span {
    padding: 0.4em 0.9em;
    border-radius: 4px;
    color: var(--c-link);
}
.pagination .disabled { color: var(--c-meta); }

/* ============================================================
   Archives / category / tag lists
   ============================================================ */

.archive-year {
    font-size: 1.2em;
    color: var(--c-heading);
    margin-top: 1.5em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--c-border);
}
.archive-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5em 0 1em;
}
.archive-list li {
    padding: 0.35em 0;
    display: flex;
    gap: 1em;
    align-items: baseline;
}
.archive-list .archive-date {
    color: var(--c-meta);
    font-size: 0.85em;
    min-width: 5em;
    font-variant-numeric: tabular-nums;
}

.term-cloud a {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-heading);
    padding: 0.35em 0.9em;
    border-radius: 15px;
    margin: 0.3em 0.3em 0.3em 0;
    font-size: 0.95em;
}
.term-cloud a:hover { background: var(--c-link); color: #fff; text-decoration: none; }
.term-cloud .count { color: var(--c-meta); font-size: 0.85em; margin-left: 0.35em; }

/* ============================================================
   Page (static)
   ============================================================ */

.page {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 2em 2.25em;
    box-shadow: 0 2px 6px var(--c-shadow);
    line-height: 1.8;
}
.page-title { margin-top: 0; }

.about-portrait {
    float: right;
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 50%;
    margin: 0 0 1em 1.5em;
    box-shadow: 0 2px 6px var(--c-shadow);
}
@media (max-width: 768px) {
    .about-portrait {
        float: none;
        display: block;
        margin: 0 auto 1em;
        width: 140px;
        height: 140px;
    }
}

/* ============================================================
   Newsletter signup
   ============================================================ */

.newsletter-signup {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 1.5em 1.75em;
    margin-top: 2em;
    box-shadow: 0 2px 6px var(--c-shadow);
    border-top: 3px solid var(--c-link);
}
.newsletter-signup h2 {
    margin: 0 0 0.25em;
    font-size: 1.2em;
}
.newsletter-sub {
    color: var(--c-meta);
    margin: 0 0 1em;
    font-size: 0.92em;
}

.newsletter-form {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
}
.newsletter-form input[type="email"] {
    flex: 1 1 200px;
    min-width: 0;
    padding: 0.55em 0.9em;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 0.95em;
    background: #fff;
    color: var(--c-body);
    font-family: inherit;
}
.newsletter-form input[type="email"]:focus {
    outline: none;
    border-color: var(--c-link);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}
.newsletter-form button {
    padding: 0.55em 1.1em;
    background: var(--c-link);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}
.newsletter-form button:hover { background: var(--c-link-hover); }
.newsletter-form button:disabled {
    background: var(--c-meta);
    cursor: not-allowed;
}

.newsletter-msg {
    min-height: 1.25em;
    margin: 0.75em 0 0;
    font-size: 0.9em;
}
.newsletter-success { color: #27ae60; }
.newsletter-error { color: #c0392b; }

/* Newsletter landing page */
.newsletter-landing {
    background: var(--c-card-bg);
    border-radius: 8px;
    padding: 2.5em 2.25em;
    box-shadow: 0 2px 6px var(--c-shadow);
    text-align: center;
}
.newsletter-landing h2 {
    margin-top: 0;
    font-size: 1.8em;
}
.newsletter-landing-sub {
    color: var(--c-meta);
    font-size: 1.05em;
    margin-bottom: 1.5em;
}
.newsletter-landing .newsletter-form {
    max-width: 480px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .newsletter-form { flex-direction: column; }
    .newsletter-form button { width: 100%; }
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid var(--c-border);
    text-align: center;
    color: var(--c-meta);
    font-size: 0.85em;
}

/* ============================================================
   Responsive: collapse to single column under 768px
   ============================================================ */

@media (max-width: 768px) {
    .layout,
    .layout.no-panel {
        grid-template-columns: 1fr;
    }
    .sidebar { position: static; height: auto; }
    .sidebar-inner { padding: 1.5em 1em; }
    .avatar { width: 5em; height: 5em; }
    .site-nav { flex-grow: 0; margin: 1em 0; }
    .site-nav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25em;
    }
    .site-nav .nav-item a { padding: 0.5em 0.8em; }
    .panel { position: static; height: auto; padding: 1em; }
    .main { padding: 1.5em 1em; }
    .article, .page { padding: 1.5em 1.25em; }
    .post-card h2 { font-size: 1.2em; }
    .post-card { flex-direction: column-reverse; }
    .post-card-thumb { flex: 0 0 auto; width: 100%; min-height: 160px; max-height: 200px; }
}
