/* ==========================================================================
   DasCommerce Theme — Dark Corporate / Telegram-inspired
   ========================================================================== */

:root {
    /* Backgrounds */
    --bg-primary: #0e1621;
    --bg-secondary: #17212b;
    --bg-elevated: #1e2c3a;
    --bg-card-hover: #243447;

    /* Accent */
    --accent: #5288c1;
    --accent-hover: #6ab2f2;

    /* Text */
    --text-primary: #f5f5f5;
    --text-secondary: #8b9db5;
    --text-muted: #5c7186;

    /* Borders */
    --border: #263545;

    /* Code */
    --bg-code: #0b1018;

    /* Tags */
    --tag-bg: #1a3a5c;
    --tag-text: #6ab2f2;

    /* Ghost custom font support */
    --gh-font-heading: var(--font-heading, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    --gh-font-body: var(--font-body, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);

    /* Misc */
    --success: #3fb8a9;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
    --max-width: 1200px;
    --max-width-narrow: 720px;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

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

body {
    font-family: var(--gh-font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
}

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

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.container-narrow {
    max-width: var(--max-width-narrow);
    margin: 0 auto;
    padding: 0 24px;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--accent);
    font-size: 0.75rem;
    color: var(--text-secondary);
    height: 30px;
    line-height: 30px;
    letter-spacing: 0.02em;
}

.topbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.topbar a {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition);
}

.topbar a:hover {
    color: #fff;
}

@media (max-width: 768px) {
    .topbar {
        display: none;
    }
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 64px;
    gap: 32px;
}

.site-logo {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    flex-shrink: 0;
}

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

.logo-light {
    font-weight: 300;
    color: var(--text-secondary);
}

.logo-bold {
    font-weight: 700;
}

.site-nav {
    flex: 1;
}

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 8px;
}

.site-nav a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.site-nav a:hover,
.site-nav .nav-current a {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.search-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.search-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

/* Mobile menu */

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all var(--transition);
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 80px 24px;
    text-align: center;
}

.hero-inner {
    max-width: 640px;
    margin: 0 auto;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 16px;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 32px;
}

.hero-cta {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ==========================================================================
   Post Feed
   ========================================================================== */

.post-feed-section {
    padding: 32px 0 60px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 32px;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

/* Featured post (first on homepage) */

.featured-post {
    margin-bottom: 48px;
}

.featured-post-link {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.featured-post-link:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
}

.featured-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-height: 300px;
}

.featured-post-content {
    padding: 32px 32px 32px 0;
}

.featured-post-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin: 12px 0;
    color: var(--text-primary);
}

.featured-post-excerpt {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Post card grid */

.post-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.post-card-link {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    height: 100%;
}

.post-card-link:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: translateY(-2px);
}

.post-card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.post-card-content {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.post-card-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.post-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin: 12px 0 8px;
    color: var(--text-primary);
}

.post-card-excerpt {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    flex: 1;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Single Post
   ========================================================================== */

.post-header {
    padding: 60px 0 32px;
    text-align: center;
}

.post-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 4px 12px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 16px;
}

.post-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 16px;
}

.post-excerpt {
    font-size: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.post-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.post-meta-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-meta-author a {
    color: var(--text-secondary);
    font-weight: 500;
}

.author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.post-hero-image {
    max-width: 1000px;
    margin: 0 auto 48px;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.post-hero-image figcaption {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
}

/* Post content */

.post-content {
    padding-bottom: 48px;
}

.post-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 48px 0 16px;
}

.post-content h3 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 40px 0 12px;
}

.post-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 32px 0 8px;
}

.post-content p {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.0625rem;
    line-height: 1.8;
}

.post-content ul,
.post-content ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 0 4px 24px;
    margin: 32px 0;
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-style: italic;
}

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

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

.post-content img {
    border-radius: var(--radius);
    margin: 32px auto;
}

.post-content figure {
    margin: 32px 0;
}

.post-content figcaption {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 48px 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 0.9rem;
}

.post-content th,
.post-content td {
    border: 1px solid var(--border);
    padding: 12px 16px;
    text-align: left;
}

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

.post-content td {
    background: var(--bg-secondary);
}

/* Code */

.post-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875em;
    background: var(--bg-code);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--tag-text);
}

.post-content pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    overflow-x: auto;
    margin: 32px 0;
    line-height: 1.5;
}

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

/* Post footer */

.post-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.tag-pill {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 6px 14px;
    border-radius: 20px;
    transition: all var(--transition);
}

.tag-pill:hover {
    background: var(--accent);
    color: #fff;
}

.post-share {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.post-share a {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Related posts */

.related-posts {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 60px 0;
}

/* ==========================================================================
   Tag & Author Pages
   ========================================================================== */

.tag-header,
.author-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 60px 0;
    text-align: center;
}

.tag-title,
.author-name {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.tag-description,
.author-bio {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

.tag-count {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.author-profile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.author-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.author-location {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Error Page
   ========================================================================== */

.error-page {
    text-align: center;
    padding: 120px 24px;
}

.error-code {
    font-size: 8rem;
    font-weight: 700;
    color: var(--bg-elevated);
    line-height: 1;
    margin-bottom: 16px;
}

.error-message {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

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

.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 60px 0 32px;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 48px;
    margin-bottom: 48px;
}

.footer-col h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.footer-col ul {
    list-style: none;
}

.footer-col li {
    margin-bottom: 10px;
}

.footer-col a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color var(--transition);
}

.footer-col a:hover {
    color: var(--text-primary);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-bottom a {
    color: var(--text-secondary);
}

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

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 48px;
    font-size: 0.875rem;
}

.pagination a {
    color: var(--accent);
    font-weight: 500;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.pagination a:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

/* ==========================================================================
   Ghost-specific overrides
   ========================================================================== */

.kg-width-wide {
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.kg-width-full {
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

.kg-bookmark-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 32px 0;
}

.kg-bookmark-container {
    display: flex;
    text-decoration: none;
    color: var(--text-primary);
}

.kg-bookmark-content {
    padding: 20px;
    flex: 1;
}

.kg-bookmark-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
}

.kg-bookmark-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.kg-bookmark-metadata {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kg-bookmark-thumbnail img {
    width: 200px;
    height: 100%;
    object-fit: cover;
}

.kg-callout-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 32px 0;
    display: flex;
    gap: 12px;
}

.kg-toggle-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 24px 0;
    padding: 16px 20px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .header-inner {
        gap: 16px;
    }

    .site-nav {
        display: none;
    }

    .site-nav.is-open {
        display: block;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        padding: 12px 0;
        z-index: 99;
    }

    .site-nav.is-open ul {
        flex-direction: column;
        gap: 0;
    }

    .site-nav.is-open li a {
        display: block;
        padding: 12px 24px;
        border-radius: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-menu-btn.is-active span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .mobile-menu-btn.is-active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.is-active span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .hero {
        padding: 48px 24px;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .featured-post-link {
        grid-template-columns: 1fr;
    }

    .featured-post-content {
        padding: 24px;
    }

    .featured-post-title {
        font-size: 1.35rem;
    }

    .post-feed {
        grid-template-columns: 1fr;
    }

    .post-title {
        font-size: 1.75rem;
    }

    .post-content h2 {
        font-size: 1.375rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .author-profile {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header-actions .btn {
        display: none;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .post-title {
        font-size: 1.5rem;
    }
}
